diff --git a/.all-contributorsrc b/.all-contributorsrc index 0fcd57dd293..10756a01aa0 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -22,13 +22,21 @@ "avatar_url": "https://avatars1.githubusercontent.com/u/4381558?v=4", "profile": "https://github.com/mediumTaj", "contributions": [ - "review" + "code", + "design", + "bug" + ] + }, + { "login": "germanattanasio", "name": "German Attanasio", "avatar_url": "https://avatars3.githubusercontent.com/u/313157?v=4", "profile": "https://germanattanasio.com", "contributions": [ - "code" + "code", + "design", + "doc", + "test" ] } ], diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 73b3f4e35d7..dca3f55a880 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,37 +1,22 @@ [bumpversion] -current_version = 8.3.1 +current_version = 16.2.0 commit = True message = Update version numbers from {current_version} -> {new_version} - -[bumpversion:file:gradle.properties] +search = {current_version} +replace = {new_version} [bumpversion:file:README.md] [bumpversion:file:assistant/README.md] -[bumpversion:file:compare-comply/README.md] - [bumpversion:file:discovery/README.md] -[bumpversion:file:language-translator/README.md] - -[bumpversion:file:natural-language-classifier/README.md] - [bumpversion:file:natural-language-understanding/README.md] -[bumpversion:file:personality-insights/README.md] - [bumpversion:file:speech-to-text/README.md] [bumpversion:file:text-to-speech/README.md] -[bumpversion:file:tone-analyzer/README.md] - -[bumpversion:file:visual-recognition/README.md] - [bumpversion:file:docker/pom.xml] -[bumpversion:file:examples/build.gradle] -search = {current_version} -replace = {new_version} - +[bumpversion:file:.github/workflows/deploy.yml] diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cdc9d8c65ab..4736f1db669 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -4,14 +4,15 @@ If you encounter an issue with the Java SDK, you are welcome to submit a [bug re Before that, please search for similar issues. It's possible somebody has encountered this issue already. # Building and testing -This project uses [Gradle] as the build tool (> v1.x). Here are some helpful commands: +This project uses [Maven] as the build tool (> v1.x). Here are some helpful commands: ```sh cd java-sdk -gradle jar # build jar file (build/libs/watson-developer-cloud-6.14.0.jar) -gradle test # run tests -gradle check # performs quality checks on source files and generates reports -gradle testReport # run tests and generate the aggregated test report (build/reports/allTests) -gradle codeCoverageReport # run tests and generate the code coverage report (build/reports/jacoco) +mvn clean # Delete target directory. +mvn test # Run tests +mvn package # Take the compiled code and package it in its distributable format, e.g. JAR. +mvn verify # Run any checks to verify the MVN package is valid and meets quality criteria. +mvn verify -fae -DskipITs=false # Run Integration tests to verify the MVN package is valid and meets quality criteria. +mvn install # Install the package into the local maven repository cache. ``` # Pull Requests @@ -19,8 +20,8 @@ gradle codeCoverageReport # run tests and generate the code coverage report (bui If you want to contribute to the repository, here's a quick guide: 1. Fork the repository 1. Edit the [`config.properties`](../common/src/test/resources/config.properties) file to add your service credentials to the appropriate fields. - 2. develop and test your code changes, gradle: `gradle test`. - * Run `checkstyle`: `gradle checkstyle`. 🏁 + 2. develop and test your code changes: `mvn verify -fae -DskipITs=false`. + * Run `checkstyle`: `mvn checkstyle:check`. 🏁 * Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change. * Check for unnecessary whitespace with git diff --check before committing. 3. Make the test pass diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000000..5c51075c04f --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,48 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support documentation. +# This workflow will do a clean install of java dependencies, build the source code and run tests across different versions of java +# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven + +name: Build and Test + +on: + push: + branches: [ '**' ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build_test: + name: Build and Test on Java ${{ matrix.java-version }} and ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + java-version: ['8'] + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java-version }} + distribution: 'adopt' + + - name: Install Java dependencies + run: curl -s https://codecov.io/bash > $HOME/codecov-bash.sh && chmod +x $HOME/codecov-bash.sh + + - name: Execute Java unit tests + env: + MVN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' + run: mvn verify -fae -DskipITs $MVN_ARGS + + - name: Publish Java code coverage + if: github.ref == 'refs/heads/master' + env: + CC_TOK: ${{ secrets.CODECOV_TOKEN }} + run: $HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CC_TOK diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000000..2568b34895b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,122 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support documentation. +# This workflow will download a prebuilt Java version, install dependencies, build and deploy/publish a new release +# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven + +name: Deploy and Publish + +on: + workflow_run: + workflows: ["Build and Test"] + branches: [ master ] + types: + - completed + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + deploy: + if: "!contains(github.event.head_commit.message, 'skip ci')" + name: Deploy and Publish + env: + MVN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GH_TOKEN }} + persist-credentials: true + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Set up Java + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Build Java package + run: mvn verify -fae -DskipITs -Dskip.unit.tests $MVN_ARGS + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install Semantic Release dependencies + run: | + pip3 install --user bump2version + npm install -g semantic-release + npm install -g @semantic-release/changelog + npm install -g @semantic-release/exec + npm install -g @semantic-release/git + npm install -g @semantic-release/github + npm install -g @semantic-release/commit-analyzer + npm install -g @semantic-release/release-notes-generator + + - name: Check if semantic release generated a release + id: is_new_release + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + echo "IS_NEW_RELEASE=$(npx semantic-release --dry-run | grep -c -i "Published release")" >> $GITHUB_OUTPUT + echo "The full TAG - ${{ github.ref }}" + + - name: Get the nextRelease.version from semantic release + if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }} + id: next_release + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: echo "NEXT_RELEASE=$(npx semantic-release --dry-run | grep -oP "Published release \K[0-9]+\.[0-9]+\.[0-9]+")" >> $GITHUB_OUTPUT + + - name: Publish to Git Releases and Tags + if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release # --dry-run --branches 9662_addcheck + + - name: Publish to Maven Central + env: + GHA_TAG: "refs/tags/v16.2.0" # for setMavenVersion_gha + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} # for .travis.settings.xml + CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} + GPG_KEYNAME: ${{ secrets.SIGNING_KEY }} + GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} # for setupSigning_gha + run: | + echo "The NEXT_RELEASE - ${{ steps.next_release.outputs.NEXT_RELEASE }}" + echo -e "\n\033[0;35mCommand: setupSigning" + build/setupSigning_gha.sh + echo -e "\n\033[0;35mCommand: setMavenVersion" + build/setMavenVersion_gha.sh + echo -e "\n\033[0;35mCommand: mvn deploy" + mvn deploy --settings build/.travis.settings.xml -DskipITs -Dskip.unit.tests -P central $MVN_ARGS + + - name: Publish Java docs + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + GHA_REPO_SLUG: ${{ github.repository }} + GHA_BRANCH: ${{ github.ref }} # non PR only need to get last part + GHA_PULL_REQUEST: ${{ github.event.number }} + GHA_BUILD_NUMBER: ${{ github.run_number }} + GHA_JOB_NUMBER: ${{ github.job_number }} + GHA_COMMIT: ${{ github.sha }} + GHA_TAG: "refs/tags/v16.2.0" # for setMavenVersion_gha + run: | + build/setMavenVersion_gha.sh + mvn clean javadoc:aggregate $MVN_ARGS + build/publish_gha.sh + + - name: SKIP - Publish/Deploy to Git and Maven Central + if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '0' }} + run: | + echo -e "\n\033[0;35mCommand: Skipping the deployment because semantic release has determined there are no relevant changes that warrent a new release.\n" diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 00000000000..426617a7ac9 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,79 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support documentation. +# This workflow will download a prebuilt Java version, install dependencies and run integration tests + +name: Run Integration Tests + +on: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + integration_test: + name: Build and Run Integration Tests on Java ${{ matrix.java-version }} and ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + java-version: ['8'] + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java-version }} + distribution: 'adopt' + + - name: Execute Java integration tests + # continue-on-error: true + env: + MVN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' + NATURAL_LANGUAGE_UNDERSTANDING_APIKEY: ${{ secrets.NLU_APIKEY }} + NATURAL_LANGUAGE_UNDERSTANDING_URL: "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com" + SPEECH_TO_TEXT_APIKEY: ${{ secrets.STT_APIKEY }} + SPEECH_TO_TEXT_URL: "https://api.us-south.speech-to-text.watson.cloud.ibm.com" + SPEECH_TO_TEXT_CUSTOM_ID: ${{ secrets.STT_APIKEY_CUSTOM_ID }} + SPEECH_TO_TEXT_ACOUSTIC_CUSTOM_ID: ${{ secrets.STT_APIKEY_ACOUSTIC_CUSTOM_ID }} + TEXT_TO_SPEECH_APIKEY: ${{ secrets.TTS_APIKEY }} + TEXT_TO_SPEECH_URL: "https://api.us-south.text-to-speech.watson.cloud.ibm.com" + ASSISTANT_APIKEY: ${{ secrets.WA_APIKEY }} + ASSISTANT_WORKSPACE_ID: ${{ secrets.WA_WORKSPACE_ID }} + ASSISTANT_ASSISTANT_ID: ${{ secrets.WA_ASSISTANT_ID }} + ASSISTANT_URL: "https://api.us-south.assistant.watson.cloud.ibm.com" + DISCOVERY_V2_APIKEY: ${{ secrets.D2_APIKEY }} + DISCOVERY_V2_PROJECT_ID: ${{ secrets.D2_PROJECT_ID }} + DISCOVERY_V2_COLLECTION_ID: ${{ secrets.D2_COLLECTION_ID }} + DISCOVERY_V2_URL: "https://api.us-south.discovery.watson.cloud.ibm.com" + run: | + mvn test -Dtest=v1/AssistantServiceIT -DfailIfNoTests=false -pl assistant,common $MVN_ARGS + mvn test -Dtest=v2/AssistantServiceIT -DfailIfNoTests=false -pl assistant,common $MVN_ARGS + mvn test -Dtest=v2/DiscoveryIT -DfailIfNoTests=false -pl discovery,common $MVN_ARGS + mvn test -Dtest=NaturalLanguageUnderstandingIT -DfailIfNoTests=false -pl natural-language-understanding,common $MVN_ARGS + mvn test -Dtest=SpeechToTextIT -DfailIfNoTests=false -pl speech-to-text,common $MVN_ARGS + mvn test -Dtest=TextToSpeechIT -DfailIfNoTests=false -pl text-to-speech,common $MVN_ARGS + mvn test -Dtest=CustomizationsIT -DfailIfNoTests=false -pl text-to-speech,common $MVN_ARGS + + # Do not notify on success. We will leave the code here just in case we decide to switch gears + - name: Notify slack on success + if: false # success() + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} + uses: voxmedia/github-action-slack-notify-build@v1 + with: + channel: watson-e2e-tests + status: SUCCESS + color: good + + - name: Notify slack on failure + if: false # failure() + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} + uses: voxmedia/github-action-slack-notify-build@v1 + with: + channel: watson-e2e-tests + status: FAILED + color: danger diff --git a/.gitignore b/.gitignore index c430fc4728c..220350e7b47 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ .idea .project .settings -build out target bin/ @@ -33,4 +32,35 @@ package-lock.json .pre-commit-config.yaml .secrets.baseline *.test-metadata.txt -*.py \ No newline at end of file +*.py +fix-copyrights.sh +/.utility/secring.gpg +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +/**/target/ +/**/test-output/ +.settings/ +.factorypath +*-apiref.json + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar +*.key + +/node_modules \ No newline at end of file diff --git a/.releaserc b/.releaserc index c6e99960da4..5fe2ab68c63 100644 --- a/.releaserc +++ b/.releaserc @@ -1,6 +1,7 @@ { - "branch": "master", "debug": true, + "branches": [ "master" ], + "tagFormat": "v${version}", "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", @@ -8,25 +9,15 @@ [ "@semantic-release/exec", { - "prepareCmd": "bumpversion --current-version ${lastRelease.version} --new-version ${nextRelease.version} --verbose --allow-dirty patch" + "prepareCmd": "bump2version --allow-dirty --current-version ${lastRelease.version} --new-version ${nextRelease.version} patch" } ], [ "@semantic-release/git", { - "message": "docs(release): Add release notes for ${nextRelease.version}" + "message": "chore(release): ${nextRelease.version} release notes\n\n${nextRelease.notes}" } ], - [ - "@semantic-release/github", - { - "assets": [ - { - "path": "ibm-watson/build/libs/*.jar", - "name": "ibm-watson-${nextRelease.version}-jar-with-dependencies.jar" - } - ] - } - ] + "@semantic-release/github" ] -} +} \ No newline at end of file diff --git a/.secrets.baseline b/.secrets.baseline index 30699ff4865..63e7fc50b13 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -1,9 +1,9 @@ { "exclude": { - "files": "package-lock.json|credentials.json", + "files": "package-lock.json|credentials.json|^.secrets.baseline$", "lines": null }, - "generated_at": "2020-03-03T19:34:45Z", + "generated_at": "2024-02-26T19:16:17Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -25,9 +25,7 @@ "name": "CloudantDetector" }, { - "name": "Db2Detector" - }, - { + "ghe_instance": "github.ibm.com", "name": "GheDetector" }, { @@ -66,8 +64,57 @@ "name": "TwilioKeyDetector" } ], - "results": {}, - "version": "0.13.0+ibm.9.dss", + "results": { + "CHANGELOG.md": [ + { + "hashed_secret": "939999726d2023fca902233e45790c08081dc91b", + "is_secret": false, + "is_verified": false, + "line_number": 182, + "type": "Hex High Entropy String", + "verified_result": null + } + ], + "assistant/src/test/resources/assistant/assistant.json": [ + { + "hashed_secret": "49568690e3778497671beb117ceecc48e01cdd4c", + "is_secret": false, + "is_verified": false, + "line_number": 117, + "type": "Secret Keyword", + "verified_result": null + } + ], + "assistant/src/test/resources/assistant/message_response.json": [ + { + "hashed_secret": "d506bd5213c46bd49e16c634754ad70113408252", + "is_secret": false, + "is_verified": false, + "line_number": 165, + "type": "Secret Keyword", + "verified_result": null + } + ], + "discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java": [ + { + "hashed_secret": "e8fc807ce6fbcda13f91c5b64850173873de0cdc", + "is_secret": false, + "is_verified": false, + "line_number": 42, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "fdee05598fdd57ff8e9ae29e92c25a04f2c52fa6", + "is_secret": false, + "is_verified": false, + "line_number": 44, + "type": "Secret Keyword", + "verified_result": null + } + ] + }, + "version": "0.13.1+ibm.56.dss", "word_list": { "file": null, "hash": null diff --git a/.travis.yml b/.travis.yml index ffa38a0135f..02a7a19eae2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,75 +1,78 @@ +--- language: java -dist: trusty +dist: xenial os: linux + jdk: -- openjdk7 -- oraclejdk8 + - openjdk8 + +notifications: + email: true + branches: except: - - gh-pages -before_cache: -- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock -- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ + - gh-pages + cache: directories: - - "$HOME/.m2" - - "$HOME/.gradle/caches/" - - "$HOME/.gradle/wrapper/" -before_install: -- | - if [ "$TRAVIS_JDK_VERSION" == "openjdk7" ]; then - sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}/jre/lib/ext/bcprov-ext-jdk15on-158.jar" - sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security - echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security - fi -- sudo apt-get update -- sudo apt-get install python -install: -- if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then cd appscan; make asoc-tool; cd - ../; fi -- pip install --user bumpversion -before_script: -- if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then chmod a+x ./appscan/ASOC.sh; fi -- env -- echo "TRAVIS_TAG = '${TRAVIS_TAG}'" -script: -- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] - && openssl aes-256-cbc -K $encrypted_42d9c68e608d_key -iv $encrypted_42d9c68e608d_iv -in secrets.tar.enc -out secrets.tar -d - && tar xvf secrets.tar - || true' -- if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then ./appscan/ASOC.sh; fi -- "./gradlew install -x check" -- "./gradlew checkstyleMain" -- "./gradlew checkstyleTest" -- "./gradlew shadowJar" -- if [ "${TRAVIS_EVENT_TYPE}" == "push" ] && [ "${TRAVIS_BRANCH}" != "master" ] && [ "${TRAVIS_TAG}" != "${TRAVIS_BRANCH}" ]; then ./gradlew codeCoverageReport --continue; fi -- "./gradlew docs > /dev/null" -after_success: -- bash <(curl -s https://codecov.io/bash) -before_deploy: -- nvm install 12 -- npm install @semantic-release/changelog -- npm install @semantic-release/exec -- npm install @semantic-release/git -deploy: -- provider: script - skip_cleanup: true - script: npx semantic-release - on: - branch: master - jdk: openjdk7 -- provider: script - script: ".utility/push-javadoc-to-gh-pages.sh" - skip_cleanup: true - on: - repo: watson-developer-cloud/java-sdk - jdk: openjdk7 - tags: true -- provider: script - skip_cleanup: true - script: ".utility/deploy-travis-wrapper.sh" - on: - tags: true - jdk: openjdk7 -notifications: - email: true + - "$HOME/.m2" + +env: + global: + - MVN_ARGS="--settings build/.travis.settings.xml" + +stages: + - name: Build and test + - name: Semantic-Release + if: branch = master AND type = push AND fork = false + - name: Publish-Release + if: tag IS present + +jobs: + include: + - stage: Build and test + jdk: openjdk8 + language: java + install: + - curl -s https://codecov.io/bash > $HOME/codecov-bash.sh && chmod +x $HOME/codecov-bash.sh + script: + - build/setMavenVersion.sh + - mvn verify -fae -DskipITs $MVN_ARGS + after_success: + - build/publishCodeCoverage.sh + + - stage: Semantic-Release + install: + - sudo apt-get install python + - nvm install 12 + - npm install -g npm@6.x + - pip install --user bump2version + - npm install @semantic-release/changelog + - npm install @semantic-release/exec + - npm install @semantic-release/git + - npm install @semantic-release/github + script: + - npx semantic-release + after_success: + - echo "Semantic release has successfully created a new tagged-release" + + - stage: Publish-Release + jdk: openjdk8 + name: Publish-Javadoc + install: true + script: + - build/setMavenVersion.sh + - mvn clean javadoc:aggregate $MVN_ARGS + - build/publishJavadoc.sh + after_success: + - echo "Javadocs successfully published to gh-pages!" + + - jdk: openjdk8 + name: Publish-To-Maven-Central + install: true + script: + - build/setupSigning.sh + - build/setMavenVersion.sh + - mvn deploy $MVN_ARGS -DskipTests -P central + after_success: + - echo "Maven artifacts successfully published to Maven Central!" \ No newline at end of file diff --git a/.utility/bintray-properties.gradle b/.utility/bintray-properties.gradle deleted file mode 100644 index cafd26342be..00000000000 --- a/.utility/bintray-properties.gradle +++ /dev/null @@ -1,8 +0,0 @@ -ext { - packageName = PACKAGE_NAME - libraryName = NAME - artifact = ARTIFACT_ID - libraryDescription = DESCRIPTION -} - -apply from: rootProject.file('.utility/bintray-release.gradle') \ No newline at end of file diff --git a/.utility/bintray-release.gradle b/.utility/bintray-release.gradle deleted file mode 100644 index f4ef12de562..00000000000 --- a/.utility/bintray-release.gradle +++ /dev/null @@ -1,97 +0,0 @@ -apply plugin: 'com.jfrog.bintray' -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: 'java' -apply plugin: 'java-library' -apply plugin: 'maven' -apply plugin: 'maven-publish' - -bintrayUpload.dependsOn assemble -bintrayUpload.dependsOn sourcesJar -bintrayUpload.dependsOn javadocJar - -bintray { - user = System.getenv('BINTRAY_USER') - key = System.getenv('BINTRAY_APIKEY') - publications = ['maven'] - publish = true - pkg { - repo = 'ibm-cloud-sdk-repo' - name = packageName - userOrg = 'ibm-cloud-sdks' - licenses = ['Apache-2.0'] - vcsUrl = 'https://github.com/watson-developer-cloud/java-sdk.git' - version { - name = project.property('version') - vcsTag = project.property('version') - released = new Date() - gpg { - sign = true - } - mavenCentralSync { - sync = true - user = System.getenv('SONATYPE_USER') - password = System.getenv('SONATYPE_PASSWORD') //pragma: whitelist secret - } - } - } -} - -def pomConfig = { - scm { - connection 'scm:git:git@github.com:watson-developer-cloud/java-sdk.git' - developerConnection 'scm:git:git@github.com:watson-developer-cloud/java-sdk.git' - url 'https://github.com/watson-developer-cloud/java-sdk' - } - - issueManagement { - system 'GitHub' - url 'https://github.com/watson-developer-cloud/java-sdk/issues' - - } - - ciManagement { - system 'Travis CI' - url 'https://travis-ci.org/watson-developer-cloud/java-sdk' - } - - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - id 'german' - name 'German Attanasio' - email 'germanatt@us.ibm.com' - } - developer { - id 'logan' - name 'Logan Patino' - email 'loganpatino10@ibm.com' - } - } -} - -publishing { - publications { - maven(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - artifact shadowJar - groupId 'com.ibm.watson' - artifactId artifact - version project.property('version') - pom.withXml { - def root = asNode() - root.appendNode('description', libraryDescription) - root.appendNode('name', libraryName) - root.appendNode('url', 'https://cloud.ibm.com/developer/watson/dashboard') - root.children().last() + pomConfig - } - } - } -} \ No newline at end of file diff --git a/.utility/cd/secring.gpg.enc b/.utility/cd/secring.gpg.enc deleted file mode 100644 index ab53a4058a5..00000000000 Binary files a/.utility/cd/secring.gpg.enc and /dev/null differ diff --git a/.utility/deploy-travis-wrapper.sh b/.utility/deploy-travis-wrapper.sh deleted file mode 100755 index 83070cc73ea..00000000000 --- a/.utility/deploy-travis-wrapper.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -./gradlew bintrayUpload & - -# output every 9 min to prevent a Travis timeout -PID=$! -while [[ $(ps -p $PID | tail -n +2) ]]; do - echo 'Deploying...' - sleep 540 -done diff --git a/.utility/generate-index-html.sh b/.utility/generate-index-html.sh deleted file mode 100755 index 5b896491bad..00000000000 --- a/.utility/generate-index-html.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# based on https://odoepner.wordpress.com/2012/02/17/shell-script-to-generate-simple-index-html/ - -echo ' - - - - - - IBM Watson Developer Cloud - - - -
- - -

Info - | Documentation - | GitHub - | Maven -

- -

Javadoc by branch/tag:

- -
- - -' diff --git a/.utility/push-javadoc-to-gh-pages.sh b/.utility/push-javadoc-to-gh-pages.sh deleted file mode 100755 index 31f444cab13..00000000000 --- a/.utility/push-javadoc-to-gh-pages.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then - - git config --global user.email "wps@us.ibm.com" - git config --global user.name "Watson Github Bot" - git clone --quiet --branch=gh-pages https://${GITHUB_TOKEN_DOCS}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null - - pushd gh-pages - # on tagged builds, $TRAVIS_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master) - rm -rf docs/$TRAVIS_BRANCH - mkdir -p docs/$TRAVIS_BRANCH - cp -rf ../build/docs/all/* docs/$TRAVIS_BRANCH - ../.utility/generate-index-html.sh > index.html - - # update the latest/ symlink - # on tagged builds, $TRAVIS_TAG is set to the tag, but it's blank on regular builds, unlike $TRAVIS_BRANCH - if [ $TRAVIS_TAG ]; then - rm latest - ln -s ./$TRAVIS_TAG latest - fi - - git add -f . - git commit -m "Latest javadoc for $TRAVIS_BRANCH ($TRAVIS_COMMIT)" - git push -fq origin gh-pages > /dev/null - - popd - - echo -e "Published Javadoc for build $TRAVIS_BUILD_NUMBER ($TRAVIS_JOB_NUMBER) on branch $TRAVIS_BRANCH.\n" - -else - - echo -e "Not publishing docs for build $TRAVIS_BUILD_NUMBER ($TRAVIS_JOB_NUMBER) on branch $TRAVIS_BRANCH of repo $TRAVIS_REPO_SLUG" - -fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 621e83a4248..aff974d8a1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,459 @@ +# [16.2.0](https://github.com/watson-developer-cloud/java-sdk/compare/v16.1.0...v16.2.0) (2026-01-14) + + +### Features + +* **stt:** add recognize enrichments, add new function detectLanguage ([b4620f1](https://github.com/watson-developer-cloud/java-sdk/commit/b4620f12b813f0d13a9790e779f84ed2d852370a)) +* **wa-v2:** add dtmf and end_session response types ([5d7be56](https://github.com/watson-developer-cloud/java-sdk/commit/5d7be56a31d88486ef04fb0ea1ee209815ad9c27)) + +# [16.1.0](https://github.com/watson-developer-cloud/java-sdk/compare/v16.0.0...v16.1.0) (2025-11-11) + + +### Features + +* **stt:** add new sad_module param to recognize functions ([1321a46](https://github.com/watson-developer-cloud/java-sdk/commit/1321a46a0d894888330ce6677bef2f5da755c0ff)) +* **tts:** add new voice models ([ef52d55](https://github.com/watson-developer-cloud/java-sdk/commit/ef52d55d3abf731410e9fd3aaf41ea7f58738b97)) + +# [16.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v15.0.0...v16.0.0) (2025-10-09) + + +### Bug Fixes + +* **wa-v2:** fix missing path parameter in HTTP request creation for message functions ([c379682](https://github.com/watson-developer-cloud/java-sdk/commit/c3796825e2bad8f9b2177be3572929397387ad48)) + + +### Features + +* **wa-v2:** add environmentId param to sessions functions and update sdk headers ([7d33340](https://github.com/watson-developer-cloud/java-sdk/commit/7d33340f84796145516e615f0c59c94c52325468)) + + +### BREAKING CHANGES + +* **wa-v2:** `assistantId` and `environmentId` are now required parameters for the `createSession` and `deleteSession` functions + +# [15.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v14.0.2...v15.0.0) (2025-06-18) + + +### Features + +* **stt,tts:** new models and voices ([e2aaf08](https://github.com/watson-developer-cloud/java-sdk/commit/e2aaf0850dd30ce1dfe8c9534171b84a1a146765)) +* **wa-v2:** add new turn event type ([3ec3da0](https://github.com/watson-developer-cloud/java-sdk/commit/3ec3da0fff08ac3b4d1314b9b8c6767d4645ed6c)) + + +### BREAKING CHANGES + +* **wa-v2:** conversationalSearch is now a required parameter when constructing SearchSettings + +Add new llmMetadata property +Add new turn event TurnEventGenerativeAICalledCallout + +## [14.0.2](https://github.com/watson-developer-cloud/java-sdk/compare/v14.0.1...v14.0.2) (2025-05-27) + + +### Bug Fixes + +* **wa-v2:** add missing turn events ([99970d2](https://github.com/watson-developer-cloud/java-sdk/commit/99970d25be792724509df4aad804a8d4cbd164b7)) + +## [14.0.1](https://github.com/watson-developer-cloud/java-sdk/compare/v14.0.0...v14.0.1) (2025-05-07) + + +### Bug Fixes + +* **wa-v2:** add conversational_search_end turn event ([ca524b1](https://github.com/watson-developer-cloud/java-sdk/commit/ca524b1753150ff7f5b0b8a2fac17428a3c41c8d)) + +# [14.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v13.0.0...v14.0.0) (2024-12-05) + + +### Bug Fixes + +* **nlu:** remove summarization param ([3fa8b85](https://github.com/watson-developer-cloud/java-sdk/commit/3fa8b850dac020d11fa3534236723afaeb1af089)) + + +### Features + +* **discov1:** remove discoV1 ([2d64d0d](https://github.com/watson-developer-cloud/java-sdk/commit/2d64d0d76b2838617c639b9eb651df4460628398)) +* **discov2:** add methods for new batches api ([750a115](https://github.com/watson-developer-cloud/java-sdk/commit/750a1155f081ff1bddcb9b963f3c56e3402595b9)) +* **lt:** remove lt and other deprecated resources ([254428b](https://github.com/watson-developer-cloud/java-sdk/commit/254428b0bd0167c0df3acfefe1128a9655cd5d7e)) +* **stt:** add new speech models ([5ca34b2](https://github.com/watson-developer-cloud/java-sdk/commit/5ca34b2542ca3aff3f2c1d039dbf9ae99eb62504)) +* **stt:** readd interimResults and lowLatency wss params ([6696356](https://github.com/watson-developer-cloud/java-sdk/commit/669635661a4eb81847e448d40bb8181509beada1)) +* **WxA:** add new functions and update required params ([a429786](https://github.com/watson-developer-cloud/java-sdk/commit/a429786aed4c0e9c8411599fcd262343eb831905)) + + +### BREAKING CHANGES + +* **WxA:** `environmentId` now required for `message` and `messageStateless` functions + +Add support for message streaming and new APIs +New functions: createProviders, listProviders, updateProviders, createReleaseExport, downloadReleaseExport, createReleaseImport, getReleaseImportStatus, messageStream, messageStreamStateless +* **lt:** LanguageTranslator functionality has been removed +* **discov1:** DiscoveryV1 functionality has been removed + +# [13.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v12.0.1...v13.0.0) (2024-05-20) + + +### Features + +* **discov2:** add ocrEnabled parameter ([45ec51d](https://github.com/watson-developer-cloud/java-sdk/commit/45ec51d59adce5923f30e59790d08d22002c6417)) +* **stt:** add speechBeginEvent param to recognize func ([5cb5238](https://github.com/watson-developer-cloud/java-sdk/commit/5cb5238bb7822c6397c0fe2fdf7c0c71dae600ac)) +* **stt:** remove interimResults and lowLatency wss params ([4c571c2](https://github.com/watson-developer-cloud/java-sdk/commit/4c571c22e725858908b57628ec251b178e763392)) + + +### BREAKING CHANGES + +* **stt:** RecognizeWithWebsocketsOptions interimResults and +lowLatency properties removed + +## [12.0.1](https://github.com/watson-developer-cloud/java-sdk/compare/v12.0.0...v12.0.1) (2024-03-13) + + +### Bug Fixes + +* **stt:** change smartFormattingVersion to a Long ([258c406](https://github.com/watson-developer-cloud/java-sdk/commit/258c406c6d38f676d1961691453742cd6402cc45)) +* **wss:** add smartFormattingVersion to websockets ([9806d3c](https://github.com/watson-developer-cloud/java-sdk/commit/9806d3cce178322c2011451fc7e41e67539d90ca)) + +# [12.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v11.0.1...v12.0.0) (2024-02-26) + + +### Bug Fixes + +* **wa-v2:** fix tests and delete unused models ([3e7e9c7](https://github.com/watson-developer-cloud/java-sdk/commit/3e7e9c79dd524833f8a1ccaa50f60e9a6ef969cb)) + + +### Features + +* **disco-v2:** class changes ([ba46325](https://github.com/watson-developer-cloud/java-sdk/commit/ba463252ae00560c0cec40c960b7649efd06fd83)) +* **discov2:** new EnrichmentOptions parameters ([78d93b7](https://github.com/watson-developer-cloud/java-sdk/commit/78d93b70dd570ce8acd8260b676b0d124f31de9d)) +* **mcsp:** update sdk-core for MCSP authenticator support ([8e9f831](https://github.com/watson-developer-cloud/java-sdk/commit/8e9f8319f92f51d74d4fc1b1a433e0415a38b206)) +* **nlu:** add support for userMetadata param ([a00b9d7](https://github.com/watson-developer-cloud/java-sdk/commit/a00b9d76dddb1bfba98db8938f4f07ddbaa56de7)) +* **stt:** new params ([56755c6](https://github.com/watson-developer-cloud/java-sdk/commit/56755c6f50bf0638de3c85093ea819db7e7071fe)) +* **wa-v2:** new method params ([439ed47](https://github.com/watson-developer-cloud/java-sdk/commit/439ed4784e9a0a1d510bacfa0b0cd656afa87dff)) +* **wa-v2:** support for private variables ([89f2209](https://github.com/watson-developer-cloud/java-sdk/commit/89f2209f937a22b6b00fa26cfddcb4ab991c541f)) + + +### BREAKING CHANGES + +* **disco-v2:** TableBodyCells properties changed to string lists. +Location property changed from Map to TableElementLocation. +* **wa-v2:** Multiple class name changes and Log class property type +changes + +## [11.0.1](https://github.com/watson-developer-cloud/java-sdk/compare/v11.0.0...v11.0.1) (2023-08-08) + + +### Bug Fixes + +* **pom:** upgrade sdk-core ([#1220](https://github.com/watson-developer-cloud/java-sdk/issues/1220)) ([5ce39c7](https://github.com/watson-developer-cloud/java-sdk/commit/5ce39c7c800bd8ae7b4dfa17ffdaf7a865f1fc4c)) + +# [11.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v10.1.0...v11.0.0) (2023-03-16) + + +### Features + +* **assistantv1:** update based on api definitions ([d2aebb9](https://github.com/watson-developer-cloud/java-sdk/commit/d2aebb9b0f9428b9ba7673f6e768049df32acac7)) +* **assistantv2:** add new assistant, environment, and skills lifecycle methods ([aaf9b77](https://github.com/watson-developer-cloud/java-sdk/commit/aaf9b773317042358240fb62fd369dad69678092)) +* **discoveryv1:** update based on latest api definitions ([a810f01](https://github.com/watson-developer-cloud/java-sdk/commit/a810f01ef76b8513f26c0fc1a0e07a06d5bad50c)) +* **discoveryv2:** update based on api definitions ([1e2682f](https://github.com/watson-developer-cloud/java-sdk/commit/1e2682f82318500d817c4a9e78493277773780f1)) +* **language translator:** update based on api definitions ([d45607b](https://github.com/watson-developer-cloud/java-sdk/commit/d45607b472b5c1899cba393e628c1d632ffcf6f0)) +* **natural language understanding:** update based on api definitions ([a743cb7](https://github.com/watson-developer-cloud/java-sdk/commit/a743cb7f774b66790da4e9fbe059602e93cbbf6f)) +* **speech to text:** update based on new api definitions ([0a7058b](https://github.com/watson-developer-cloud/java-sdk/commit/0a7058bc169c8d39a7e541b677108e75d2067bbe)) +* **text to speech:** update based on api definitions ([54fd47d](https://github.com/watson-developer-cloud/java-sdk/commit/54fd47dd50ea517834c4109a1ecca87785662507)) + + +### BREAKING CHANGES + +* **natural language understanding:** removes the 'sentimentModel' functions and models +* **discoveryv2:** 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. +* **assistantv2:** 'createSession' param replaced with 'requestAnalytics' param. 'language' property +removed from 'Environment' model. method name changes in environment and release models. +* **assistantv1:** public interface 'Model' in 'WorkspaceSystemSettingsNlp' has been removed + +# [10.1.0](https://github.com/watson-developer-cloud/java-sdk/compare/v10.0.1...v10.1.0) (2022-08-10) + + +### Bug Fixes + +* **assistantv2:** add discrim bug hand edit for TurnEvent models ([4f4894f](https://github.com/watson-developer-cloud/java-sdk/commit/4f4894f17197d9bebf138e539758b5c072dcc36a)) +* **discov2:** make enrichement_id required and linting changes ([995e687](https://github.com/watson-developer-cloud/java-sdk/commit/995e687a07a1af9806b2f66dbcdeeaac03978d8b)) + + +### Features + +* **assistantv1:** update models and add new methods ([64a2622](https://github.com/watson-developer-cloud/java-sdk/commit/64a2622378df1874e3e259c09bceb9978a3a9aba)) +* **assistantv2:** update models and add new methods ([2f164cd](https://github.com/watson-developer-cloud/java-sdk/commit/2f164cd0a1f48749044c8b70f5e95ce72a3a69fc)) +* **discov2:** update models and add new methods ([a29cb73](https://github.com/watson-developer-cloud/java-sdk/commit/a29cb7311798d7023112773b930bde993be2d804)) +* **nlu:** add new parameter to create/updateClassificationsModel ([680d2c0](https://github.com/watson-developer-cloud/java-sdk/commit/680d2c0a94198ca4ec605755a89f47b4f8cca296)) +* **stt:** add and remove method parameters ([cdcc228](https://github.com/watson-developer-cloud/java-sdk/commit/cdcc2280e528ac5e2900b032a82dbb3020237b8f)) +* **tts:** add method parameters ([2a0c2f3](https://github.com/watson-developer-cloud/java-sdk/commit/2a0c2f3f64c07bed920639daa391e976f75d790f)) +* **wss:** add and remove websocket params ([bfd4b0d](https://github.com/watson-developer-cloud/java-sdk/commit/bfd4b0df203f3f0dac51c5b29bcb8895b7847b14)) + +## [10.0.1](https://github.com/watson-developer-cloud/java-sdk/compare/v10.0.0...v10.0.1) (2022-04-25) + + +### Bug Fixes + +* **language-translator-v3:** add content-type to createModelOptions model properties ([afd1086](https://github.com/watson-developer-cloud/java-sdk/commit/afd1086ccbb30fa1d84b83e19c9d9a7bf472b4bc)) + +# [10.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v9.3.1...v10.0.0) (2022-03-21) + + +### Bug Fixes + +* **bumpversion:** update bumpversion file ([ca7b4e8](https://github.com/watson-developer-cloud/java-sdk/commit/ca7b4e87279d63fea920e279de88c80516d3bca3)) + + +### Features + +* **assistant-v1:** add new DialogNodeOutputGeneric subclasses & additional properties in workspace ([dfeacca](https://github.com/watson-developer-cloud/java-sdk/commit/dfeacca3201245a1a5902669be9e051dcb320506)) +* **assistant-v1:** generated using api-def: master & generator: 3.46.0 ([dc7f6a4](https://github.com/watson-developer-cloud/java-sdk/commit/dc7f6a4acad722a507724732f7e17ffeb992d4ba)) +* **assistant-v2:** generated using api-def: master & generator: 3.46.0 ([4fdfb2f](https://github.com/watson-developer-cloud/java-sdk/commit/4fdfb2faca5a047d841de45cba0ca26633618ef3)) +* **deprecation:** remove CC, NLC, PI, Tone Analyzer, and Visual Recognition ([1b64285](https://github.com/watson-developer-cloud/java-sdk/commit/1b64285fd5b3d0765e2435627ae65ffcce097136)) +* **discovery-v1:** document status & query aggregation update ([776048c](https://github.com/watson-developer-cloud/java-sdk/commit/776048cbc7a2d2938d63bfb6eabcc4fded56a44b)) +* **speech-to-text-v1:** add de-de_multimedia & update comments ([0d32576](https://github.com/watson-developer-cloud/java-sdk/commit/0d32576bc7405e6a4c39f01688b41f1e5bab180b)) +* **speech-to-text-v1:** add missing import ([029fdfa](https://github.com/watson-developer-cloud/java-sdk/commit/029fdfa9afc51acc3f673daf07aa43dec6dd4691)) +* **speech-to-text-v1:** supportedFeatures: customAcousticModel property added & update comments ([62e4f8e](https://github.com/watson-developer-cloud/java-sdk/commit/62e4f8ec354d2746acdcd07bce28dec348214fba)) +* **text-to-speech-v1:** add voices and update comments ([40cd035](https://github.com/watson-developer-cloud/java-sdk/commit/40cd0358c131d2e3767b16d9bedf2ddd256e7fd2)) + + +### Reverts + +* **pom.xml:** revert change for root pom.xml ([5fecba8](https://github.com/watson-developer-cloud/java-sdk/commit/5fecba83ac663ceb6766061c81878369a46963f7)) + + +### BREAKING CHANGES + +* **discovery-v1:** QueryAggregation: BREAKING QueryAggregation subclasses changed. +* **assistant-v2:** MessageOutputDebug: BREAKING nodesVisited type DialogNodesVisited changed to +DialogNodeVisited, RuntimeEntity: BREAKING optional metadata property removed +* **assistant-v1:** OutputData: BREAKING required text property removed, RuntimeEntity: BREAKING +optional metadata property removed + +## [9.3.1](https://github.com/watson-developer-cloud/java-sdk/compare/v9.3.0...v9.3.1) (2021-12-02) + + +### Bug Fixes + +* **deploy.yml:** up the version for node to fix semantic-release ([bcda21d](https://github.com/watson-developer-cloud/java-sdk/commit/bcda21d843a55ff81894735c720dc47775890ae4)) +* **pom.xml:** update sdk-core version to fix Gson 2.8.9 java.lang.NoSuchFieldError ([40b287e](https://github.com/watson-developer-cloud/java-sdk/commit/40b287ecd79dfb898de3051d673cd406af7364a7)) + +# [9.3.0](https://github.com/watson-developer-cloud/java-sdk/compare/v9.2.2...v9.3.0) (2021-09-14) + + +### Bug Fixes + +* **assistant-v1:** location is no longer a required parameter for RuntimeEntity ([4014b36](https://github.com/watson-developer-cloud/java-sdk/commit/4014b365cd862ceca885855796fc8595c7662f36)) +* **assistant-v2:** add answers to searchResult ([8d53d6c](https://github.com/watson-developer-cloud/java-sdk/commit/8d53d6c71b6ef6fb31119ed5bcd082e1bf6dcbb6)) +* **assistant-v2:** location is no longer a required parameter for RuntimeEntity ([2971a3b](https://github.com/watson-developer-cloud/java-sdk/commit/2971a3b22fab6092e5f4c05c6e96f2871c5d4905)) +* **discovery-v1:** change authentication to authenticated property in StatusDetails ([e7b3cae](https://github.com/watson-developer-cloud/java-sdk/commit/e7b3caeebc07e53a11421369237c013df6dd1d88)) +* **discovery-v1:** status is now deserialized as an object ([c72b497](https://github.com/watson-developer-cloud/java-sdk/commit/c72b497317ca33a9b6017458f8f2fce9ee528748)) +* **natural-language-understanding-v1:** listClassificationsModels return type change ([5776b7b](https://github.com/watson-developer-cloud/java-sdk/commit/5776b7b97cedef31420fe88fa59d7e3fce048638)) +* **natural-language-understanding-v1:** remove unused models ([8e894dc](https://github.com/watson-developer-cloud/java-sdk/commit/8e894dc16b8aeabf76f9e9c33977188a9f840d16)) + + +### Features + +* **assistant-v1:** add altText property to DialogNodeOutputGeneric & RuntimeResponseGeneric ([66acc78](https://github.com/watson-developer-cloud/java-sdk/commit/66acc78bcb3ce1d4fe495c93ca646d4d8741c98a)) +* **assistant-v1:** add extra sensitivity values for RuntimeResponseGenericRuntimeResponseTypeImage ([86b331d](https://github.com/watson-developer-cloud/java-sdk/commit/86b331d935b8b1719cb7b1cafff24baaaa423506)) +* **assistant-v2:** add altText property to RuntimeResponseGeneric ([798f780](https://github.com/watson-developer-cloud/java-sdk/commit/798f780b71a67ec3e3b13ef19f44dec151d3c22c)) +* **assistant-v2:** add SEARCH as a type of the message to MessageInput & MessageInputStateless ([b9a3427](https://github.com/watson-developer-cloud/java-sdk/commit/b9a342794f2594033c5a48b8323610f30eedd527)) +* **assistant-v2:** add sessionStartTime & state properties to MessageContextGlobalSystem ([6cd0b2e](https://github.com/watson-developer-cloud/java-sdk/commit/6cd0b2e50079f7435ee935588d2a38cdc7c5bab7)) +* **discovery-v2:** add CONVERSATIONAL_SEARCH & CONTENT_INTELLIGENCE as a type of a project ([ec6e753](https://github.com/watson-developer-cloud/java-sdk/commit/ec6e7531d8c39a0c3aa3c4a392071e982a1fba65)) +* **speech-to-text-v1:** add more languages supported for next generation models ([2fbd050](https://github.com/watson-developer-cloud/java-sdk/commit/2fbd050306f2912fc7648e4ed70cd48abea54dad)) +* **speech-to-text-v1:** add more languages supported for next generation models ([c03ea09](https://github.com/watson-developer-cloud/java-sdk/commit/c03ea099880c06f1717486c226debfede9eeb30b)) +* **text-to-speech-v1:** add new voice models ([54d2338](https://github.com/watson-developer-cloud/java-sdk/commit/54d2338a4d216e629db767415d6e066e6e22a45e)) + +## [9.2.2](https://github.com/watson-developer-cloud/java-sdk/compare/v9.2.1...v9.2.2) (2021-09-01) + + +### Bug Fixes + +* **nlc:** add a deprecation message ([#1185](https://github.com/watson-developer-cloud/java-sdk/issues/1185)) ([b460cdd](https://github.com/watson-developer-cloud/java-sdk/commit/b460cddc4e1b27765441a8cfc1e0139bd92b5ff7)) + +## [9.2.1](https://github.com/watson-developer-cloud/java-sdk/compare/v9.2.0...v9.2.1) (2021-08-17) + + +### Bug Fixes + +* **deploy:** use bump2version ([d4bbc44](https://github.com/watson-developer-cloud/java-sdk/commit/d4bbc44cd49b4227cd2338f99a0aad58c0019753)) +* **deploy:** use python ([03168b4](https://github.com/watson-developer-cloud/java-sdk/commit/03168b48e64780f3d17eb714f2adf6ff8c479d26)) +* **deploy.xml:** fix typo on deploy.xml gha ([9136c47](https://github.com/watson-developer-cloud/java-sdk/commit/9136c47c549be29b7b600e844946da928ca42890)) +* **pom.xml:** update java-sdk-core version ([c6814a5](https://github.com/watson-developer-cloud/java-sdk/commit/c6814a58a4a271689fa1df8d3dc4772c838bce05)) + +# [9.2.0](https://github.com/watson-developer-cloud/java-sdk/compare/v9.1.1...v9.2.0) (2021-06-02) + + +### Bug Fixes + +* **text-to-speech-v1:** generated using api def sdk-2021-05-11-rerelease and gen 3.31.0 ([e825419](https://github.com/watson-developer-cloud/java-sdk/commit/e8254194cd199c3039a61a58c65039eadecfb562)) + + +### Features + +* **generation:** generated using api def sdk-2021-05-11 & gen 3.31.0 ([82ef647](https://github.com/watson-developer-cloud/java-sdk/commit/82ef647c855b7d226104ab4a3bf56de8dce748c5)) +* **generation:** generated using api def: sdk-2021-05-11 and generator: 3.31.0 ([c039886](https://github.com/watson-developer-cloud/java-sdk/commit/c039886481d21e70c2d66bbf3aacb56543ada9a3)) +* **natural-language-understanding-v1:** generated using api def 5b4cdff & gen 3.31.0 ([ac51578](https://github.com/watson-developer-cloud/java-sdk/commit/ac515782a0e1e1541b3852d490d0ad8f8d8fce9e)) + +## [9.1.1](https://github.com/watson-developer-cloud/java-sdk/compare/v9.1.0...v9.1.1) (2021-05-17) + + +### Bug Fixes + +* **bumpversion:** update bumpversion configuration ([e6b97d6](https://github.com/watson-developer-cloud/java-sdk/commit/e6b97d6d13a627290dea54dea14d67d6aab3bdfa)) + +# [9.1.0](https://github.com/watson-developer-cloud/java-sdk/compare/v9.0.2...v9.1.0) (2021-04-30) + + +### Bug Fixes + +* **assistant-v1:** override toString method to allow null values ([dc0a023](https://github.com/watson-developer-cloud/java-sdk/commit/dc0a023d6b1f6748134d584f71dc804494ade737)) + + +### Features + +* **assistant-v1:** add updateDialogNodeNullable as a new function ([90e3ea5](https://github.com/watson-developer-cloud/java-sdk/commit/90e3ea5c7f9036c096721724320e7f4000b91325)) + +## [9.0.2](https://github.com/watson-developer-cloud/java-sdk/compare/v9.0.1...v9.0.2) (2020-12-21) + + +### Bug Fixes + +* **generation:** api def '8be1cdc78c7998b055bc8ea895dddd7c8496b2a4' gen tag 3.19.0 ([1ddf534](https://github.com/watson-developer-cloud/java-sdk/commit/1ddf534ff0d10481e7246abb37df1b88d9421d9e)) + +## [9.0.1](https://github.com/watson-developer-cloud/java-sdk/compare/v9.0.0...v9.0.1) (2020-12-11) + + +### Bug Fixes + +* **readme:** add extra line to readme to trigger patch release ([f5d1a06](https://github.com/watson-developer-cloud/java-sdk/commit/f5d1a0696835e079a3349b5a4575a1d1a1658047)) + +# [9.0.0](https://github.com/watson-developer-cloud/java-sdk/compare/v8.6.3...v9.0.0) (2020-12-10) + + +### Bug Fixes + +* **sdk-version:** fix sdk-version ([3019159](https://github.com/watson-developer-cloud/java-sdk/commit/3019159999a36e5065bdfe33f2976e625aec10f4)) +* **visual-recognition-v4:** remove trainingStatus as a parameter for create & update Collection ([02e3dfd](https://github.com/watson-developer-cloud/java-sdk/commit/02e3dfd0fb972f3081c91921f6acf61fdcc2f1e6)) +* **visual-recognition-v4:** remove trainingStatus as a parameter for create & update Collection ([5568bf9](https://github.com/watson-developer-cloud/java-sdk/commit/5568bf99e47ad92420253c936db7bc8fac13a7f0)) +* typo in migration guide ([984a350](https://github.com/watson-developer-cloud/java-sdk/commit/984a3503502a7867470b3e342fe959643ae0a561)) +* update version to 9.0.0-rc.2 ([ab57379](https://github.com/watson-developer-cloud/java-sdk/commit/ab573794f351e00f6fb97e3fed0e7d3ad20fb824)) + + +### chore + +* update for semantic-release ([22a7d00](https://github.com/watson-developer-cloud/java-sdk/commit/22a7d008c6e333a944c3b0f6a96f142f587e5aed)) + + +### Features + +* **generation:** api def tag 'sdk-major-release-2020' gen tag 3.19.0 ([3414833](https://github.com/watson-developer-cloud/java-sdk/commit/3414833807abe8534e6daf838500a5426e9e4e04)) +* add bumpversion release candidate support ([b794bb6](https://github.com/watson-developer-cloud/java-sdk/commit/b794bb6407e461af0edd99952e08b98e8d4a95e2)) +* **generation:** api def tag 'sdk-major-release-2020-rc01' gen commit '7cc0550' ([3bec20d](https://github.com/watson-developer-cloud/java-sdk/commit/3bec20d5ccae38ba2a1f1d8adf6cf16cdc2c6a18)) +* **speech-to-text-v1:** add RecognizeWithWebsocketsOptions model ([d3b7fe9](https://github.com/watson-developer-cloud/java-sdk/commit/d3b7fe91fad17fa6ef6dd00a5ecc38b689dfd016)) + + +### BREAKING CHANGES + +* **generation:** api def tag 'sdk-major-release-2020' gen tag 3.19.0 +* generated with 3.18.0 of the IBM openapi sdk generator + +# [9.0.0-rc.3](https://github.com/watson-developer-cloud/java-sdk/compare/v9.0.0-rc.2...v9.0.0-rc.3) (2020-12-03) + + +### Features + +* **generation:** api def tag 'sdk-major-release-2020' gen tag 3.19.0 ([3414833](https://github.com/watson-developer-cloud/java-sdk/commit/3414833807abe8534e6daf838500a5426e9e4e04)) + + +### BREAKING CHANGES + +* **generation:** api def tag 'sdk-major-release-2020' gen tag 3.19.0 + +# [9.0.0-rc.2](https://github.com/watson-developer-cloud/java-sdk/compare/v9.0.0-rc.1...v9.0.0-rc.2) (2020-11-11) + + +### Bug Fixes + +* typo in migration guide ([984a350](https://github.com/watson-developer-cloud/java-sdk/commit/984a3503502a7867470b3e342fe959643ae0a561)) +* update version to 9.0.0-rc.2 ([ab57379](https://github.com/watson-developer-cloud/java-sdk/commit/ab573794f351e00f6fb97e3fed0e7d3ad20fb824)) + + +### Features + +* add bumpversion release candidate support ([b794bb6](https://github.com/watson-developer-cloud/java-sdk/commit/b794bb6407e461af0edd99952e08b98e8d4a95e2)) + +# [9.0.0-rc.1](https://github.com/watson-developer-cloud/java-sdk/compare/v8.6.3...v9.0.0-rc.1) (2020-11-10) + + +### chore + +* update for semantic-release ([22a7d00](https://github.com/watson-developer-cloud/java-sdk/commit/22a7d008c6e333a944c3b0f6a96f142f587e5aed)) + + +### Features + +* **generation:** api def tag 'sdk-major-release-2020-rc01' gen commit '7cc0550' ([3bec20d](https://github.com/watson-developer-cloud/java-sdk/commit/3bec20d5ccae38ba2a1f1d8adf6cf16cdc2c6a18)) +* **speech-to-text-v1:** add RecognizeWithWebsocketsOptions model ([d3b7fe9](https://github.com/watson-developer-cloud/java-sdk/commit/d3b7fe91fad17fa6ef6dd00a5ecc38b689dfd016)) + + +### BREAKING CHANGES + +* generated with 3.18.0 of the IBM openapi sdk generator + +## [8.6.3](https://github.com/watson-developer-cloud/java-sdk/compare/v8.6.2...v8.6.3) (2020-10-26) + + +### Bug Fixes + +* **java-sdk-core-version:** update java-sdk-core version to fix serialization error on disco-v2 ([e75e97d](https://github.com/watson-developer-cloud/java-sdk/commit/e75e97d99b98376d568b87ba9747779bf9c8d39f)) + +## [8.6.2](https://github.com/watson-developer-cloud/java-sdk/compare/v8.6.1...v8.6.2) (2020-10-18) + + +### Bug Fixes + +* **decrpyt-script:** place encrypted file on the right path ([07737f2](https://github.com/watson-developer-cloud/java-sdk/commit/07737f257604defdda795511049b59ab19b8d406)) +* **decrypt-script:** update decrypt script ([2a28685](https://github.com/watson-developer-cloud/java-sdk/commit/2a286855dee6c663b9faeffbcae786364bec8e10)) +* **readme:** create a patch for latest update on speech-to-text ([b858e48](https://github.com/watson-developer-cloud/java-sdk/commit/b858e481ef9961c69e787652c67a9fcca661c0c4)) +* **tests&keys:** update api keys and integration tests ([26049c1](https://github.com/watson-developer-cloud/java-sdk/commit/26049c160b91e23f8f41703f3a90ebfdfb2e778c)) + +## [8.6.1](https://github.com/watson-developer-cloud/java-sdk/compare/v8.6.0...v8.6.1) (2020-09-28) + + +### Bug Fixes + +* **generation:** api def tag 'sdk-2020-08-20' with disco-v2 passage update gen tag '2.3.1' ([1b8b67c](https://github.com/watson-developer-cloud/java-sdk/commit/1b8b67c194c4cd2d0a6b01c43a4e15da31b9294b)) + +# [8.6.0](https://github.com/watson-developer-cloud/java-sdk/compare/v8.5.0...v8.6.0) (2020-08-25) + + +### Features + +* **generation:** api def tag 'sdk-2020-08-20' and gen tag '2.3.1' ([1129e9b](https://github.com/watson-developer-cloud/java-sdk/commit/1129e9b39e417408dc4cb22f497d7f3bb4361f9e)) + +# [8.5.0](https://github.com/watson-developer-cloud/java-sdk/compare/v8.4.0...v8.5.0) (2020-06-03) + + +### Features + +* june release ([a637c98](https://github.com/watson-developer-cloud/java-sdk/commit/a637c985990f7776a7fec25f6190405991a1cc87)) + +# [8.4.0](https://github.com/watson-developer-cloud/java-sdk/compare/v8.3.1...v8.4.0) (2020-04-23) + + +### Bug Fixes + +* **javadoc:** update links to common classes ([973d153](https://github.com/watson-developer-cloud/java-sdk/commit/973d153fa0b66be2ad486f394e87d1f32b9a836a)) + + +### Features + +* **assistant:** auto-generate code ([515fb60](https://github.com/watson-developer-cloud/java-sdk/commit/515fb605e110e3171fcecb1323ae7ccb2ac9a07e)) +* **discovery:** auto-generate code ([9812072](https://github.com/watson-developer-cloud/java-sdk/commit/9812072be571d908156b43a508c61dc5057ef10f)) +* **language-translator:** auto-generate code ([2676798](https://github.com/watson-developer-cloud/java-sdk/commit/2676798211fe65bb972107907df5c4febe813d27)) +* **speech-to-text:** auto-generate code ([2261d67](https://github.com/watson-developer-cloud/java-sdk/commit/2261d67fb350df90bb932c4878edf93001f73dba)) +* **text-to-speech:** auto-generate code ([87be679](https://github.com/watson-developer-cloud/java-sdk/commit/87be6796a17402aa03456de37c2510b889e3fe06)) + ## [8.3.1](https://github.com/watson-developer-cloud/java-sdk/compare/v8.3.0...v8.3.1) (2020-03-06) diff --git a/MIGRATION-V8.md b/MIGRATION-V8.md deleted file mode 100644 index 2395fafa535..00000000000 --- a/MIGRATION-V8.md +++ /dev/null @@ -1,313 +0,0 @@ -### v8.0.0 Migration guide -This document should serve as a guide to breaking changes for users moving from code using the v7.x.x version of the SDK to v8.x.x. - -#### Authentication - -##### v7.x.x - -Previously, there were different builder objects for authentication. For example: - -```java -// username and password -BasicAuthConfig config = new BasicAuthConfig.Builder() - .username("") - .password("") - .url("") - .build(); -``` - -This could be set multiple ways: - -```java -// in the constructor -IamOptions options = new IamOptions.Builder() - .apiKey("") - .url("") - .build(); -Assistant service = new Assistant("2019-02-28", options); - -// after instantiation -service.setAuthenticator(options); - -// inline in the constructor (only for username and password!) -Assistant service = new Assistant("2019-02-28", "", ""); -``` - -Overall, it was a little too open-ended and very confusing to follow. For this release, we've decided to standardize things, while developing a pattern that should be more scalable. - -##### v8.x.x - -There are 5 authentication variants supplied in the SDK (shown below), and it's possible now to create your own authentication implementation if you need something specific by implementing the `Authenticator` implementation. - -##### Basic -You can authenticate with basic auth using the `BasicAuthenticator`. This allows you to pass in a username and password. - -```java -Authenticator authenticator = new BasicAuthenticator("", ""); -``` - -##### Bearer token -Use the `BearerTokenAuthenticator`. This one accepts just the bearer token. - -```java -Authenticator authenticator = new BearerTokenAuthenticator(""); -``` - -##### Cloud Pak for Data -This class helps you authenticate with your services on (Cloud Pak for Data)[https://www.ibm.com/analytics/cloud-pak-for-data). - -```java -// constructor with required parameters -Authenticator authenticator = new CloudPakForDataAuthenticator( - "", - "", - "" -); -``` - -There's also another constructor to disable SSL verification or send request headers on the token exchange. - -##### IAM -Like the `CloudPakForDataAuthenticator`, there's a basic constructor - -```java -Authenticator authenticator = new IamAuthenticator(""); -``` - -and another one to supply additional arguments like a particular token exchange URL, a client ID and secret, and the same options to disable SSL verification and send headers. - -##### None -Finally, there's the `NoAuthAuthenticator`, which is pretty self-explanatory. Pass this when you don't need any authentication to happen. - -```java -Assistant service = new Assistant("2019-02-28", new NoAuthAuthenticator()); -``` - -#### Supplying credentials - -As before, you can supply credentials to your service using external `ibm-credentials.env` files. - -```java -Assistant service = new Assistant("2019-02-28"); -WorkspaceCollection response = service.listWorkspaces().execute().getResult(); -``` - -##### v7.x.x - -Previously we would look for these files first in the system `home` directory, followed by the current project directory. - -##### v8.x.x - -Now in order to allow developers to have different configurations for each project we look first in the current project directory, followed by the home directory. - -#### Setting the service url - -##### v7.x.x - -For a while now, we've allowed users to set the service URL with `setEndPoint()`: - -```java -IamOptions options = new IamOptions.Builder() - .apiKey("") - .url("") - .build(); -Assistant service = new Assistant("2019-02-28", options); -service.setEndPoint(""); -``` - -##### v8.x.x - -To align with our other SDKs and be a bit more clear, that method has been renamed to `setServiceUrl()`: - -```java -Authenticator authenticator = new IamAuthenticator(""); -Assistant service = new Assistant("2019-02-28", authenticator); -service.setServiceUrl(""); -``` - -#### More model builders -If you've used the SDK before, you're probably familiar with the use of the builder pattern across the board. With this release, we've tweaked the generation process to capture better which are models that are being constructed to be sent to the service. These are models we'd prefer to have builders, making it easier to put them together. - -There are unfortunately a decent number of models which move to this pattern, but it's one we expect to use well into the future. Here's the comprehensive list of models that now use this: - -##### Assistant v1 -- `CaptureGroup` -- `DialogNodeAction` -- `DialogNodeNextStep` -- `DialogNodeOutputGeneric` -- `DialogNodeOutputModifiers` -- `DialogNodeOutputOptionsElement` -- `DialogNodeOutputOptionsElementValue` -- `DialogNodeOutputTextValuesElement` -- `DialogNodeVisitedDetails` -- `DialogSuggestion` -- `DialogSuggestionValue` -- `LogMessage` -- `Mention` -- `MessageContextMetadata` -- `MessageRequest` -- `RuntimeEntity` -- `RuntimeIntent` -- `WorkspaceSystemSettings` -- `WorkspaceSystemSettingsDisambiguation` -- `WorkspaceSystemSettingsTooling` -##### Assistant v2 -- `CaptureGroup` -- `MessageContext` -- `MessageContextGlobal` -- `MessageContextGlobalSystem` -- `MessageContextSkill` -- `MessageInputOptions` -- `RuntimeEntity` -- `RuntimeIntent` -##### Compare and Comply -- `Category` -- `FeedbackDataInput` -- `Label` -- `Location` -- `OriginalLabelsIn` -- `ShortDoc` -- `TypeLabel` -- `UpdatedLabelsIn` -##### Discovery -- `Configuration` -- `Conversions` -- `CredentialDetails` -- `Credentials` -- `Enrichment` -- `EventData` -- `Expansion` -- `Expansions` -- `FontSetting` -- `HtmlSettings` -- `NluEnrichmentConcepts` -- `NluEnrichmentRelations` -- `NormalizationOperation` -- `PdfHeadingDetection` -- `PdfSettings` -- `SegmentSettings` -- `Source` -- `SourceOptions` -- `SourceOptionsBuckets` -- `SourceOptionsFolder` -- `SourceOptionsObject` -- `SourceOptionsSiteColl` -- `SourceOptionsWebCrawl` -- `SourceSchedule` -- `TokenDictRule` -- `TrainingExample` -- `WordHeadingDetection` -- `WordSettings` -- `WordStyle` -- `XPathPatterns` -##### Natural Language Classifier -- `ClassifyInput` -##### Natural Language Understanding -- `MetadataOptions` -- `SyntaxOptionsTokens` -##### Speech to Text -- `CustomWord` -##### Text to Speech -- `Translation` -- `Word` -- `Words` - -#### Removed `ContentType` constant from models - -Previously, options models which accepted a `contentType` parameter would typically contain a set of constants for possible values. For example: - -```java -RecognizeOptions.ContentType.AUDIO_WAV -``` - -These have been removed. You can use the `HttpMediaType` helper class to achieve the same thing: -```java -// equivalent to above -HttpMediaType.AUDIO_WAV -``` - -#### Service changes - -##### Assistant v1 - -* `includeCount` is no longer a parameter of the `listWorkspaces()` method -* `includeCount` is no longer a parameter of the `listIntents()` method -* `includeCount` is no longer a parameter of the `listExamples()` method -* `includeCount` is no longer a parameter of the `listCounterexamples()` method -* `includeCount` is no longer a parameter of the `listEntities()` method -* `includeCount` is no longer a parameter of the `listValues()` method -* `includeCount` is no longer a parameter of the `listSynonyms()` method -* `includeCount` is no longer a parameter of the `listDialogNodes()` method -* `valueType` was renamed to `type` in the `createValue()` method -* `newValueType` was renamed to `newType` in the `updateValue()` method -* `nodeType` was renamed to `type` in the `createDialogNode()` method -* `nodeType` was renamed to `type` in the `createDialogNode()` method -* `newNodeType` was renamed to `newType` in the `updateDialogNode()` method -* `ValueType` was renamed to `Type` in the `CreateValue` model -* `NodeType` was renamed to `Type` in the `DialogNode` model -* `ActionType` was renamed to `Type` in the `DialogNodeAction` model -* `SEARCH_SKILL` constant was added to the `DialogNodeOutputGeneric` model -* `QueryType` constants were added to the `DialogNodeOutputGeneric` model -* `queryType` property was added to the `DialogNodeOutputGeneric` model -* `query` property was added to the `DialogNodeOutputGeneric` model -* `filter` property was added to the `DialogNodeOutputGeneric` model -* `discoveryVersion` property was added to the `DialogNodeOutputGeneric` model -* `output` property type was converted from `Map` to `DialogSuggestionOutput` in the `DialogSuggestion` model -* `LogMessage` model no longer has `additionalProperties` -* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric` -* `RuntimeEntity` model no longer has `additionalProperties` -* `RuntimeIntent` model no longer has `additionalProperties` -* `ValueType` was renamed to `Type` in the `Value` model - -##### Assistant v2 - -* `ActionType` was renamed to `Type` in the `DialogNodeAction` model -* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric` - -##### Compare Comply v1 - -* `convertToHtml()` method does not require a `filename` parameter - -##### Discovery v1 - -* `returnFields` was renamed to `xReturn` in the `query()` method -* `loggingOptOut` was renamed to `xWatsonLoggingOptOut` in the `query()` method -* `spellingSuggestions` was added to the `query()` method -* `collectionIds` is no longer a parameter of the `query()` method -* `returnFields` was renamed to `xReturn` in the `QueryNotices()` method -* `loggingOptOut` was renamed to `xWatsonLoggingOptOut` in the `federatedQuery()` method -* `collectionIds` is now required in the `federatedQuery()` method -* `returnFields` was renamed to `xReturn` in the `federatedQuery()` method -* `returnFields` was renamed to `xReturn` in the `federatedQueryNotices()` method -* `enrichmentName` was renamed to `enrichment` in the `Enrichment` model -* `FieldTypeEnumValue` was renamed to `TypeEnumValue` in the `Field` model -* `FieldType` was renamed to `Type` in the `Field` model -* `fieldName` was renamed to `field` in the `Field` model -* `testConfigurationInEnvironment()` method was removed -* `queryEntities()` method was removed -* `queryRelations()` method was removed - -##### Language Translator v3 - -* `defaultModels` was renamed to `xDefault` in the `listModels()` method -* `translationOutput` was renamed to `translation` in the `Translation` model - -##### Natural Language Classifier v1 - -* `metadata` was renamed to `trainingMetadata` in the `createClassifier()` method - -##### Speech to Text v1 - -* `finalResults` was renamed to `xFinal` in the `SpeakerLabelsResult` model -* `finalResults` was renamed to `xFinal` in the `SpeechRecognitionResult` model - -##### Visual Recognition v3 - -* `detectFaces()` method was removed -* `className` was renamed to `xClass` in the `Class` model -* `className` was renamed to `xClass` in the `ClassResult` model diff --git a/README.md b/README.md index 83f4d77094b..8ad9af32b9d 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,13 @@ # Watson APIs Java SDK -[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) - -[![Build Status](https://travis-ci.org/watson-developer-cloud/java-sdk.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/java-sdk) -[![Slack](https://wdc-slack-inviter.mybluemix.net/badge.svg)](https://wdc-slack-inviter.mybluemix.net) +[![Build and Test](https://github.com/watson-developer-cloud/java-sdk/actions/workflows/build-test.yml/badge.svg)](https://github.com/watson-developer-cloud/java-sdk/actions/workflows/build-test.yml) +[![Deploy and Publish](https://github.com/watson-developer-cloud/java-sdk/actions/workflows/deploy.yml/badge.svg)](https://github.com/watson-developer-cloud/java-sdk/actions/workflows/deploy.yml) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson/ibm-watson/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson/ibm-watson) [![CLA assistant](https://cla-assistant.io/readme/badge/watson-developer-cloud/java-sdk)](https://cla-assistant.io/watson-developer-cloud/java-sdk) -Java client library to use the [Watson APIs][wdc]. +## Deprecated builds +[![Build Status](https://travis-ci.org/watson-developer-cloud/java-sdk.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/java-sdk) -
- Table of Contents - - * [Before you begin](#before-you-begin) - * [Installation](#installation) - * [Maven](#maven) - * [Gradle](#gradle) - * [Usage](#usage) - * [Running in IBM Cloud](#running-in-ibm-cloud) - * [Authentication](#authentication) - * [IAM](#iam) - * [Username and password](#username-and-password) - * [ICP](#icp) - * [Cloud Pak for Data](#cloud-pak-for-data) - * [Using the SDK](#using-the-sdk) - * [Parsing responses](#parsing-responses) - * [Configuring the HTTP client](#configuring-the-http-client) - * [Making asynchronous API calls](#making-asynchronous-api-calls) - * [Default headers](#default-headers) - * [Sending request headers](#sending-request-headers) - * [Canceling requests](#canceling-requests) - * [Transaction IDs](#transaction-ids) - * [FAQ](#faq) - * IBM Watson Services - * [Assistant](assistant) - * [Compare and Comply](compare-comply) - * [Discovery](discovery) - * [Language Translator](language-translator) - * [Natural Language Classifier](natural-language-classifier) - * [Natural Language Understanding](natural-language-understanding) - * [Personality Insights](personality-insights) - * [Speech to Text](speech-to-text) - * [Text to Speech](text-to-speech) - * [Tone Analyzer](tone-analyzer) - * [Tradeoff Analytics](tradeoff-analytics) - * [Visual Recognition](visual-recognition) - * [Android](#android) - * [Debug](#debug) - * [Eclipse and Intellij](#working-with-eclipse-and-intellij-idea) - * [License](#license) - * [Contributing](#contributing) - * [Featured projects](#featured-projects) - -
+Java client library to use the [Watson APIs][wdc]. ## Before you begin * You need an [IBM Cloud][ibm-cloud-onboarding] account. @@ -65,7 +21,7 @@ All the services: com.ibm.watson ibm-watson - 8.3.1 + 16.2.0 ``` @@ -75,7 +31,7 @@ Only Discovery: com.ibm.watson discovery - 8.3.1 + 16.2.0 ``` @@ -83,19 +39,15 @@ Only Discovery: All the services: ```gradle -'com.ibm.watson:ibm-watson:8.3.1' +'com.ibm.watson:ibm-watson:16.2.0' ``` Only Assistant: ```gradle -'com.ibm.watson:assistant:8.3.1' +'com.ibm.watson:assistant:16.2.0' ``` -##### JAR - -Download the jar with dependencies [here][jar]. - Now, you are ready to see some [examples](https://github.com/watson-developer-cloud/java-sdk/tree/master/examples/src/main/java/com/ibm/watson). ## Usage @@ -115,6 +67,13 @@ If you have more than one plan, you can use `CredentialUtils` to get the service Watson services are migrating to token-based Identity and Access Management (IAM) authentication. +As of `v9.2.1`, the preferred approach of initializing an authenticator is the builder pattern. This pattern supports +constructing the authenticator with only the properties that you need. Also, if you're authenticating to a Watson service +on Cloud Pak for Data that supports IAM, you must use the builder pattern. + +- You can initialize the authenticator with either of the following approaches: + - In the builder of the authenticator (builder pattern). + - In the constructor of the authenticator (deprecated, but still available). - With some service instances, you authenticate to the API by using **[IAM](#iam)**. - In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance. - If you're using a Watson service on Cloud Pak for Data, you'll need to authenticate in a [specific way](#cloud-pak-for-data). @@ -147,7 +106,7 @@ The file downloaded will be called `ibm-credentials.env`. This is the name the S As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following: ```java -Discovery service = new Discovery("2019-04-30"); +Discovery service = new Discovery("2023-03-31"); ``` And that's it! @@ -173,15 +132,27 @@ Some services use token-based Identity and Access Management (IAM) authenticatio You supply either an IAM service **API key** or an **access token**: - Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary. -- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/services/watson/getting-started-iam.html). +- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/watson?topic=watson-iam). Supplying the IAM API key: +Builder pattern approach: + +```java +// letting the SDK manage the IAM token +Authenticator authenticator = new IamAuthenticator.Builder() + .apikey("") + .build(); +Discovery service = new Discovery("2023-03-31", authenticator); +``` + +Deprecated constructor approach: + ```java // letting the SDK manage the IAM token Authenticator authenticator = new IamAuthenticator(""); -Discovery service = new Discovery("2019-04-30", authenticator); +Discovery service = new Discovery("2023-03-31", authenticator); ``` Supplying the access token: @@ -189,14 +160,26 @@ Supplying the access token: ```java // assuming control of managing IAM token Authenticator authenticator = new BearerTokenAuthenticator(""); -Discovery service = new Discovery("2019-04-30", authenticator); +Discovery service = new Discovery("2023-03-31", authenticator); ``` #### Username and password +Builder pattern approach: + +```java +Authenticator authenticator = new BasicAuthenticator.Builder() + .username("") + .password("") + .build(); +Discovery service = new Discovery("2023-03-31", authenticator); +``` + +Deprecated constructor approach: + ```java Authenticator authenticator = new BasicAuthenticator("", ""); -Discovery service = new Discovery("2019-04-30", authenticator); +Discovery service = new Discovery("2023-03-31", authenticator); ``` #### ICP @@ -204,7 +187,7 @@ Authenticating with ICP is similar to the basic username and password method, ex ```java Authenticator authenticator = new BasicAuthenticator("", ""); -Discovery service = new Discovery("2019-04-30", authenticator); +Discovery service = new Discovery("2023-03-31", authenticator); HttpConfigOptions options = new HttpConfigOptions.Builder() .disableSslVerification(true) @@ -216,6 +199,23 @@ service.configureClient(options); #### Cloud Pak for Data Like IAM, you can pass in credentials to let the SDK manage an access token for you or directly supply an access token to do it yourself. +Builder pattern approach: + +```java +// letting the SDK manage the token +Authenticator authenticator = new CloudPakForDataAuthenticator.Builder() + .url("") + .username("") + .password("") + .disableSSLVerification(true) + .headers(null) + .build(); +Discovery service = new Discovery("2023-03-31", authenticator); +service.setServiceUrl(""); +``` + +Deprecated constructor approach: + ```java // letting the SDK manage the token Authenticator authenticator = new CloudPakForDataAuthenticator( @@ -225,19 +225,32 @@ Authenticator authenticator = new CloudPakForDataAuthenticator( true, // disabling SSL verification null, ); -Discovery service = new Discovery("2019-04-30", authenticator); +Discovery service = new Discovery("2023-03-31", authenticator); service.setServiceUrl(""); ``` ```java // assuming control of managing the access token Authenticator authenticator = new BearerTokenAuthenticator(""); -Discovery service = new Discovery("2019-04-30", authenticator); +Discovery service = new Discovery("2023-03-31", authenticator); service.setServiceUrl(""); ``` Be sure to both disable SSL verification when authenticating and set the endpoint explicitly to the URL given in Cloud Pak for Data. +#### MCSP +To use the SDK through a third party cloud provider (such as AWS), use the `MCSPAuthenticator`. This will require the base endpoint URL for the MCSP token service (e.g. https://iam.platform.saas.ibm.com) and an apikey. + +```java +// letting the SDK manage the token +Authenticator authenticator = new MCSPAuthenticator.Builder() + .apikey("apikey") + .url("token_service_endpoint") + .build(); +Assistant service = new Assistant("2023-06-15", authenticator); +service.setServiceUrl(""); +``` + ## Using the SDK ### Parsing responses @@ -261,20 +274,26 @@ System.out.println("Response header names: " + responseHeaders.names()); ### Configuring the HTTP client -The HTTP client can be configured by using the `configureClient()` method on your service object, passing in an `HttpConfigOptions` object. Currently, the following options are supported: +The HTTP client can be configured by using the `setProxy()` method on your authenticator and using the `configureClient()` method on your service object, passing in an `HttpConfigOptions` object. For a full list of configurable options look at this linked Builder class for [HttpConfigOptions](https://github.com/IBM/java-sdk-core/blob/c053e1ccf4bc4267b0ce0be5538564fac088f57b/src/main/java/com/ibm/cloud/sdk/core/http/HttpConfigOptions.java#L95). Currently, the following options are supported: - Disabling SSL verification (only do this if you really mean to!) ⚠️ +- Setting gzip compression +- Setting max retry and retry interval - Using a proxy (more info here: [OkHTTPClient Proxy authentication how to?](https://stackoverflow.com/a/35567936/456564)) - Setting HTTP logging verbosity Here's an example of setting the above: ```java -Discovery service = new Discovery("2019-04-30"); +Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", 8080)); +IamAuthenticator authenticator = new IamAuthenticator(apiKey); +authenticator.setProxy(proxy); + +Discovery service = new Discovery("2023-03-31", authenticator); // setting configuration options HttpConfigOptions options = new HttpConfigOptions.Builder() .disableSslVerification(true) - .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", 8080))) + .proxy(proxy) .loggingLevel(HttpConfigOptions.LoggingLevel.BASIC) .build(); @@ -396,7 +415,7 @@ Doing so will call your `onFailure()` implementation. ### Transaction IDs -Every SDK call returns a response with a transaction ID in the `x-global-transaction-id` header. This transaction ID is useful for troubleshooting and accessing relevant logs from your service instance. +Every SDK call returns a response with a transaction ID in the `X-Global-Transaction-Id` header. This transaction ID is useful for troubleshooting and accessing relevant logs from your service instance. ```java Assistant service = new Assistant("2019-02-28"); @@ -406,14 +425,28 @@ Response response; try { // In a successful case, you can grab the ID with the following code. response = service.listWorkspaces(options).execute(); - String transactionId = response.getHeaders().values("x-global-transaction-id").get(0); + String transactionId = response.getHeaders().values("X-Global-Transaction-Id").get(0); } catch (ServiceResponseException e) { // This is how you get the ID from a failed request. // Make sure to use the ServiceResponseException class or one of its subclasses! - String transactionId = e.getHeaders().values("x-global-transaction-id").get(0); + String transactionId = e.getHeaders().values("X-Global-Transaction-Id").get(0); } ``` +However, the transaction ID isn't available when the API doesn't return a response for some reason. In that case, you can set your own transaction ID in the request. For example, replace `` in the following example with a unique transaction ID. +```java +Authenticator authenticator = new IamAuthenticator("apiKey"); +service = new Assistant("{version-date}", authenticator); +service.setServiceUrl("{serviceUrl}"); + +Map headers = new HashMap<>(); +headers.put("X-Global-Transaction-Id", ""); +service.setDefaultHeaders(headers); + +MessageOptions options = new MessageOptions.Builder(workspaceId).build(); +MessageResponse result = service.message(options).execute().getResult(); +``` + ## FAQ ### Does this SDK play well with Android? @@ -435,13 +468,13 @@ We do :sunglasses: http://ibm.github.io/ [wdc]: https://www.ibm.com/watson/developer/ [ibm_cloud]: https://cloud.ibm.com [apache_maven]: http://maven.apache.org/ -[vcap_services]: https://cloud.ibm.com/docs/services/watson/getting-started-variables.html +[vcap_services]: https://cloud.ibm.com/docs/watson?topic=watson-vcapServices [ibm-cloud-onboarding]: http://cloud.ibm.com/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Java ## Featured projects We'd love to highlight cool open-source projects that use this SDK! If you'd like to get your project added to the list, feel free to make an issue linking us to it. -[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/v8.3.1/ibm-watson-8.3.1-jar-with-dependencies.jar +[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/v16.2.0/ibm-watson-16.2.0-jar-with-dependencies.jar ## Contributors ✨ @@ -453,8 +486,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - + + + + +

Logan Patino

💻 🎨 🐛

Ajiemar Santiago

👀

German Attanasio

💻

Ajiemar Santiago

💻 🎨 🐛

German Attanasio

💻 🎨 📖 ⚠️

Kevin Kowalski

💻 🎨 🐛 📖 ⚠️ 💬️

Jeff Arn

💻 🎨 🐛 📖 ⚠️ 💬️

Angelo Paparazzi

💻 🎨 🐛 📖 ⚠️ 💬️ 🥷🏼
diff --git a/RELEASE.md b/RELEASE.md index 4ec7e5ad18c..02e3e8a4a07 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -17,7 +17,7 @@ If things **don't** go smoothly, you'll need to follow some other instructions t The most common reason for a release to fail is because of a Travis timeout. Builds are only allowed to run for a maximum of 1 hour, and unfortunately the syncing process between Bintray and Maven Central can be slow enough to go over this time limit sometimes. If this happens, you should do the following: - Navigate to the code on Bintray at [this URL](https://bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo). If you're not a member of the ibm-cloud-sdks organization, ask the maintainer of this SDK repo for access. -- Navigate to the "Maven Central" tab in each of the packages that didn't sync. Here's an example: https://bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo/com.ibm.watson%3Alanguage-translator#central. You can figure out which packages to sync manually by checking the failed Travis build log or by looking at the "Last Synced" date for the package. +- Navigate to the "Maven Central" tab in each of the packages that didn't sync. Here's an example: https://bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo/com.ibm.watson%3Anatural-language-understanding#central. You can figure out which packages to sync manually by checking the failed Travis build log or by looking at the "Last Synced" date for the package. - Click the "Sync" button. If you need to provide Sonatype credentials, you can also ask the maintainer of this SDK repo for those. Bintray sync diff --git a/assistant/README.md b/assistant/README.md index dfe2e052a3e..457f2b4b38a 100644 --- a/assistant/README.md +++ b/assistant/README.md @@ -8,14 +8,14 @@ com.ibm.watson assistant - 8.3.1 + 16.2.0 ``` ##### Gradle ```gradle -'com.ibm.watson:assistant:8.3.1' +'com.ibm.watson:assistant:16.2.0' ``` ## Usage diff --git a/assistant/build.gradle b/assistant/build.gradle deleted file mode 100644 index ec219455832..00000000000 --- a/assistant/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/assistant/gradle.properties b/assistant/gradle.properties deleted file mode 100644 index 72e0aa5bdd0..00000000000 --- a/assistant/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:assistant -ARTIFACT_ID=assistant -NAME=IBM Watson Java SDK - Assistant -DESCRIPTION=Java client library to use the IBM Assistant API \ No newline at end of file diff --git a/assistant/pom.xml b/assistant/pom.xml new file mode 100644 index 00000000000..5450d344495 --- /dev/null +++ b/assistant/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + assistant + jar + IBM Watson Java SDK - Assistant + + + + com.ibm.cloud + sdk-core + + + ${project.groupId} + common + compile + + + ${project.groupId} + common + test-jar + tests + test + + + org.testng + testng + test + + + com.launchdarkly + okhttp-eventsource + 4.1.1 + + + com.squareup.okhttp3 + mockwebserver + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java index c006a765259..2c99bedb32f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029 + */ + package com.ibm.watson.assistant.v1; import com.google.gson.JsonObject; @@ -20,6 +25,8 @@ import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import com.ibm.watson.assistant.v1.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v1.model.BulkClassifyResponse; import com.ibm.watson.assistant.v1.model.Counterexample; import com.ibm.watson.assistant.v1.model.CounterexampleCollection; import com.ibm.watson.assistant.v1.model.CreateCounterexampleOptions; @@ -29,6 +36,7 @@ import com.ibm.watson.assistant.v1.model.CreateIntentOptions; import com.ibm.watson.assistant.v1.model.CreateSynonymOptions; import com.ibm.watson.assistant.v1.model.CreateValueOptions; +import com.ibm.watson.assistant.v1.model.CreateWorkspaceAsyncOptions; import com.ibm.watson.assistant.v1.model.CreateWorkspaceOptions; import com.ibm.watson.assistant.v1.model.DeleteCounterexampleOptions; import com.ibm.watson.assistant.v1.model.DeleteDialogNodeOptions; @@ -46,6 +54,7 @@ import com.ibm.watson.assistant.v1.model.EntityMentionCollection; import com.ibm.watson.assistant.v1.model.Example; import com.ibm.watson.assistant.v1.model.ExampleCollection; +import com.ibm.watson.assistant.v1.model.ExportWorkspaceAsyncOptions; import com.ibm.watson.assistant.v1.model.GetCounterexampleOptions; import com.ibm.watson.assistant.v1.model.GetDialogNodeOptions; import com.ibm.watson.assistant.v1.model.GetEntityOptions; @@ -73,196 +82,328 @@ import com.ibm.watson.assistant.v1.model.Synonym; import com.ibm.watson.assistant.v1.model.SynonymCollection; import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions; +import com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions; import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; import com.ibm.watson.assistant.v1.model.UpdateIntentOptions; import com.ibm.watson.assistant.v1.model.UpdateSynonymOptions; import com.ibm.watson.assistant.v1.model.UpdateValueOptions; +import com.ibm.watson.assistant.v1.model.UpdateWorkspaceAsyncOptions; import com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions; import com.ibm.watson.assistant.v1.model.Value; import com.ibm.watson.assistant.v1.model.ValueCollection; import com.ibm.watson.assistant.v1.model.Workspace; import com.ibm.watson.assistant.v1.model.WorkspaceCollection; import com.ibm.watson.common.SdkCommon; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; /** - * The IBM Watson™ Assistant service combines machine learning, natural language understanding, and an integrated - * dialog editor to create conversation flows between your apps and your users. + * The IBM Watson&trade; Assistant service combines machine learning, natural language + * understanding, and an integrated dialog editor to create conversation flows between your apps and + * your users. * - * The Assistant v1 API provides authoring methods your application can use to create or update a workspace. + *

The Assistant v1 API provides authoring methods your application can use to create or update a + * workspace. * - * @version v1 - * @see Assistant + *

API Version: 1.0 See: https://cloud.ibm.com/docs/assistant */ public class Assistant extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "assistant"; + /** Default service name used when configuring the `Assistant` client. */ + public static final String DEFAULT_SERVICE_NAME = "assistant"; - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/assistant/api"; + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.assistant.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `Assistant` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Assistant` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2021-11-27`. */ - public Assistant(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + public Assistant(String version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Assistant` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. + * Constructs an instance of the `Assistant` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2021-11-27`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Assistant(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Assistant` client with the specified serviceName. + * Constructs an instance of the `Assistant` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2021-11-27`. + * @param serviceName the service name to be used when configuring the client instance */ - public Assistant(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Assistant(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Assistant` client with the specified Authenticator - * and serviceName. + * Constructs an instance of the `Assistant` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2021-11-27`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, String serviceName, Authenticator authenticator) { + public Assistant(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } /** - * Get response to user input. + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2021-11-27`. * - * Send user input to a workspace and receive a response. + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + + /** + * Update dialog node. * - * **Important:** This method has been superseded by the new v2 runtime API. The v2 API offers significant advantages, - * including ease of deployment, automatic state management, versioning, and search capabilities. For more - * information, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-api-overview). + *

Update an existing dialog node with new or modified data. * - * There is no rate limit for this operation. + *

If you want to update multiple dialog nodes with a single API call, consider using the + * **[Update workspace](#update-workspace)** method instead. + * + * @param UpdateDialogNodeNullableOptions the {@link UpdateDialogNodeNullableOptions} containing + * the options for the call + * @return a {@link ServiceCall} with a result of type {@link DialogNode} + */ + public ServiceCall updateDialogNodeNullable( + UpdateDialogNodeNullableOptions UpdateDialogNodeNullableOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + UpdateDialogNodeNullableOptions, "UpdateDialogNodeNullableOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", UpdateDialogNodeNullableOptions.workspaceId()); + pathParamsMap.put("dialog_node", UpdateDialogNodeNullableOptions.dialogNode()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "testUpdateDialogNode"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (UpdateDialogNodeNullableOptions.includeAudit() != null) { + builder.query( + "include_audit", String.valueOf(UpdateDialogNodeNullableOptions.includeAudit())); + } + builder.bodyContent( + com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithSerializeNulls() + .toJson(UpdateDialogNodeNullableOptions.body()), + "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get response to user input. + * + *

Send user input to a workspace and receive a response. + * + *

**Important:** This method has been superseded by the new v2 runtime API. The v2 API offers + * significant advantages, including ease of deployment, automatic state management, versioning, + * and search capabilities. For more information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-api-overview). * * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponse} + * @return a {@link ServiceCall} with a result of type {@link MessageResponse} */ public ServiceCall message(MessageOptions messageOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, - "messageOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "message" }; - String[] pathParameters = { messageOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, "messageOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", messageOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/message", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "message"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (messageOptions.nodesVisitedDetails() != null) { builder.query("nodes_visited_details", String.valueOf(messageOptions.nodesVisitedDetails())); } final JsonObject contentJson = new JsonObject(); if (messageOptions.input() != null) { - contentJson.add("input", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.input())); + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.input())); } if (messageOptions.intents() != null) { - contentJson.add("intents", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions - .intents())); + contentJson.add( + "intents", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.intents())); } if (messageOptions.entities() != null) { - contentJson.add("entities", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions - .entities())); + contentJson.add( + "entities", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageOptions.entities())); } if (messageOptions.alternateIntents() != null) { contentJson.addProperty("alternate_intents", messageOptions.alternateIntents()); } if (messageOptions.context() != null) { - contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions - .context())); + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.context())); } if (messageOptions.output() != null) { - contentJson.add("output", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions - .output())); + contentJson.add( + "output", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.output())); + } + if (messageOptions.userId() != null) { + contentJson.addProperty("user_id", messageOptions.userId()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * List workspaces. + * Identify intents and entities in multiple user utterances. * - * List the workspaces associated with a Watson Assistant service instance. + *

Send multiple user inputs to a workspace in a single request and receive information about + * the intents and entities recognized in each input. This method is useful for testing and + * comparing the performance of different workspaces. * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. + *

This method is available only with Enterprise with Data Isolation plans. * - * @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection} + * @param bulkClassifyOptions the {@link BulkClassifyOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link BulkClassifyResponse} */ - public ServiceCall listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) { - String[] pathSegments = { "v1/workspaces" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listWorkspaces"); + public ServiceCall bulkClassify(BulkClassifyOptions bulkClassifyOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + bulkClassifyOptions, "bulkClassifyOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", bulkClassifyOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/bulk_classify", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "bulkClassify"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listWorkspacesOptions != null) { - if (listWorkspacesOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit())); - } - if (listWorkspacesOptions.sort() != null) { - builder.query("sort", listWorkspacesOptions.sort()); - } - if (listWorkspacesOptions.cursor() != null) { - builder.query("cursor", listWorkspacesOptions.cursor()); - } - if (listWorkspacesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit())); - } + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (bulkClassifyOptions.input() != null) { + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(bulkClassifyOptions.input())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List workspaces. * - * List the workspaces associated with a Watson Assistant service instance. + *

List the workspaces associated with a Watson Assistant service instance. * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. + * @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link WorkspaceCollection} + */ + public ServiceCall listWorkspaces( + ListWorkspacesOptions listWorkspacesOptions) { + if (listWorkspacesOptions == null) { + listWorkspacesOptions = new ListWorkspacesOptions.Builder().build(); + } + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "listWorkspaces"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listWorkspacesOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit())); + } + if (listWorkspacesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listWorkspacesOptions.includeCount())); + } + if (listWorkspacesOptions.sort() != null) { + builder.query("sort", String.valueOf(listWorkspacesOptions.sort())); + } + if (listWorkspacesOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listWorkspacesOptions.cursor())); + } + if (listWorkspacesOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List workspaces. + * + *

List the workspaces associated with a Watson Assistant service instance. * - * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection} + * @return a {@link ServiceCall} with a result of type {@link WorkspaceCollection} */ public ServiceCall listWorkspaces() { return listWorkspaces(null); @@ -271,27 +412,35 @@ public ServiceCall listWorkspaces() { /** * Create workspace. * - * Create a workspace based on component objects. You must provide workspace components defining the content of the - * new workspace. + *

Create a workspace based on component objects. You must provide workspace components + * defining the content of the new workspace. * - * This operation is limited to 30 requests per 30 minutes. For more information, see **Rate limiting**. + *

**Note:** The new workspace data cannot be larger than 1.5 MB. For larger requests, use the + * **Create workspace asynchronously** method. * - * @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) { - String[] pathSegments = { "v1/workspaces" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createWorkspace"); + boolean skipBody = false; + if (createWorkspaceOptions == null) { + createWorkspaceOptions = new CreateWorkspaceOptions.Builder().build(); + skipBody = true; + } + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "createWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (createWorkspaceOptions != null) { - if (createWorkspaceOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(createWorkspaceOptions.includeAudit())); - } + builder.query("version", String.valueOf(this.version)); + if (createWorkspaceOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(createWorkspaceOptions.includeAudit())); + } + if (!skipBody) { final JsonObject contentJson = new JsonObject(); if (createWorkspaceOptions.name() != null) { contentJson.addProperty("name", createWorkspaceOptions.name()); @@ -302,54 +451,69 @@ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorks if (createWorkspaceOptions.language() != null) { contentJson.addProperty("language", createWorkspaceOptions.language()); } + if (createWorkspaceOptions.dialogNodes() != null) { + contentJson.add( + "dialog_nodes", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.dialogNodes())); + } + if (createWorkspaceOptions.counterexamples() != null) { + contentJson.add( + "counterexamples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.counterexamples())); + } if (createWorkspaceOptions.metadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createWorkspaceOptions.metadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.metadata())); } if (createWorkspaceOptions.learningOptOut() != null) { contentJson.addProperty("learning_opt_out", createWorkspaceOptions.learningOptOut()); } if (createWorkspaceOptions.systemSettings() != null) { - contentJson.add("system_settings", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createWorkspaceOptions.systemSettings())); + contentJson.add( + "system_settings", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.systemSettings())); + } + if (createWorkspaceOptions.webhooks() != null) { + contentJson.add( + "webhooks", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.webhooks())); } if (createWorkspaceOptions.intents() != null) { - contentJson.add("intents", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions - .intents())); + contentJson.add( + "intents", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.intents())); } if (createWorkspaceOptions.entities() != null) { - contentJson.add("entities", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createWorkspaceOptions.entities())); - } - if (createWorkspaceOptions.dialogNodes() != null) { - contentJson.add("dialog_nodes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createWorkspaceOptions.dialogNodes())); - } - if (createWorkspaceOptions.counterexamples() != null) { - contentJson.add("counterexamples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createWorkspaceOptions.counterexamples())); - } - if (createWorkspaceOptions.webhooks() != null) { - contentJson.add("webhooks", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createWorkspaceOptions.webhooks())); + contentJson.add( + "entities", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.entities())); } builder.bodyJson(contentJson); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create workspace. * - * Create a workspace based on component objects. You must provide workspace components defining the content of the - * new workspace. + *

Create a workspace based on component objects. You must provide workspace components + * defining the content of the new workspace. * - * This operation is limited to 30 requests per 30 minutes. For more information, see **Rate limiting**. + *

**Note:** The new workspace data cannot be larger than 1.5 MB. For larger requests, use the + * **Create workspace asynchronously** method. * - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall createWorkspace() { return createWorkspace(null); @@ -358,27 +522,26 @@ public ServiceCall createWorkspace() { /** * Get information about a workspace. * - * Get information about a workspace, optionally including all workspace content. - * - * With **export**=`false`, this operation is limited to 6000 requests per 5 minutes. With **export**=`true`, the - * limit is 20 requests per 30 minutes. For more information, see **Rate limiting**. + *

Get information about a workspace, optionally including all workspace content. * * @param getWorkspaceOptions the {@link GetWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getWorkspaceOptions, - "getWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { getWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getWorkspaceOptions, "getWorkspaceOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getWorkspaceOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getWorkspaceOptions.export() != null) { builder.query("export", String.valueOf(getWorkspaceOptions.export())); } @@ -386,38 +549,43 @@ public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptio builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit())); } if (getWorkspaceOptions.sort() != null) { - builder.query("sort", getWorkspaceOptions.sort()); + builder.query("sort", String.valueOf(getWorkspaceOptions.sort())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update workspace. * - * Update an existing workspace with new or modified data. You must provide component objects defining the content of - * the updated workspace. + *

Update an existing workspace with new or modified data. You must provide component objects + * defining the content of the updated workspace. * - * This operation is limited to 30 request per 30 minutes. For more information, see **Rate limiting**. + *

**Note:** The new workspace data cannot be larger than 1.5 MB. For larger requests, use the + * **Update workspace asynchronously** method. * - * @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateWorkspaceOptions, - "updateWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { updateWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateWorkspace"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateWorkspaceOptions, "updateWorkspaceOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateWorkspaceOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "updateWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateWorkspaceOptions.append() != null) { builder.query("append", String.valueOf(updateWorkspaceOptions.append())); } @@ -434,143 +602,414 @@ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorks if (updateWorkspaceOptions.language() != null) { contentJson.addProperty("language", updateWorkspaceOptions.language()); } + if (updateWorkspaceOptions.dialogNodes() != null) { + contentJson.add( + "dialog_nodes", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.dialogNodes())); + } + if (updateWorkspaceOptions.counterexamples() != null) { + contentJson.add( + "counterexamples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.counterexamples())); + } if (updateWorkspaceOptions.metadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions - .metadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.metadata())); } if (updateWorkspaceOptions.learningOptOut() != null) { contentJson.addProperty("learning_opt_out", updateWorkspaceOptions.learningOptOut()); } if (updateWorkspaceOptions.systemSettings() != null) { - contentJson.add("system_settings", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateWorkspaceOptions.systemSettings())); + contentJson.add( + "system_settings", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.systemSettings())); + } + if (updateWorkspaceOptions.webhooks() != null) { + contentJson.add( + "webhooks", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.webhooks())); } if (updateWorkspaceOptions.intents() != null) { - contentJson.add("intents", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions - .intents())); + contentJson.add( + "intents", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.intents())); } if (updateWorkspaceOptions.entities() != null) { - contentJson.add("entities", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions - .entities())); + contentJson.add( + "entities", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.entities())); } - if (updateWorkspaceOptions.dialogNodes() != null) { - contentJson.add("dialog_nodes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateWorkspaceOptions.dialogNodes())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete workspace. + * + *

Delete a workspace from the service instance. + * + * @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteWorkspaceOptions, "deleteWorkspaceOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteWorkspaceOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "deleteWorkspace"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (updateWorkspaceOptions.counterexamples() != null) { - contentJson.add("counterexamples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateWorkspaceOptions.counterexamples())); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create workspace asynchronously. + * + *

Create a workspace asynchronously based on component objects. You must provide workspace + * components defining the content of the new workspace. + * + *

A successful call to this method only initiates asynchronous creation of the workspace. The + * new workspace is not available until processing completes. To check the status of the + * asynchronous operation, use the **Get information about a workspace** method. + * + * @param createWorkspaceAsyncOptions the {@link CreateWorkspaceAsyncOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link Workspace} + */ + public ServiceCall createWorkspaceAsync( + CreateWorkspaceAsyncOptions createWorkspaceAsyncOptions) { + boolean skipBody = false; + if (createWorkspaceAsyncOptions == null) { + createWorkspaceAsyncOptions = new CreateWorkspaceAsyncOptions.Builder().build(); + skipBody = true; + } + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces_async")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "createWorkspaceAsync"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (updateWorkspaceOptions.webhooks() != null) { - contentJson.add("webhooks", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions - .webhooks())); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (!skipBody) { + final JsonObject contentJson = new JsonObject(); + if (createWorkspaceAsyncOptions.name() != null) { + contentJson.addProperty("name", createWorkspaceAsyncOptions.name()); + } + if (createWorkspaceAsyncOptions.description() != null) { + contentJson.addProperty("description", createWorkspaceAsyncOptions.description()); + } + if (createWorkspaceAsyncOptions.language() != null) { + contentJson.addProperty("language", createWorkspaceAsyncOptions.language()); + } + if (createWorkspaceAsyncOptions.dialogNodes() != null) { + contentJson.add( + "dialog_nodes", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.dialogNodes())); + } + if (createWorkspaceAsyncOptions.counterexamples() != null) { + contentJson.add( + "counterexamples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.counterexamples())); + } + if (createWorkspaceAsyncOptions.metadata() != null) { + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.metadata())); + } + if (createWorkspaceAsyncOptions.learningOptOut() != null) { + contentJson.addProperty("learning_opt_out", createWorkspaceAsyncOptions.learningOptOut()); + } + if (createWorkspaceAsyncOptions.systemSettings() != null) { + contentJson.add( + "system_settings", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.systemSettings())); + } + if (createWorkspaceAsyncOptions.webhooks() != null) { + contentJson.add( + "webhooks", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.webhooks())); + } + if (createWorkspaceAsyncOptions.intents() != null) { + contentJson.add( + "intents", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.intents())); + } + if (createWorkspaceAsyncOptions.entities() != null) { + contentJson.add( + "entities", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceAsyncOptions.entities())); + } + builder.bodyJson(contentJson); } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Delete workspace. + * Create workspace asynchronously. * - * Delete a workspace from the service instance. + *

Create a workspace asynchronously based on component objects. You must provide workspace + * components defining the content of the new workspace. * - * This operation is limited to 30 requests per 30 minutes. For more information, see **Rate limiting**. + *

A successful call to this method only initiates asynchronous creation of the workspace. The + * new workspace is not available until processing completes. To check the status of the + * asynchronous operation, use the **Get information about a workspace** method. * - * @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ - public ServiceCall deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteWorkspaceOptions, - "deleteWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { deleteWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteWorkspace"); + public ServiceCall createWorkspaceAsync() { + return createWorkspaceAsync(null); + } + + /** + * Update workspace asynchronously. + * + *

Update an existing workspace asynchronously with new or modified data. You must provide + * component objects defining the content of the updated workspace. + * + *

A successful call to this method only initiates an asynchronous update of the workspace. The + * updated workspace is not available until processing completes. To check the status of the + * asynchronous operation, use the **Get information about a workspace** method. + * + * @param updateWorkspaceAsyncOptions the {@link UpdateWorkspaceAsyncOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link Workspace} + */ + public ServiceCall updateWorkspaceAsync( + UpdateWorkspaceAsyncOptions updateWorkspaceAsyncOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateWorkspaceAsyncOptions, "updateWorkspaceAsyncOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateWorkspaceAsyncOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces_async/{workspace_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "updateWorkspaceAsync"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (updateWorkspaceAsyncOptions.append() != null) { + builder.query("append", String.valueOf(updateWorkspaceAsyncOptions.append())); + } + final JsonObject contentJson = new JsonObject(); + if (updateWorkspaceAsyncOptions.name() != null) { + contentJson.addProperty("name", updateWorkspaceAsyncOptions.name()); + } + if (updateWorkspaceAsyncOptions.description() != null) { + contentJson.addProperty("description", updateWorkspaceAsyncOptions.description()); + } + if (updateWorkspaceAsyncOptions.language() != null) { + contentJson.addProperty("language", updateWorkspaceAsyncOptions.language()); + } + if (updateWorkspaceAsyncOptions.dialogNodes() != null) { + contentJson.add( + "dialog_nodes", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.dialogNodes())); + } + if (updateWorkspaceAsyncOptions.counterexamples() != null) { + contentJson.add( + "counterexamples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.counterexamples())); + } + if (updateWorkspaceAsyncOptions.metadata() != null) { + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.metadata())); + } + if (updateWorkspaceAsyncOptions.learningOptOut() != null) { + contentJson.addProperty("learning_opt_out", updateWorkspaceAsyncOptions.learningOptOut()); + } + if (updateWorkspaceAsyncOptions.systemSettings() != null) { + contentJson.add( + "system_settings", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.systemSettings())); + } + if (updateWorkspaceAsyncOptions.webhooks() != null) { + contentJson.add( + "webhooks", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.webhooks())); + } + if (updateWorkspaceAsyncOptions.intents() != null) { + contentJson.add( + "intents", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.intents())); + } + if (updateWorkspaceAsyncOptions.entities() != null) { + contentJson.add( + "entities", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceAsyncOptions.entities())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + /** + * Export workspace asynchronously. + * + *

Export the entire workspace asynchronously, including all workspace content. + * + *

A successful call to this method only initiates an asynchronous export. The exported JSON + * data is not available until processing completes. After the initial request is submitted, you + * can continue to poll by calling the same request again and checking the value of the **status** + * property. When processing has completed, the request returns the exported JSON data. Remember + * that the usual rate limits apply. + * + * @param exportWorkspaceAsyncOptions the {@link ExportWorkspaceAsyncOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link Workspace} + */ + public ServiceCall exportWorkspaceAsync( + ExportWorkspaceAsyncOptions exportWorkspaceAsyncOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + exportWorkspaceAsyncOptions, "exportWorkspaceAsyncOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", exportWorkspaceAsyncOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces_async/{workspace_id}/export", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "exportWorkspaceAsync"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (exportWorkspaceAsyncOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(exportWorkspaceAsyncOptions.includeAudit())); + } + if (exportWorkspaceAsyncOptions.sort() != null) { + builder.query("sort", String.valueOf(exportWorkspaceAsyncOptions.sort())); + } + if (exportWorkspaceAsyncOptions.verbose() != null) { + builder.query("verbose", String.valueOf(exportWorkspaceAsyncOptions.verbose())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List intents. * - * List the intents for a workspace. - * - * With **export**=`false`, this operation is limited to 2000 requests per 30 minutes. With **export**=`true`, the - * limit is 400 requests per 30 minutes. For more information, see **Rate limiting**. + *

List the intents for a workspace. * * @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IntentCollection} + * @return a {@link ServiceCall} with a result of type {@link IntentCollection} */ public ServiceCall listIntents(ListIntentsOptions listIntentsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listIntentsOptions, - "listIntentsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { listIntentsOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listIntentsOptions, "listIntentsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listIntentsOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listIntents"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listIntentsOptions.export() != null) { builder.query("export", String.valueOf(listIntentsOptions.export())); } if (listIntentsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listIntentsOptions.pageLimit())); } + if (listIntentsOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listIntentsOptions.includeCount())); + } if (listIntentsOptions.sort() != null) { - builder.query("sort", listIntentsOptions.sort()); + builder.query("sort", String.valueOf(listIntentsOptions.sort())); } if (listIntentsOptions.cursor() != null) { - builder.query("cursor", listIntentsOptions.cursor()); + builder.query("cursor", String.valueOf(listIntentsOptions.cursor())); } if (listIntentsOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create intent. * - * Create a new intent. + *

Create a new intent. * - * If you want to create multiple intents with a single API call, consider using the **[Update + *

If you want to create multiple intents with a single API call, consider using the **[Update * workspace](#update-workspace)** method instead. * - * This operation is limited to 2000 requests per 30 minutes. For more information, see **Rate limiting**. - * * @param createIntentOptions the {@link CreateIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Intent} + * @return a {@link ServiceCall} with a result of type {@link Intent} */ public ServiceCall createIntent(CreateIntentOptions createIntentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createIntentOptions, - "createIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { createIntentOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createIntentOptions, "createIntentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createIntentOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createIntentOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createIntentOptions.includeAudit())); } @@ -580,79 +1019,82 @@ public ServiceCall createIntent(CreateIntentOptions createIntentOptions) contentJson.addProperty("description", createIntentOptions.description()); } if (createIntentOptions.examples() != null) { - contentJson.add("examples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createIntentOptions - .examples())); + contentJson.add( + "examples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createIntentOptions.examples())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get intent. * - * Get information about an intent, optionally including all intent content. - * - * With **export**=`false`, this operation is limited to 6000 requests per 5 minutes. With **export**=`true`, the - * limit is 400 requests per 30 minutes. For more information, see **Rate limiting**. + *

Get information about an intent, optionally including all intent content. * * @param getIntentOptions the {@link GetIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Intent} + * @return a {@link ServiceCall} with a result of type {@link Intent} */ public ServiceCall getIntent(GetIntentOptions getIntentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getIntentOptions, - "getIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { getIntentOptions.workspaceId(), getIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getIntentOptions, "getIntentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getIntentOptions.workspaceId()); + pathParamsMap.put("intent", getIntentOptions.intent()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getIntentOptions.export() != null) { builder.query("export", String.valueOf(getIntentOptions.export())); } if (getIntentOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getIntentOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update intent. * - * Update an existing intent with new or modified data. You must provide component objects defining the content of the - * updated intent. + *

Update an existing intent with new or modified data. You must provide component objects + * defining the content of the updated intent. * - * If you want to update multiple intents with a single API call, consider using the **[Update + *

If you want to update multiple intents with a single API call, consider using the **[Update * workspace](#update-workspace)** method instead. * - * This operation is limited to 2000 requests per 30 minutes. For more information, see **Rate limiting**. - * * @param updateIntentOptions the {@link UpdateIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Intent} + * @return a {@link ServiceCall} with a result of type {@link Intent} */ public ServiceCall updateIntent(UpdateIntentOptions updateIntentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateIntentOptions, - "updateIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { updateIntentOptions.workspaceId(), updateIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateIntentOptions, "updateIntentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateIntentOptions.workspaceId()); + pathParamsMap.put("intent", updateIntentOptions.intent()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateIntentOptions.append() != null) { builder.query("append", String.valueOf(updateIntentOptions.append())); } @@ -667,40 +1109,42 @@ public ServiceCall updateIntent(UpdateIntentOptions updateIntentOptions) contentJson.addProperty("description", updateIntentOptions.newDescription()); } if (updateIntentOptions.newExamples() != null) { - contentJson.add("examples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateIntentOptions - .newExamples())); + contentJson.add( + "examples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateIntentOptions.newExamples())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete intent. * - * Delete an intent from a workspace. - * - * This operation is limited to 2000 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete an intent from a workspace. * * @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteIntent(DeleteIntentOptions deleteIntentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteIntentOptions, - "deleteIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { deleteIntentOptions.workspaceId(), deleteIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteIntentOptions, "deleteIntentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteIntentOptions.workspaceId()); + pathParamsMap.put("intent", deleteIntentOptions.intent()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -708,145 +1152,165 @@ public ServiceCall deleteIntent(DeleteIntentOptions deleteIntentOptions) { /** * List user input examples. * - * List the user input examples for an intent, optionally including contextual entity mentions. - * - * This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**. + *

List the user input examples for an intent, optionally including contextual entity mentions. * * @param listExamplesOptions the {@link ListExamplesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ExampleCollection} + * @return a {@link ServiceCall} with a result of type {@link ExampleCollection} */ public ServiceCall listExamples(ListExamplesOptions listExamplesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listExamplesOptions, - "listExamplesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents", "examples" }; - String[] pathParameters = { listExamplesOptions.workspaceId(), listExamplesOptions.intent() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listExamplesOptions, "listExamplesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listExamplesOptions.workspaceId()); + pathParamsMap.put("intent", listExamplesOptions.intent()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listExamples"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listExamplesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listExamplesOptions.pageLimit())); } + if (listExamplesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listExamplesOptions.includeCount())); + } if (listExamplesOptions.sort() != null) { - builder.query("sort", listExamplesOptions.sort()); + builder.query("sort", String.valueOf(listExamplesOptions.sort())); } if (listExamplesOptions.cursor() != null) { - builder.query("cursor", listExamplesOptions.cursor()); + builder.query("cursor", String.valueOf(listExamplesOptions.cursor())); } if (listExamplesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listExamplesOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create user input example. * - * Add a new user input example to an intent. - * - * If you want to add multiple exaples with a single API call, consider using the **[Update intent](#update-intent)** - * method instead. + *

Add a new user input example to an intent. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

If you want to add multiple examples with a single API call, consider using the **[Update + * intent](#update-intent)** method instead. * - * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} + * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Example} */ public ServiceCall createExample(CreateExampleOptions createExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createExampleOptions, - "createExampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents", "examples" }; - String[] pathParameters = { createExampleOptions.workspaceId(), createExampleOptions.intent() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createExampleOptions, "createExampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createExampleOptions.workspaceId()); + pathParamsMap.put("intent", createExampleOptions.intent()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createExampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createExampleOptions.includeAudit())); } final JsonObject contentJson = new JsonObject(); contentJson.addProperty("text", createExampleOptions.text()); if (createExampleOptions.mentions() != null) { - contentJson.add("mentions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createExampleOptions - .mentions())); + contentJson.add( + "mentions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createExampleOptions.mentions())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get user input example. * - * Get information about a user input example. - * - * This operation is limited to 6000 requests per 5 minutes. For more information, see **Rate limiting**. + *

Get information about a user input example. * * @param getExampleOptions the {@link GetExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} + * @return a {@link ServiceCall} with a result of type {@link Example} */ public ServiceCall getExample(GetExampleOptions getExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getExampleOptions, - "getExampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents", "examples" }; - String[] pathParameters = { getExampleOptions.workspaceId(), getExampleOptions.intent(), getExampleOptions.text() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getExampleOptions, "getExampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getExampleOptions.workspaceId()); + pathParamsMap.put("intent", getExampleOptions.intent()); + pathParamsMap.put("text", getExampleOptions.text()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getExampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getExampleOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update user input example. * - * Update the text of a user input example. + *

Update the text of a user input example. * - * If you want to update multiple examples with a single API call, consider using the **[Update + *

If you want to update multiple examples with a single API call, consider using the **[Update * intent](#update-intent)** method instead. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param updateExampleOptions the {@link UpdateExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} + * @param updateExampleOptions the {@link UpdateExampleOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Example} */ public ServiceCall updateExample(UpdateExampleOptions updateExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateExampleOptions, - "updateExampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents", "examples" }; - String[] pathParameters = { updateExampleOptions.workspaceId(), updateExampleOptions.intent(), updateExampleOptions - .text() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateExampleOptions, "updateExampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateExampleOptions.workspaceId()); + pathParamsMap.put("intent", updateExampleOptions.intent()); + pathParamsMap.put("text", updateExampleOptions.text()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateExampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateExampleOptions.includeAudit())); } @@ -855,41 +1319,46 @@ public ServiceCall updateExample(UpdateExampleOptions updateExampleOpti contentJson.addProperty("text", updateExampleOptions.newText()); } if (updateExampleOptions.newMentions() != null) { - contentJson.add("mentions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateExampleOptions - .newMentions())); + contentJson.add( + "mentions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateExampleOptions.newMentions())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete user input example. * - * Delete a user input example from an intent. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete a user input example from an intent. * - * @param deleteExampleOptions the {@link DeleteExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteExampleOptions the {@link DeleteExampleOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteExampleOptions, - "deleteExampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents", "examples" }; - String[] pathParameters = { deleteExampleOptions.workspaceId(), deleteExampleOptions.intent(), deleteExampleOptions - .text() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteExampleOptions, "deleteExampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteExampleOptions.workspaceId()); + pathParamsMap.put("intent", deleteExampleOptions.intent()); + pathParamsMap.put("text", deleteExampleOptions.text()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -897,141 +1366,162 @@ public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions /** * List counterexamples. * - * List the counterexamples for a workspace. Counterexamples are examples that have been marked as irrelevant input. + *

List the counterexamples for a workspace. Counterexamples are examples that have been marked + * as irrelevant input. * - * This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param listCounterexamplesOptions the {@link ListCounterexamplesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link CounterexampleCollection} + * @param listCounterexamplesOptions the {@link ListCounterexamplesOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link CounterexampleCollection} */ public ServiceCall listCounterexamples( ListCounterexamplesOptions listCounterexamplesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listCounterexamplesOptions, - "listCounterexamplesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { listCounterexamplesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listCounterexamples"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listCounterexamplesOptions, "listCounterexamplesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listCounterexamplesOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "listCounterexamples"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listCounterexamplesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listCounterexamplesOptions.pageLimit())); } + if (listCounterexamplesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listCounterexamplesOptions.includeCount())); + } if (listCounterexamplesOptions.sort() != null) { - builder.query("sort", listCounterexamplesOptions.sort()); + builder.query("sort", String.valueOf(listCounterexamplesOptions.sort())); } if (listCounterexamplesOptions.cursor() != null) { - builder.query("cursor", listCounterexamplesOptions.cursor()); + builder.query("cursor", String.valueOf(listCounterexamplesOptions.cursor())); } if (listCounterexamplesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listCounterexamplesOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create counterexample. * - * Add a new counterexample to a workspace. Counterexamples are examples that have been marked as irrelevant input. - * - * If you want to add multiple counterexamples with a single API call, consider using the **[Update - * workspace](#update-workspace)** method instead. + *

Add a new counterexample to a workspace. Counterexamples are examples that have been marked + * as irrelevant input. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

If you want to add multiple counterexamples with a single API call, consider using the + * **[Update workspace](#update-workspace)** method instead. * - * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} + * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link Counterexample} */ - public ServiceCall createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createCounterexampleOptions, - "createCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { createCounterexampleOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createCounterexample"); + public ServiceCall createCounterexample( + CreateCounterexampleOptions createCounterexampleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createCounterexampleOptions, "createCounterexampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createCounterexampleOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "createCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createCounterexampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createCounterexampleOptions.includeAudit())); } final JsonObject contentJson = new JsonObject(); contentJson.addProperty("text", createCounterexampleOptions.text()); builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get counterexample. * - * Get information about a counterexample. Counterexamples are examples that have been marked as irrelevant input. - * - * This operation is limited to 6000 requests per 5 minutes. For more information, see **Rate limiting**. + *

Get information about a counterexample. Counterexamples are examples that have been marked + * as irrelevant input. * - * @param getCounterexampleOptions the {@link GetCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} + * @param getCounterexampleOptions the {@link GetCounterexampleOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Counterexample} */ - public ServiceCall getCounterexample(GetCounterexampleOptions getCounterexampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getCounterexampleOptions, - "getCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { getCounterexampleOptions.workspaceId(), getCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getCounterexample"); + public ServiceCall getCounterexample( + GetCounterexampleOptions getCounterexampleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getCounterexampleOptions, "getCounterexampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getCounterexampleOptions.workspaceId()); + pathParamsMap.put("text", getCounterexampleOptions.text()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/counterexamples/{text}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "getCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getCounterexampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getCounterexampleOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update counterexample. * - * Update the text of a counterexample. Counterexamples are examples that have been marked as irrelevant input. + *

Update the text of a counterexample. Counterexamples are examples that have been marked as + * irrelevant input. * - * If you want to update multiple counterexamples with a single API call, consider using the **[Update - * workspace](#update-workspace)** method instead. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} + * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link Counterexample} */ - public ServiceCall updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateCounterexampleOptions, - "updateCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateCounterexample"); + public ServiceCall updateCounterexample( + UpdateCounterexampleOptions updateCounterexampleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateCounterexampleOptions, "updateCounterexampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateCounterexampleOptions.workspaceId()); + pathParamsMap.put("text", updateCounterexampleOptions.text()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/counterexamples/{text}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "updateCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateCounterexampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateCounterexampleOptions.includeAudit())); } @@ -1040,36 +1530,42 @@ public ServiceCall updateCounterexample(UpdateCounterexampleOpti contentJson.addProperty("text", updateCounterexampleOptions.newText()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete counterexample. * - * Delete a counterexample from a workspace. Counterexamples are examples that have been marked as irrelevant input. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete a counterexample from a workspace. Counterexamples are examples that have been marked + * as irrelevant input. * - * @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall deleteCounterexample(DeleteCounterexampleOptions deleteCounterexampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCounterexampleOptions, - "deleteCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { deleteCounterexampleOptions.workspaceId(), deleteCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteCounterexample"); + public ServiceCall deleteCounterexample( + DeleteCounterexampleOptions deleteCounterexampleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteCounterexampleOptions, "deleteCounterexampleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteCounterexampleOptions.workspaceId()); + pathParamsMap.put("text", deleteCounterexampleOptions.text()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/counterexamples/{text}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "deleteCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1077,74 +1573,76 @@ public ServiceCall deleteCounterexample(DeleteCounterexampleOptions delete /** * List entities. * - * List the entities for a workspace. - * - * With **export**=`false`, this operation is limited to 1000 requests per 30 minutes. With **export**=`true`, the - * limit is 200 requests per 30 minutes. For more information, see **Rate limiting**. + *

List the entities for a workspace. * * @param listEntitiesOptions the {@link ListEntitiesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityCollection} + * @return a {@link ServiceCall} with a result of type {@link EntityCollection} */ public ServiceCall listEntities(ListEntitiesOptions listEntitiesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listEntitiesOptions, - "listEntitiesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { listEntitiesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listEntitiesOptions, "listEntitiesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listEntitiesOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listEntities"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listEntitiesOptions.export() != null) { builder.query("export", String.valueOf(listEntitiesOptions.export())); } if (listEntitiesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listEntitiesOptions.pageLimit())); } + if (listEntitiesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listEntitiesOptions.includeCount())); + } if (listEntitiesOptions.sort() != null) { - builder.query("sort", listEntitiesOptions.sort()); + builder.query("sort", String.valueOf(listEntitiesOptions.sort())); } if (listEntitiesOptions.cursor() != null) { - builder.query("cursor", listEntitiesOptions.cursor()); + builder.query("cursor", String.valueOf(listEntitiesOptions.cursor())); } if (listEntitiesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listEntitiesOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create entity. * - * Create a new entity, or enable a system entity. + *

Create a new entity, or enable a system entity. * - * If you want to create multiple entities with a single API call, consider using the **[Update + *

If you want to create multiple entities with a single API call, consider using the **[Update * workspace](#update-workspace)** method instead. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * * @param createEntityOptions the {@link CreateEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Entity} + * @return a {@link ServiceCall} with a result of type {@link Entity} */ public ServiceCall createEntity(CreateEntityOptions createEntityOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createEntityOptions, - "createEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { createEntityOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createEntityOptions, "createEntityOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createEntityOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createEntityOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createEntityOptions.includeAudit())); } @@ -1154,86 +1652,91 @@ public ServiceCall createEntity(CreateEntityOptions createEntityOptions) contentJson.addProperty("description", createEntityOptions.description()); } if (createEntityOptions.metadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEntityOptions - .metadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createEntityOptions.metadata())); } if (createEntityOptions.fuzzyMatch() != null) { contentJson.addProperty("fuzzy_match", createEntityOptions.fuzzyMatch()); } if (createEntityOptions.values() != null) { - contentJson.add("values", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEntityOptions - .values())); + contentJson.add( + "values", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createEntityOptions.values())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get entity. * - * Get information about an entity, optionally including all entity content. - * - * With **export**=`false`, this operation is limited to 6000 requests per 5 minutes. With **export**=`true`, the - * limit is 200 requests per 30 minutes. For more information, see **Rate limiting**. + *

Get information about an entity, optionally including all entity content. * * @param getEntityOptions the {@link GetEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Entity} + * @return a {@link ServiceCall} with a result of type {@link Entity} */ public ServiceCall getEntity(GetEntityOptions getEntityOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getEntityOptions, - "getEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { getEntityOptions.workspaceId(), getEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getEntityOptions, "getEntityOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getEntityOptions.workspaceId()); + pathParamsMap.put("entity", getEntityOptions.entity()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getEntityOptions.export() != null) { builder.query("export", String.valueOf(getEntityOptions.export())); } if (getEntityOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getEntityOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update entity. * - * Update an existing entity with new or modified data. You must provide component objects defining the content of the - * updated entity. + *

Update an existing entity with new or modified data. You must provide component objects + * defining the content of the updated entity. * - * If you want to update multiple entities with a single API call, consider using the **[Update + *

If you want to update multiple entities with a single API call, consider using the **[Update * workspace](#update-workspace)** method instead. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * * @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Entity} + * @return a {@link ServiceCall} with a result of type {@link Entity} */ public ServiceCall updateEntity(UpdateEntityOptions updateEntityOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateEntityOptions, - "updateEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { updateEntityOptions.workspaceId(), updateEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateEntityOptions, "updateEntityOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateEntityOptions.workspaceId()); + pathParamsMap.put("entity", updateEntityOptions.entity()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateEntityOptions.append() != null) { builder.query("append", String.valueOf(updateEntityOptions.append())); } @@ -1248,47 +1751,51 @@ public ServiceCall updateEntity(UpdateEntityOptions updateEntityOptions) contentJson.addProperty("description", updateEntityOptions.newDescription()); } if (updateEntityOptions.newMetadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateEntityOptions - .newMetadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateEntityOptions.newMetadata())); } if (updateEntityOptions.newFuzzyMatch() != null) { contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch()); } if (updateEntityOptions.newValues() != null) { - contentJson.add("values", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateEntityOptions - .newValues())); + contentJson.add( + "values", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateEntityOptions.newValues())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete entity. * - * Delete an entity from a workspace, or disable a system entity. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete an entity from a workspace, or disable a system entity. * * @param deleteEntityOptions the {@link DeleteEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteEntity(DeleteEntityOptions deleteEntityOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteEntityOptions, - "deleteEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { deleteEntityOptions.workspaceId(), deleteEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteEntityOptions, "deleteEntityOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteEntityOptions.workspaceId()); + pathParamsMap.put("entity", deleteEntityOptions.entity()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1296,199 +1803,225 @@ public ServiceCall deleteEntity(DeleteEntityOptions deleteEntityOptions) { /** * List entity mentions. * - * List mentions for a contextual entity. An entity mention is an occurrence of a contextual entity in the context of - * an intent user input example. - * - * This operation is limited to 200 requests per 30 minutes. For more information, see **Rate limiting**. + *

List mentions for a contextual entity. An entity mention is an occurrence of a contextual + * entity in the context of an intent user input example. * * @param listMentionsOptions the {@link ListMentionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityMentionCollection} + * @return a {@link ServiceCall} with a result of type {@link EntityMentionCollection} */ - public ServiceCall listMentions(ListMentionsOptions listMentionsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listMentionsOptions, - "listMentionsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "mentions" }; - String[] pathParameters = { listMentionsOptions.workspaceId(), listMentionsOptions.entity() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + public ServiceCall listMentions( + ListMentionsOptions listMentionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listMentionsOptions, "listMentionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listMentionsOptions.workspaceId()); + pathParamsMap.put("entity", listMentionsOptions.entity()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/mentions", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listMentions"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listMentionsOptions.export() != null) { builder.query("export", String.valueOf(listMentionsOptions.export())); } if (listMentionsOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listMentionsOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List entity values. * - * List the values for an entity. - * - * This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**. + *

List the values for an entity. * * @param listValuesOptions the {@link ListValuesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ValueCollection} + * @return a {@link ServiceCall} with a result of type {@link ValueCollection} */ public ServiceCall listValues(ListValuesOptions listValuesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listValuesOptions, - "listValuesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values" }; - String[] pathParameters = { listValuesOptions.workspaceId(), listValuesOptions.entity() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listValuesOptions, "listValuesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listValuesOptions.workspaceId()); + pathParamsMap.put("entity", listValuesOptions.entity()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listValues"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listValuesOptions.export() != null) { builder.query("export", String.valueOf(listValuesOptions.export())); } if (listValuesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listValuesOptions.pageLimit())); } + if (listValuesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listValuesOptions.includeCount())); + } if (listValuesOptions.sort() != null) { - builder.query("sort", listValuesOptions.sort()); + builder.query("sort", String.valueOf(listValuesOptions.sort())); } if (listValuesOptions.cursor() != null) { - builder.query("cursor", listValuesOptions.cursor()); + builder.query("cursor", String.valueOf(listValuesOptions.cursor())); } if (listValuesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listValuesOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create entity value. * - * Create a new value for an entity. + *

Create a new value for an entity. * - * If you want to create multiple entity values with a single API call, consider using the **[Update - * entity](#update-entity)** method instead. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

If you want to create multiple entity values with a single API call, consider using the + * **[Update entity](#update-entity)** method instead. * * @param createValueOptions the {@link CreateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} + * @return a {@link ServiceCall} with a result of type {@link Value} */ public ServiceCall createValue(CreateValueOptions createValueOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createValueOptions, - "createValueOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values" }; - String[] pathParameters = { createValueOptions.workspaceId(), createValueOptions.entity() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createValueOptions, "createValueOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createValueOptions.workspaceId()); + pathParamsMap.put("entity", createValueOptions.entity()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createValueOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createValueOptions.includeAudit())); } final JsonObject contentJson = new JsonObject(); contentJson.addProperty("value", createValueOptions.value()); if (createValueOptions.metadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createValueOptions - .metadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createValueOptions.metadata())); } if (createValueOptions.type() != null) { contentJson.addProperty("type", createValueOptions.type()); } if (createValueOptions.synonyms() != null) { - contentJson.add("synonyms", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createValueOptions - .synonyms())); + contentJson.add( + "synonyms", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createValueOptions.synonyms())); } if (createValueOptions.patterns() != null) { - contentJson.add("patterns", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createValueOptions - .patterns())); + contentJson.add( + "patterns", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createValueOptions.patterns())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get entity value. * - * Get information about an entity value. - * - * This operation is limited to 6000 requests per 5 minutes. For more information, see **Rate limiting**. + *

Get information about an entity value. * * @param getValueOptions the {@link GetValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} + * @return a {@link ServiceCall} with a result of type {@link Value} */ public ServiceCall getValue(GetValueOptions getValueOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getValueOptions, - "getValueOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values" }; - String[] pathParameters = { getValueOptions.workspaceId(), getValueOptions.entity(), getValueOptions.value() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getValueOptions, "getValueOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getValueOptions.workspaceId()); + pathParamsMap.put("entity", getValueOptions.entity()); + pathParamsMap.put("value", getValueOptions.value()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getValueOptions.export() != null) { builder.query("export", String.valueOf(getValueOptions.export())); } if (getValueOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getValueOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update entity value. * - * Update an existing entity value with new or modified data. You must provide component objects defining the content - * of the updated entity value. + *

Update an existing entity value with new or modified data. You must provide component + * objects defining the content of the updated entity value. * - * If you want to update multiple entity values with a single API call, consider using the **[Update - * entity](#update-entity)** method instead. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

If you want to update multiple entity values with a single API call, consider using the + * **[Update entity](#update-entity)** method instead. * * @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} + * @return a {@link ServiceCall} with a result of type {@link Value} */ public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateValueOptions, - "updateValueOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values" }; - String[] pathParameters = { updateValueOptions.workspaceId(), updateValueOptions.entity(), updateValueOptions - .value() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateValueOptions, "updateValueOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateValueOptions.workspaceId()); + pathParamsMap.put("entity", updateValueOptions.entity()); + pathParamsMap.put("value", updateValueOptions.value()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateValueOptions.append() != null) { builder.query("append", String.valueOf(updateValueOptions.append())); } @@ -1500,52 +2033,60 @@ public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { contentJson.addProperty("value", updateValueOptions.newValue()); } if (updateValueOptions.newMetadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions - .newMetadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateValueOptions.newMetadata())); } if (updateValueOptions.newType() != null) { contentJson.addProperty("type", updateValueOptions.newType()); } if (updateValueOptions.newSynonyms() != null) { - contentJson.add("synonyms", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions - .newSynonyms())); + contentJson.add( + "synonyms", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateValueOptions.newSynonyms())); } if (updateValueOptions.newPatterns() != null) { - contentJson.add("patterns", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions - .newPatterns())); + contentJson.add( + "patterns", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateValueOptions.newPatterns())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete entity value. * - * Delete a value from an entity. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete a value from an entity. * * @param deleteValueOptions the {@link DeleteValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteValue(DeleteValueOptions deleteValueOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteValueOptions, - "deleteValueOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values" }; - String[] pathParameters = { deleteValueOptions.workspaceId(), deleteValueOptions.entity(), deleteValueOptions - .value() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteValueOptions, "deleteValueOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteValueOptions.workspaceId()); + pathParamsMap.put("entity", deleteValueOptions.entity()); + pathParamsMap.put("value", deleteValueOptions.value()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1553,144 +2094,163 @@ public ServiceCall deleteValue(DeleteValueOptions deleteValueOptions) { /** * List entity value synonyms. * - * List the synonyms for an entity value. - * - * This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**. + *

List the synonyms for an entity value. * * @param listSynonymsOptions the {@link ListSynonymsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SynonymCollection} + * @return a {@link ServiceCall} with a result of type {@link SynonymCollection} */ public ServiceCall listSynonyms(ListSynonymsOptions listSynonymsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listSynonymsOptions, - "listSynonymsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" }; - String[] pathParameters = { listSynonymsOptions.workspaceId(), listSynonymsOptions.entity(), listSynonymsOptions - .value() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listSynonymsOptions, "listSynonymsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listSynonymsOptions.workspaceId()); + pathParamsMap.put("entity", listSynonymsOptions.entity()); + pathParamsMap.put("value", listSynonymsOptions.value()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listSynonyms"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listSynonymsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listSynonymsOptions.pageLimit())); } + if (listSynonymsOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listSynonymsOptions.includeCount())); + } if (listSynonymsOptions.sort() != null) { - builder.query("sort", listSynonymsOptions.sort()); + builder.query("sort", String.valueOf(listSynonymsOptions.sort())); } if (listSynonymsOptions.cursor() != null) { - builder.query("cursor", listSynonymsOptions.cursor()); + builder.query("cursor", String.valueOf(listSynonymsOptions.cursor())); } if (listSynonymsOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listSynonymsOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create entity value synonym. * - * Add a new synonym to an entity value. + *

Add a new synonym to an entity value. * - * If you want to create multiple synonyms with a single API call, consider using the **[Update + *

If you want to create multiple synonyms with a single API call, consider using the **[Update * entity](#update-entity)** or **[Update entity value](#update-entity-value)** method instead. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Synonym} + * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Synonym} */ public ServiceCall createSynonym(CreateSynonymOptions createSynonymOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createSynonymOptions, - "createSynonymOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" }; - String[] pathParameters = { createSynonymOptions.workspaceId(), createSynonymOptions.entity(), createSynonymOptions - .value() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createSynonymOptions, "createSynonymOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createSynonymOptions.workspaceId()); + pathParamsMap.put("entity", createSynonymOptions.entity()); + pathParamsMap.put("value", createSynonymOptions.value()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createSynonymOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createSynonymOptions.includeAudit())); } final JsonObject contentJson = new JsonObject(); contentJson.addProperty("synonym", createSynonymOptions.synonym()); builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get entity value synonym. * - * Get information about a synonym of an entity value. - * - * This operation is limited to 6000 requests per 5 minutes. For more information, see **Rate limiting**. + *

Get information about a synonym of an entity value. * * @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Synonym} + * @return a {@link ServiceCall} with a result of type {@link Synonym} */ public ServiceCall getSynonym(GetSynonymOptions getSynonymOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getSynonymOptions, - "getSynonymOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" }; - String[] pathParameters = { getSynonymOptions.workspaceId(), getSynonymOptions.entity(), getSynonymOptions.value(), - getSynonymOptions.synonym() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getSynonymOptions, "getSynonymOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getSynonymOptions.workspaceId()); + pathParamsMap.put("entity", getSynonymOptions.entity()); + pathParamsMap.put("value", getSynonymOptions.value()); + pathParamsMap.put("synonym", getSynonymOptions.synonym()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getSynonymOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update entity value synonym. * - * Update an existing entity value synonym with new text. + *

Update an existing entity value synonym with new text. * - * If you want to update multiple synonyms with a single API call, consider using the **[Update + *

If you want to update multiple synonyms with a single API call, consider using the **[Update * entity](#update-entity)** or **[Update entity value](#update-entity-value)** method instead. * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Synonym} + * @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Synonym} */ public ServiceCall updateSynonym(UpdateSynonymOptions updateSynonymOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateSynonymOptions, - "updateSynonymOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" }; - String[] pathParameters = { updateSynonymOptions.workspaceId(), updateSynonymOptions.entity(), updateSynonymOptions - .value(), updateSynonymOptions.synonym() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateSynonymOptions, "updateSynonymOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateSynonymOptions.workspaceId()); + pathParamsMap.put("entity", updateSynonymOptions.entity()); + pathParamsMap.put("value", updateSynonymOptions.value()); + pathParamsMap.put("synonym", updateSynonymOptions.synonym()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateSynonymOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateSynonymOptions.includeAudit())); } @@ -1699,37 +2259,41 @@ public ServiceCall updateSynonym(UpdateSynonymOptions updateSynonymOpti contentJson.addProperty("synonym", updateSynonymOptions.newSynonym()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete entity value synonym. * - * Delete a synonym from an entity value. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete a synonym from an entity value. * - * @param deleteSynonymOptions the {@link DeleteSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteSynonymOptions the {@link DeleteSynonymOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteSynonym(DeleteSynonymOptions deleteSynonymOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteSynonymOptions, - "deleteSynonymOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" }; - String[] pathParameters = { deleteSynonymOptions.workspaceId(), deleteSynonymOptions.entity(), deleteSynonymOptions - .value(), deleteSynonymOptions.synonym() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteSynonymOptions, "deleteSynonymOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteSynonymOptions.workspaceId()); + pathParamsMap.put("entity", deleteSynonymOptions.entity()); + pathParamsMap.put("value", deleteSynonymOptions.value()); + pathParamsMap.put("synonym", deleteSynonymOptions.synonym()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1737,70 +2301,78 @@ public ServiceCall deleteSynonym(DeleteSynonymOptions deleteSynonymOptions /** * List dialog nodes. * - * List the dialog nodes for a workspace. - * - * This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**. + *

List the dialog nodes for a workspace. * - * @param listDialogNodesOptions the {@link ListDialogNodesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNodeCollection} + * @param listDialogNodesOptions the {@link ListDialogNodesOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link DialogNodeCollection} */ - public ServiceCall listDialogNodes(ListDialogNodesOptions listDialogNodesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listDialogNodesOptions, - "listDialogNodesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { listDialogNodesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listDialogNodes"); + public ServiceCall listDialogNodes( + ListDialogNodesOptions listDialogNodesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listDialogNodesOptions, "listDialogNodesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listDialogNodesOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "listDialogNodes"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listDialogNodesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listDialogNodesOptions.pageLimit())); } + if (listDialogNodesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listDialogNodesOptions.includeCount())); + } if (listDialogNodesOptions.sort() != null) { - builder.query("sort", listDialogNodesOptions.sort()); + builder.query("sort", String.valueOf(listDialogNodesOptions.sort())); } if (listDialogNodesOptions.cursor() != null) { - builder.query("cursor", listDialogNodesOptions.cursor()); + builder.query("cursor", String.valueOf(listDialogNodesOptions.cursor())); } if (listDialogNodesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listDialogNodesOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create dialog node. * - * Create a new dialog node. + *

Create a new dialog node. * - * If you want to create multiple dialog nodes with a single API call, consider using the **[Update - * workspace](#update-workspace)** method instead. - * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. + *

If you want to create multiple dialog nodes with a single API call, consider using the + * **[Update workspace](#update-workspace)** method instead. * - * @param createDialogNodeOptions the {@link CreateDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} + * @param createDialogNodeOptions the {@link CreateDialogNodeOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link DialogNode} */ public ServiceCall createDialogNode(CreateDialogNodeOptions createDialogNodeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createDialogNodeOptions, - "createDialogNodeOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { createDialogNodeOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createDialogNode"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createDialogNodeOptions, "createDialogNodeOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createDialogNodeOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "createDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createDialogNodeOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createDialogNodeOptions.includeAudit())); } @@ -1819,20 +2391,28 @@ public ServiceCall createDialogNode(CreateDialogNodeOptions createDi contentJson.addProperty("previous_sibling", createDialogNodeOptions.previousSibling()); } if (createDialogNodeOptions.output() != null) { - contentJson.add("output", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions - .output())); + contentJson.add( + "output", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDialogNodeOptions.output())); } if (createDialogNodeOptions.context() != null) { - contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions - .context())); + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDialogNodeOptions.context())); } if (createDialogNodeOptions.metadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions - .metadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDialogNodeOptions.metadata())); } if (createDialogNodeOptions.nextStep() != null) { - contentJson.add("next_step", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createDialogNodeOptions.nextStep())); + contentJson.add( + "next_step", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDialogNodeOptions.nextStep())); } if (createDialogNodeOptions.title() != null) { contentJson.addProperty("title", createDialogNodeOptions.title()); @@ -1847,8 +2427,10 @@ public ServiceCall createDialogNode(CreateDialogNodeOptions createDi contentJson.addProperty("variable", createDialogNodeOptions.variable()); } if (createDialogNodeOptions.actions() != null) { - contentJson.add("actions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions - .actions())); + contentJson.add( + "actions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDialogNodeOptions.actions())); } if (createDialogNodeOptions.digressIn() != null) { contentJson.addProperty("digress_in", createDialogNodeOptions.digressIn()); @@ -1863,73 +2445,83 @@ public ServiceCall createDialogNode(CreateDialogNodeOptions createDi contentJson.addProperty("user_label", createDialogNodeOptions.userLabel()); } if (createDialogNodeOptions.disambiguationOptOut() != null) { - contentJson.addProperty("disambiguation_opt_out", createDialogNodeOptions.disambiguationOptOut()); + contentJson.addProperty( + "disambiguation_opt_out", createDialogNodeOptions.disambiguationOptOut()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get dialog node. * - * Get information about a dialog node. - * - * This operation is limited to 6000 requests per 5 minutes. For more information, see **Rate limiting**. + *

Get information about a dialog node. * - * @param getDialogNodeOptions the {@link GetDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} + * @param getDialogNodeOptions the {@link GetDialogNodeOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link DialogNode} */ public ServiceCall getDialogNode(GetDialogNodeOptions getDialogNodeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getDialogNodeOptions, - "getDialogNodeOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { getDialogNodeOptions.workspaceId(), getDialogNodeOptions.dialogNode() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getDialogNodeOptions, "getDialogNodeOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getDialogNodeOptions.workspaceId()); + pathParamsMap.put("dialog_node", getDialogNodeOptions.dialogNode()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getDialogNodeOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getDialogNodeOptions.includeAudit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update dialog node. * - * Update an existing dialog node with new or modified data. + *

Update an existing dialog node with new or modified data. * - * If you want to update multiple dialog nodes with a single API call, consider using the **[Update - * workspace](#update-workspace)** method instead. - * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. + *

If you want to update multiple dialog nodes with a single API call, consider using the + * **[Update workspace](#update-workspace)** method instead. * - * @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} + * @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link DialogNode} */ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateDialogNodeOptions, - "updateDialogNodeOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { updateDialogNodeOptions.workspaceId(), updateDialogNodeOptions.dialogNode() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateDialogNode"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateDialogNodeOptions, "updateDialogNodeOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateDialogNodeOptions.workspaceId()); + pathParamsMap.put("dialog_node", updateDialogNodeOptions.dialogNode()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "updateDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateDialogNodeOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateDialogNodeOptions.includeAudit())); } @@ -1950,20 +2542,28 @@ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDi contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling()); } if (updateDialogNodeOptions.newOutput() != null) { - contentJson.add("output", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions - .newOutput())); + contentJson.add( + "output", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateDialogNodeOptions.newOutput())); } if (updateDialogNodeOptions.newContext() != null) { - contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions - .newContext())); + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateDialogNodeOptions.newContext())); } if (updateDialogNodeOptions.newMetadata() != null) { - contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions - .newMetadata())); + contentJson.add( + "metadata", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateDialogNodeOptions.newMetadata())); } if (updateDialogNodeOptions.newNextStep() != null) { - contentJson.add("next_step", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateDialogNodeOptions.newNextStep())); + contentJson.add( + "next_step", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateDialogNodeOptions.newNextStep())); } if (updateDialogNodeOptions.newTitle() != null) { contentJson.addProperty("title", updateDialogNodeOptions.newTitle()); @@ -1978,8 +2578,10 @@ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDi contentJson.addProperty("variable", updateDialogNodeOptions.newVariable()); } if (updateDialogNodeOptions.newActions() != null) { - contentJson.add("actions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions - .newActions())); + contentJson.add( + "actions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateDialogNodeOptions.newActions())); } if (updateDialogNodeOptions.newDigressIn() != null) { contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn()); @@ -1994,39 +2596,44 @@ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDi contentJson.addProperty("user_label", updateDialogNodeOptions.newUserLabel()); } if (updateDialogNodeOptions.newDisambiguationOptOut() != null) { - contentJson.addProperty("disambiguation_opt_out", updateDialogNodeOptions.newDisambiguationOptOut()); + contentJson.addProperty( + "disambiguation_opt_out", updateDialogNodeOptions.newDisambiguationOptOut()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete dialog node. * - * Delete a dialog node from a workspace. - * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. + *

Delete a dialog node from a workspace. * - * @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteDialogNode(DeleteDialogNodeOptions deleteDialogNodeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDialogNodeOptions, - "deleteDialogNodeOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { deleteDialogNodeOptions.workspaceId(), deleteDialogNodeOptions.dialogNode() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteDialogNode"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteDialogNodeOptions, "deleteDialogNodeOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteDialogNodeOptions.workspaceId()); + pathParamsMap.put("dialog_node", deleteDialogNodeOptions.dialogNode()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "deleteDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2034,112 +2641,125 @@ public ServiceCall deleteDialogNode(DeleteDialogNodeOptions deleteDialogNo /** * List log events in a workspace. * - * List the events from the log of a specific workspace. + *

List the events from the log of a specific workspace. + * + *

This method requires Manager access. * - * If **cursor** is not specified, this operation is limited to 40 requests per 30 minutes. If **cursor** is - * specified, the limit is 120 requests per minute. For more information, see **Rate limiting**. + *

**Note:** If you use the **cursor** parameter to retrieve results one page at a time, + * subsequent requests must be no more than 5 minutes apart. Any returned value for the **cursor** + * parameter becomes invalid after 5 minutes. For more information about using pagination, see + * [Pagination](#pagination). * * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} + * @return a {@link ServiceCall} with a result of type {@link LogCollection} */ public ServiceCall listLogs(ListLogsOptions listLogsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listLogsOptions, - "listLogsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "logs" }; - String[] pathParameters = { listLogsOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listLogsOptions, "listLogsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listLogsOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/logs", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listLogs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listLogsOptions.sort() != null) { - builder.query("sort", listLogsOptions.sort()); + builder.query("sort", String.valueOf(listLogsOptions.sort())); } if (listLogsOptions.filter() != null) { - builder.query("filter", listLogsOptions.filter()); + builder.query("filter", String.valueOf(listLogsOptions.filter())); } if (listLogsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit())); } if (listLogsOptions.cursor() != null) { - builder.query("cursor", listLogsOptions.cursor()); + builder.query("cursor", String.valueOf(listLogsOptions.cursor())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List log events in all workspaces. * - * List the events from the logs of all workspaces in the service instance. + *

List the events from the logs of all workspaces in the service instance. * - * If **cursor** is not specified, this operation is limited to 40 requests per 30 minutes. If **cursor** is - * specified, the limit is 120 requests per minute. For more information, see **Rate limiting**. + *

**Note:** If you use the **cursor** parameter to retrieve results one page at a time, + * subsequent requests must be no more than 5 minutes apart. Any returned value for the **cursor** + * parameter becomes invalid after 5 minutes. For more information about using pagination, see + * [Pagination](#pagination). * * @param listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} + * @return a {@link ServiceCall} with a result of type {@link LogCollection} */ public ServiceCall listAllLogs(ListAllLogsOptions listAllLogsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listAllLogsOptions, - "listAllLogsOptions cannot be null"); - String[] pathSegments = { "v1/logs" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listAllLogsOptions, "listAllLogsOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/logs")); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listAllLogs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("filter", listAllLogsOptions.filter()); + builder.query("version", String.valueOf(this.version)); + builder.query("filter", String.valueOf(listAllLogsOptions.filter())); if (listAllLogsOptions.sort() != null) { - builder.query("sort", listAllLogsOptions.sort()); + builder.query("sort", String.valueOf(listAllLogsOptions.sort())); } if (listAllLogsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit())); } if (listAllLogsOptions.cursor() != null) { - builder.query("cursor", listAllLogsOptions.cursor()); + builder.query("cursor", String.valueOf(listAllLogsOptions.cursor())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete labeled data. * - * Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with - * the customer ID. + *

Deletes all data associated with a specified customer ID. The method has no effect if no + * data is associated with the customer ID. * - * 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 + *

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/assistant?topic=assistant-information-security#information-security). * - * This operation is limited to 4 requests per minute. For more information, see **Rate limiting**. + *

**Note:** This operation is intended only for deleting data associated with a single + * specific customer, not for deleting data associated with multiple customers or for any other + * purpose. For more information, see [Labeling and deleting data in Watson + * Assistant](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security-gdpr-wa). * - * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, - "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteUserData"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteUserDataOptions, "deleteUserDataOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } - } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/AgentAvailabilityMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/AgentAvailabilityMessage.java new file mode 100644 index 00000000000..026d672a48e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/AgentAvailabilityMessage.java @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** AgentAvailabilityMessage. */ +public class AgentAvailabilityMessage extends GenericModel { + + protected String message; + + /** Builder. */ + public static class Builder { + private String message; + + /** + * Instantiates a new Builder from an existing AgentAvailabilityMessage instance. + * + * @param agentAvailabilityMessage the instance to initialize the Builder with + */ + private Builder(AgentAvailabilityMessage agentAvailabilityMessage) { + this.message = agentAvailabilityMessage.message; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a AgentAvailabilityMessage. + * + * @return the new AgentAvailabilityMessage instance + */ + public AgentAvailabilityMessage build() { + return new AgentAvailabilityMessage(this); + } + + /** + * Set the message. + * + * @param message the message + * @return the AgentAvailabilityMessage builder + */ + public Builder message(String message) { + this.message = message; + return this; + } + } + + protected AgentAvailabilityMessage() {} + + protected AgentAvailabilityMessage(Builder builder) { + message = builder.message; + } + + /** + * New builder. + * + * @return a AgentAvailabilityMessage builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the message. + * + *

The text of the message. + * + * @return the message + */ + public String message() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptions.java new file mode 100644 index 00000000000..b5634172827 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptions.java @@ -0,0 +1,139 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The bulkClassify options. */ +public class BulkClassifyOptions extends GenericModel { + + protected String workspaceId; + protected List input; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private List input; + + /** + * Instantiates a new Builder from an existing BulkClassifyOptions instance. + * + * @param bulkClassifyOptions the instance to initialize the Builder with + */ + private Builder(BulkClassifyOptions bulkClassifyOptions) { + this.workspaceId = bulkClassifyOptions.workspaceId; + this.input = bulkClassifyOptions.input; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a BulkClassifyOptions. + * + * @return the new BulkClassifyOptions instance + */ + public BulkClassifyOptions build() { + return new BulkClassifyOptions(this); + } + + /** + * Adds a new element to input. + * + * @param input the new element to be added + * @return the BulkClassifyOptions builder + */ + public Builder addInput(BulkClassifyUtterance input) { + com.ibm.cloud.sdk.core.util.Validator.notNull(input, "input cannot be null"); + if (this.input == null) { + this.input = new ArrayList(); + } + this.input.add(input); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the BulkClassifyOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the input. Existing input will be replaced. + * + * @param input the input + * @return the BulkClassifyOptions builder + */ + public Builder input(List input) { + this.input = input; + return this; + } + } + + protected BulkClassifyOptions() {} + + protected BulkClassifyOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + input = builder.input; + } + + /** + * New builder. + * + * @return a BulkClassifyOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the input. + * + *

An array of input utterances to classify. + * + * @return the input + */ + public List input() { + return input; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutput.java new file mode 100644 index 00000000000..791bdf2cc90 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutput.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** BulkClassifyOutput. */ +public class BulkClassifyOutput extends GenericModel { + + protected BulkClassifyUtterance input; + protected List entities; + protected List intents; + + protected BulkClassifyOutput() {} + + /** + * Gets the input. + * + *

The user input utterance to classify. + * + * @return the input + */ + public BulkClassifyUtterance getInput() { + return input; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the utterance. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the utterance. + * + * @return the intents + */ + public List getIntents() { + return intents; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponse.java new file mode 100644 index 00000000000..30569021eac --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponse.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** BulkClassifyResponse. */ +public class BulkClassifyResponse extends GenericModel { + + protected List output; + + protected BulkClassifyResponse() {} + + /** + * Gets the output. + * + *

An array of objects that contain classification information for the submitted input + * utterances. + * + * @return the output + */ + public List getOutput() { + return output; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtterance.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtterance.java new file mode 100644 index 00000000000..76611d1f716 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtterance.java @@ -0,0 +1,95 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The user input utterance to classify. */ +public class BulkClassifyUtterance extends GenericModel { + + protected String text; + + /** Builder. */ + public static class Builder { + private String text; + + /** + * Instantiates a new Builder from an existing BulkClassifyUtterance instance. + * + * @param bulkClassifyUtterance the instance to initialize the Builder with + */ + private Builder(BulkClassifyUtterance bulkClassifyUtterance) { + this.text = bulkClassifyUtterance.text; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param text the text + */ + public Builder(String text) { + this.text = text; + } + + /** + * Builds a BulkClassifyUtterance. + * + * @return the new BulkClassifyUtterance instance + */ + public BulkClassifyUtterance build() { + return new BulkClassifyUtterance(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the BulkClassifyUtterance builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected BulkClassifyUtterance() {} + + protected BulkClassifyUtterance(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + } + + /** + * New builder. + * + * @return a BulkClassifyUtterance builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the text. + * + *

The text of the input utterance. + * + * @return the text + */ + public String text() { + return text; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java index 7bf71fa34cd..939e5f580ac 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,36 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A recognized capture group for a pattern-based entity. - */ +/** A recognized capture group for a pattern-based entity. */ public class CaptureGroup extends GenericModel { protected String group; protected List location; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String group; private List location; + /** + * Instantiates a new Builder from an existing CaptureGroup instance. + * + * @param captureGroup the instance to initialize the Builder with + */ private Builder(CaptureGroup captureGroup) { this.group = captureGroup.group; this.location = captureGroup.location; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -55,21 +53,20 @@ public Builder(String group) { /** * Builds a CaptureGroup. * - * @return the captureGroup + * @return the new CaptureGroup instance */ public CaptureGroup build() { return new CaptureGroup(this); } /** - * Adds an location to location. + * Adds a new element to location. * - * @param location the new location + * @param location the new element to be added * @return the CaptureGroup builder */ public Builder addLocation(Long location) { - com.ibm.cloud.sdk.core.util.Validator.notNull(location, - "location cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(location, "location cannot be null"); if (this.location == null) { this.location = new ArrayList(); } @@ -89,8 +86,7 @@ public Builder group(String group) { } /** - * Set the location. - * Existing location will be replaced. + * Set the location. Existing location will be replaced. * * @param location the location * @return the CaptureGroup builder @@ -101,9 +97,10 @@ public Builder location(List location) { } } + protected CaptureGroup() {} + protected CaptureGroup(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.group, - "group cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.group, "group cannot be null"); group = builder.group; location = builder.location; } @@ -120,7 +117,7 @@ public Builder newBuilder() { /** * Gets the group. * - * A recognized capture group for the entity. + *

A recognized capture group for the entity. * * @return the group */ @@ -131,7 +128,8 @@ public String group() { /** * Gets the location. * - * Zero-based character offsets that indicate where the entity value begins and ends in the input text. + *

Zero-based character offsets that indicate where the entity value begins and ends in the + * input text. * * @return the location */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferInfo.java new file mode 100644 index 00000000000..d5840b03af2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferInfo.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information used by an integration to transfer the conversation to a different channel. */ +public class ChannelTransferInfo extends GenericModel { + + protected ChannelTransferTarget target; + + /** Builder. */ + public static class Builder { + private ChannelTransferTarget target; + + /** + * Instantiates a new Builder from an existing ChannelTransferInfo instance. + * + * @param channelTransferInfo the instance to initialize the Builder with + */ + private Builder(ChannelTransferInfo channelTransferInfo) { + this.target = channelTransferInfo.target; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param target the target + */ + public Builder(ChannelTransferTarget target) { + this.target = target; + } + + /** + * Builds a ChannelTransferInfo. + * + * @return the new ChannelTransferInfo instance + */ + public ChannelTransferInfo build() { + return new ChannelTransferInfo(this); + } + + /** + * Set the target. + * + * @param target the target + * @return the ChannelTransferInfo builder + */ + public Builder target(ChannelTransferTarget target) { + this.target = target; + return this; + } + } + + protected ChannelTransferInfo() {} + + protected ChannelTransferInfo(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.target, "target cannot be null"); + target = builder.target; + } + + /** + * New builder. + * + * @return a ChannelTransferInfo builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the target. + * + *

An object specifying target channels available for the transfer. Each property of this + * object represents an available transfer target. Currently, the only supported property is + * **chat**, representing the web chat integration. + * + * @return the target + */ + public ChannelTransferTarget target() { + return target; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferTarget.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferTarget.java new file mode 100644 index 00000000000..eb7cb1078af --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferTarget.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object specifying target channels available for the transfer. Each property of this object + * represents an available transfer target. Currently, the only supported property is **chat**, + * representing the web chat integration. + */ +public class ChannelTransferTarget extends GenericModel { + + protected ChannelTransferTargetChat chat; + + /** Builder. */ + public static class Builder { + private ChannelTransferTargetChat chat; + + /** + * Instantiates a new Builder from an existing ChannelTransferTarget instance. + * + * @param channelTransferTarget the instance to initialize the Builder with + */ + private Builder(ChannelTransferTarget channelTransferTarget) { + this.chat = channelTransferTarget.chat; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ChannelTransferTarget. + * + * @return the new ChannelTransferTarget instance + */ + public ChannelTransferTarget build() { + return new ChannelTransferTarget(this); + } + + /** + * Set the chat. + * + * @param chat the chat + * @return the ChannelTransferTarget builder + */ + public Builder chat(ChannelTransferTargetChat chat) { + this.chat = chat; + return this; + } + } + + protected ChannelTransferTarget() {} + + protected ChannelTransferTarget(Builder builder) { + chat = builder.chat; + } + + /** + * New builder. + * + * @return a ChannelTransferTarget builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the chat. + * + *

Information for transferring to the web chat integration. + * + * @return the chat + */ + public ChannelTransferTargetChat chat() { + return chat; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetChat.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetChat.java new file mode 100644 index 00000000000..a8641098311 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetChat.java @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information for transferring to the web chat integration. */ +public class ChannelTransferTargetChat extends GenericModel { + + protected String url; + + /** Builder. */ + public static class Builder { + private String url; + + /** + * Instantiates a new Builder from an existing ChannelTransferTargetChat instance. + * + * @param channelTransferTargetChat the instance to initialize the Builder with + */ + private Builder(ChannelTransferTargetChat channelTransferTargetChat) { + this.url = channelTransferTargetChat.url; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ChannelTransferTargetChat. + * + * @return the new ChannelTransferTargetChat instance + */ + public ChannelTransferTargetChat build() { + return new ChannelTransferTargetChat(this); + } + + /** + * Set the url. + * + * @param url the url + * @return the ChannelTransferTargetChat builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + } + + protected ChannelTransferTargetChat() {} + + protected ChannelTransferTargetChat(Builder builder) { + url = builder.url; + } + + /** + * New builder. + * + * @return a ChannelTransferTargetChat builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The URL of the target web chat. + * + * @return the url + */ + public String url() { + return url; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java index 7c36025b4a9..6b3c1d60a6c 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,33 +10,140 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; /** - * State information for the conversation. To maintain state, include the context from the previous response. + * State information for the conversation. To maintain state, include the context from the previous + * response. + * + *

This type supports additional properties of type Object. Any context variable. */ public class Context extends DynamicModel { @SerializedName("conversation_id") protected String conversationId; + @SerializedName("system") - protected SystemResponse system; + protected Map system; + @SerializedName("metadata") protected MessageContextMetadata metadata; public Context() { - super(new TypeToken() { - }); + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private String conversationId; + private Map system; + private MessageContextMetadata metadata; + private Map dynamicProperties; + + /** + * Instantiates a new Builder from an existing Context instance. + * + * @param context the instance to initialize the Builder with + */ + private Builder(Context context) { + this.conversationId = context.conversationId; + this.system = context.system; + this.metadata = context.metadata; + this.dynamicProperties = context.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a Context. + * + * @return the new Context instance + */ + public Context build() { + return new Context(this); + } + + /** + * Set the conversationId. + * + * @param conversationId the conversationId + * @return the Context builder + */ + public Builder conversationId(String conversationId) { + this.conversationId = conversationId; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the Context builder + */ + public Builder system(Map system) { + this.system = system; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the Context builder + */ + public Builder metadata(MessageContextMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * Add an arbitrary property. Any context variable. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the Context builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected Context(Builder builder) { + super(new TypeToken() {}); + conversationId = builder.conversationId; + system = builder.system; + metadata = builder.metadata; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a Context builder + */ + public Builder newBuilder() { + return new Builder(this); } /** * Gets the conversationId. * - * The unique identifier of the conversation. + *

The unique identifier of the conversation. The conversation ID cannot contain any of the + * following characters: `+` `=` `&&` `||` `>` `<` `!` `(` `)` `{` `}` `[` `]` `^` + * `"` `~` `*` `?` `:` `\` `/`. * * @return the conversationId */ @@ -56,11 +163,11 @@ public void setConversationId(final String conversationId) { /** * Gets the system. * - * For internal use only. + *

For internal use only. * * @return the system */ - public SystemResponse getSystem() { + public Map getSystem() { return this.system; } @@ -69,14 +176,14 @@ public SystemResponse getSystem() { * * @param system the new system */ - public void setSystem(final SystemResponse system) { + public void setSystem(final Map system) { this.system = system; } /** * Gets the metadata. * - * Metadata related to the message. + *

Metadata related to the message. * * @return the metadata */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java index b9e4c981a85..df36b2032fa 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,40 +10,34 @@ * 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.assistant.v1.model; -import java.util.Date; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; -/** - * Counterexample. - */ +/** Counterexample. */ public class Counterexample extends GenericModel { protected String text; protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String text; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing Counterexample instance. + * + * @param counterexample the instance to initialize the Builder with + */ private Builder(Counterexample counterexample) { this.text = counterexample.text; - this.created = counterexample.created; - this.updated = counterexample.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,7 +51,7 @@ public Builder(String text) { /** * Builds a Counterexample. * - * @return the counterexample + * @return the new Counterexample instance */ public Counterexample build() { return new Counterexample(this); @@ -73,36 +67,13 @@ public Builder text(String text) { this.text = text; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Counterexample builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Counterexample builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected Counterexample() {} + protected Counterexample(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); text = builder.text; - created = builder.created; - updated = builder.updated; } /** @@ -117,9 +88,9 @@ public Builder newBuilder() { /** * Gets the text. * - * The text of a user input marked as irrelevant input. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of a user input marked as irrelevant input. This string must conform to the + * following restrictions: - It cannot contain carriage return, newline, or tab characters. - It + * cannot consist of only whitespace characters. * * @return the text */ @@ -130,7 +101,7 @@ public String text() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -141,7 +112,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java index 040b72f0efd..2b07cced728 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * CounterexampleCollection. - */ +/** CounterexampleCollection. */ public class CounterexampleCollection extends GenericModel { protected List counterexamples; protected Pagination pagination; + protected CounterexampleCollection() {} + /** * Gets the counterexamples. * - * An array of objects describing the examples marked as irrelevant input. + *

An array of objects describing the examples marked as irrelevant input. * * @return the counterexamples */ @@ -38,7 +38,8 @@ public List getCounterexamples() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java index 25766cb98ae..27b3a9e92d4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,38 +10,37 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The createCounterexample options. - */ +/** The createCounterexample options. */ public class CreateCounterexampleOptions extends GenericModel { protected String workspaceId; protected String text; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String text; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateCounterexampleOptions instance. + * + * @param createCounterexampleOptions the instance to initialize the Builder with + */ private Builder(CreateCounterexampleOptions createCounterexampleOptions) { this.workspaceId = createCounterexampleOptions.workspaceId; this.text = createCounterexampleOptions.text; this.includeAudit = createCounterexampleOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,7 +56,7 @@ public Builder(String workspaceId, String text) { /** * Builds a CreateCounterexampleOptions. * - * @return the createCounterexampleOptions + * @return the new CreateCounterexampleOptions instance */ public CreateCounterexampleOptions build() { return new CreateCounterexampleOptions(this); @@ -108,11 +107,12 @@ public Builder counterexample(Counterexample counterexample) { } } + protected CreateCounterexampleOptions() {} + protected CreateCounterexampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); workspaceId = builder.workspaceId; text = builder.text; includeAudit = builder.includeAudit; @@ -130,7 +130,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -141,9 +141,9 @@ public String workspaceId() { /** * Gets the text. * - * The text of a user input marked as irrelevant input. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of a user input marked as irrelevant input. This string must conform to the + * following restrictions: - It cannot contain carriage return, newline, or tab characters. - It + * cannot consist of only whitespace characters. * * @return the text */ @@ -154,7 +154,8 @@ public String text() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java index f1943b0f786..af160c90612 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,22 +10,18 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createDialogNode options. - */ +/** The createDialogNode options. */ public class CreateDialogNodeOptions extends GenericModel { - /** - * How the dialog node is processed. - */ + /** How the dialog node is processed. */ public interface Type { /** standard. */ String STANDARD = "standard"; @@ -41,9 +37,7 @@ public interface Type { String FOLDER = "folder"; } - /** - * How an `event_handler` node is processed. - */ + /** How an `event_handler` node is processed. */ public interface EventName { /** focus. */ String FOCUS = "focus"; @@ -65,9 +59,7 @@ public interface EventName { String DIGRESSION_RETURN_PROMPT = "digression_return_prompt"; } - /** - * Whether this top-level dialog node can be digressed into. - */ + /** Whether this top-level dialog node can be digressed into. */ public interface DigressIn { /** not_available. */ String NOT_AVAILABLE = "not_available"; @@ -77,9 +69,7 @@ public interface DigressIn { String DOES_NOT_RETURN = "does_not_return"; } - /** - * Whether this dialog node can be returned to after a digression. - */ + /** Whether this dialog node can be returned to after a digression. */ public interface DigressOut { /** allow_returning. */ String ALLOW_RETURNING = "allow_returning"; @@ -89,9 +79,7 @@ public interface DigressOut { String ALLOW_ALL_NEVER_RETURN = "allow_all_never_return"; } - /** - * Whether the user can digress to top-level nodes while filling out slots. - */ + /** Whether the user can digress to top-level nodes while filling out slots. */ public interface DigressOutSlots { /** not_allowed. */ String NOT_ALLOWED = "not_allowed"; @@ -108,7 +96,7 @@ public interface DigressOutSlots { protected String parent; protected String previousSibling; protected DialogNodeOutput output; - protected Map context; + protected DialogNodeContext context; protected Map metadata; protected DialogNodeNextStep nextStep; protected String title; @@ -123,9 +111,7 @@ public interface DigressOutSlots { protected Boolean disambiguationOptOut; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String dialogNode; @@ -134,7 +120,7 @@ public static class Builder { private String parent; private String previousSibling; private DialogNodeOutput output; - private Map context; + private DialogNodeContext context; private Map metadata; private DialogNodeNextStep nextStep; private String title; @@ -149,6 +135,11 @@ public static class Builder { private Boolean disambiguationOptOut; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateDialogNodeOptions instance. + * + * @param createDialogNodeOptions the instance to initialize the Builder with + */ private Builder(CreateDialogNodeOptions createDialogNodeOptions) { this.workspaceId = createDialogNodeOptions.workspaceId; this.dialogNode = createDialogNodeOptions.dialogNode; @@ -173,11 +164,8 @@ private Builder(CreateDialogNodeOptions createDialogNodeOptions) { this.includeAudit = createDialogNodeOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -193,21 +181,20 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a CreateDialogNodeOptions. * - * @return the createDialogNodeOptions + * @return the new CreateDialogNodeOptions instance */ public CreateDialogNodeOptions build() { return new CreateDialogNodeOptions(this); } /** - * Adds an actions to actions. + * Adds a new element to actions. * - * @param actions the new actions + * @param actions the new element to be added * @return the CreateDialogNodeOptions builder */ public Builder addActions(DialogNodeAction actions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(actions, - "actions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(actions, "actions cannot be null"); if (this.actions == null) { this.actions = new ArrayList(); } @@ -298,7 +285,7 @@ public Builder output(DialogNodeOutput output) { * @param context the context * @return the CreateDialogNodeOptions builder */ - public Builder context(Map context) { + public Builder context(DialogNodeContext context) { this.context = context; return this; } @@ -370,8 +357,7 @@ public Builder variable(String variable) { } /** - * Set the actions. - * Existing actions will be replaced. + * Set the actions. Existing actions will be replaced. * * @param actions the actions * @return the CreateDialogNodeOptions builder @@ -477,11 +463,12 @@ public Builder dialogNode(DialogNode dialogNode) { } } + protected CreateDialogNodeOptions() {} + protected CreateDialogNodeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.dialogNode, - "dialogNode cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); workspaceId = builder.workspaceId; dialogNode = builder.dialogNode; description = builder.description; @@ -517,7 +504,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -528,8 +515,11 @@ public String workspaceId() { /** * Gets the dialogNode. * - * The dialog node ID. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. + *

The unique ID of the dialog node. This is an internal identifier used to refer to the dialog + * node from other dialog nodes and in the diagnostic information included with message responses. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. * * @return the dialogNode */ @@ -540,7 +530,8 @@ public String dialogNode() { /** * Gets the description. * - * The description of the dialog node. This string cannot contain carriage return, newline, or tab characters. + *

The description of the dialog node. This string cannot contain carriage return, newline, or + * tab characters. * * @return the description */ @@ -551,8 +542,8 @@ public String description() { /** * Gets the conditions. * - * The condition that will trigger the dialog node. This string cannot contain carriage return, newline, or tab - * characters. + *

The condition that will trigger the dialog node. This string cannot contain carriage return, + * newline, or tab characters. * * @return the conditions */ @@ -563,7 +554,8 @@ public String conditions() { /** * Gets the parent. * - * The ID of the parent dialog node. This property is omitted if the dialog node has no parent. + *

The unique ID of the parent dialog node. This property is omitted if the dialog node has no + * parent. * * @return the parent */ @@ -574,7 +566,8 @@ public String parent() { /** * Gets the previousSibling. * - * The ID of the previous sibling dialog node. This property is omitted if the dialog node has no previous sibling. + *

The unique ID of the previous sibling dialog node. This property is omitted if the dialog + * node has no previous sibling. * * @return the previousSibling */ @@ -585,7 +578,8 @@ public String previousSibling() { /** * Gets the output. * - * The output of the dialog node. For more information about how to specify dialog node output, see the + *

The output of the dialog node. For more information about how to specify dialog node output, + * see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). * * @return the output @@ -597,18 +591,18 @@ public DialogNodeOutput output() { /** * Gets the context. * - * The context for the dialog node. + *

The context for the dialog node. * * @return the context */ - public Map context() { + public DialogNodeContext context() { return context; } /** * Gets the metadata. * - * The metadata for the dialog node. + *

The metadata for the dialog node. * * @return the metadata */ @@ -619,7 +613,7 @@ public Map metadata() { /** * Gets the nextStep. * - * The next step to execute following this dialog node. + *

The next step to execute following this dialog node. * * @return the nextStep */ @@ -630,8 +624,13 @@ public DialogNodeNextStep nextStep() { /** * Gets the title. * - * The alias used to identify the dialog node. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. + *

A human-readable name for the dialog node. If the node is included in disambiguation, this + * title is used to populate the **label** property of the corresponding suggestion in the + * `suggestion` response type (unless it is overridden by the **user_label** property). The title + * is also used to populate the **topic** property in the `connect_to_agent` response type. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. * * @return the title */ @@ -642,7 +641,7 @@ public String title() { /** * Gets the type. * - * How the dialog node is processed. + *

How the dialog node is processed. * * @return the type */ @@ -653,7 +652,7 @@ public String type() { /** * Gets the eventName. * - * How an `event_handler` node is processed. + *

How an `event_handler` node is processed. * * @return the eventName */ @@ -664,7 +663,7 @@ public String eventName() { /** * Gets the variable. * - * The location in the dialog context where output is stored. + *

The location in the dialog context where output is stored. * * @return the variable */ @@ -675,7 +674,7 @@ public String variable() { /** * Gets the actions. * - * An array of objects describing any actions to be invoked by the dialog node. + *

An array of objects describing any actions to be invoked by the dialog node. * * @return the actions */ @@ -686,7 +685,7 @@ public List actions() { /** * Gets the digressIn. * - * Whether this top-level dialog node can be digressed into. + *

Whether this top-level dialog node can be digressed into. * * @return the digressIn */ @@ -697,7 +696,7 @@ public String digressIn() { /** * Gets the digressOut. * - * Whether this dialog node can be returned to after a digression. + *

Whether this dialog node can be returned to after a digression. * * @return the digressOut */ @@ -708,7 +707,7 @@ public String digressOut() { /** * Gets the digressOutSlots. * - * Whether the user can digress to top-level nodes while filling out slots. + *

Whether the user can digress to top-level nodes while filling out slots. * * @return the digressOutSlots */ @@ -719,7 +718,9 @@ public String digressOutSlots() { /** * Gets the userLabel. * - * A label that can be displayed externally to describe the purpose of the node to users. + *

A label that can be displayed externally to describe the purpose of the node to users. If + * set, this label is used to identify the node in disambiguation responses (overriding the value + * of the **title** property). * * @return the userLabel */ @@ -730,7 +731,8 @@ public String userLabel() { /** * Gets the disambiguationOptOut. * - * Whether the dialog node should be excluded from disambiguation suggestions. + *

Whether the dialog node should be excluded from disambiguation suggestions. Valid only when + * **type**=`standard` or `frame`. * * @return the disambiguationOptOut */ @@ -741,7 +743,8 @@ public Boolean disambiguationOptOut() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java index 9f5a8d5f596..26146110516 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,57 +10,53 @@ * 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.assistant.v1.model; +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * CreateEntity. - */ +/** CreateEntity. */ public class CreateEntity extends GenericModel { protected String entity; protected String description; protected Map metadata; + @SerializedName("fuzzy_match") protected Boolean fuzzyMatch; + protected Date created; protected Date updated; protected List values; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String entity; private String description; private Map metadata; private Boolean fuzzyMatch; - private Date created; - private Date updated; private List values; + /** + * Instantiates a new Builder from an existing CreateEntity instance. + * + * @param createEntity the instance to initialize the Builder with + */ private Builder(CreateEntity createEntity) { this.entity = createEntity.entity; this.description = createEntity.description; this.metadata = createEntity.metadata; this.fuzzyMatch = createEntity.fuzzyMatch; - this.created = createEntity.created; - this.updated = createEntity.updated; this.values = createEntity.values; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -74,21 +70,20 @@ public Builder(String entity) { /** * Builds a CreateEntity. * - * @return the createEntity + * @return the new CreateEntity instance */ public CreateEntity build() { return new CreateEntity(this); } /** - * Adds an values to values. + * Adds a new element to values. * - * @param values the new values + * @param values the new element to be added * @return the CreateEntity builder */ public Builder addValues(CreateValue values) { - com.ibm.cloud.sdk.core.util.Validator.notNull(values, - "values cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(values, "values cannot be null"); if (this.values == null) { this.values = new ArrayList(); } @@ -141,30 +136,7 @@ public Builder fuzzyMatch(Boolean fuzzyMatch) { } /** - * Set the created. - * - * @param created the created - * @return the CreateEntity builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the CreateEntity builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - - /** - * Set the values. - * Existing values will be replaced. + * Set the values. Existing values will be replaced. * * @param values the values * @return the CreateEntity builder @@ -175,15 +147,14 @@ public Builder values(List values) { } } + protected CreateEntity() {} + protected CreateEntity(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, - "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, "entity cannot be null"); entity = builder.entity; description = builder.description; metadata = builder.metadata; fuzzyMatch = builder.fuzzyMatch; - created = builder.created; - updated = builder.updated; values = builder.values; } @@ -199,9 +170,9 @@ public Builder newBuilder() { /** * Gets the entity. * - * The name of the entity. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, and hyphen characters. - * - If you specify an entity name beginning with the reserved prefix `sys-`, it must be the name of a system entity + *

The name of the entity. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, and hyphen characters. - If you specify an + * entity name beginning with the reserved prefix `sys-`, it must be the name of a system entity * that you want to enable. (Any entity content specified with the request is ignored.). * * @return the entity @@ -213,7 +184,8 @@ public String entity() { /** * Gets the description. * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters. + *

The description of the entity. This string cannot contain carriage return, newline, or tab + * characters. * * @return the description */ @@ -224,7 +196,7 @@ public String description() { /** * Gets the metadata. * - * Any metadata related to the entity. + *

Any metadata related to the entity. * * @return the metadata */ @@ -235,7 +207,7 @@ public Map metadata() { /** * Gets the fuzzyMatch. * - * Whether to use fuzzy matching for the entity. + *

Whether to use fuzzy matching for the entity. * * @return the fuzzyMatch */ @@ -246,7 +218,7 @@ public Boolean fuzzyMatch() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -257,7 +229,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ @@ -268,7 +240,7 @@ public Date updated() { /** * Gets the values. * - * An array of objects describing the entity values. + *

An array of objects describing the entity values. * * @return the values */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java index 82d904812eb..b27c226a16b 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,17 +10,15 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createEntity options. - */ +/** The createEntity options. */ public class CreateEntityOptions extends GenericModel { protected String workspaceId; @@ -31,9 +29,7 @@ public class CreateEntityOptions extends GenericModel { protected List values; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -43,6 +39,11 @@ public static class Builder { private List values; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateEntityOptions instance. + * + * @param createEntityOptions the instance to initialize the Builder with + */ private Builder(CreateEntityOptions createEntityOptions) { this.workspaceId = createEntityOptions.workspaceId; this.entity = createEntityOptions.entity; @@ -53,11 +54,8 @@ private Builder(CreateEntityOptions createEntityOptions) { this.includeAudit = createEntityOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -73,21 +71,20 @@ public Builder(String workspaceId, String entity) { /** * Builds a CreateEntityOptions. * - * @return the createEntityOptions + * @return the new CreateEntityOptions instance */ public CreateEntityOptions build() { return new CreateEntityOptions(this); } /** - * Adds an values to values. + * Adds a new element to values. * - * @param values the new values + * @param values the new element to be added * @return the CreateEntityOptions builder */ public Builder addValues(CreateValue values) { - com.ibm.cloud.sdk.core.util.Validator.notNull(values, - "values cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(values, "values cannot be null"); if (this.values == null) { this.values = new ArrayList(); } @@ -151,8 +148,7 @@ public Builder fuzzyMatch(Boolean fuzzyMatch) { } /** - * Set the values. - * Existing values will be replaced. + * Set the values. Existing values will be replaced. * * @param values the values * @return the CreateEntityOptions builder @@ -174,11 +170,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected CreateEntityOptions() {} + protected CreateEntityOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, - "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, "entity cannot be null"); workspaceId = builder.workspaceId; entity = builder.entity; description = builder.description; @@ -200,7 +197,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -211,9 +208,9 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, and hyphen characters. - * - If you specify an entity name beginning with the reserved prefix `sys-`, it must be the name of a system entity + *

The name of the entity. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, and hyphen characters. - If you specify an + * entity name beginning with the reserved prefix `sys-`, it must be the name of a system entity * that you want to enable. (Any entity content specified with the request is ignored.). * * @return the entity @@ -225,7 +222,8 @@ public String entity() { /** * Gets the description. * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters. + *

The description of the entity. This string cannot contain carriage return, newline, or tab + * characters. * * @return the description */ @@ -236,7 +234,7 @@ public String description() { /** * Gets the metadata. * - * Any metadata related to the entity. + *

Any metadata related to the entity. * * @return the metadata */ @@ -247,7 +245,7 @@ public Map metadata() { /** * Gets the fuzzyMatch. * - * Whether to use fuzzy matching for the entity. + *

Whether to use fuzzy matching for the entity. * * @return the fuzzyMatch */ @@ -258,7 +256,7 @@ public Boolean fuzzyMatch() { /** * Gets the values. * - * An array of objects describing the entity values. + *

An array of objects describing the entity values. * * @return the values */ @@ -269,7 +267,8 @@ public List values() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java index 2285a816487..7aff2e8be35 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createExample options. - */ +/** The createExample options. */ public class CreateExampleOptions extends GenericModel { protected String workspaceId; @@ -28,9 +26,7 @@ public class CreateExampleOptions extends GenericModel { protected List mentions; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; @@ -38,6 +34,11 @@ public static class Builder { private List mentions; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateExampleOptions instance. + * + * @param createExampleOptions the instance to initialize the Builder with + */ private Builder(CreateExampleOptions createExampleOptions) { this.workspaceId = createExampleOptions.workspaceId; this.intent = createExampleOptions.intent; @@ -46,11 +47,8 @@ private Builder(CreateExampleOptions createExampleOptions) { this.includeAudit = createExampleOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -68,21 +66,20 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a CreateExampleOptions. * - * @return the createExampleOptions + * @return the new CreateExampleOptions instance */ public CreateExampleOptions build() { return new CreateExampleOptions(this); } /** - * Adds an mentions to mentions. + * Adds a new element to mentions. * - * @param mentions the new mentions + * @param mentions the new element to be added * @return the CreateExampleOptions builder */ public Builder addMentions(Mention mentions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(mentions, - "mentions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(mentions, "mentions cannot be null"); if (this.mentions == null) { this.mentions = new ArrayList(); } @@ -124,8 +121,7 @@ public Builder text(String text) { } /** - * Set the mentions. - * Existing mentions will be replaced. + * Set the mentions. Existing mentions will be replaced. * * @param mentions the mentions * @return the CreateExampleOptions builder @@ -159,13 +155,13 @@ public Builder example(Example example) { } } + protected CreateExampleOptions() {} + protected CreateExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); workspaceId = builder.workspaceId; intent = builder.intent; text = builder.text; @@ -185,7 +181,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -196,7 +192,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -207,9 +203,9 @@ public String intent() { /** * Gets the text. * - * The text of a user input example. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of a user input example. This string must conform to the following restrictions: - + * It cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the text */ @@ -220,7 +216,7 @@ public String text() { /** * Gets the mentions. * - * An array of contextual entity mentions. + *

An array of contextual entity mentions. * * @return the mentions */ @@ -231,7 +227,8 @@ public List mentions() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java index 67f1068bc6e..3dae5e0730a 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,17 +10,15 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * CreateIntent. - */ +/** CreateIntent. */ public class CreateIntent extends GenericModel { protected String intent; @@ -29,29 +27,25 @@ public class CreateIntent extends GenericModel { protected Date updated; protected List examples; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String intent; private String description; - private Date created; - private Date updated; private List examples; + /** + * Instantiates a new Builder from an existing CreateIntent instance. + * + * @param createIntent the instance to initialize the Builder with + */ private Builder(CreateIntent createIntent) { this.intent = createIntent.intent; this.description = createIntent.description; - this.created = createIntent.created; - this.updated = createIntent.updated; this.examples = createIntent.examples; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -65,21 +59,20 @@ public Builder(String intent) { /** * Builds a CreateIntent. * - * @return the createIntent + * @return the new CreateIntent instance */ public CreateIntent build() { return new CreateIntent(this); } /** - * Adds an example to examples. + * Adds a new element to examples. * - * @param example the new example + * @param example the new element to be added * @return the CreateIntent builder */ public Builder addExample(Example example) { - com.ibm.cloud.sdk.core.util.Validator.notNull(example, - "example cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(example, "example cannot be null"); if (this.examples == null) { this.examples = new ArrayList(); } @@ -110,30 +103,7 @@ public Builder description(String description) { } /** - * Set the created. - * - * @param created the created - * @return the CreateIntent builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the CreateIntent builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. + * Set the examples. Existing examples will be replaced. * * @param examples the examples * @return the CreateIntent builder @@ -144,13 +114,12 @@ public Builder examples(List examples) { } } + protected CreateIntent() {} + protected CreateIntent(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, - "intent cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); intent = builder.intent; description = builder.description; - created = builder.created; - updated = builder.updated; examples = builder.examples; } @@ -166,9 +135,9 @@ public Builder newBuilder() { /** * Gets the intent. * - * The name of the intent. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - * - It cannot begin with the reserved prefix `sys-`. + *

The name of the intent. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - It cannot begin + * with the reserved prefix `sys-`. * * @return the intent */ @@ -179,7 +148,8 @@ public String intent() { /** * Gets the description. * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters. + *

The description of the intent. This string cannot contain carriage return, newline, or tab + * characters. * * @return the description */ @@ -190,7 +160,7 @@ public String description() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -201,7 +171,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ @@ -212,7 +182,7 @@ public Date updated() { /** * Gets the examples. * - * An array of user input examples for the intent. + *

An array of user input examples for the intent. * * @return the examples */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java index 922aafd6330..a1e8d20e995 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createIntent options. - */ +/** The createIntent options. */ public class CreateIntentOptions extends GenericModel { protected String workspaceId; @@ -28,9 +26,7 @@ public class CreateIntentOptions extends GenericModel { protected List examples; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; @@ -38,6 +34,11 @@ public static class Builder { private List examples; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateIntentOptions instance. + * + * @param createIntentOptions the instance to initialize the Builder with + */ private Builder(CreateIntentOptions createIntentOptions) { this.workspaceId = createIntentOptions.workspaceId; this.intent = createIntentOptions.intent; @@ -46,11 +47,8 @@ private Builder(CreateIntentOptions createIntentOptions) { this.includeAudit = createIntentOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -66,21 +64,20 @@ public Builder(String workspaceId, String intent) { /** * Builds a CreateIntentOptions. * - * @return the createIntentOptions + * @return the new CreateIntentOptions instance */ public CreateIntentOptions build() { return new CreateIntentOptions(this); } /** - * Adds an example to examples. + * Adds a new element to examples. * - * @param example the new example + * @param example the new element to be added * @return the CreateIntentOptions builder */ public Builder addExample(Example example) { - com.ibm.cloud.sdk.core.util.Validator.notNull(example, - "example cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(example, "example cannot be null"); if (this.examples == null) { this.examples = new ArrayList(); } @@ -122,8 +119,7 @@ public Builder description(String description) { } /** - * Set the examples. - * Existing examples will be replaced. + * Set the examples. Existing examples will be replaced. * * @param examples the examples * @return the CreateIntentOptions builder @@ -145,11 +141,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected CreateIntentOptions() {} + protected CreateIntentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, - "intent cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); workspaceId = builder.workspaceId; intent = builder.intent; description = builder.description; @@ -169,7 +166,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -180,9 +177,9 @@ public String workspaceId() { /** * Gets the intent. * - * The name of the intent. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - * - It cannot begin with the reserved prefix `sys-`. + *

The name of the intent. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - It cannot begin + * with the reserved prefix `sys-`. * * @return the intent */ @@ -193,7 +190,8 @@ public String intent() { /** * Gets the description. * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters. + *

The description of the intent. This string cannot contain carriage return, newline, or tab + * characters. * * @return the description */ @@ -204,7 +202,7 @@ public String description() { /** * Gets the examples. * - * An array of user input examples for the intent. + *

An array of user input examples for the intent. * * @return the examples */ @@ -215,7 +213,8 @@ public List examples() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java index 91d9975791f..5f645b90845 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The createSynonym options. - */ +/** The createSynonym options. */ public class CreateSynonymOptions extends GenericModel { protected String workspaceId; @@ -25,9 +24,7 @@ public class CreateSynonymOptions extends GenericModel { protected String synonym; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -35,6 +32,11 @@ public static class Builder { private String synonym; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateSynonymOptions instance. + * + * @param createSynonymOptions the instance to initialize the Builder with + */ private Builder(CreateSynonymOptions createSynonymOptions) { this.workspaceId = createSynonymOptions.workspaceId; this.entity = createSynonymOptions.entity; @@ -43,11 +45,8 @@ private Builder(CreateSynonymOptions createSynonymOptions) { this.includeAudit = createSynonymOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -67,7 +66,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a CreateSynonymOptions. * - * @return the createSynonymOptions + * @return the new CreateSynonymOptions instance */ public CreateSynonymOptions build() { return new CreateSynonymOptions(this); @@ -140,15 +139,14 @@ public Builder synonym(Synonym synonym) { } } + protected CreateSynonymOptions() {} + protected CreateSynonymOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.synonym, - "synonym cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.synonym, "synonym cannot be null"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -168,7 +166,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -179,7 +177,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -190,7 +188,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -201,9 +199,9 @@ public String value() { /** * Gets the synonym. * - * The text of the synonym. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the synonym. This string must conform to the following restrictions: - It cannot + * contain carriage return, newline, or tab characters. - It cannot consist of only whitespace + * characters. * * @return the synonym */ @@ -214,7 +212,8 @@ public String synonym() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java index f45dcf8eee3..75624523cf7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,23 +10,19 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * CreateValue. - */ +/** CreateValue. */ public class CreateValue extends GenericModel { - /** - * Specifies the type of entity value. - */ + /** Specifies the type of entity value. */ public interface Type { /** synonyms. */ String SYNONYMS = "synonyms"; @@ -42,33 +38,29 @@ public interface Type { protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String value; private Map metadata; private String type; private List synonyms; private List patterns; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing CreateValue instance. + * + * @param createValue the instance to initialize the Builder with + */ private Builder(CreateValue createValue) { this.value = createValue.value; this.metadata = createValue.metadata; this.type = createValue.type; this.synonyms = createValue.synonyms; this.patterns = createValue.patterns; - this.created = createValue.created; - this.updated = createValue.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -82,21 +74,20 @@ public Builder(String value) { /** * Builds a CreateValue. * - * @return the createValue + * @return the new CreateValue instance */ public CreateValue build() { return new CreateValue(this); } /** - * Adds an synonym to synonyms. + * Adds a new element to synonyms. * - * @param synonym the new synonym + * @param synonym the new element to be added * @return the CreateValue builder */ public Builder addSynonym(String synonym) { - com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, - "synonym cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, "synonym cannot be null"); if (this.synonyms == null) { this.synonyms = new ArrayList(); } @@ -105,14 +96,13 @@ public Builder addSynonym(String synonym) { } /** - * Adds an pattern to patterns. + * Adds a new element to patterns. * - * @param pattern the new pattern + * @param pattern the new element to be added * @return the CreateValue builder */ public Builder addPattern(String pattern) { - com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, - "pattern cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, "pattern cannot be null"); if (this.patterns == null) { this.patterns = new ArrayList(); } @@ -154,8 +144,7 @@ public Builder type(String type) { } /** - * Set the synonyms. - * Existing synonyms will be replaced. + * Set the synonyms. Existing synonyms will be replaced. * * @param synonyms the synonyms * @return the CreateValue builder @@ -166,8 +155,7 @@ public Builder synonyms(List synonyms) { } /** - * Set the patterns. - * Existing patterns will be replaced. + * Set the patterns. Existing patterns will be replaced. * * @param patterns the patterns * @return the CreateValue builder @@ -176,40 +164,17 @@ public Builder patterns(List patterns) { this.patterns = patterns; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the CreateValue builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the CreateValue builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected CreateValue() {} + protected CreateValue(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); value = builder.value; metadata = builder.metadata; type = builder.type; synonyms = builder.synonyms; patterns = builder.patterns; - created = builder.created; - updated = builder.updated; } /** @@ -224,9 +189,9 @@ public Builder newBuilder() { /** * Gets the value. * - * The text of the entity value. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the entity value. This string must conform to the following restrictions: - It + * cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the value */ @@ -237,7 +202,7 @@ public String value() { /** * Gets the metadata. * - * Any metadata related to the entity value. + *

Any metadata related to the entity value. * * @return the metadata */ @@ -248,7 +213,7 @@ public Map metadata() { /** * Gets the type. * - * Specifies the type of entity value. + *

Specifies the type of entity value. * * @return the type */ @@ -259,10 +224,10 @@ public String type() { /** * Gets the synonyms. * - * An array of synonyms for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A synonym must conform to the following resrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

An array of synonyms for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A synonym must conform to the following + * resrictions: - It cannot contain carriage return, newline, or tab characters. - It cannot + * consist of only whitespace characters. * * @return the synonyms */ @@ -273,9 +238,9 @@ public List synonyms() { /** * Gets the patterns. * - * An array of patterns for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A pattern is a regular expression; for more information about how to specify a pattern, see - * the + *

An array of patterns for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A pattern is a regular expression; for more + * information about how to specify a pattern, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). * * @return the patterns @@ -287,7 +252,7 @@ public List patterns() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -298,7 +263,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java index 3f3329f082d..b184a4064c6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,22 +10,18 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createValue options. - */ +/** The createValue options. */ public class CreateValueOptions extends GenericModel { - /** - * Specifies the type of entity value. - */ + /** Specifies the type of entity value. */ public interface Type { /** synonyms. */ String SYNONYMS = "synonyms"; @@ -42,9 +38,7 @@ public interface Type { protected List patterns; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -55,6 +49,11 @@ public static class Builder { private List patterns; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateValueOptions instance. + * + * @param createValueOptions the instance to initialize the Builder with + */ private Builder(CreateValueOptions createValueOptions) { this.workspaceId = createValueOptions.workspaceId; this.entity = createValueOptions.entity; @@ -66,11 +65,8 @@ private Builder(CreateValueOptions createValueOptions) { this.includeAudit = createValueOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -88,21 +84,20 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a CreateValueOptions. * - * @return the createValueOptions + * @return the new CreateValueOptions instance */ public CreateValueOptions build() { return new CreateValueOptions(this); } /** - * Adds an synonym to synonyms. + * Adds a new element to synonyms. * - * @param synonym the new synonym + * @param synonym the new element to be added * @return the CreateValueOptions builder */ public Builder addSynonym(String synonym) { - com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, - "synonym cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, "synonym cannot be null"); if (this.synonyms == null) { this.synonyms = new ArrayList(); } @@ -111,14 +106,13 @@ public Builder addSynonym(String synonym) { } /** - * Adds an pattern to patterns. + * Adds a new element to patterns. * - * @param pattern the new pattern + * @param pattern the new element to be added * @return the CreateValueOptions builder */ public Builder addPattern(String pattern) { - com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, - "pattern cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, "pattern cannot be null"); if (this.patterns == null) { this.patterns = new ArrayList(); } @@ -182,8 +176,7 @@ public Builder type(String type) { } /** - * Set the synonyms. - * Existing synonyms will be replaced. + * Set the synonyms. Existing synonyms will be replaced. * * @param synonyms the synonyms * @return the CreateValueOptions builder @@ -194,8 +187,7 @@ public Builder synonyms(List synonyms) { } /** - * Set the patterns. - * Existing patterns will be replaced. + * Set the patterns. Existing patterns will be replaced. * * @param patterns the patterns * @return the CreateValueOptions builder @@ -217,13 +209,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected CreateValueOptions() {} + protected CreateValueOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -246,7 +238,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -257,7 +249,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -268,9 +260,9 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the entity value. This string must conform to the following restrictions: - It + * cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the value */ @@ -281,7 +273,7 @@ public String value() { /** * Gets the metadata. * - * Any metadata related to the entity value. + *

Any metadata related to the entity value. * * @return the metadata */ @@ -292,7 +284,7 @@ public Map metadata() { /** * Gets the type. * - * Specifies the type of entity value. + *

Specifies the type of entity value. * * @return the type */ @@ -303,10 +295,10 @@ public String type() { /** * Gets the synonyms. * - * An array of synonyms for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A synonym must conform to the following resrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

An array of synonyms for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A synonym must conform to the following + * resrictions: - It cannot contain carriage return, newline, or tab characters. - It cannot + * consist of only whitespace characters. * * @return the synonyms */ @@ -317,9 +309,9 @@ public List synonyms() { /** * Gets the patterns. * - * An array of patterns for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A pattern is a regular expression; for more information about how to specify a pattern, see - * the + *

An array of patterns for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A pattern is a regular expression; for more + * information about how to specify a pattern, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). * * @return the patterns @@ -331,7 +323,8 @@ public List patterns() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceAsyncOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceAsyncOptions.java new file mode 100644 index 00000000000..76cdc34ed63 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceAsyncOptions.java @@ -0,0 +1,426 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** The createWorkspaceAsync options. */ +public class CreateWorkspaceAsyncOptions extends GenericModel { + + protected String name; + protected String description; + protected String language; + protected List dialogNodes; + protected List counterexamples; + protected Map metadata; + protected Boolean learningOptOut; + protected WorkspaceSystemSettings systemSettings; + protected List webhooks; + protected List intents; + protected List entities; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private String language; + private List dialogNodes; + private List counterexamples; + private Map metadata; + private Boolean learningOptOut; + private WorkspaceSystemSettings systemSettings; + private List webhooks; + private List intents; + private List entities; + + /** + * Instantiates a new Builder from an existing CreateWorkspaceAsyncOptions instance. + * + * @param createWorkspaceAsyncOptions the instance to initialize the Builder with + */ + private Builder(CreateWorkspaceAsyncOptions createWorkspaceAsyncOptions) { + this.name = createWorkspaceAsyncOptions.name; + this.description = createWorkspaceAsyncOptions.description; + this.language = createWorkspaceAsyncOptions.language; + this.dialogNodes = createWorkspaceAsyncOptions.dialogNodes; + this.counterexamples = createWorkspaceAsyncOptions.counterexamples; + this.metadata = createWorkspaceAsyncOptions.metadata; + this.learningOptOut = createWorkspaceAsyncOptions.learningOptOut; + this.systemSettings = createWorkspaceAsyncOptions.systemSettings; + this.webhooks = createWorkspaceAsyncOptions.webhooks; + this.intents = createWorkspaceAsyncOptions.intents; + this.entities = createWorkspaceAsyncOptions.entities; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a CreateWorkspaceAsyncOptions. + * + * @return the new CreateWorkspaceAsyncOptions instance + */ + public CreateWorkspaceAsyncOptions build() { + return new CreateWorkspaceAsyncOptions(this); + } + + /** + * Adds a new element to dialogNodes. + * + * @param dialogNode the new element to be added + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder addDialogNode(DialogNode dialogNode) { + com.ibm.cloud.sdk.core.util.Validator.notNull(dialogNode, "dialogNode cannot be null"); + if (this.dialogNodes == null) { + this.dialogNodes = new ArrayList(); + } + this.dialogNodes.add(dialogNode); + return this; + } + + /** + * Adds a new element to counterexamples. + * + * @param counterexample the new element to be added + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder addCounterexample(Counterexample counterexample) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + counterexample, "counterexample cannot be null"); + if (this.counterexamples == null) { + this.counterexamples = new ArrayList(); + } + this.counterexamples.add(counterexample); + return this; + } + + /** + * Adds a new element to webhooks. + * + * @param webhooks the new element to be added + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder addWebhooks(Webhook webhooks) { + com.ibm.cloud.sdk.core.util.Validator.notNull(webhooks, "webhooks cannot be null"); + if (this.webhooks == null) { + this.webhooks = new ArrayList(); + } + this.webhooks.add(webhooks); + return this; + } + + /** + * Adds a new element to intents. + * + * @param intent the new element to be added + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder addIntent(CreateIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity the new element to be added + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder addEntity(CreateEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the dialogNodes. Existing dialogNodes will be replaced. + * + * @param dialogNodes the dialogNodes + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder dialogNodes(List dialogNodes) { + this.dialogNodes = dialogNodes; + return this; + } + + /** + * Set the counterexamples. Existing counterexamples will be replaced. + * + * @param counterexamples the counterexamples + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the learningOptOut. + * + * @param learningOptOut the learningOptOut + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; + return this; + } + + /** + * Set the systemSettings. + * + * @param systemSettings the systemSettings + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder systemSettings(WorkspaceSystemSettings systemSettings) { + this.systemSettings = systemSettings; + return this; + } + + /** + * Set the webhooks. Existing webhooks will be replaced. + * + * @param webhooks the webhooks + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder webhooks(List webhooks) { + this.webhooks = webhooks; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder intents(List intents) { + this.intents = intents; + return this; + } + + /** + * Set the entities. Existing entities will be replaced. + * + * @param entities the entities + * @return the CreateWorkspaceAsyncOptions builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + } + + protected CreateWorkspaceAsyncOptions() {} + + protected CreateWorkspaceAsyncOptions(Builder builder) { + name = builder.name; + description = builder.description; + language = builder.language; + dialogNodes = builder.dialogNodes; + counterexamples = builder.counterexamples; + metadata = builder.metadata; + learningOptOut = builder.learningOptOut; + systemSettings = builder.systemSettings; + webhooks = builder.webhooks; + intents = builder.intents; + entities = builder.entities; + } + + /** + * New builder. + * + * @return a CreateWorkspaceAsyncOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of the workspace. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the workspace. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the language. + * + *

The language of the workspace. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List dialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List counterexamples() { + return counterexamples; + } + + /** + * Gets the metadata. + * + *

Any metadata related to the workspace. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the learningOptOut. + * + *

Whether training data from the workspace (including artifacts such as intents and entities) + * can be used by IBM for general service improvements. `true` indicates that workspace training + * data is not to be used. + * + * @return the learningOptOut + */ + public Boolean learningOptOut() { + return learningOptOut; + } + + /** + * Gets the systemSettings. + * + *

Global settings for the workspace. + * + * @return the systemSettings + */ + public WorkspaceSystemSettings systemSettings() { + return systemSettings; + } + + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List webhooks() { + return webhooks; + } + + /** + * Gets the intents. + * + *

An array of objects defining the intents for the workspace. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of objects describing the entities for the workspace. + * + * @return the entities + */ + public List entities() { + return entities; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java index 52ed3cffe14..baa22d73fff 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,156 +10,150 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createWorkspace options. - */ +/** The createWorkspace options. */ public class CreateWorkspaceOptions extends GenericModel { protected String name; protected String description; protected String language; + protected List dialogNodes; + protected List counterexamples; protected Map metadata; protected Boolean learningOptOut; protected WorkspaceSystemSettings systemSettings; + protected List webhooks; protected List intents; protected List entities; - protected List dialogNodes; - protected List counterexamples; - protected List webhooks; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String name; private String description; private String language; + private List dialogNodes; + private List counterexamples; private Map metadata; private Boolean learningOptOut; private WorkspaceSystemSettings systemSettings; + private List webhooks; private List intents; private List entities; - private List dialogNodes; - private List counterexamples; - private List webhooks; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing CreateWorkspaceOptions instance. + * + * @param createWorkspaceOptions the instance to initialize the Builder with + */ private Builder(CreateWorkspaceOptions createWorkspaceOptions) { this.name = createWorkspaceOptions.name; this.description = createWorkspaceOptions.description; this.language = createWorkspaceOptions.language; + this.dialogNodes = createWorkspaceOptions.dialogNodes; + this.counterexamples = createWorkspaceOptions.counterexamples; this.metadata = createWorkspaceOptions.metadata; this.learningOptOut = createWorkspaceOptions.learningOptOut; this.systemSettings = createWorkspaceOptions.systemSettings; + this.webhooks = createWorkspaceOptions.webhooks; this.intents = createWorkspaceOptions.intents; this.entities = createWorkspaceOptions.entities; - this.dialogNodes = createWorkspaceOptions.dialogNodes; - this.counterexamples = createWorkspaceOptions.counterexamples; - this.webhooks = createWorkspaceOptions.webhooks; this.includeAudit = createWorkspaceOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a CreateWorkspaceOptions. * - * @return the createWorkspaceOptions + * @return the new CreateWorkspaceOptions instance */ public CreateWorkspaceOptions build() { return new CreateWorkspaceOptions(this); } /** - * Adds an intent to intents. + * Adds a new element to dialogNodes. * - * @param intent the new intent + * @param dialogNode the new element to be added * @return the CreateWorkspaceOptions builder */ - public Builder addIntent(CreateIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, - "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); + public Builder addDialogNode(DialogNode dialogNode) { + com.ibm.cloud.sdk.core.util.Validator.notNull(dialogNode, "dialogNode cannot be null"); + if (this.dialogNodes == null) { + this.dialogNodes = new ArrayList(); } - this.intents.add(intent); + this.dialogNodes.add(dialogNode); return this; } /** - * Adds an entity to entities. + * Adds a new element to counterexamples. * - * @param entity the new entity + * @param counterexample the new element to be added * @return the CreateWorkspaceOptions builder */ - public Builder addEntity(CreateEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, - "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); + public Builder addCounterexample(Counterexample counterexample) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + counterexample, "counterexample cannot be null"); + if (this.counterexamples == null) { + this.counterexamples = new ArrayList(); } - this.entities.add(entity); + this.counterexamples.add(counterexample); return this; } /** - * Adds an dialogNode to dialogNodes. + * Adds a new element to webhooks. * - * @param dialogNode the new dialogNode + * @param webhooks the new element to be added * @return the CreateWorkspaceOptions builder */ - public Builder addDialogNode(DialogNode dialogNode) { - com.ibm.cloud.sdk.core.util.Validator.notNull(dialogNode, - "dialogNode cannot be null"); - if (this.dialogNodes == null) { - this.dialogNodes = new ArrayList(); + public Builder addWebhooks(Webhook webhooks) { + com.ibm.cloud.sdk.core.util.Validator.notNull(webhooks, "webhooks cannot be null"); + if (this.webhooks == null) { + this.webhooks = new ArrayList(); } - this.dialogNodes.add(dialogNode); + this.webhooks.add(webhooks); return this; } /** - * Adds an counterexample to counterexamples. + * Adds a new element to intents. * - * @param counterexample the new counterexample + * @param intent the new element to be added * @return the CreateWorkspaceOptions builder */ - public Builder addCounterexample(Counterexample counterexample) { - com.ibm.cloud.sdk.core.util.Validator.notNull(counterexample, - "counterexample cannot be null"); - if (this.counterexamples == null) { - this.counterexamples = new ArrayList(); + public Builder addIntent(CreateIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); } - this.counterexamples.add(counterexample); + this.intents.add(intent); return this; } /** - * Adds an webhooks to webhooks. + * Adds a new element to entities. * - * @param webhooks the new webhooks + * @param entity the new element to be added * @return the CreateWorkspaceOptions builder */ - public Builder addWebhooks(Webhook webhooks) { - com.ibm.cloud.sdk.core.util.Validator.notNull(webhooks, - "webhooks cannot be null"); - if (this.webhooks == null) { - this.webhooks = new ArrayList(); + public Builder addEntity(CreateEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); } - this.webhooks.add(webhooks); + this.entities.add(entity); return this; } @@ -197,95 +191,90 @@ public Builder language(String language) { } /** - * Set the metadata. + * Set the dialogNodes. Existing dialogNodes will be replaced. * - * @param metadata the metadata + * @param dialogNodes the dialogNodes * @return the CreateWorkspaceOptions builder */ - public Builder metadata(Map metadata) { - this.metadata = metadata; + public Builder dialogNodes(List dialogNodes) { + this.dialogNodes = dialogNodes; return this; } /** - * Set the learningOptOut. + * Set the counterexamples. Existing counterexamples will be replaced. * - * @param learningOptOut the learningOptOut + * @param counterexamples the counterexamples * @return the CreateWorkspaceOptions builder */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; return this; } /** - * Set the systemSettings. + * Set the metadata. * - * @param systemSettings the systemSettings + * @param metadata the metadata * @return the CreateWorkspaceOptions builder */ - public Builder systemSettings(WorkspaceSystemSettings systemSettings) { - this.systemSettings = systemSettings; + public Builder metadata(Map metadata) { + this.metadata = metadata; return this; } /** - * Set the intents. - * Existing intents will be replaced. + * Set the learningOptOut. * - * @param intents the intents + * @param learningOptOut the learningOptOut * @return the CreateWorkspaceOptions builder */ - public Builder intents(List intents) { - this.intents = intents; + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; return this; } /** - * Set the entities. - * Existing entities will be replaced. + * Set the systemSettings. * - * @param entities the entities + * @param systemSettings the systemSettings * @return the CreateWorkspaceOptions builder */ - public Builder entities(List entities) { - this.entities = entities; + public Builder systemSettings(WorkspaceSystemSettings systemSettings) { + this.systemSettings = systemSettings; return this; } /** - * Set the dialogNodes. - * Existing dialogNodes will be replaced. + * Set the webhooks. Existing webhooks will be replaced. * - * @param dialogNodes the dialogNodes + * @param webhooks the webhooks * @return the CreateWorkspaceOptions builder */ - public Builder dialogNodes(List dialogNodes) { - this.dialogNodes = dialogNodes; + public Builder webhooks(List webhooks) { + this.webhooks = webhooks; return this; } /** - * Set the counterexamples. - * Existing counterexamples will be replaced. + * Set the intents. Existing intents will be replaced. * - * @param counterexamples the counterexamples + * @param intents the intents * @return the CreateWorkspaceOptions builder */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; + public Builder intents(List intents) { + this.intents = intents; return this; } /** - * Set the webhooks. - * Existing webhooks will be replaced. + * Set the entities. Existing entities will be replaced. * - * @param webhooks the webhooks + * @param entities the entities * @return the CreateWorkspaceOptions builder */ - public Builder webhooks(List webhooks) { - this.webhooks = webhooks; + public Builder entities(List entities) { + this.entities = entities; return this; } @@ -301,18 +290,20 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected CreateWorkspaceOptions() {} + protected CreateWorkspaceOptions(Builder builder) { name = builder.name; description = builder.description; language = builder.language; + dialogNodes = builder.dialogNodes; + counterexamples = builder.counterexamples; metadata = builder.metadata; learningOptOut = builder.learningOptOut; systemSettings = builder.systemSettings; + webhooks = builder.webhooks; intents = builder.intents; entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - webhooks = builder.webhooks; includeAudit = builder.includeAudit; } @@ -328,7 +319,8 @@ public Builder newBuilder() { /** * Gets the name. * - * The name of the workspace. This string cannot contain carriage return, newline, or tab characters. + *

The name of the workspace. This string cannot contain carriage return, newline, or tab + * characters. * * @return the name */ @@ -339,7 +331,8 @@ public String name() { /** * Gets the description. * - * The description of the workspace. This string cannot contain carriage return, newline, or tab characters. + *

The description of the workspace. This string cannot contain carriage return, newline, or + * tab characters. * * @return the description */ @@ -350,7 +343,7 @@ public String description() { /** * Gets the language. * - * The language of the workspace. + *

The language of the workspace. * * @return the language */ @@ -358,10 +351,32 @@ public String language() { return language; } + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List dialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List counterexamples() { + return counterexamples; + } + /** * Gets the metadata. * - * Any metadata related to the workspace. + *

Any metadata related to the workspace. * * @return the metadata */ @@ -372,8 +387,9 @@ public Map metadata() { /** * Gets the learningOptOut. * - * Whether training data from the workspace (including artifacts such as intents and entities) can be used by IBM for - * general service improvements. `true` indicates that workspace training data is not to be used. + *

Whether training data from the workspace (including artifacts such as intents and entities) + * can be used by IBM for general service improvements. `true` indicates that workspace training + * data is not to be used. * * @return the learningOptOut */ @@ -384,7 +400,7 @@ public Boolean learningOptOut() { /** * Gets the systemSettings. * - * Global settings for the workspace. + *

Global settings for the workspace. * * @return the systemSettings */ @@ -392,10 +408,19 @@ public WorkspaceSystemSettings systemSettings() { return systemSettings; } + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List webhooks() { + return webhooks; + } + /** * Gets the intents. * - * An array of objects defining the intents for the workspace. + *

An array of objects defining the intents for the workspace. * * @return the intents */ @@ -406,7 +431,7 @@ public List intents() { /** * Gets the entities. * - * An array of objects describing the entities for the workspace. + *

An array of objects describing the entities for the workspace. * * @return the entities */ @@ -414,41 +439,11 @@ public List entities() { return entities; } - /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List dialogNodes() { - return dialogNodes; - } - - /** - * Gets the counterexamples. - * - * An array of objects defining input examples that have been marked as irrelevant input. - * - * @return the counterexamples - */ - public List counterexamples() { - return counterexamples; - } - - /** - * Gets the webhooks. - * - * @return the webhooks - */ - public List webhooks() { - return webhooks; - } - /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java index 51d926adebc..bdaaa73d6a2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteCounterexample options. - */ +/** The deleteCounterexample options. */ public class DeleteCounterexampleOptions extends GenericModel { protected String workspaceId; protected String text; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String text; + /** + * Instantiates a new Builder from an existing DeleteCounterexampleOptions instance. + * + * @param deleteCounterexampleOptions the instance to initialize the Builder with + */ private Builder(DeleteCounterexampleOptions deleteCounterexampleOptions) { this.workspaceId = deleteCounterexampleOptions.workspaceId; this.text = deleteCounterexampleOptions.text; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String workspaceId, String text) { /** * Builds a DeleteCounterexampleOptions. * - * @return the deleteCounterexampleOptions + * @return the new DeleteCounterexampleOptions instance */ public DeleteCounterexampleOptions build() { return new DeleteCounterexampleOptions(this); @@ -83,11 +82,12 @@ public Builder text(String text) { } } + protected DeleteCounterexampleOptions() {} + protected DeleteCounterexampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, - "text cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, "text cannot be empty"); workspaceId = builder.workspaceId; text = builder.text; } @@ -104,7 +104,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -115,7 +115,7 @@ public String workspaceId() { /** * Gets the text. * - * The text of a user input counterexample (for example, `What are you wearing?`). + *

The text of a user input counterexample (for example, `What are you wearing?`). * * @return the text */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java index fd387bec5af..ddd3bc396cc 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteDialogNode options. - */ +/** The deleteDialogNode options. */ public class DeleteDialogNodeOptions extends GenericModel { protected String workspaceId; protected String dialogNode; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String dialogNode; + /** + * Instantiates a new Builder from an existing DeleteDialogNodeOptions instance. + * + * @param deleteDialogNodeOptions the instance to initialize the Builder with + */ private Builder(DeleteDialogNodeOptions deleteDialogNodeOptions) { this.workspaceId = deleteDialogNodeOptions.workspaceId; this.dialogNode = deleteDialogNodeOptions.dialogNode; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a DeleteDialogNodeOptions. * - * @return the deleteDialogNodeOptions + * @return the new DeleteDialogNodeOptions instance */ public DeleteDialogNodeOptions build() { return new DeleteDialogNodeOptions(this); @@ -83,11 +82,13 @@ public Builder dialogNode(String dialogNode) { } } + protected DeleteDialogNodeOptions() {} + protected DeleteDialogNodeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.dialogNode, - "dialogNode cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.dialogNode, "dialogNode cannot be empty"); workspaceId = builder.workspaceId; dialogNode = builder.dialogNode; } @@ -104,7 +105,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -115,7 +116,7 @@ public String workspaceId() { /** * Gets the dialogNode. * - * The dialog node ID (for example, `get_order`). + *

The dialog node ID (for example, `node_1_1479323581900`). * * @return the dialogNode */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java index 7482c3774f8..d6ddd677fee 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteEntity options. - */ +/** The deleteEntity options. */ public class DeleteEntityOptions extends GenericModel { protected String workspaceId; protected String entity; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; + /** + * Instantiates a new Builder from an existing DeleteEntityOptions instance. + * + * @param deleteEntityOptions the instance to initialize the Builder with + */ private Builder(DeleteEntityOptions deleteEntityOptions) { this.workspaceId = deleteEntityOptions.workspaceId; this.entity = deleteEntityOptions.entity; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a DeleteEntityOptions. * - * @return the deleteEntityOptions + * @return the new DeleteEntityOptions instance */ public DeleteEntityOptions build() { return new DeleteEntityOptions(this); @@ -83,11 +82,12 @@ public Builder entity(String entity) { } } + protected DeleteEntityOptions() {} + protected DeleteEntityOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; } @@ -104,7 +104,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -115,7 +115,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java index a122728b709..5599e588a58 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,38 +10,37 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteExample options. - */ +/** The deleteExample options. */ public class DeleteExampleOptions extends GenericModel { protected String workspaceId; protected String intent; protected String text; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; private String text; + /** + * Instantiates a new Builder from an existing DeleteExampleOptions instance. + * + * @param deleteExampleOptions the instance to initialize the Builder with + */ private Builder(DeleteExampleOptions deleteExampleOptions) { this.workspaceId = deleteExampleOptions.workspaceId; this.intent = deleteExampleOptions.intent; this.text = deleteExampleOptions.text; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -59,7 +58,7 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a DeleteExampleOptions. * - * @return the deleteExampleOptions + * @return the new DeleteExampleOptions instance */ public DeleteExampleOptions build() { return new DeleteExampleOptions(this); @@ -99,13 +98,13 @@ public Builder text(String text) { } } + protected DeleteExampleOptions() {} + protected DeleteExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, - "text cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, "text cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; text = builder.text; @@ -123,7 +122,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -134,7 +133,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -145,7 +144,7 @@ public String intent() { /** * Gets the text. * - * The text of the user input example. + *

The text of the user input example. * * @return the text */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java index 0ae8fff7907..9394b8ae511 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteIntent options. - */ +/** The deleteIntent options. */ public class DeleteIntentOptions extends GenericModel { protected String workspaceId; protected String intent; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; + /** + * Instantiates a new Builder from an existing DeleteIntentOptions instance. + * + * @param deleteIntentOptions the instance to initialize the Builder with + */ private Builder(DeleteIntentOptions deleteIntentOptions) { this.workspaceId = deleteIntentOptions.workspaceId; this.intent = deleteIntentOptions.intent; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a DeleteIntentOptions. * - * @return the deleteIntentOptions + * @return the new DeleteIntentOptions instance */ public DeleteIntentOptions build() { return new DeleteIntentOptions(this); @@ -83,11 +82,12 @@ public Builder intent(String intent) { } } + protected DeleteIntentOptions() {} + protected DeleteIntentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; } @@ -104,7 +104,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -115,7 +115,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java index 83af1148b0f..f4bb375e6a3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteSynonym options. - */ +/** The deleteSynonym options. */ public class DeleteSynonymOptions extends GenericModel { protected String workspaceId; @@ -24,15 +23,18 @@ public class DeleteSynonymOptions extends GenericModel { protected String value; protected String synonym; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; private String value; private String synonym; + /** + * Instantiates a new Builder from an existing DeleteSynonymOptions instance. + * + * @param deleteSynonymOptions the instance to initialize the Builder with + */ private Builder(DeleteSynonymOptions deleteSynonymOptions) { this.workspaceId = deleteSynonymOptions.workspaceId; this.entity = deleteSynonymOptions.entity; @@ -40,11 +42,8 @@ private Builder(DeleteSynonymOptions deleteSynonymOptions) { this.synonym = deleteSynonymOptions.synonym; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -64,7 +63,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a DeleteSynonymOptions. * - * @return the deleteSynonymOptions + * @return the new DeleteSynonymOptions instance */ public DeleteSynonymOptions build() { return new DeleteSynonymOptions(this); @@ -115,15 +114,14 @@ public Builder synonym(String synonym) { } } + protected DeleteSynonymOptions() {} + protected DeleteSynonymOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.synonym, - "synonym cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.synonym, "synonym cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -142,7 +140,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -153,7 +151,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -164,7 +162,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -175,7 +173,7 @@ public String value() { /** * Gets the synonym. * - * The text of the synonym. + *

The text of the synonym. * * @return the synonym */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java index 5be45eadc9d..c53c1735afe 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteUserData options. - */ +/** The deleteUserData options. */ public class DeleteUserDataOptions extends GenericModel { protected String customerId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customerId; + /** + * Instantiates a new Builder from an existing DeleteUserDataOptions instance. + * + * @param deleteUserDataOptions the instance to initialize the Builder with + */ private Builder(DeleteUserDataOptions deleteUserDataOptions) { this.customerId = deleteUserDataOptions.customerId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); @@ -67,9 +66,10 @@ public Builder customerId(String customerId) { } } + protected DeleteUserDataOptions() {} + protected DeleteUserDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, - "customerId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, "customerId cannot be null"); customerId = builder.customerId; } @@ -85,7 +85,7 @@ public Builder newBuilder() { /** * Gets the customerId. * - * The customer ID for which all data is to be deleted. + *

The customer ID for which all data is to be deleted. * * @return the customerId */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java index 46b7982240d..9338a62ac2e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,38 +10,37 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteValue options. - */ +/** The deleteValue options. */ public class DeleteValueOptions extends GenericModel { protected String workspaceId; protected String entity; protected String value; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; private String value; + /** + * Instantiates a new Builder from an existing DeleteValueOptions instance. + * + * @param deleteValueOptions the instance to initialize the Builder with + */ private Builder(DeleteValueOptions deleteValueOptions) { this.workspaceId = deleteValueOptions.workspaceId; this.entity = deleteValueOptions.entity; this.value = deleteValueOptions.value; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -59,7 +58,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a DeleteValueOptions. * - * @return the deleteValueOptions + * @return the new DeleteValueOptions instance */ public DeleteValueOptions build() { return new DeleteValueOptions(this); @@ -99,13 +98,13 @@ public Builder value(String value) { } } + protected DeleteValueOptions() {} + protected DeleteValueOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -123,7 +122,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -134,7 +133,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -145,7 +144,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java index dce312bb8ee..85d048abf77 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteWorkspace options. - */ +/** The deleteWorkspace options. */ public class DeleteWorkspaceOptions extends GenericModel { protected String workspaceId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; + /** + * Instantiates a new Builder from an existing DeleteWorkspaceOptions instance. + * + * @param deleteWorkspaceOptions the instance to initialize the Builder with + */ private Builder(DeleteWorkspaceOptions deleteWorkspaceOptions) { this.workspaceId = deleteWorkspaceOptions.workspaceId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String workspaceId) { /** * Builds a DeleteWorkspaceOptions. * - * @return the deleteWorkspaceOptions + * @return the new DeleteWorkspaceOptions instance */ public DeleteWorkspaceOptions build() { return new DeleteWorkspaceOptions(this); @@ -67,9 +66,11 @@ public Builder workspaceId(String workspaceId) { } } + protected DeleteWorkspaceOptions() {} + protected DeleteWorkspaceOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; } @@ -85,7 +86,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java index 2d9d40dfbbb..b76dcc8ca40 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,20 @@ * 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.assistant.v1.model; +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * DialogNode. - */ +/** DialogNode. */ public class DialogNode extends GenericModel { - /** - * How the dialog node is processed. - */ + /** How the dialog node is processed. */ public interface Type { /** standard. */ String STANDARD = "standard"; @@ -43,9 +39,7 @@ public interface Type { String FOLDER = "folder"; } - /** - * How an `event_handler` node is processed. - */ + /** How an `event_handler` node is processed. */ public interface EventName { /** focus. */ String FOCUS = "focus"; @@ -67,9 +61,7 @@ public interface EventName { String DIGRESSION_RETURN_PROMPT = "digression_return_prompt"; } - /** - * Whether this top-level dialog node can be digressed into. - */ + /** Whether this top-level dialog node can be digressed into. */ public interface DigressIn { /** not_available. */ String NOT_AVAILABLE = "not_available"; @@ -79,9 +71,7 @@ public interface DigressIn { String DOES_NOT_RETURN = "does_not_return"; } - /** - * Whether this dialog node can be returned to after a digression. - */ + /** Whether this dialog node can be returned to after a digression. */ public interface DigressOut { /** allow_returning. */ String ALLOW_RETURNING = "allow_returning"; @@ -91,9 +81,7 @@ public interface DigressOut { String ALLOW_ALL_NEVER_RETURN = "allow_all_never_return"; } - /** - * Whether the user can digress to top-level nodes while filling out slots. - */ + /** Whether the user can digress to top-level nodes while filling out slots. */ public interface DigressOutSlots { /** not_allowed. */ String NOT_ALLOWED = "not_allowed"; @@ -105,39 +93,50 @@ public interface DigressOutSlots { @SerializedName("dialog_node") protected String dialogNode; + protected String description; protected String conditions; protected String parent; + @SerializedName("previous_sibling") protected String previousSibling; + protected DialogNodeOutput output; - protected Map context; + protected DialogNodeContext context; protected Map metadata; + @SerializedName("next_step") protected DialogNodeNextStep nextStep; + protected String title; protected String type; + @SerializedName("event_name") protected String eventName; + protected String variable; protected List actions; + @SerializedName("digress_in") protected String digressIn; + @SerializedName("digress_out") protected String digressOut; + @SerializedName("digress_out_slots") protected String digressOutSlots; + @SerializedName("user_label") protected String userLabel; + @SerializedName("disambiguation_opt_out") protected Boolean disambiguationOptOut; + protected Boolean disabled; protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String dialogNode; private String description; @@ -145,7 +144,7 @@ public static class Builder { private String parent; private String previousSibling; private DialogNodeOutput output; - private Map context; + private DialogNodeContext context; private Map metadata; private DialogNodeNextStep nextStep; private String title; @@ -158,10 +157,12 @@ public static class Builder { private String digressOutSlots; private String userLabel; private Boolean disambiguationOptOut; - private Boolean disabled; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing DialogNode instance. + * + * @param dialogNode the instance to initialize the Builder with + */ private Builder(DialogNode dialogNode) { this.dialogNode = dialogNode.dialogNode; this.description = dialogNode.description; @@ -182,16 +183,10 @@ private Builder(DialogNode dialogNode) { this.digressOutSlots = dialogNode.digressOutSlots; this.userLabel = dialogNode.userLabel; this.disambiguationOptOut = dialogNode.disambiguationOptOut; - this.disabled = dialogNode.disabled; - this.created = dialogNode.created; - this.updated = dialogNode.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -205,21 +200,20 @@ public Builder(String dialogNode) { /** * Builds a DialogNode. * - * @return the dialogNode + * @return the new DialogNode instance */ public DialogNode build() { return new DialogNode(this); } /** - * Adds an actions to actions. + * Adds a new element to actions. * - * @param actions the new actions + * @param actions the new element to be added * @return the DialogNode builder */ public Builder addActions(DialogNodeAction actions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(actions, - "actions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(actions, "actions cannot be null"); if (this.actions == null) { this.actions = new ArrayList(); } @@ -299,7 +293,7 @@ public Builder output(DialogNodeOutput output) { * @param context the context * @return the DialogNode builder */ - public Builder context(Map context) { + public Builder context(DialogNodeContext context) { this.context = context; return this; } @@ -371,8 +365,7 @@ public Builder variable(String variable) { } /** - * Set the actions. - * Existing actions will be replaced. + * Set the actions. Existing actions will be replaced. * * @param actions the actions * @return the DialogNode builder @@ -436,44 +429,12 @@ public Builder disambiguationOptOut(Boolean disambiguationOptOut) { this.disambiguationOptOut = disambiguationOptOut; return this; } - - /** - * Set the disabled. - * - * @param disabled the disabled - * @return the DialogNode builder - */ - public Builder disabled(Boolean disabled) { - this.disabled = disabled; - return this; - } - - /** - * Set the created. - * - * @param created the created - * @return the DialogNode builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the DialogNode builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected DialogNode() {} + protected DialogNode(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.dialogNode, - "dialogNode cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); dialogNode = builder.dialogNode; description = builder.description; conditions = builder.conditions; @@ -493,9 +454,6 @@ protected DialogNode(Builder builder) { digressOutSlots = builder.digressOutSlots; userLabel = builder.userLabel; disambiguationOptOut = builder.disambiguationOptOut; - disabled = builder.disabled; - created = builder.created; - updated = builder.updated; } /** @@ -510,8 +468,11 @@ public Builder newBuilder() { /** * Gets the dialogNode. * - * The dialog node ID. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. + *

The unique ID of the dialog node. This is an internal identifier used to refer to the dialog + * node from other dialog nodes and in the diagnostic information included with message responses. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. * * @return the dialogNode */ @@ -522,7 +483,8 @@ public String dialogNode() { /** * Gets the description. * - * The description of the dialog node. This string cannot contain carriage return, newline, or tab characters. + *

The description of the dialog node. This string cannot contain carriage return, newline, or + * tab characters. * * @return the description */ @@ -533,8 +495,8 @@ public String description() { /** * Gets the conditions. * - * The condition that will trigger the dialog node. This string cannot contain carriage return, newline, or tab - * characters. + *

The condition that will trigger the dialog node. This string cannot contain carriage return, + * newline, or tab characters. * * @return the conditions */ @@ -545,7 +507,8 @@ public String conditions() { /** * Gets the parent. * - * The ID of the parent dialog node. This property is omitted if the dialog node has no parent. + *

The unique ID of the parent dialog node. This property is omitted if the dialog node has no + * parent. * * @return the parent */ @@ -556,7 +519,8 @@ public String parent() { /** * Gets the previousSibling. * - * The ID of the previous sibling dialog node. This property is omitted if the dialog node has no previous sibling. + *

The unique ID of the previous sibling dialog node. This property is omitted if the dialog + * node has no previous sibling. * * @return the previousSibling */ @@ -567,7 +531,8 @@ public String previousSibling() { /** * Gets the output. * - * The output of the dialog node. For more information about how to specify dialog node output, see the + *

The output of the dialog node. For more information about how to specify dialog node output, + * see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). * * @return the output @@ -579,18 +544,18 @@ public DialogNodeOutput output() { /** * Gets the context. * - * The context for the dialog node. + *

The context for the dialog node. * * @return the context */ - public Map context() { + public DialogNodeContext context() { return context; } /** * Gets the metadata. * - * The metadata for the dialog node. + *

The metadata for the dialog node. * * @return the metadata */ @@ -601,7 +566,7 @@ public Map metadata() { /** * Gets the nextStep. * - * The next step to execute following this dialog node. + *

The next step to execute following this dialog node. * * @return the nextStep */ @@ -612,8 +577,13 @@ public DialogNodeNextStep nextStep() { /** * Gets the title. * - * The alias used to identify the dialog node. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. + *

A human-readable name for the dialog node. If the node is included in disambiguation, this + * title is used to populate the **label** property of the corresponding suggestion in the + * `suggestion` response type (unless it is overridden by the **user_label** property). The title + * is also used to populate the **topic** property in the `connect_to_agent` response type. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. * * @return the title */ @@ -624,7 +594,7 @@ public String title() { /** * Gets the type. * - * How the dialog node is processed. + *

How the dialog node is processed. * * @return the type */ @@ -635,7 +605,7 @@ public String type() { /** * Gets the eventName. * - * How an `event_handler` node is processed. + *

How an `event_handler` node is processed. * * @return the eventName */ @@ -646,7 +616,7 @@ public String eventName() { /** * Gets the variable. * - * The location in the dialog context where output is stored. + *

The location in the dialog context where output is stored. * * @return the variable */ @@ -657,7 +627,7 @@ public String variable() { /** * Gets the actions. * - * An array of objects describing any actions to be invoked by the dialog node. + *

An array of objects describing any actions to be invoked by the dialog node. * * @return the actions */ @@ -668,7 +638,7 @@ public List actions() { /** * Gets the digressIn. * - * Whether this top-level dialog node can be digressed into. + *

Whether this top-level dialog node can be digressed into. * * @return the digressIn */ @@ -679,7 +649,7 @@ public String digressIn() { /** * Gets the digressOut. * - * Whether this dialog node can be returned to after a digression. + *

Whether this dialog node can be returned to after a digression. * * @return the digressOut */ @@ -690,7 +660,7 @@ public String digressOut() { /** * Gets the digressOutSlots. * - * Whether the user can digress to top-level nodes while filling out slots. + *

Whether the user can digress to top-level nodes while filling out slots. * * @return the digressOutSlots */ @@ -701,7 +671,9 @@ public String digressOutSlots() { /** * Gets the userLabel. * - * A label that can be displayed externally to describe the purpose of the node to users. + *

A label that can be displayed externally to describe the purpose of the node to users. If + * set, this label is used to identify the node in disambiguation responses (overriding the value + * of the **title** property). * * @return the userLabel */ @@ -712,7 +684,8 @@ public String userLabel() { /** * Gets the disambiguationOptOut. * - * Whether the dialog node should be excluded from disambiguation suggestions. + *

Whether the dialog node should be excluded from disambiguation suggestions. Valid only when + * **type**=`standard` or `frame`. * * @return the disambiguationOptOut */ @@ -723,7 +696,7 @@ public Boolean disambiguationOptOut() { /** * Gets the disabled. * - * For internal use only. + *

For internal use only. * * @return the disabled */ @@ -734,7 +707,7 @@ public Boolean disabled() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -745,7 +718,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java index a42f71ad448..7460443db77 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,21 +10,17 @@ * 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.assistant.v1.model; -import java.util.Map; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; -/** - * DialogNodeAction. - */ +/** DialogNodeAction. */ public class DialogNodeAction extends GenericModel { - /** - * The type of action to invoke. - */ + /** The type of action to invoke. */ public interface Type { /** client. */ String CLIENT = "client"; @@ -41,13 +37,13 @@ public interface Type { protected String name; protected String type; protected Map parameters; + @SerializedName("result_variable") protected String resultVariable; + protected String credentials; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String name; private String type; @@ -55,6 +51,11 @@ public static class Builder { private String resultVariable; private String credentials; + /** + * Instantiates a new Builder from an existing DialogNodeAction instance. + * + * @param dialogNodeAction the instance to initialize the Builder with + */ private Builder(DialogNodeAction dialogNodeAction) { this.name = dialogNodeAction.name; this.type = dialogNodeAction.type; @@ -63,11 +64,8 @@ private Builder(DialogNodeAction dialogNodeAction) { this.credentials = dialogNodeAction.credentials; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -83,7 +81,7 @@ public Builder(String name, String resultVariable) { /** * Builds a DialogNodeAction. * - * @return the dialogNodeAction + * @return the new DialogNodeAction instance */ public DialogNodeAction build() { return new DialogNodeAction(this); @@ -145,11 +143,12 @@ public Builder credentials(String credentials) { } } + protected DialogNodeAction() {} + protected DialogNodeAction(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.resultVariable, - "resultVariable cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.resultVariable, "resultVariable cannot be null"); name = builder.name; type = builder.type; parameters = builder.parameters; @@ -169,7 +168,7 @@ public Builder newBuilder() { /** * Gets the name. * - * The name of the action. + *

The name of the action. * * @return the name */ @@ -180,7 +179,7 @@ public String name() { /** * Gets the type. * - * The type of action to invoke. + *

The type of action to invoke. * * @return the type */ @@ -191,7 +190,7 @@ public String type() { /** * Gets the parameters. * - * A map of key/value pairs to be provided to the action. + *

A map of key/value pairs to be provided to the action. * * @return the parameters */ @@ -202,7 +201,7 @@ public Map parameters() { /** * Gets the resultVariable. * - * The location in the dialog context where the result of the action is stored. + *

The location in the dialog context where the result of the action is stored. * * @return the resultVariable */ @@ -213,7 +212,8 @@ public String resultVariable() { /** * Gets the credentials. * - * The name of the context variable that the client application will use to pass in credentials for the action. + *

The name of the context variable that the client application will use to pass in credentials + * for the action. * * @return the credentials */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java index 4ce60702047..5b138fa9802 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,26 +10,27 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * An array of dialog nodes. - */ +/** An array of dialog nodes. */ public class DialogNodeCollection extends GenericModel { @SerializedName("dialog_nodes") protected List dialogNodes; + protected Pagination pagination; + protected DialogNodeCollection() {} + /** * Gets the dialogNodes. * - * An array of objects describing the dialog nodes defined for the workspace. + *

An array of objects describing the dialog nodes defined for the workspace. * * @return the dialogNodes */ @@ -40,7 +41,8 @@ public List getDialogNodes() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeContext.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeContext.java new file mode 100644 index 00000000000..281a6738ce2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeContext.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; + +/** + * The context for the dialog node. + * + *

This type supports additional properties of type Object. Any context variable. + */ +public class DialogNodeContext extends DynamicModel { + + @SerializedName("integrations") + protected Map> integrations; + + public DialogNodeContext() { + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private Map> integrations; + private Map dynamicProperties; + + /** + * Instantiates a new Builder from an existing DialogNodeContext instance. + * + * @param dialogNodeContext the instance to initialize the Builder with + */ + private Builder(DialogNodeContext dialogNodeContext) { + this.integrations = dialogNodeContext.integrations; + this.dynamicProperties = dialogNodeContext.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DialogNodeContext. + * + * @return the new DialogNodeContext instance + */ + public DialogNodeContext build() { + return new DialogNodeContext(this); + } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the DialogNodeContext builder + */ + public Builder integrations(Map> integrations) { + this.integrations = integrations; + return this; + } + + /** + * Add an arbitrary property. Any context variable. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the DialogNodeContext builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected DialogNodeContext(Builder builder) { + super(new TypeToken() {}); + integrations = builder.integrations; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a DialogNodeContext builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the integrations. + * + *

Context data intended for specific integrations. + * + * @return the integrations + */ + public Map> getIntegrations() { + return this.integrations; + } + + /** + * Sets the integrations. + * + * @param integrations the new integrations + */ + public void setIntegrations(final Map> integrations) { + this.integrations = integrations; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java index 9b06e27daa0..9ef1cafb650 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,36 +10,25 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The next step to execute following this dialog node. - */ +/** The next step to execute following this dialog node. */ public class DialogNodeNextStep extends GenericModel { /** - * What happens after the dialog node completes. The valid values depend on the node type: - * - The following values are valid for any node: - * - `get_user_input` - * - `skip_user_input` - * - `jump_to` - * - If the node is of type `event_handler` and its parent node is of type `slot` or `frame`, additional values are - * also valid: - * - if **event_name**=`filled` and the type of the parent node is `slot`: - * - `reprompt` - * - `skip_all_slots` - * - if **event_name**=`nomatch` and the type of the parent node is `slot`: - * - `reprompt` - * - `skip_slot` - * - `skip_all_slots` - * - if **event_name**=`generic` and the type of the parent node is `frame`: - * - `reprompt` - * - `skip_slot` - * - `skip_all_slots` - * If you specify `jump_to`, then you must also specify a value for the `dialog_node` property. + * What happens after the dialog node completes. The valid values depend on the node type: - The + * following values are valid for any node: - `get_user_input` - `skip_user_input` - `jump_to` - + * If the node is of type `event_handler` and its parent node is of type `slot` or `frame`, + * additional values are also valid: - if **event_name**=`filled` and the type of the parent node + * is `slot`: - `reprompt` - `skip_all_slots` - if **event_name**=`nomatch` and the type of the + * parent node is `slot`: - `reprompt` - `skip_slot` - `skip_all_slots` - if + * **event_name**=`generic` and the type of the parent node is `frame`: - `reprompt` - `skip_slot` + * - `skip_all_slots` If you specify `jump_to`, then you must also specify a value for the + * `dialog_node` property. */ public interface Behavior { /** get_user_input. */ @@ -56,9 +45,7 @@ public interface Behavior { String SKIP_ALL_SLOTS = "skip_all_slots"; } - /** - * Which part of the dialog node to process next. - */ + /** Which part of the dialog node to process next. */ public interface Selector { /** condition. */ String CONDITION = "condition"; @@ -71,29 +58,31 @@ public interface Selector { } protected String behavior; + @SerializedName("dialog_node") protected String dialogNode; + protected String selector; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String behavior; private String dialogNode; private String selector; + /** + * Instantiates a new Builder from an existing DialogNodeNextStep instance. + * + * @param dialogNodeNextStep the instance to initialize the Builder with + */ private Builder(DialogNodeNextStep dialogNodeNextStep) { this.behavior = dialogNodeNextStep.behavior; this.dialogNode = dialogNodeNextStep.dialogNode; this.selector = dialogNodeNextStep.selector; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -107,7 +96,7 @@ public Builder(String behavior) { /** * Builds a DialogNodeNextStep. * - * @return the dialogNodeNextStep + * @return the new DialogNodeNextStep instance */ public DialogNodeNextStep build() { return new DialogNodeNextStep(this); @@ -147,9 +136,10 @@ public Builder selector(String selector) { } } + protected DialogNodeNextStep() {} + protected DialogNodeNextStep(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.behavior, - "behavior cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.behavior, "behavior cannot be null"); behavior = builder.behavior; dialogNode = builder.dialogNode; selector = builder.selector; @@ -167,25 +157,15 @@ public Builder newBuilder() { /** * Gets the behavior. * - * What happens after the dialog node completes. The valid values depend on the node type: - * - The following values are valid for any node: - * - `get_user_input` - * - `skip_user_input` - * - `jump_to` - * - If the node is of type `event_handler` and its parent node is of type `slot` or `frame`, additional values are - * also valid: - * - if **event_name**=`filled` and the type of the parent node is `slot`: - * - `reprompt` - * - `skip_all_slots` - * - if **event_name**=`nomatch` and the type of the parent node is `slot`: - * - `reprompt` - * - `skip_slot` - * - `skip_all_slots` - * - if **event_name**=`generic` and the type of the parent node is `frame`: - * - `reprompt` - * - `skip_slot` - * - `skip_all_slots` - * If you specify `jump_to`, then you must also specify a value for the `dialog_node` property. + *

What happens after the dialog node completes. The valid values depend on the node type: - + * The following values are valid for any node: - `get_user_input` - `skip_user_input` - `jump_to` + * - If the node is of type `event_handler` and its parent node is of type `slot` or `frame`, + * additional values are also valid: - if **event_name**=`filled` and the type of the parent node + * is `slot`: - `reprompt` - `skip_all_slots` - if **event_name**=`nomatch` and the type of the + * parent node is `slot`: - `reprompt` - `skip_slot` - `skip_all_slots` - if + * **event_name**=`generic` and the type of the parent node is `frame`: - `reprompt` - `skip_slot` + * - `skip_all_slots` If you specify `jump_to`, then you must also specify a value for the + * `dialog_node` property. * * @return the behavior */ @@ -196,7 +176,8 @@ public String behavior() { /** * Gets the dialogNode. * - * The ID of the dialog node to process next. This parameter is required if **behavior**=`jump_to`. + *

The unique ID of the dialog node to process next. This parameter is required if + * **behavior**=`jump_to`. * * @return the dialogNode */ @@ -207,7 +188,7 @@ public String dialogNode() { /** * Gets the selector. * - * Which part of the dialog node to process next. + *

Which part of the dialog node to process next. * * @return the selector */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java index 4e4cd540756..2f49be9ea5c 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,34 +10,157 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * The output of the dialog node. For more information about how to specify dialog node output, see the + * The output of the dialog node. For more information about how to specify dialog node output, see + * the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). + * + *

This type supports additional properties of type Object. Any additional data included in the + * dialog node output. */ public class DialogNodeOutput extends DynamicModel { @SerializedName("generic") protected List generic; + + @SerializedName("integrations") + protected Map> integrations; + @SerializedName("modifiers") protected DialogNodeOutputModifiers modifiers; public DialogNodeOutput() { - super(new TypeToken() { - }); + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private List generic; + private Map> integrations; + private DialogNodeOutputModifiers modifiers; + private Map dynamicProperties; + + /** + * Instantiates a new Builder from an existing DialogNodeOutput instance. + * + * @param dialogNodeOutput the instance to initialize the Builder with + */ + private Builder(DialogNodeOutput dialogNodeOutput) { + this.generic = dialogNodeOutput.generic; + this.integrations = dialogNodeOutput.integrations; + this.modifiers = dialogNodeOutput.modifiers; + this.dynamicProperties = dialogNodeOutput.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DialogNodeOutput. + * + * @return the new DialogNodeOutput instance + */ + public DialogNodeOutput build() { + return new DialogNodeOutput(this); + } + + /** + * Adds a new element to generic. + * + * @param generic the new element to be added + * @return the DialogNodeOutput builder + */ + public Builder addGeneric(DialogNodeOutputGeneric generic) { + com.ibm.cloud.sdk.core.util.Validator.notNull(generic, "generic cannot be null"); + if (this.generic == null) { + this.generic = new ArrayList(); + } + this.generic.add(generic); + return this; + } + + /** + * Set the generic. Existing generic will be replaced. + * + * @param generic the generic + * @return the DialogNodeOutput builder + */ + public Builder generic(List generic) { + this.generic = generic; + return this; + } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the DialogNodeOutput builder + */ + public Builder integrations(Map> integrations) { + this.integrations = integrations; + return this; + } + + /** + * Set the modifiers. + * + * @param modifiers the modifiers + * @return the DialogNodeOutput builder + */ + public Builder modifiers(DialogNodeOutputModifiers modifiers) { + this.modifiers = modifiers; + return this; + } + + /** + * Add an arbitrary property. Any additional data included in the dialog node output. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the DialogNodeOutput builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected DialogNodeOutput(Builder builder) { + super(new TypeToken() {}); + generic = builder.generic; + integrations = builder.integrations; + modifiers = builder.modifiers; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a DialogNodeOutput builder + */ + public Builder newBuilder() { + return new Builder(this); } /** * Gets the generic. * - * An array of objects describing the output defined for the dialog node. + *

An array of objects describing the output defined for the dialog node. * * @return the generic */ @@ -54,10 +177,31 @@ public void setGeneric(final List generic) { this.generic = generic; } + /** + * Gets the integrations. + * + *

Output intended for specific integrations. For more information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-responses-json). + * + * @return the integrations + */ + public Map> getIntegrations() { + return this.integrations; + } + + /** + * Sets the integrations. + * + * @param integrations the new integrations + */ + public void setIntegrations(final Map> integrations) { + this.integrations = integrations; + } + /** * Gets the modifiers. * - * Options that modify how specified output is handled. + *

Options that modify how specified output is handled. * * @return the modifiers */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfo.java new file mode 100644 index 00000000000..0ec868810d1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfo.java @@ -0,0 +1,86 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Routing or other contextual information to be used by target service desk systems. */ +public class DialogNodeOutputConnectToAgentTransferInfo extends GenericModel { + + protected Map> target; + + /** Builder. */ + public static class Builder { + private Map> target; + + /** + * Instantiates a new Builder from an existing DialogNodeOutputConnectToAgentTransferInfo + * instance. + * + * @param dialogNodeOutputConnectToAgentTransferInfo the instance to initialize the Builder with + */ + private Builder( + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfo) { + this.target = dialogNodeOutputConnectToAgentTransferInfo.target; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DialogNodeOutputConnectToAgentTransferInfo. + * + * @return the new DialogNodeOutputConnectToAgentTransferInfo instance + */ + public DialogNodeOutputConnectToAgentTransferInfo build() { + return new DialogNodeOutputConnectToAgentTransferInfo(this); + } + + /** + * Set the target. + * + * @param target the target + * @return the DialogNodeOutputConnectToAgentTransferInfo builder + */ + public Builder target(Map> target) { + this.target = target; + return this; + } + } + + protected DialogNodeOutputConnectToAgentTransferInfo() {} + + protected DialogNodeOutputConnectToAgentTransferInfo(Builder builder) { + target = builder.target; + } + + /** + * New builder. + * + * @return a DialogNodeOutputConnectToAgentTransferInfo builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the target. + * + * @return the target + */ + public Map> target() { + return target; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java index 06e14ef9fd5..0dcac9e1e65 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,45 +10,62 @@ * 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.assistant.v1.model; -import java.util.ArrayList; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; /** * DialogNodeOutputGeneric. + * + *

Classes which extend this class: - DialogNodeOutputGenericDialogNodeOutputResponseTypeText - + * DialogNodeOutputGenericDialogNodeOutputResponseTypePause - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeImage - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeOption - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe */ public class DialogNodeOutputGeneric extends GenericModel { - - /** - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **search_skill** response type is available only for Plus and Premium users, and is used only by the - * v2 runtime API. - */ - public interface ResponseType { - /** text. */ - String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** search_skill. */ - String SEARCH_SKILL = "search_skill"; + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "response_type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "audio", DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.class); + discriminatorMapping.put( + "channel_transfer", + DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.class); + discriminatorMapping.put( + "connect_to_agent", + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.class); + discriminatorMapping.put( + "iframe", DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.class); + discriminatorMapping.put( + "image", DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.class); + discriminatorMapping.put( + "option", DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.class); + discriminatorMapping.put( + "pause", DialogNodeOutputGenericDialogNodeOutputResponseTypePause.class); + discriminatorMapping.put( + "search_skill", DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.class); + discriminatorMapping.put("text", DialogNodeOutputGenericDialogNodeOutputResponseTypeText.class); + discriminatorMapping.put( + "user_defined", DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.class); + discriminatorMapping.put( + "video", DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.class); } - - /** - * How a response is selected from the list, if more than one response is specified. Valid only when - * **response_type**=`text`. - */ + /** How a response is selected from the list, if more than one response is specified. */ public interface SelectionPolicy { /** sequential. */ String SEQUENTIAL = "sequential"; @@ -58,9 +75,7 @@ public interface SelectionPolicy { String MULTILINE = "multiline"; } - /** - * The preferred type of control to display, if supported by the channel. Valid only when **response_type**=`option`. - */ + /** The preferred type of control to display, if supported by the channel. */ public interface Preference { /** dropdown. */ String DROPDOWN = "dropdown"; @@ -68,9 +83,7 @@ public interface Preference { String BUTTON = "button"; } - /** - * The type of the search query. Required when **response_type**=`search_skill`. - */ + /** The type of the search query. */ public interface QueryType { /** natural_language. */ String NATURAL_LANGUAGE = "natural_language"; @@ -80,339 +93,64 @@ public interface QueryType { @SerializedName("response_type") protected String responseType; + protected List values; + @SerializedName("selection_policy") protected String selectionPolicy; + protected String delimiter; + protected List channels; protected Long time; protected Boolean typing; protected String source; protected String title; protected String description; + + @SerializedName("alt_text") + protected String altText; + protected String preference; protected List options; + @SerializedName("message_to_human_agent") protected String messageToHumanAgent; + + @SerializedName("agent_available") + protected AgentAvailabilityMessage agentAvailable; + + @SerializedName("agent_unavailable") + protected AgentAvailabilityMessage agentUnavailable; + protected String query; + @SerializedName("query_type") protected String queryType; + protected String filter; + @SerializedName("discovery_version") protected String discoveryVersion; - /** - * Builder. - */ - public static class Builder { - private String responseType; - private List values; - private String selectionPolicy; - private String delimiter; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String query; - private String queryType; - private String filter; - private String discoveryVersion; - - private Builder(DialogNodeOutputGeneric dialogNodeOutputGeneric) { - this.responseType = dialogNodeOutputGeneric.responseType; - this.values = dialogNodeOutputGeneric.values; - this.selectionPolicy = dialogNodeOutputGeneric.selectionPolicy; - this.delimiter = dialogNodeOutputGeneric.delimiter; - this.time = dialogNodeOutputGeneric.time; - this.typing = dialogNodeOutputGeneric.typing; - this.source = dialogNodeOutputGeneric.source; - this.title = dialogNodeOutputGeneric.title; - this.description = dialogNodeOutputGeneric.description; - this.preference = dialogNodeOutputGeneric.preference; - this.options = dialogNodeOutputGeneric.options; - this.messageToHumanAgent = dialogNodeOutputGeneric.messageToHumanAgent; - this.query = dialogNodeOutputGeneric.query; - this.queryType = dialogNodeOutputGeneric.queryType; - this.filter = dialogNodeOutputGeneric.filter; - this.discoveryVersion = dialogNodeOutputGeneric.discoveryVersion; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a DialogNodeOutputGeneric. - * - * @return the dialogNodeOutputGeneric - */ - public DialogNodeOutputGeneric build() { - return new DialogNodeOutputGeneric(this); - } - - /** - * Adds an values to values. - * - * @param values the new values - * @return the DialogNodeOutputGeneric builder - */ - public Builder addValues(DialogNodeOutputTextValuesElement values) { - com.ibm.cloud.sdk.core.util.Validator.notNull(values, - "values cannot be null"); - if (this.values == null) { - this.values = new ArrayList(); - } - this.values.add(values); - return this; - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the DialogNodeOutputGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, - "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the DialogNodeOutputGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the values. - * Existing values will be replaced. - * - * @param values the values - * @return the DialogNodeOutputGeneric builder - */ - public Builder values(List values) { - this.values = values; - return this; - } - - /** - * Set the selectionPolicy. - * - * @param selectionPolicy the selectionPolicy - * @return the DialogNodeOutputGeneric builder - */ - public Builder selectionPolicy(String selectionPolicy) { - this.selectionPolicy = selectionPolicy; - return this; - } - - /** - * Set the delimiter. - * - * @param delimiter the delimiter - * @return the DialogNodeOutputGeneric builder - */ - public Builder delimiter(String delimiter) { - this.delimiter = delimiter; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the DialogNodeOutputGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the DialogNodeOutputGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the DialogNodeOutputGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the DialogNodeOutputGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the DialogNodeOutputGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the DialogNodeOutputGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. - * Existing options will be replaced. - * - * @param options the options - * @return the DialogNodeOutputGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the DialogNodeOutputGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the DialogNodeOutputGeneric builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the queryType. - * - * @param queryType the queryType - * @return the DialogNodeOutputGeneric builder - */ - public Builder queryType(String queryType) { - this.queryType = queryType; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the DialogNodeOutputGeneric builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the discoveryVersion. - * - * @param discoveryVersion the discoveryVersion - * @return the DialogNodeOutputGeneric builder - */ - public Builder discoveryVersion(String discoveryVersion) { - this.discoveryVersion = discoveryVersion; - return this; - } - } + @SerializedName("message_to_user") + protected String messageToUser; - protected DialogNodeOutputGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.responseType, - "responseType cannot be null"); - responseType = builder.responseType; - values = builder.values; - selectionPolicy = builder.selectionPolicy; - delimiter = builder.delimiter; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - query = builder.query; - queryType = builder.queryType; - filter = builder.filter; - discoveryVersion = builder.discoveryVersion; - } + @SerializedName("user_defined") + protected Map userDefined; - /** - * New builder. - * - * @return a DialogNodeOutputGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } + @SerializedName("channel_options") + protected Map channelOptions; + + @SerializedName("image_url") + protected String imageUrl; + + protected DialogNodeOutputGeneric() {} /** * Gets the responseType. * - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **search_skill** response type is available only for Plus and Premium users, and is used only by the - * v2 runtime API. + *

The type of response returned by the dialog node. The specified response type must be + * supported by the client application or channel. * * @return the responseType */ @@ -423,7 +161,7 @@ public String responseType() { /** * Gets the values. * - * A list of one or more objects defining text responses. Required when **response_type**=`text`. + *

A list of one or more objects defining text responses. * * @return the values */ @@ -434,8 +172,7 @@ public List values() { /** * Gets the selectionPolicy. * - * How a response is selected from the list, if more than one response is specified. Valid only when - * **response_type**=`text`. + *

How a response is selected from the list, if more than one response is specified. * * @return the selectionPolicy */ @@ -446,7 +183,7 @@ public String selectionPolicy() { /** * Gets the delimiter. * - * The delimiter to use as a separator between responses when `selection_policy`=`multiline`. + *

The delimiter to use as a separator between responses when `selection_policy`=`multiline`. * * @return the delimiter */ @@ -454,11 +191,21 @@ public String delimiter() { return delimiter; } + /** + * Gets the channels. + * + *

An array of objects specifying channels for which the response is intended. + * + * @return the channels + */ + public List channels() { + return channels; + } + /** * Gets the time. * - * How long to pause, in milliseconds. The valid values are from 0 to 10000. Valid only when - * **response_type**=`pause`. + *

How long to pause, in milliseconds. The valid values are from 0 to 10000. * * @return the time */ @@ -469,8 +216,8 @@ public Long time() { /** * Gets the typing. * - * Whether to send a "user is typing" event during the pause. Ignored if the channel does not support this event. - * Valid only when **response_type**=`pause`. + *

Whether to send a "user is typing" event during the pause. Ignored if the channel does not + * support this event. * * @return the typing */ @@ -481,7 +228,7 @@ public Boolean typing() { /** * Gets the source. * - * The URL of the image. Required when **response_type**=`image`. + *

The `https:` URL of the image. * * @return the source */ @@ -492,7 +239,7 @@ public String source() { /** * Gets the title. * - * An optional title to show before the response. Valid only when **response_type**=`image` or `option`. + *

An optional title to show before the response. * * @return the title */ @@ -503,7 +250,7 @@ public String title() { /** * Gets the description. * - * An optional description to show with the response. Valid only when **response_type**=`image` or `option`. + *

An optional description to show with the response. * * @return the description */ @@ -511,10 +258,22 @@ public String description() { return description; } + /** + * Gets the altText. + * + *

Descriptive text that can be used for screen readers or other situations where the image + * cannot be seen. + * + * @return the altText + */ + public String altText() { + return altText; + } + /** * Gets the preference. * - * The preferred type of control to display, if supported by the channel. Valid only when **response_type**=`option`. + *

The preferred type of control to display, if supported by the channel. * * @return the preference */ @@ -525,8 +284,8 @@ public String preference() { /** * Gets the options. * - * An array of objects describing the options from which the user can choose. You can include up to 20 options. - * Required when **response_type**=`option`. + *

An array of objects describing the options from which the user can choose. You can include + * up to 20 options. * * @return the options */ @@ -537,8 +296,7 @@ public List options() { /** * Gets the messageToHumanAgent. * - * An optional message to be sent to the human agent who will be taking over the conversation. Valid only when - * **reponse_type**=`connect_to_agent`. + *

An optional message to be sent to the human agent who will be taking over the conversation. * * @return the messageToHumanAgent */ @@ -546,13 +304,37 @@ public String messageToHumanAgent() { return messageToHumanAgent; } + /** + * Gets the agentAvailable. + * + *

An optional message to be displayed to the user to indicate that the conversation will be + * transferred to the next available agent. + * + * @return the agentAvailable + */ + public AgentAvailabilityMessage agentAvailable() { + return agentAvailable; + } + + /** + * Gets the agentUnavailable. + * + *

An optional message to be displayed to the user to indicate that no online agent is + * available to take over the conversation. + * + * @return the agentUnavailable + */ + public AgentAvailabilityMessage agentUnavailable() { + return agentUnavailable; + } + /** * Gets the query. * - * The text of the search query. This can be either a natural-language query or a query that uses the Discovery query - * language syntax, depending on the value of the **query_type** property. For more information, see the [Discovery - * service documentation](https://cloud.ibm.com/docs/discovery/query-operators.html#query-operators). - * Required when **response_type**=`search_skill`. + *

The text of the search query. This can be either a natural-language query or a query that + * uses the Discovery query language syntax, depending on the value of the **query_type** + * property. For more information, see the [Discovery service + * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-operators#query-operators). * * @return the query */ @@ -563,7 +345,7 @@ public String query() { /** * Gets the queryType. * - * The type of the search query. Required when **response_type**=`search_skill`. + *

The type of the search query. * * @return the queryType */ @@ -574,9 +356,9 @@ public String queryType() { /** * Gets the filter. * - * An optional filter that narrows the set of documents to be searched. For more information, see the [Discovery - * service documentation]([Discovery service - * documentation](https://cloud.ibm.com/docs/discovery/query-parameters.html#filter). + *

An optional filter that narrows the set of documents to be searched. For more information, + * see the [Discovery service documentation]([Discovery service + * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-parameters#filter). * * @return the filter */ @@ -587,11 +369,56 @@ public String filter() { /** * Gets the discoveryVersion. * - * The version of the Discovery service API to use for the query. + *

The version of the Discovery service API to use for the query. * * @return the discoveryVersion */ public String discoveryVersion() { return discoveryVersion; } + + /** + * Gets the messageToUser. + * + *

The message to display to the user when initiating a channel transfer. + * + * @return the messageToUser + */ + public String messageToUser() { + return messageToUser; + } + + /** + * Gets the userDefined. + * + *

An object containing any properties for the user-defined response type. The total size of + * this object cannot exceed 5000 bytes. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the channelOptions. + * + *

For internal use only. + * + * @return the channelOptions + */ + public Map channelOptions() { + return channelOptions; + } + + /** + * Gets the imageUrl. + * + *

The URL of an image that shows a preview of the embedded content. + * + * @return the imageUrl + */ + public String imageUrl() { + return imageUrl; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.java new file mode 100644 index 00000000000..d217dc51fad --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.java @@ -0,0 +1,191 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio + extends DialogNodeOutputGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private List channels; + private Map channelOptions; + private String altText; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio the instance to initialize + * the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.responseType; + this.source = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.source; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.description; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.channels; + this.channelOptions = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.channelOptions; + this.altText = dialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.altText; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the channelOptions. + * + * @param channelOptions the channelOptions + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder channelOptions(Map channelOptions) { + this.channelOptions = channelOptions; + return this; + } + + /** + * Set the altText. + * + * @param altText the altText + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder altText(String altText) { + this.altText = altText; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + channels = builder.channels; + channelOptions = builder.channelOptions; + altText = builder.altText; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.java new file mode 100644 index 00000000000..1b52182a23f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.java @@ -0,0 +1,172 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer + extends DialogNodeOutputGeneric { + + @SerializedName("transfer_info") + private ChannelTransferInfo transferInfo; + + /** Builder. */ + public static class Builder { + private String responseType; + private String messageToUser; + private ChannelTransferInfo transferInfo; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer the instance to + * initialize the Builder with + */ + public Builder( + DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer) { + this.responseType = + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.responseType; + this.messageToUser = + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.messageToUser; + this.transferInfo = + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.transferInfo; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param messageToUser the messageToUser + * @param transferInfo the transferInfo + */ + public Builder(String responseType, String messageToUser, ChannelTransferInfo transferInfo) { + this.responseType = responseType; + this.messageToUser = messageToUser; + this.transferInfo = transferInfo; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the messageToUser. + * + * @param messageToUser the messageToUser + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer builder + */ + public Builder messageToUser(String messageToUser) { + this.messageToUser = messageToUser; + return this; + } + + /** + * Set the transferInfo. + * + * @param transferInfo the transferInfo + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer builder + */ + public Builder transferInfo(ChannelTransferInfo transferInfo) { + this.transferInfo = transferInfo; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.messageToUser, "messageToUser cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.transferInfo, "transferInfo cannot be null"); + responseType = builder.responseType; + messageToUser = builder.messageToUser; + transferInfo = builder.transferInfo; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public ChannelTransferInfo transferInfo() { + return transferInfo; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.java new file mode 100644 index 00000000000..ef1563daa0d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.java @@ -0,0 +1,194 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + extends DialogNodeOutputGeneric { + + @SerializedName("transfer_info") + private DialogNodeOutputConnectToAgentTransferInfo transferInfo; + + /** Builder. */ + public static class Builder { + private String responseType; + private String messageToHumanAgent; + private AgentAvailabilityMessage agentAvailable; + private AgentAvailabilityMessage agentUnavailable; + private DialogNodeOutputConnectToAgentTransferInfo transferInfo; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent the instance to + * initialize the Builder with + */ + public Builder( + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent) { + this.responseType = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.responseType; + this.messageToHumanAgent = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.messageToHumanAgent; + this.agentAvailable = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.agentAvailable; + this.agentUnavailable = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.agentUnavailable; + this.transferInfo = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.transferInfo; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + */ + public Builder(String responseType) { + this.responseType = responseType; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the messageToHumanAgent. + * + * @param messageToHumanAgent the messageToHumanAgent + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder messageToHumanAgent(String messageToHumanAgent) { + this.messageToHumanAgent = messageToHumanAgent; + return this; + } + + /** + * Set the agentAvailable. + * + * @param agentAvailable the agentAvailable + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder agentAvailable(AgentAvailabilityMessage agentAvailable) { + this.agentAvailable = agentAvailable; + return this; + } + + /** + * Set the agentUnavailable. + * + * @param agentUnavailable the agentUnavailable + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder agentUnavailable(AgentAvailabilityMessage agentUnavailable) { + this.agentUnavailable = agentUnavailable; + return this; + } + + /** + * Set the transferInfo. + * + * @param transferInfo the transferInfo + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder transferInfo(DialogNodeOutputConnectToAgentTransferInfo transferInfo) { + this.transferInfo = transferInfo; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + responseType = builder.responseType; + messageToHumanAgent = builder.messageToHumanAgent; + agentAvailable = builder.agentAvailable; + agentUnavailable = builder.agentUnavailable; + transferInfo = builder.transferInfo; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public DialogNodeOutputConnectToAgentTransferInfo transferInfo() { + return transferInfo; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.java new file mode 100644 index 00000000000..c89aa5abf81 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.java @@ -0,0 +1,176 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe + extends DialogNodeOutputGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private String imageUrl; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe the instance to initialize + * the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.responseType; + this.source = dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.source; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.description; + this.imageUrl = dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.imageUrl; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the imageUrl. + * + * @param imageUrl the imageUrl + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder imageUrl(String imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + imageUrl = builder.imageUrl; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.java new file mode 100644 index 00000000000..ea268461887 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.java @@ -0,0 +1,176 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeImage. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeImage + extends DialogNodeOutputGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private List channels; + private String altText; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeImage instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeImage the instance to initialize + * the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeImage) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.responseType; + this.source = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.source; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.description; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.channels; + this.altText = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.altText; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeImage. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeImage build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the altText. + * + * @param altText the altText + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder altText(String altText) { + this.altText = altText; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeImage() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeImage(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + channels = builder.channels; + altText = builder.altText; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.java new file mode 100644 index 00000000000..a83ebe08971 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.java @@ -0,0 +1,203 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeOption. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeOption + extends DialogNodeOutputGeneric { + + /** The preferred type of control to display, if supported by the channel. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String title; + private String description; + private String preference; + private List options; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeOption instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeOption the instance to initialize + * the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeOption) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.responseType; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.description; + this.preference = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.preference; + this.options = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.options; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param title the title + * @param options the options + */ + public Builder( + String responseType, String title, List options) { + this.responseType = responseType; + this.title = title; + this.options = options; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeOption. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeOption build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption(this); + } + + /** + * Adds a new element to options. + * + * @param options the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder addOptions(DialogNodeOutputOptionsElement options) { + com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); + if (this.options == null) { + this.options = new ArrayList(); + } + this.options.add(options); + return this; + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the preference. + * + * @param preference the preference + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder preference(String preference) { + this.preference = preference; + return this; + } + + /** + * Set the options. Existing options will be replaced. + * + * @param options the options + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder options(List options) { + this.options = options; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeOption() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeOption(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.options, "options cannot be null"); + responseType = builder.responseType; + title = builder.title; + description = builder.description; + preference = builder.preference; + options = builder.options; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePause.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePause.java new file mode 100644 index 00000000000..ae005273baf --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePause.java @@ -0,0 +1,148 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypePause. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypePause + extends DialogNodeOutputGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private Long time; + private Boolean typing; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypePause instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypePause the instance to initialize + * the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypePause) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.responseType; + this.time = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.time; + this.typing = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.typing; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param time the time + */ + public Builder(String responseType, Long time) { + this.responseType = responseType; + this.time = time; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypePause. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypePause instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypePause build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypePause(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the time. + * + * @param time the time + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder time(long time) { + this.time = time; + return this; + } + + /** + * Set the typing. + * + * @param typing the typing + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder typing(Boolean typing) { + this.typing = typing; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypePause() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypePause(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.time, "time cannot be null"); + responseType = builder.responseType; + time = builder.time; + typing = builder.typing; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.java new file mode 100644 index 00000000000..49c046a5b8c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.java @@ -0,0 +1,189 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + extends DialogNodeOutputGeneric { + + /** The type of the search query. */ + public interface QueryType { + /** natural_language. */ + String NATURAL_LANGUAGE = "natural_language"; + /** discovery_query_language. */ + String DISCOVERY_QUERY_LANGUAGE = "discovery_query_language"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String query; + private String queryType; + private String filter; + private String discoveryVersion; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill the instance to + * initialize the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill) { + this.responseType = + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.responseType; + this.query = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.query; + this.queryType = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.queryType; + this.filter = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.filter; + this.discoveryVersion = + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.discoveryVersion; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param query the query + * @param queryType the queryType + */ + public Builder(String responseType, String query, String queryType) { + this.responseType = responseType; + this.query = query; + this.queryType = queryType; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the query. + * + * @param query the query + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder query(String query) { + this.query = query; + return this; + } + + /** + * Set the queryType. + * + * @param queryType the queryType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder queryType(String queryType) { + this.queryType = queryType; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the discoveryVersion. + * + * @param discoveryVersion the discoveryVersion + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder discoveryVersion(String discoveryVersion) { + this.discoveryVersion = discoveryVersion; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.query, "query cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.queryType, "queryType cannot be null"); + responseType = builder.responseType; + query = builder.query; + queryType = builder.queryType; + filter = builder.filter; + discoveryVersion = builder.discoveryVersion; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeText.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeText.java new file mode 100644 index 00000000000..d37ffd716c9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeText.java @@ -0,0 +1,188 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeText. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeText + extends DialogNodeOutputGeneric { + + /** How a response is selected from the list, if more than one response is specified. */ + public interface SelectionPolicy { + /** sequential. */ + String SEQUENTIAL = "sequential"; + /** random. */ + String RANDOM = "random"; + /** multiline. */ + String MULTILINE = "multiline"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private List values; + private String selectionPolicy; + private String delimiter; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeText instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeText the instance to initialize the + * Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeText) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.responseType; + this.values = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.values; + this.selectionPolicy = + dialogNodeOutputGenericDialogNodeOutputResponseTypeText.selectionPolicy; + this.delimiter = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.delimiter; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param values the values + */ + public Builder(String responseType, List values) { + this.responseType = responseType; + this.values = values; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeText. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeText instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeText build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeText(this); + } + + /** + * Adds a new element to values. + * + * @param values the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder addValues(DialogNodeOutputTextValuesElement values) { + com.ibm.cloud.sdk.core.util.Validator.notNull(values, "values cannot be null"); + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(values); + return this; + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the values. Existing values will be replaced. + * + * @param values the values + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder values(List values) { + this.values = values; + return this; + } + + /** + * Set the selectionPolicy. + * + * @param selectionPolicy the selectionPolicy + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder selectionPolicy(String selectionPolicy) { + this.selectionPolicy = selectionPolicy; + return this; + } + + /** + * Set the delimiter. + * + * @param delimiter the delimiter + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder delimiter(String delimiter) { + this.delimiter = delimiter; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeText() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeText(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.values, "values cannot be null"); + responseType = builder.responseType; + values = builder.values; + selectionPolicy = builder.selectionPolicy; + delimiter = builder.delimiter; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.java new file mode 100644 index 00000000000..f9524dd5b2e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.java @@ -0,0 +1,137 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined + extends DialogNodeOutputGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private Map userDefined; + private List channels; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined the instance to + * initialize the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined) { + this.responseType = + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.responseType; + this.userDefined = dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.userDefined; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param userDefined the userDefined + */ + public Builder(String responseType, Map userDefined) { + this.responseType = responseType; + this.userDefined = userDefined; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.userDefined, "userDefined cannot be null"); + responseType = builder.responseType; + userDefined = builder.userDefined; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.java new file mode 100644 index 00000000000..51975ba1cb9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.java @@ -0,0 +1,191 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo + extends DialogNodeOutputGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private List channels; + private Map channelOptions; + private String altText; + + /** + * Instantiates a new Builder from an existing + * DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo instance. + * + * @param dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo the instance to initialize + * the Builder with + */ + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.responseType; + this.source = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.source; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.description; + this.channels = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.channels; + this.channelOptions = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.channelOptions; + this.altText = dialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.altText; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the channelOptions. + * + * @param channelOptions the channelOptions + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder channelOptions(Map channelOptions) { + this.channelOptions = channelOptions; + return this; + } + + /** + * Set the altText. + * + * @param altText the altText + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder altText(String altText) { + this.altText = altText; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo() {} + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + channels = builder.channels; + channelOptions = builder.channelOptions; + altText = builder.altText; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java index f039762dd91..03ff8da2fa9 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,37 +10,36 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Options that modify how specified output is handled. - */ +/** Options that modify how specified output is handled. */ public class DialogNodeOutputModifiers extends GenericModel { protected Boolean overwrite; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean overwrite; + /** + * Instantiates a new Builder from an existing DialogNodeOutputModifiers instance. + * + * @param dialogNodeOutputModifiers the instance to initialize the Builder with + */ private Builder(DialogNodeOutputModifiers dialogNodeOutputModifiers) { this.overwrite = dialogNodeOutputModifiers.overwrite; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a DialogNodeOutputModifiers. * - * @return the dialogNodeOutputModifiers + * @return the new DialogNodeOutputModifiers instance */ public DialogNodeOutputModifiers build() { return new DialogNodeOutputModifiers(this); @@ -58,6 +57,8 @@ public Builder overwrite(Boolean overwrite) { } } + protected DialogNodeOutputModifiers() {} + protected DialogNodeOutputModifiers(Builder builder) { overwrite = builder.overwrite; } @@ -74,8 +75,9 @@ public Builder newBuilder() { /** * Gets the overwrite. * - * Whether values in the output will overwrite output values in an array specified by previously executed dialog - * nodes. If this option is set to `false`, new values will be appended to previously specified values. + *

Whether values in the output will overwrite output values in an array specified by + * previously executed dialog nodes. If this option is set to `false`, new values will be appended + * to previously specified values. * * @return the overwrite */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java index a57820b860d..f5c0d073b1c 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * DialogNodeOutputOptionsElement. - */ +/** DialogNodeOutputOptionsElement. */ public class DialogNodeOutputOptionsElement extends GenericModel { protected String label; protected DialogNodeOutputOptionsElementValue value; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String label; private DialogNodeOutputOptionsElementValue value; + /** + * Instantiates a new Builder from an existing DialogNodeOutputOptionsElement instance. + * + * @param dialogNodeOutputOptionsElement the instance to initialize the Builder with + */ private Builder(DialogNodeOutputOptionsElement dialogNodeOutputOptionsElement) { this.label = dialogNodeOutputOptionsElement.label; this.value = dialogNodeOutputOptionsElement.value; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String label, DialogNodeOutputOptionsElementValue value) { /** * Builds a DialogNodeOutputOptionsElement. * - * @return the dialogNodeOutputOptionsElement + * @return the new DialogNodeOutputOptionsElement instance */ public DialogNodeOutputOptionsElement build() { return new DialogNodeOutputOptionsElement(this); @@ -83,11 +82,11 @@ public Builder value(DialogNodeOutputOptionsElementValue value) { } } + protected DialogNodeOutputOptionsElement() {} + protected DialogNodeOutputOptionsElement(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.label, - "label cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.label, "label cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); label = builder.label; value = builder.value; } @@ -104,7 +103,7 @@ public Builder newBuilder() { /** * Gets the label. * - * The user-facing label for the option. + *

The user-facing label for the option. * * @return the label */ @@ -115,8 +114,8 @@ public String label() { /** * Gets the value. * - * An object defining the message input to be sent to the Watson Assistant service if the user selects the - * corresponding option. + *

An object defining the message input to be sent to the Watson Assistant service if the user + * selects the corresponding option. * * @return the value */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java index b1a19784765..c6d8c1d0372 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,16 +10,16 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - /** - * An object defining the message input to be sent to the Watson Assistant service if the user selects the corresponding - * option. + * An object defining the message input to be sent to the Watson Assistant service if the user + * selects the corresponding option. */ public class DialogNodeOutputOptionsElementValue extends GenericModel { @@ -27,44 +27,43 @@ public class DialogNodeOutputOptionsElementValue extends GenericModel { protected List intents; protected List entities; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private MessageInput input; private List intents; private List entities; + /** + * Instantiates a new Builder from an existing DialogNodeOutputOptionsElementValue instance. + * + * @param dialogNodeOutputOptionsElementValue the instance to initialize the Builder with + */ private Builder(DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValue) { this.input = dialogNodeOutputOptionsElementValue.input; this.intents = dialogNodeOutputOptionsElementValue.intents; this.entities = dialogNodeOutputOptionsElementValue.entities; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a DialogNodeOutputOptionsElementValue. * - * @return the dialogNodeOutputOptionsElementValue + * @return the new DialogNodeOutputOptionsElementValue instance */ public DialogNodeOutputOptionsElementValue build() { return new DialogNodeOutputOptionsElementValue(this); } /** - * Adds an intents to intents. + * Adds a new element to intents. * - * @param intents the new intents + * @param intents the new element to be added * @return the DialogNodeOutputOptionsElementValue builder */ public Builder addIntents(RuntimeIntent intents) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intents, - "intents cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(intents, "intents cannot be null"); if (this.intents == null) { this.intents = new ArrayList(); } @@ -73,14 +72,13 @@ public Builder addIntents(RuntimeIntent intents) { } /** - * Adds an entities to entities. + * Adds a new element to entities. * - * @param entities the new entities + * @param entities the new element to be added * @return the DialogNodeOutputOptionsElementValue builder */ public Builder addEntities(RuntimeEntity entities) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entities, - "entities cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(entities, "entities cannot be null"); if (this.entities == null) { this.entities = new ArrayList(); } @@ -100,8 +98,7 @@ public Builder input(MessageInput input) { } /** - * Set the intents. - * Existing intents will be replaced. + * Set the intents. Existing intents will be replaced. * * @param intents the intents * @return the DialogNodeOutputOptionsElementValue builder @@ -112,8 +109,7 @@ public Builder intents(List intents) { } /** - * Set the entities. - * Existing entities will be replaced. + * Set the entities. Existing entities will be replaced. * * @param entities the entities * @return the DialogNodeOutputOptionsElementValue builder @@ -124,6 +120,8 @@ public Builder entities(List entities) { } } + protected DialogNodeOutputOptionsElementValue() {} + protected DialogNodeOutputOptionsElementValue(Builder builder) { input = builder.input; intents = builder.intents; @@ -142,7 +140,7 @@ public Builder newBuilder() { /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ @@ -153,10 +151,10 @@ public MessageInput input() { /** * Gets the intents. * - * An array of intents to be used while processing the input. + *

An array of intents to be used while processing the input. * - * **Note:** This property is supported for backward compatibility with applications that use the v1 **Get response to - * user input** method. + *

**Note:** This property is supported for backward compatibility with applications that use + * the v1 **Get response to user input** method. * * @return the intents */ @@ -167,10 +165,10 @@ public List intents() { /** * Gets the entities. * - * An array of entities to be used while processing the user input. + *

An array of entities to be used while processing the user input. * - * **Note:** This property is supported for backward compatibility with applications that use the v1 **Get response to - * user input** method. + *

**Note:** This property is supported for backward compatibility with applications that use + * the v1 **Get response to user input** method. * * @return the entities */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java index 0114a5be911..ba8d16b6a74 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,37 +10,36 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * DialogNodeOutputTextValuesElement. - */ +/** DialogNodeOutputTextValuesElement. */ public class DialogNodeOutputTextValuesElement extends GenericModel { protected String text; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String text; + /** + * Instantiates a new Builder from an existing DialogNodeOutputTextValuesElement instance. + * + * @param dialogNodeOutputTextValuesElement the instance to initialize the Builder with + */ private Builder(DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElement) { this.text = dialogNodeOutputTextValuesElement.text; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a DialogNodeOutputTextValuesElement. * - * @return the dialogNodeOutputTextValuesElement + * @return the new DialogNodeOutputTextValuesElement instance */ public DialogNodeOutputTextValuesElement build() { return new DialogNodeOutputTextValuesElement(this); @@ -58,6 +57,8 @@ public Builder text(String text) { } } + protected DialogNodeOutputTextValuesElement() {} + protected DialogNodeOutputTextValuesElement(Builder builder) { text = builder.text; } @@ -74,8 +75,8 @@ public Builder newBuilder() { /** * Gets the text. * - * The text of a response. This string can include newline characters (`\n`), Markdown tagging, or other special - * characters, if supported by the channel. + *

The text of a response. This string can include newline characters (`\n`), Markdown tagging, + * or other special characters, if supported by the channel. * * @return the text */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java index c349762a940..78d92f013cd 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,45 +10,45 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * DialogNodeVisitedDetails. - */ +/** DialogNodeVisitedDetails. */ public class DialogNodeVisitedDetails extends GenericModel { @SerializedName("dialog_node") protected String dialogNode; + protected String title; protected String conditions; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String dialogNode; private String title; private String conditions; + /** + * Instantiates a new Builder from an existing DialogNodeVisitedDetails instance. + * + * @param dialogNodeVisitedDetails the instance to initialize the Builder with + */ private Builder(DialogNodeVisitedDetails dialogNodeVisitedDetails) { this.dialogNode = dialogNodeVisitedDetails.dialogNode; this.title = dialogNodeVisitedDetails.title; this.conditions = dialogNodeVisitedDetails.conditions; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a DialogNodeVisitedDetails. * - * @return the dialogNodeVisitedDetails + * @return the new DialogNodeVisitedDetails instance */ public DialogNodeVisitedDetails build() { return new DialogNodeVisitedDetails(this); @@ -88,6 +88,8 @@ public Builder conditions(String conditions) { } } + protected DialogNodeVisitedDetails() {} + protected DialogNodeVisitedDetails(Builder builder) { dialogNode = builder.dialogNode; title = builder.title; @@ -106,7 +108,7 @@ public Builder newBuilder() { /** * Gets the dialogNode. * - * A dialog node that was triggered during processing of the input message. + *

The unique ID of a dialog node that was triggered during processing of the input message. * * @return the dialogNode */ @@ -117,7 +119,7 @@ public String dialogNode() { /** * Gets the title. * - * The title of the dialog node. + *

The title of the dialog node. * * @return the title */ @@ -128,7 +130,7 @@ public String title() { /** * Gets the conditions. * - * The conditions that trigger the dialog node. + *

The conditions that trigger the dialog node. * * @return the conditions */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java index ba9d03e4c84..30b7a68c1b9 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,31 +10,35 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; -/** - * DialogSuggestion. - */ +/** DialogSuggestion. */ public class DialogSuggestion extends GenericModel { protected String label; protected DialogSuggestionValue value; - protected DialogSuggestionOutput output; + protected Map output; + @SerializedName("dialog_node") protected String dialogNode; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String label; private DialogSuggestionValue value; - private DialogSuggestionOutput output; + private Map output; private String dialogNode; + /** + * Instantiates a new Builder from an existing DialogSuggestion instance. + * + * @param dialogSuggestion the instance to initialize the Builder with + */ private Builder(DialogSuggestion dialogSuggestion) { this.label = dialogSuggestion.label; this.value = dialogSuggestion.value; @@ -42,11 +46,8 @@ private Builder(DialogSuggestion dialogSuggestion) { this.dialogNode = dialogSuggestion.dialogNode; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -62,7 +63,7 @@ public Builder(String label, DialogSuggestionValue value) { /** * Builds a DialogSuggestion. * - * @return the dialogSuggestion + * @return the new DialogSuggestion instance */ public DialogSuggestion build() { return new DialogSuggestion(this); @@ -96,7 +97,7 @@ public Builder value(DialogSuggestionValue value) { * @param output the output * @return the DialogSuggestion builder */ - public Builder output(DialogSuggestionOutput output) { + public Builder output(Map output) { this.output = output; return this; } @@ -113,11 +114,11 @@ public Builder dialogNode(String dialogNode) { } } + protected DialogSuggestion() {} + protected DialogSuggestion(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.label, - "label cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.label, "label cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); label = builder.label; value = builder.value; output = builder.output; @@ -136,8 +137,8 @@ public Builder newBuilder() { /** * Gets the label. * - * The user-facing label for the disambiguation option. This label is taken from the **title** or **user_label** - * property of the corresponding dialog node, depending on the disambiguation options. + *

The user-facing label for the disambiguation option. This label is taken from the **title** + * or **user_label** property of the corresponding dialog node. * * @return the label */ @@ -148,8 +149,11 @@ public String label() { /** * Gets the value. * - * An object defining the message input, intents, and entities to be sent to the Watson Assistant service if the user - * selects the corresponding disambiguation option. + *

An object defining the message input, intents, and entities to be sent to the Watson + * Assistant service if the user selects the corresponding disambiguation option. + * + *

**Note:** These properties must be included in the request body of the next message sent to + * the assistant. Do not modify or remove any of the included properties. * * @return the value */ @@ -160,20 +164,21 @@ public DialogSuggestionValue value() { /** * Gets the output. * - * The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding - * option. + *

The dialog output that will be returned from the Watson Assistant service if the user + * selects the corresponding option. * * @return the output */ - public DialogSuggestionOutput output() { + public Map output() { return output; } /** * Gets the dialogNode. * - * The ID of the dialog node that the **label** property is taken from. The **label** property is populated using the - * value of the dialog node's **user_label** property. + *

The unique ID of the dialog node that the **label** property is taken from. The **label** + * property is populated using the value of the dialog node's **title** or **user_label** + * property. * * @return the dialogNode */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionOutput.java deleted file mode 100644 index 08696f60971..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionOutput.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.assistant.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; - -/** - * The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding - * option. - */ -public class DialogSuggestionOutput extends DynamicModel { - - @SerializedName("nodes_visited") - protected List nodesVisited; - @SerializedName("nodes_visited_details") - protected List nodesVisitedDetails; - @SerializedName("text") - protected List text; - @SerializedName("generic") - protected List generic; - - public DialogSuggestionOutput() { - super(new TypeToken() { - }); - } - - /** - * Gets the nodesVisited. - * - * An array of the nodes that were triggered to create the response, in the order in which they were visited. This - * information is useful for debugging and for tracing the path taken through the node tree. - * - * @return the nodesVisited - */ - public List getNodesVisited() { - return this.nodesVisited; - } - - /** - * Sets the nodesVisited. - * - * @param nodesVisited the new nodesVisited - */ - public void setNodesVisited(final List nodesVisited) { - this.nodesVisited = nodesVisited; - } - - /** - * Gets the nodesVisitedDetails. - * - * An array of objects containing detailed diagnostic information about the nodes that were triggered during - * processing of the input message. Included only if **nodes_visited_details** is set to `true` in the message - * request. - * - * @return the nodesVisitedDetails - */ - public List getNodesVisitedDetails() { - return this.nodesVisitedDetails; - } - - /** - * Sets the nodesVisitedDetails. - * - * @param nodesVisitedDetails the new nodesVisitedDetails - */ - public void setNodesVisitedDetails(final List nodesVisitedDetails) { - this.nodesVisitedDetails = nodesVisitedDetails; - } - - /** - * Gets the text. - * - * An array of responses to the user. - * - * @return the text - */ - public List getText() { - return this.text; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final List text) { - this.text = text; - } - - /** - * Gets the generic. - * - * Output intended for any channel. It is the responsibility of the client application to implement the supported - * response types. - * - * @return the generic - */ - public List getGeneric() { - return this.generic; - } - - /** - * Sets the generic. - * - * @param generic the new generic - */ - public void setGeneric(final List generic) { - this.generic = generic; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionResponseGeneric.java deleted file mode 100644 index eef03218bbe..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionResponseGeneric.java +++ /dev/null @@ -1,444 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * DialogSuggestionResponseGeneric. - */ -public class DialogSuggestionResponseGeneric extends GenericModel { - - /** - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for Plus - * and Premium users. The **search_skill** response type is available only for Plus and Premium users, and is used - * only by the v2 runtime API. - */ - public interface ResponseType { - /** text. */ - String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** search_skill. */ - String SEARCH_SKILL = "search_skill"; - } - - /** - * The preferred type of control to display. - */ - public interface Preference { - /** dropdown. */ - String DROPDOWN = "dropdown"; - /** button. */ - String BUTTON = "button"; - } - - @SerializedName("response_type") - protected String responseType; - protected String text; - protected Long time; - protected Boolean typing; - protected String source; - protected String title; - protected String description; - protected String preference; - protected List options; - @SerializedName("message_to_human_agent") - protected String messageToHumanAgent; - protected String topic; - @SerializedName("dialog_node") - protected String dialogNode; - - /** - * Builder. - */ - public static class Builder { - private String responseType; - private String text; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String topic; - private String dialogNode; - - private Builder(DialogSuggestionResponseGeneric dialogSuggestionResponseGeneric) { - this.responseType = dialogSuggestionResponseGeneric.responseType; - this.text = dialogSuggestionResponseGeneric.text; - this.time = dialogSuggestionResponseGeneric.time; - this.typing = dialogSuggestionResponseGeneric.typing; - this.source = dialogSuggestionResponseGeneric.source; - this.title = dialogSuggestionResponseGeneric.title; - this.description = dialogSuggestionResponseGeneric.description; - this.preference = dialogSuggestionResponseGeneric.preference; - this.options = dialogSuggestionResponseGeneric.options; - this.messageToHumanAgent = dialogSuggestionResponseGeneric.messageToHumanAgent; - this.topic = dialogSuggestionResponseGeneric.topic; - this.dialogNode = dialogSuggestionResponseGeneric.dialogNode; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a DialogSuggestionResponseGeneric. - * - * @return the dialogSuggestionResponseGeneric - */ - public DialogSuggestionResponseGeneric build() { - return new DialogSuggestionResponseGeneric(this); - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, - "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. - * Existing options will be replaced. - * - * @param options the options - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the topic. - * - * @param topic the topic - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder topic(String topic) { - this.topic = topic; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - } - - protected DialogSuggestionResponseGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.responseType, - "responseType cannot be null"); - responseType = builder.responseType; - text = builder.text; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - topic = builder.topic; - dialogNode = builder.dialogNode; - } - - /** - * New builder. - * - * @return a DialogSuggestionResponseGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the responseType. - * - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for Plus - * and Premium users. The **search_skill** response type is available only for Plus and Premium users, and is used - * only by the v2 runtime API. - * - * @return the responseType - */ - public String responseType() { - return responseType; - } - - /** - * Gets the text. - * - * The text of the response. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the time. - * - * How long to pause, in milliseconds. - * - * @return the time - */ - public Long time() { - return time; - } - - /** - * Gets the typing. - * - * Whether to send a "user is typing" event during the pause. - * - * @return the typing - */ - public Boolean typing() { - return typing; - } - - /** - * Gets the source. - * - * The URL of the image. - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the title. - * - * The title or introductory text to show before the response. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the description. - * - * The description to show with the the response. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the preference. - * - * The preferred type of control to display. - * - * @return the preference - */ - public String preference() { - return preference; - } - - /** - * Gets the options. - * - * An array of objects describing the options from which the user can choose. - * - * @return the options - */ - public List options() { - return options; - } - - /** - * Gets the messageToHumanAgent. - * - * A message to be sent to the human agent who will be taking over the conversation. - * - * @return the messageToHumanAgent - */ - public String messageToHumanAgent() { - return messageToHumanAgent; - } - - /** - * Gets the topic. - * - * A label identifying the topic of the conversation, derived from the **user_label** property of the relevant node. - * - * @return the topic - */ - public String topic() { - return topic; - } - - /** - * Gets the dialogNode. - * - * The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated using the - * value of the dialog node's **user_label** property. - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java index 0dd76cb7a12..3c5e1530df1 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,16 +10,19 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - /** - * An object defining the message input, intents, and entities to be sent to the Watson Assistant service if the user - * selects the corresponding disambiguation option. + * An object defining the message input, intents, and entities to be sent to the Watson Assistant + * service if the user selects the corresponding disambiguation option. + * + *

**Note:** These properties must be included in the request body of the next message sent to + * the assistant. Do not modify or remove any of the included properties. */ public class DialogSuggestionValue extends GenericModel { @@ -27,44 +30,43 @@ public class DialogSuggestionValue extends GenericModel { protected List intents; protected List entities; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private MessageInput input; private List intents; private List entities; + /** + * Instantiates a new Builder from an existing DialogSuggestionValue instance. + * + * @param dialogSuggestionValue the instance to initialize the Builder with + */ private Builder(DialogSuggestionValue dialogSuggestionValue) { this.input = dialogSuggestionValue.input; this.intents = dialogSuggestionValue.intents; this.entities = dialogSuggestionValue.entities; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a DialogSuggestionValue. * - * @return the dialogSuggestionValue + * @return the new DialogSuggestionValue instance */ public DialogSuggestionValue build() { return new DialogSuggestionValue(this); } /** - * Adds an intents to intents. + * Adds a new element to intents. * - * @param intents the new intents + * @param intents the new element to be added * @return the DialogSuggestionValue builder */ public Builder addIntents(RuntimeIntent intents) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intents, - "intents cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(intents, "intents cannot be null"); if (this.intents == null) { this.intents = new ArrayList(); } @@ -73,14 +75,13 @@ public Builder addIntents(RuntimeIntent intents) { } /** - * Adds an entities to entities. + * Adds a new element to entities. * - * @param entities the new entities + * @param entities the new element to be added * @return the DialogSuggestionValue builder */ public Builder addEntities(RuntimeEntity entities) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entities, - "entities cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(entities, "entities cannot be null"); if (this.entities == null) { this.entities = new ArrayList(); } @@ -100,8 +101,7 @@ public Builder input(MessageInput input) { } /** - * Set the intents. - * Existing intents will be replaced. + * Set the intents. Existing intents will be replaced. * * @param intents the intents * @return the DialogSuggestionValue builder @@ -112,8 +112,7 @@ public Builder intents(List intents) { } /** - * Set the entities. - * Existing entities will be replaced. + * Set the entities. Existing entities will be replaced. * * @param entities the entities * @return the DialogSuggestionValue builder @@ -124,6 +123,8 @@ public Builder entities(List entities) { } } + protected DialogSuggestionValue() {} + protected DialogSuggestionValue(Builder builder) { input = builder.input; intents = builder.intents; @@ -142,7 +143,7 @@ public Builder newBuilder() { /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ @@ -153,7 +154,7 @@ public MessageInput input() { /** * Gets the intents. * - * An array of intents to be sent along with the user input. + *

An array of intents to be sent along with the user input. * * @return the intents */ @@ -164,7 +165,7 @@ public List intents() { /** * Gets the entities. * - * An array of entities to be sent along with the user input. + *

An array of entities to be sent along with the user input. * * @return the entities */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java index 3bab9daa84e..c753e9cb885 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,35 +10,37 @@ * 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.assistant.v1.model; +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.Date; import java.util.List; import java.util.Map; -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Entity. - */ +/** Entity. */ public class Entity extends GenericModel { protected String entity; protected String description; protected Map metadata; + @SerializedName("fuzzy_match") protected Boolean fuzzyMatch; + protected Date created; protected Date updated; protected List values; + protected Entity() {} + /** * Gets the entity. * - * The name of the entity. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, and hyphen characters. - * - If you specify an entity name beginning with the reserved prefix `sys-`, it must be the name of a system entity + *

The name of the entity. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, and hyphen characters. - If you specify an + * entity name beginning with the reserved prefix `sys-`, it must be the name of a system entity * that you want to enable. (Any entity content specified with the request is ignored.). * * @return the entity @@ -50,7 +52,8 @@ public String getEntity() { /** * Gets the description. * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters. + *

The description of the entity. This string cannot contain carriage return, newline, or tab + * characters. * * @return the description */ @@ -61,7 +64,7 @@ public String getDescription() { /** * Gets the metadata. * - * Any metadata related to the entity. + *

Any metadata related to the entity. * * @return the metadata */ @@ -72,7 +75,7 @@ public Map getMetadata() { /** * Gets the fuzzyMatch. * - * Whether to use fuzzy matching for the entity. + *

Whether to use fuzzy matching for the entity. * * @return the fuzzyMatch */ @@ -83,7 +86,7 @@ public Boolean isFuzzyMatch() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -94,7 +97,7 @@ public Date getCreated() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ @@ -105,7 +108,7 @@ public Date getUpdated() { /** * Gets the values. * - * An array of objects describing the entity values. + *

An array of objects describing the entity values. * * @return the values */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java index 1419a1fcf3d..744c50c0a00 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * An array of objects describing the entities for the workspace. - */ +/** An array of objects describing the entities for the workspace. */ public class EntityCollection extends GenericModel { protected List entities; protected Pagination pagination; + protected EntityCollection() {} + /** * Gets the entities. * - * An array of objects describing the entities defined for the workspace. + *

An array of objects describing the entities defined for the workspace. * * @return the entities */ @@ -38,7 +38,8 @@ public List getEntities() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java index aae6ec1f583..a381eb16e49 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,25 +10,25 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * An object describing a contextual entity mention. - */ +/** An object describing a contextual entity mention. */ public class EntityMention extends GenericModel { protected String text; protected String intent; protected List location; + protected EntityMention() {} + /** * Gets the text. * - * The text of the user input example. + *

The text of the user input example. * * @return the text */ @@ -39,7 +39,7 @@ public String getText() { /** * Gets the intent. * - * The name of the intent. + *

The name of the intent. * * @return the intent */ @@ -50,7 +50,8 @@ public String getIntent() { /** * Gets the location. * - * An array of zero-based character offsets that indicate where the entity mentions begin and end in the input text. + *

An array of zero-based character offsets that indicate where the entity mentions begin and + * end in the input text. * * @return the location */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java index 12094f25dec..8d31644fb15 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * EntityMentionCollection. - */ +/** EntityMentionCollection. */ public class EntityMentionCollection extends GenericModel { protected List examples; protected Pagination pagination; + protected EntityMentionCollection() {} + /** * Gets the examples. * - * An array of objects describing the entity mentions defined for an entity. + *

An array of objects describing the entity mentions defined for an entity. * * @return the examples */ @@ -38,7 +38,8 @@ public List getExamples() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java index 5eb5e738400..422e3a5cbea 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,17 +10,15 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Example. - */ +/** Example. */ public class Example extends GenericModel { protected String text; @@ -28,27 +26,23 @@ public class Example extends GenericModel { protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String text; private List mentions; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing Example instance. + * + * @param example the instance to initialize the Builder with + */ private Builder(Example example) { this.text = example.text; this.mentions = example.mentions; - this.created = example.created; - this.updated = example.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -62,21 +56,20 @@ public Builder(String text) { /** * Builds a Example. * - * @return the example + * @return the new Example instance */ public Example build() { return new Example(this); } /** - * Adds an mentions to mentions. + * Adds a new element to mentions. * - * @param mentions the new mentions + * @param mentions the new element to be added * @return the Example builder */ public Builder addMentions(Mention mentions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(mentions, - "mentions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(mentions, "mentions cannot be null"); if (this.mentions == null) { this.mentions = new ArrayList(); } @@ -96,8 +89,7 @@ public Builder text(String text) { } /** - * Set the mentions. - * Existing mentions will be replaced. + * Set the mentions. Existing mentions will be replaced. * * @param mentions the mentions * @return the Example builder @@ -106,37 +98,14 @@ public Builder mentions(List mentions) { this.mentions = mentions; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Example builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Example builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected Example() {} + protected Example(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); text = builder.text; mentions = builder.mentions; - created = builder.created; - updated = builder.updated; } /** @@ -151,9 +120,9 @@ public Builder newBuilder() { /** * Gets the text. * - * The text of a user input example. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of a user input example. This string must conform to the following restrictions: - + * It cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the text */ @@ -164,7 +133,7 @@ public String text() { /** * Gets the mentions. * - * An array of contextual entity mentions. + *

An array of contextual entity mentions. * * @return the mentions */ @@ -175,7 +144,7 @@ public List mentions() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -186,7 +155,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java index 1fbed0937ed..1b8e27a8fca 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * ExampleCollection. - */ +/** ExampleCollection. */ public class ExampleCollection extends GenericModel { protected List examples; protected Pagination pagination; + protected ExampleCollection() {} + /** * Gets the examples. * - * An array of objects describing the examples defined for the intent. + *

An array of objects describing the examples defined for the intent. * * @return the examples */ @@ -38,7 +38,8 @@ public List getExamples() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExportWorkspaceAsyncOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExportWorkspaceAsyncOptions.java new file mode 100644 index 00000000000..b9176939565 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExportWorkspaceAsyncOptions.java @@ -0,0 +1,186 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The exportWorkspaceAsync options. */ +public class ExportWorkspaceAsyncOptions extends GenericModel { + + /** + * Indicates how the returned workspace data will be sorted. Specify `sort=stable` to sort all + * workspace objects by unique identifier, in ascending alphabetical order. + */ + public interface Sort { + /** stable. */ + String STABLE = "stable"; + } + + protected String workspaceId; + protected Boolean includeAudit; + protected String sort; + protected Boolean verbose; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private Boolean includeAudit; + private String sort; + private Boolean verbose; + + /** + * Instantiates a new Builder from an existing ExportWorkspaceAsyncOptions instance. + * + * @param exportWorkspaceAsyncOptions the instance to initialize the Builder with + */ + private Builder(ExportWorkspaceAsyncOptions exportWorkspaceAsyncOptions) { + this.workspaceId = exportWorkspaceAsyncOptions.workspaceId; + this.includeAudit = exportWorkspaceAsyncOptions.includeAudit; + this.sort = exportWorkspaceAsyncOptions.sort; + this.verbose = exportWorkspaceAsyncOptions.verbose; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a ExportWorkspaceAsyncOptions. + * + * @return the new ExportWorkspaceAsyncOptions instance + */ + public ExportWorkspaceAsyncOptions build() { + return new ExportWorkspaceAsyncOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ExportWorkspaceAsyncOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ExportWorkspaceAsyncOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ExportWorkspaceAsyncOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the verbose. + * + * @param verbose the verbose + * @return the ExportWorkspaceAsyncOptions builder + */ + public Builder verbose(Boolean verbose) { + this.verbose = verbose; + return this; + } + } + + protected ExportWorkspaceAsyncOptions() {} + + protected ExportWorkspaceAsyncOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + includeAudit = builder.includeAudit; + sort = builder.sort; + verbose = builder.verbose; + } + + /** + * New builder. + * + * @return a ExportWorkspaceAsyncOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } + + /** + * Gets the sort. + * + *

Indicates how the returned workspace data will be sorted. Specify `sort=stable` to sort all + * workspace objects by unique identifier, in ascending alphabetical order. + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the verbose. + * + *

Whether the response should include the `counts` property, which indicates how many of each + * component (such as intents and entities) the workspace contains. + * + * @return the verbose + */ + public Boolean verbose() { + return verbose; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java index 617a7da9eb7..d97e00dff21 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,38 +10,37 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getCounterexample options. - */ +/** The getCounterexample options. */ public class GetCounterexampleOptions extends GenericModel { protected String workspaceId; protected String text; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String text; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetCounterexampleOptions instance. + * + * @param getCounterexampleOptions the instance to initialize the Builder with + */ private Builder(GetCounterexampleOptions getCounterexampleOptions) { this.workspaceId = getCounterexampleOptions.workspaceId; this.text = getCounterexampleOptions.text; this.includeAudit = getCounterexampleOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,7 +56,7 @@ public Builder(String workspaceId, String text) { /** * Builds a GetCounterexampleOptions. * - * @return the getCounterexampleOptions + * @return the new GetCounterexampleOptions instance */ public GetCounterexampleOptions build() { return new GetCounterexampleOptions(this); @@ -97,11 +96,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetCounterexampleOptions() {} + protected GetCounterexampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, - "text cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, "text cannot be empty"); workspaceId = builder.workspaceId; text = builder.text; includeAudit = builder.includeAudit; @@ -119,7 +119,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -130,7 +130,7 @@ public String workspaceId() { /** * Gets the text. * - * The text of a user input counterexample (for example, `What are you wearing?`). + *

The text of a user input counterexample (for example, `What are you wearing?`). * * @return the text */ @@ -141,7 +141,8 @@ public String text() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java index 40acceba96b..3787e207644 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,38 +10,37 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getDialogNode options. - */ +/** The getDialogNode options. */ public class GetDialogNodeOptions extends GenericModel { protected String workspaceId; protected String dialogNode; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String dialogNode; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetDialogNodeOptions instance. + * + * @param getDialogNodeOptions the instance to initialize the Builder with + */ private Builder(GetDialogNodeOptions getDialogNodeOptions) { this.workspaceId = getDialogNodeOptions.workspaceId; this.dialogNode = getDialogNodeOptions.dialogNode; this.includeAudit = getDialogNodeOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,7 +56,7 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a GetDialogNodeOptions. * - * @return the getDialogNodeOptions + * @return the new GetDialogNodeOptions instance */ public GetDialogNodeOptions build() { return new GetDialogNodeOptions(this); @@ -97,11 +96,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetDialogNodeOptions() {} + protected GetDialogNodeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.dialogNode, - "dialogNode cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.dialogNode, "dialogNode cannot be empty"); workspaceId = builder.workspaceId; dialogNode = builder.dialogNode; includeAudit = builder.includeAudit; @@ -119,7 +120,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -130,7 +131,7 @@ public String workspaceId() { /** * Gets the dialogNode. * - * The dialog node ID (for example, `get_order`). + *

The dialog node ID (for example, `node_1_1479323581900`). * * @return the dialogNode */ @@ -141,7 +142,8 @@ public String dialogNode() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java index 42387ef57c7..a1176c282a5 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getEntity options. - */ +/** The getEntity options. */ public class GetEntityOptions extends GenericModel { protected String workspaceId; @@ -24,15 +23,18 @@ public class GetEntityOptions extends GenericModel { protected Boolean export; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; private Boolean export; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetEntityOptions instance. + * + * @param getEntityOptions the instance to initialize the Builder with + */ private Builder(GetEntityOptions getEntityOptions) { this.workspaceId = getEntityOptions.workspaceId; this.entity = getEntityOptions.entity; @@ -40,11 +42,8 @@ private Builder(GetEntityOptions getEntityOptions) { this.includeAudit = getEntityOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -60,7 +59,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a GetEntityOptions. * - * @return the getEntityOptions + * @return the new GetEntityOptions instance */ public GetEntityOptions build() { return new GetEntityOptions(this); @@ -111,11 +110,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetEntityOptions() {} + protected GetEntityOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; export = builder.export; @@ -134,7 +134,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -145,7 +145,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -156,8 +156,9 @@ public String entity() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -168,7 +169,8 @@ public Boolean export() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java index a0d409a6215..416bb3a5801 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getExample options. - */ +/** The getExample options. */ public class GetExampleOptions extends GenericModel { protected String workspaceId; @@ -24,15 +23,18 @@ public class GetExampleOptions extends GenericModel { protected String text; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; private String text; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetExampleOptions instance. + * + * @param getExampleOptions the instance to initialize the Builder with + */ private Builder(GetExampleOptions getExampleOptions) { this.workspaceId = getExampleOptions.workspaceId; this.intent = getExampleOptions.intent; @@ -40,11 +42,8 @@ private Builder(GetExampleOptions getExampleOptions) { this.includeAudit = getExampleOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -62,7 +61,7 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a GetExampleOptions. * - * @return the getExampleOptions + * @return the new GetExampleOptions instance */ public GetExampleOptions build() { return new GetExampleOptions(this); @@ -113,13 +112,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetExampleOptions() {} + protected GetExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, - "text cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, "text cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; text = builder.text; @@ -138,7 +137,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -149,7 +148,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -160,7 +159,7 @@ public String intent() { /** * Gets the text. * - * The text of the user input example. + *

The text of the user input example. * * @return the text */ @@ -171,7 +170,8 @@ public String text() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java index 60fdb8505f7..358b9fbcc13 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getIntent options. - */ +/** The getIntent options. */ public class GetIntentOptions extends GenericModel { protected String workspaceId; @@ -24,15 +23,18 @@ public class GetIntentOptions extends GenericModel { protected Boolean export; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; private Boolean export; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetIntentOptions instance. + * + * @param getIntentOptions the instance to initialize the Builder with + */ private Builder(GetIntentOptions getIntentOptions) { this.workspaceId = getIntentOptions.workspaceId; this.intent = getIntentOptions.intent; @@ -40,11 +42,8 @@ private Builder(GetIntentOptions getIntentOptions) { this.includeAudit = getIntentOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -60,7 +59,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a GetIntentOptions. * - * @return the getIntentOptions + * @return the new GetIntentOptions instance */ public GetIntentOptions build() { return new GetIntentOptions(this); @@ -111,11 +110,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetIntentOptions() {} + protected GetIntentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; export = builder.export; @@ -134,7 +134,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -145,7 +145,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -156,8 +156,9 @@ public String intent() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -168,7 +169,8 @@ public Boolean export() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java index 25df5f39758..4bb883c447b 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getSynonym options. - */ +/** The getSynonym options. */ public class GetSynonymOptions extends GenericModel { protected String workspaceId; @@ -25,9 +24,7 @@ public class GetSynonymOptions extends GenericModel { protected String synonym; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -35,6 +32,11 @@ public static class Builder { private String synonym; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetSynonymOptions instance. + * + * @param getSynonymOptions the instance to initialize the Builder with + */ private Builder(GetSynonymOptions getSynonymOptions) { this.workspaceId = getSynonymOptions.workspaceId; this.entity = getSynonymOptions.entity; @@ -43,11 +45,8 @@ private Builder(GetSynonymOptions getSynonymOptions) { this.includeAudit = getSynonymOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -67,7 +66,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a GetSynonymOptions. * - * @return the getSynonymOptions + * @return the new GetSynonymOptions instance */ public GetSynonymOptions build() { return new GetSynonymOptions(this); @@ -129,15 +128,14 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetSynonymOptions() {} + protected GetSynonymOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.synonym, - "synonym cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.synonym, "synonym cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -157,7 +155,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -168,7 +166,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -179,7 +177,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -190,7 +188,7 @@ public String value() { /** * Gets the synonym. * - * The text of the synonym. + *

The text of the synonym. * * @return the synonym */ @@ -201,7 +199,8 @@ public String synonym() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java index 791ae08f3c5..004815013fb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getValue options. - */ +/** The getValue options. */ public class GetValueOptions extends GenericModel { protected String workspaceId; @@ -25,9 +24,7 @@ public class GetValueOptions extends GenericModel { protected Boolean export; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -35,6 +32,11 @@ public static class Builder { private Boolean export; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing GetValueOptions instance. + * + * @param getValueOptions the instance to initialize the Builder with + */ private Builder(GetValueOptions getValueOptions) { this.workspaceId = getValueOptions.workspaceId; this.entity = getValueOptions.entity; @@ -43,11 +45,8 @@ private Builder(GetValueOptions getValueOptions) { this.includeAudit = getValueOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -65,7 +64,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a GetValueOptions. * - * @return the getValueOptions + * @return the new GetValueOptions instance */ public GetValueOptions build() { return new GetValueOptions(this); @@ -127,13 +126,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected GetValueOptions() {} + protected GetValueOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -153,7 +152,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -164,7 +163,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -175,7 +174,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -186,8 +185,9 @@ public String value() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -198,7 +198,8 @@ public Boolean export() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java index bc4709b2d9b..636698cf092 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,18 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getWorkspace options. - */ +/** The getWorkspace options. */ public class GetWorkspaceOptions extends GenericModel { /** - * Indicates how the returned workspace data will be sorted. This parameter is valid only if **export**=`true`. - * Specify `sort=stable` to sort all workspace objects by unique identifier, in ascending alphabetical order. + * Indicates how the returned workspace data will be sorted. This parameter is valid only if + * **export**=`true`. Specify `sort=stable` to sort all workspace objects by unique identifier, in + * ascending alphabetical order. */ public interface Sort { /** stable. */ @@ -33,15 +33,18 @@ public interface Sort { protected Boolean includeAudit; protected String sort; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private Boolean export; private Boolean includeAudit; private String sort; + /** + * Instantiates a new Builder from an existing GetWorkspaceOptions instance. + * + * @param getWorkspaceOptions the instance to initialize the Builder with + */ private Builder(GetWorkspaceOptions getWorkspaceOptions) { this.workspaceId = getWorkspaceOptions.workspaceId; this.export = getWorkspaceOptions.export; @@ -49,11 +52,8 @@ private Builder(GetWorkspaceOptions getWorkspaceOptions) { this.sort = getWorkspaceOptions.sort; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -67,7 +67,7 @@ public Builder(String workspaceId) { /** * Builds a GetWorkspaceOptions. * - * @return the getWorkspaceOptions + * @return the new GetWorkspaceOptions instance */ public GetWorkspaceOptions build() { return new GetWorkspaceOptions(this); @@ -118,9 +118,11 @@ public Builder sort(String sort) { } } + protected GetWorkspaceOptions() {} + protected GetWorkspaceOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; export = builder.export; includeAudit = builder.includeAudit; @@ -139,7 +141,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -150,8 +152,9 @@ public String workspaceId() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -162,7 +165,8 @@ public Boolean export() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ @@ -173,8 +177,9 @@ public Boolean includeAudit() { /** * Gets the sort. * - * Indicates how the returned workspace data will be sorted. This parameter is valid only if **export**=`true`. - * Specify `sort=stable` to sort all workspace objects by unique identifier, in ascending alphabetical order. + *

Indicates how the returned workspace data will be sorted. This parameter is valid only if + * **export**=`true`. Specify `sort=stable` to sort all workspace objects by unique identifier, in + * ascending alphabetical order. * * @return the sort */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java index 465dea8b8b4..c9d78bf9a3d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.Date; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Intent. - */ +/** Intent. */ public class Intent extends GenericModel { protected String intent; @@ -28,12 +26,14 @@ public class Intent extends GenericModel { protected Date updated; protected List examples; + protected Intent() {} + /** * Gets the intent. * - * The name of the intent. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - * - It cannot begin with the reserved prefix `sys-`. + *

The name of the intent. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - It cannot begin + * with the reserved prefix `sys-`. * * @return the intent */ @@ -44,7 +44,8 @@ public String getIntent() { /** * Gets the description. * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters. + *

The description of the intent. This string cannot contain carriage return, newline, or tab + * characters. * * @return the description */ @@ -55,7 +56,7 @@ public String getDescription() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -66,7 +67,7 @@ public Date getCreated() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ @@ -77,7 +78,7 @@ public Date getUpdated() { /** * Gets the examples. * - * An array of user input examples for the intent. + *

An array of user input examples for the intent. * * @return the examples */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java index f7cc8700703..aff2659db5b 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * IntentCollection. - */ +/** IntentCollection. */ public class IntentCollection extends GenericModel { protected List intents; protected Pagination pagination; + protected IntentCollection() {} + /** * Gets the intents. * - * An array of objects describing the intents defined for the workspace. + *

An array of objects describing the intents defined for the workspace. * * @return the intents */ @@ -38,7 +38,8 @@ public List getIntents() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java index 606f25e108e..f230f37b470 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listAllLogs options. - */ +/** The listAllLogs options. */ public class ListAllLogsOptions extends GenericModel { protected String filter; @@ -24,15 +23,18 @@ public class ListAllLogsOptions extends GenericModel { protected Long pageLimit; protected String cursor; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String filter; private String sort; private Long pageLimit; private String cursor; + /** + * Instantiates a new Builder from an existing ListAllLogsOptions instance. + * + * @param listAllLogsOptions the instance to initialize the Builder with + */ private Builder(ListAllLogsOptions listAllLogsOptions) { this.filter = listAllLogsOptions.filter; this.sort = listAllLogsOptions.sort; @@ -40,11 +42,8 @@ private Builder(ListAllLogsOptions listAllLogsOptions) { this.cursor = listAllLogsOptions.cursor; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -58,7 +57,7 @@ public Builder(String filter) { /** * Builds a ListAllLogsOptions. * - * @return the listAllLogsOptions + * @return the new ListAllLogsOptions instance */ public ListAllLogsOptions build() { return new ListAllLogsOptions(this); @@ -109,9 +108,10 @@ public Builder cursor(String cursor) { } } + protected ListAllLogsOptions() {} + protected ListAllLogsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.filter, - "filter cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.filter, "filter cannot be null"); filter = builder.filter; sort = builder.sort; pageLimit = builder.pageLimit; @@ -130,9 +130,11 @@ public Builder newBuilder() { /** * Gets the filter. * - * A cacheable parameter that limits the results to those matching the specified filter. You must specify a filter - * query that includes a value for `language`, as well as a value for `request.context.system.assistant_id`, - * `workspace_id`, or `request.context.metadata.deployment`. For more information, see the + *

A cacheable parameter that limits the results to those matching the specified filter. You + * must specify a filter query that includes a value for `language`, as well as a value for + * `request.context.system.assistant_id`, `workspace_id`, or + * `request.context.metadata.deployment`. These required filters must be specified using the exact + * match (`::`) operator. For more information, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-reference#filter-reference). * * @return the filter @@ -144,8 +146,8 @@ public String filter() { /** * Gets the sort. * - * How to sort the returned log events. You can sort by **request_timestamp**. To reverse the sort order, prefix the - * parameter value with a minus sign (`-`). + *

How to sort the returned log events. You can sort by **request_timestamp**. To reverse the + * sort order, prefix the parameter value with a minus sign (`-`). * * @return the sort */ @@ -156,7 +158,7 @@ public String sort() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -167,7 +169,7 @@ public Long pageLimit() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java index a5afea01e72..923a6cf0e28 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listCounterexamples options. - */ +/** The listCounterexamples options. */ public class ListCounterexamplesOptions extends GenericModel { /** - * The attribute by which returned counterexamples will be sorted. To reverse the sort order, prefix the value with a - * minus sign (`-`). + * The attribute by which returned counterexamples will be sorted. To reverse the sort order, + * prefix the value with a minus sign (`-`). */ public interface Sort { /** text. */ @@ -32,33 +31,36 @@ public interface Sort { protected String workspaceId; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListCounterexamplesOptions instance. + * + * @param listCounterexamplesOptions the instance to initialize the Builder with + */ private Builder(ListCounterexamplesOptions listCounterexamplesOptions) { this.workspaceId = listCounterexamplesOptions.workspaceId; this.pageLimit = listCounterexamplesOptions.pageLimit; + this.includeCount = listCounterexamplesOptions.includeCount; this.sort = listCounterexamplesOptions.sort; this.cursor = listCounterexamplesOptions.cursor; this.includeAudit = listCounterexamplesOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -72,7 +74,7 @@ public Builder(String workspaceId) { /** * Builds a ListCounterexamplesOptions. * - * @return the listCounterexamplesOptions + * @return the new ListCounterexamplesOptions instance */ public ListCounterexamplesOptions build() { return new ListCounterexamplesOptions(this); @@ -100,6 +102,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListCounterexamplesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -134,11 +147,14 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListCounterexamplesOptions() {} + protected ListCounterexamplesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -156,7 +172,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -167,7 +183,7 @@ public String workspaceId() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -175,11 +191,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned counterexamples will be sorted. To reverse the sort order, prefix the value with a - * minus sign (`-`). + *

The attribute by which returned counterexamples will be sorted. To reverse the sort order, + * prefix the value with a minus sign (`-`). * * @return the sort */ @@ -190,7 +219,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -201,7 +230,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java index 72f9a53aed5..e0e379f240d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listDialogNodes options. - */ +/** The listDialogNodes options. */ public class ListDialogNodesOptions extends GenericModel { /** - * The attribute by which returned dialog nodes will be sorted. To reverse the sort order, prefix the value with a - * minus sign (`-`). + * The attribute by which returned dialog nodes will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). */ public interface Sort { /** dialog_node. */ @@ -32,33 +31,36 @@ public interface Sort { protected String workspaceId; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListDialogNodesOptions instance. + * + * @param listDialogNodesOptions the instance to initialize the Builder with + */ private Builder(ListDialogNodesOptions listDialogNodesOptions) { this.workspaceId = listDialogNodesOptions.workspaceId; this.pageLimit = listDialogNodesOptions.pageLimit; + this.includeCount = listDialogNodesOptions.includeCount; this.sort = listDialogNodesOptions.sort; this.cursor = listDialogNodesOptions.cursor; this.includeAudit = listDialogNodesOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -72,7 +74,7 @@ public Builder(String workspaceId) { /** * Builds a ListDialogNodesOptions. * - * @return the listDialogNodesOptions + * @return the new ListDialogNodesOptions instance */ public ListDialogNodesOptions build() { return new ListDialogNodesOptions(this); @@ -100,6 +102,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListDialogNodesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -134,11 +147,14 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListDialogNodesOptions() {} + protected ListDialogNodesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -156,7 +172,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -167,7 +183,7 @@ public String workspaceId() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -175,11 +191,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned dialog nodes will be sorted. To reverse the sort order, prefix the value with a - * minus sign (`-`). + *

The attribute by which returned dialog nodes will be sorted. To reverse the sort order, + * prefix the value with a minus sign (`-`). * * @return the sort */ @@ -190,7 +219,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -201,7 +230,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java index dc95f29adfe..5bde74c0b60 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listEntities options. - */ +/** The listEntities options. */ public class ListEntitiesOptions extends GenericModel { /** - * The attribute by which returned entities will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + * The attribute by which returned entities will be sorted. To reverse the sort order, prefix the + * value with a minus sign (`-`). */ public interface Sort { /** entity. */ @@ -33,35 +32,38 @@ public interface Sort { protected String workspaceId; protected Boolean export; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private Boolean export; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListEntitiesOptions instance. + * + * @param listEntitiesOptions the instance to initialize the Builder with + */ private Builder(ListEntitiesOptions listEntitiesOptions) { this.workspaceId = listEntitiesOptions.workspaceId; this.export = listEntitiesOptions.export; this.pageLimit = listEntitiesOptions.pageLimit; + this.includeCount = listEntitiesOptions.includeCount; this.sort = listEntitiesOptions.sort; this.cursor = listEntitiesOptions.cursor; this.includeAudit = listEntitiesOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -75,7 +77,7 @@ public Builder(String workspaceId) { /** * Builds a ListEntitiesOptions. * - * @return the listEntitiesOptions + * @return the new ListEntitiesOptions instance */ public ListEntitiesOptions build() { return new ListEntitiesOptions(this); @@ -114,6 +116,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListEntitiesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -148,12 +161,15 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListEntitiesOptions() {} + protected ListEntitiesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; export = builder.export; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -171,7 +187,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -182,8 +198,9 @@ public String workspaceId() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -194,7 +211,7 @@ public Boolean export() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -202,11 +219,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned entities will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + *

The attribute by which returned entities will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). * * @return the sort */ @@ -217,7 +247,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -228,7 +258,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java index f3473f10d68..cb9c4d04abe 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listExamples options. - */ +/** The listExamples options. */ public class ListExamplesOptions extends GenericModel { /** - * The attribute by which returned examples will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + * The attribute by which returned examples will be sorted. To reverse the sort order, prefix the + * value with a minus sign (`-`). */ public interface Sort { /** text. */ @@ -33,35 +32,38 @@ public interface Sort { protected String workspaceId; protected String intent; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListExamplesOptions instance. + * + * @param listExamplesOptions the instance to initialize the Builder with + */ private Builder(ListExamplesOptions listExamplesOptions) { this.workspaceId = listExamplesOptions.workspaceId; this.intent = listExamplesOptions.intent; this.pageLimit = listExamplesOptions.pageLimit; + this.includeCount = listExamplesOptions.includeCount; this.sort = listExamplesOptions.sort; this.cursor = listExamplesOptions.cursor; this.includeAudit = listExamplesOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -77,7 +79,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a ListExamplesOptions. * - * @return the listExamplesOptions + * @return the new ListExamplesOptions instance */ public ListExamplesOptions build() { return new ListExamplesOptions(this); @@ -116,6 +118,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListExamplesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -150,14 +163,16 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListExamplesOptions() {} + protected ListExamplesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -175,7 +190,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -186,7 +201,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -197,7 +212,7 @@ public String intent() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -205,11 +220,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned examples will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + *

The attribute by which returned examples will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). * * @return the sort */ @@ -220,7 +248,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -231,7 +259,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java index 25c942ec8ea..a022fe595f4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listIntents options. - */ +/** The listIntents options. */ public class ListIntentsOptions extends GenericModel { /** - * The attribute by which returned intents will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + * The attribute by which returned intents will be sorted. To reverse the sort order, prefix the + * value with a minus sign (`-`). */ public interface Sort { /** intent. */ @@ -33,35 +32,38 @@ public interface Sort { protected String workspaceId; protected Boolean export; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private Boolean export; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListIntentsOptions instance. + * + * @param listIntentsOptions the instance to initialize the Builder with + */ private Builder(ListIntentsOptions listIntentsOptions) { this.workspaceId = listIntentsOptions.workspaceId; this.export = listIntentsOptions.export; this.pageLimit = listIntentsOptions.pageLimit; + this.includeCount = listIntentsOptions.includeCount; this.sort = listIntentsOptions.sort; this.cursor = listIntentsOptions.cursor; this.includeAudit = listIntentsOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -75,7 +77,7 @@ public Builder(String workspaceId) { /** * Builds a ListIntentsOptions. * - * @return the listIntentsOptions + * @return the new ListIntentsOptions instance */ public ListIntentsOptions build() { return new ListIntentsOptions(this); @@ -114,6 +116,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListIntentsOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -148,12 +161,15 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListIntentsOptions() {} + protected ListIntentsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; export = builder.export; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -171,7 +187,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -182,8 +198,9 @@ public String workspaceId() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -194,7 +211,7 @@ public Boolean export() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -202,11 +219,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned intents will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + *

The attribute by which returned intents will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). * * @return the sort */ @@ -217,7 +247,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -228,7 +258,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java index b074491a8c6..92e26d0d00f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listLogs options. - */ +/** The listLogs options. */ public class ListLogsOptions extends GenericModel { protected String workspaceId; @@ -25,9 +24,7 @@ public class ListLogsOptions extends GenericModel { protected Long pageLimit; protected String cursor; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String sort; @@ -35,6 +32,11 @@ public static class Builder { private Long pageLimit; private String cursor; + /** + * Instantiates a new Builder from an existing ListLogsOptions instance. + * + * @param listLogsOptions the instance to initialize the Builder with + */ private Builder(ListLogsOptions listLogsOptions) { this.workspaceId = listLogsOptions.workspaceId; this.sort = listLogsOptions.sort; @@ -43,11 +45,8 @@ private Builder(ListLogsOptions listLogsOptions) { this.cursor = listLogsOptions.cursor; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -61,7 +60,7 @@ public Builder(String workspaceId) { /** * Builds a ListLogsOptions. * - * @return the listLogsOptions + * @return the new ListLogsOptions instance */ public ListLogsOptions build() { return new ListLogsOptions(this); @@ -123,9 +122,11 @@ public Builder cursor(String cursor) { } } + protected ListLogsOptions() {} + protected ListLogsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; sort = builder.sort; filter = builder.filter; @@ -145,7 +146,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -156,8 +157,8 @@ public String workspaceId() { /** * Gets the sort. * - * How to sort the returned log events. You can sort by **request_timestamp**. To reverse the sort order, prefix the - * parameter value with a minus sign (`-`). + *

How to sort the returned log events. You can sort by **request_timestamp**. To reverse the + * sort order, prefix the parameter value with a minus sign (`-`). * * @return the sort */ @@ -168,7 +169,8 @@ public String sort() { /** * Gets the filter. * - * A cacheable parameter that limits the results to those matching the specified filter. For more information, see the + *

A cacheable parameter that limits the results to those matching the specified filter. For + * more information, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-reference#filter-reference). * * @return the filter @@ -180,7 +182,9 @@ public String filter() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. + * + *

**Note:** If the API is not returning your data, try lowering the page_limit value. * * @return the pageLimit */ @@ -191,7 +195,7 @@ public Long pageLimit() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java index adbb8d57aa7..b2a5de946ec 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listMentions options. - */ +/** The listMentions options. */ public class ListMentionsOptions extends GenericModel { protected String workspaceId; @@ -24,15 +23,18 @@ public class ListMentionsOptions extends GenericModel { protected Boolean export; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; private Boolean export; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListMentionsOptions instance. + * + * @param listMentionsOptions the instance to initialize the Builder with + */ private Builder(ListMentionsOptions listMentionsOptions) { this.workspaceId = listMentionsOptions.workspaceId; this.entity = listMentionsOptions.entity; @@ -40,11 +42,8 @@ private Builder(ListMentionsOptions listMentionsOptions) { this.includeAudit = listMentionsOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -60,7 +59,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a ListMentionsOptions. * - * @return the listMentionsOptions + * @return the new ListMentionsOptions instance */ public ListMentionsOptions build() { return new ListMentionsOptions(this); @@ -111,11 +110,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListMentionsOptions() {} + protected ListMentionsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; export = builder.export; @@ -134,7 +134,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -145,7 +145,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -156,8 +156,9 @@ public String entity() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -168,7 +169,8 @@ public Boolean export() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java index cb3f5c20ece..3c794bbbe0a 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listSynonyms options. - */ +/** The listSynonyms options. */ public class ListSynonymsOptions extends GenericModel { /** - * The attribute by which returned entity value synonyms will be sorted. To reverse the sort order, prefix the value - * with a minus sign (`-`). + * The attribute by which returned entity value synonyms will be sorted. To reverse the sort + * order, prefix the value with a minus sign (`-`). */ public interface Sort { /** synonym. */ @@ -34,37 +33,40 @@ public interface Sort { protected String entity; protected String value; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; private String value; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListSynonymsOptions instance. + * + * @param listSynonymsOptions the instance to initialize the Builder with + */ private Builder(ListSynonymsOptions listSynonymsOptions) { this.workspaceId = listSynonymsOptions.workspaceId; this.entity = listSynonymsOptions.entity; this.value = listSynonymsOptions.value; this.pageLimit = listSynonymsOptions.pageLimit; + this.includeCount = listSynonymsOptions.includeCount; this.sort = listSynonymsOptions.sort; this.cursor = listSynonymsOptions.cursor; this.includeAudit = listSynonymsOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -82,7 +84,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a ListSynonymsOptions. * - * @return the listSynonymsOptions + * @return the new ListSynonymsOptions instance */ public ListSynonymsOptions build() { return new ListSynonymsOptions(this); @@ -132,6 +134,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListSynonymsOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -166,17 +179,18 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListSynonymsOptions() {} + protected ListSynonymsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -194,7 +208,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -205,7 +219,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -216,7 +230,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -227,7 +241,7 @@ public String value() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -235,11 +249,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned entity value synonyms will be sorted. To reverse the sort order, prefix the value - * with a minus sign (`-`). + *

The attribute by which returned entity value synonyms will be sorted. To reverse the sort + * order, prefix the value with a minus sign (`-`). * * @return the sort */ @@ -250,7 +277,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -261,7 +288,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java index 7bd300da481..93d4ed90e18 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listValues options. - */ +/** The listValues options. */ public class ListValuesOptions extends GenericModel { /** - * The attribute by which returned entity values will be sorted. To reverse the sort order, prefix the value with a - * minus sign (`-`). + * The attribute by which returned entity values will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). */ public interface Sort { /** value. */ @@ -34,37 +33,40 @@ public interface Sort { protected String entity; protected Boolean export; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; private Boolean export; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListValuesOptions instance. + * + * @param listValuesOptions the instance to initialize the Builder with + */ private Builder(ListValuesOptions listValuesOptions) { this.workspaceId = listValuesOptions.workspaceId; this.entity = listValuesOptions.entity; this.export = listValuesOptions.export; this.pageLimit = listValuesOptions.pageLimit; + this.includeCount = listValuesOptions.includeCount; this.sort = listValuesOptions.sort; this.cursor = listValuesOptions.cursor; this.includeAudit = listValuesOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -80,7 +82,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a ListValuesOptions. * - * @return the listValuesOptions + * @return the new ListValuesOptions instance */ public ListValuesOptions build() { return new ListValuesOptions(this); @@ -130,6 +132,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListValuesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -164,15 +177,17 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListValuesOptions() {} + protected ListValuesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; export = builder.export; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -190,7 +205,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -201,7 +216,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -212,8 +227,9 @@ public String entity() { /** * Gets the export. * - * Whether to include all element content in the returned data. If **export**=`false`, the returned data includes only - * information about the element itself. If **export**=`true`, all content, including subelements, is included. + *

Whether to include all element content in the returned data. If **export**=`false`, the + * returned data includes only information about the element itself. If **export**=`true`, all + * content, including subelements, is included. * * @return the export */ @@ -224,7 +240,7 @@ public Boolean export() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -232,11 +248,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned entity values will be sorted. To reverse the sort order, prefix the value with a - * minus sign (`-`). + *

The attribute by which returned entity values will be sorted. To reverse the sort order, + * prefix the value with a minus sign (`-`). * * @return the sort */ @@ -247,7 +276,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -258,7 +287,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java index 8c3a7c48e0b..14521421214 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,17 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listWorkspaces options. - */ +/** The listWorkspaces options. */ public class ListWorkspacesOptions extends GenericModel { /** - * The attribute by which returned workspaces will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + * The attribute by which returned workspaces will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). */ public interface Sort { /** name. */ @@ -31,36 +30,39 @@ public interface Sort { } protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing ListWorkspacesOptions instance. + * + * @param listWorkspacesOptions the instance to initialize the Builder with + */ private Builder(ListWorkspacesOptions listWorkspacesOptions) { this.pageLimit = listWorkspacesOptions.pageLimit; + this.includeCount = listWorkspacesOptions.includeCount; this.sort = listWorkspacesOptions.sort; this.cursor = listWorkspacesOptions.cursor; this.includeAudit = listWorkspacesOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a ListWorkspacesOptions. * - * @return the listWorkspacesOptions + * @return the new ListWorkspacesOptions instance */ public ListWorkspacesOptions build() { return new ListWorkspacesOptions(this); @@ -77,6 +79,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListWorkspacesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -111,8 +124,11 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected ListWorkspacesOptions() {} + protected ListWorkspacesOptions(Builder builder) { pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -130,7 +146,7 @@ public Builder newBuilder() { /** * Gets the pageLimit. * - * The number of records to return in each page of results. + *

The number of records to return in each page of results. * * @return the pageLimit */ @@ -138,11 +154,24 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * - * The attribute by which returned workspaces will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). + *

The attribute by which returned workspaces will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). * * @return the sort */ @@ -153,7 +182,7 @@ public String sort() { /** * Gets the cursor. * - * A token identifying the page of results to retrieve. + *

A token identifying the page of results to retrieve. * * @return the cursor */ @@ -164,7 +193,8 @@ public String cursor() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java index 2edbee1b720..60faa6695c8 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,38 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Log. - */ +/** Log. */ public class Log extends GenericModel { protected MessageRequest request; protected MessageResponse response; + @SerializedName("log_id") protected String logId; + @SerializedName("request_timestamp") protected String requestTimestamp; + @SerializedName("response_timestamp") protected String responseTimestamp; + @SerializedName("workspace_id") protected String workspaceId; + protected String language; + protected Log() {} + /** * Gets the request. * - * A request sent to the workspace, including the user input and context. + *

A request sent to the workspace, including the user input and context. * * @return the request */ @@ -46,7 +52,8 @@ public MessageRequest getRequest() { /** * Gets the response. * - * The response sent by the workspace, including the output text, detected intents and entities, and context. + *

The response sent by the workspace, including the output text, detected intents and + * entities, and context. * * @return the response */ @@ -57,7 +64,7 @@ public MessageResponse getResponse() { /** * Gets the logId. * - * A unique identifier for the logged event. + *

A unique identifier for the logged event. * * @return the logId */ @@ -68,7 +75,7 @@ public String getLogId() { /** * Gets the requestTimestamp. * - * The timestamp for receipt of the message. + *

The timestamp for receipt of the message. * * @return the requestTimestamp */ @@ -79,7 +86,7 @@ public String getRequestTimestamp() { /** * Gets the responseTimestamp. * - * The timestamp for the system response to the message. + *

The timestamp for the system response to the message. * * @return the responseTimestamp */ @@ -90,7 +97,7 @@ public String getResponseTimestamp() { /** * Gets the workspaceId. * - * The unique identifier of the workspace where the request was made. + *

The unique identifier of the workspace where the request was made. * * @return the workspaceId */ @@ -101,7 +108,7 @@ public String getWorkspaceId() { /** * Gets the language. * - * The language of the workspace where the message request was made. + *

The language of the workspace where the message request was made. * * @return the language */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java index ce2530b2332..741d5a7db9d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * LogCollection. - */ +/** LogCollection. */ public class LogCollection extends GenericModel { protected List logs; protected LogPagination pagination; + protected LogCollection() {} + /** * Gets the logs. * - * An array of objects describing log events. + *

An array of objects describing log events. * * @return the logs */ @@ -38,7 +38,8 @@ public List getLogs() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java index cc606815d4e..6bfac0d0157 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,18 +10,15 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Log message details. - */ +/** Log message details. */ public class LogMessage extends GenericModel { - /** - * The severity of the log message. - */ + /** The severity of the log message. */ public interface Level { /** info. */ String INFO = "info"; @@ -33,40 +30,48 @@ public interface Level { protected String level; protected String msg; + protected String code; + protected LogMessageSource source; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String level; private String msg; + private String code; + private LogMessageSource source; + /** + * Instantiates a new Builder from an existing LogMessage instance. + * + * @param logMessage the instance to initialize the Builder with + */ private Builder(LogMessage logMessage) { this.level = logMessage.level; this.msg = logMessage.msg; + this.code = logMessage.code; + this.source = logMessage.source; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param level the level * @param msg the msg + * @param code the code */ - public Builder(String level, String msg) { + public Builder(String level, String msg, String code) { this.level = level; this.msg = msg; + this.code = code; } /** * Builds a LogMessage. * - * @return the logMessage + * @return the new LogMessage instance */ public LogMessage build() { return new LogMessage(this); @@ -93,15 +98,40 @@ public Builder msg(String msg) { this.msg = msg; return this; } + + /** + * Set the code. + * + * @param code the code + * @return the LogMessage builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the LogMessage builder + */ + public Builder source(LogMessageSource source) { + this.source = source; + return this; + } } + protected LogMessage() {} + protected LogMessage(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.level, - "level cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.msg, - "msg cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.level, "level cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.msg, "msg cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.code, "code cannot be null"); level = builder.level; msg = builder.msg; + code = builder.code; + source = builder.source; } /** @@ -116,7 +146,7 @@ public Builder newBuilder() { /** * Gets the level. * - * The severity of the log message. + *

The severity of the log message. * * @return the level */ @@ -127,11 +157,33 @@ public String level() { /** * Gets the msg. * - * The text of the log message. + *

The text of the log message. * * @return the msg */ public String msg() { return msg; } + + /** + * Gets the code. + * + *

A code that indicates the category to which the error message belongs. + * + * @return the code + */ + public String code() { + return code; + } + + /** + * Gets the source. + * + *

An object that identifies the dialog element that generated the error message. + * + * @return the source + */ + public LogMessageSource source() { + return source; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessageSource.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessageSource.java new file mode 100644 index 00000000000..a1445839df5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessageSource.java @@ -0,0 +1,120 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object that identifies the dialog element that generated the error message. */ +public class LogMessageSource extends GenericModel { + + /** A string that indicates the type of dialog element that generated the error message. */ + public interface Type { + /** dialog_node. */ + String DIALOG_NODE = "dialog_node"; + } + + protected String type; + + @SerializedName("dialog_node") + protected String dialogNode; + + /** Builder. */ + public static class Builder { + private String type; + private String dialogNode; + + /** + * Instantiates a new Builder from an existing LogMessageSource instance. + * + * @param logMessageSource the instance to initialize the Builder with + */ + private Builder(LogMessageSource logMessageSource) { + this.type = logMessageSource.type; + this.dialogNode = logMessageSource.dialogNode; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a LogMessageSource. + * + * @return the new LogMessageSource instance + */ + public LogMessageSource build() { + return new LogMessageSource(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the LogMessageSource builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the LogMessageSource builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + } + + protected LogMessageSource() {} + + protected LogMessageSource(Builder builder) { + type = builder.type; + dialogNode = builder.dialogNode; + } + + /** + * New builder. + * + * @return a LogMessageSource builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + *

A string that indicates the type of dialog element that generated the error message. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the dialogNode. + * + *

The unique identifier of the dialog node that generated the error message. + * + * @return the dialogNode + */ + public String dialogNode() { + return dialogNode; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java index 45f6e8ea59b..1abfdc2cf6f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,26 +10,32 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * The pagination data for the returned objects. + * The pagination data for the returned objects. For more information about using pagination, see + * [Pagination](#pagination). */ public class LogPagination extends GenericModel { @SerializedName("next_url") protected String nextUrl; + protected Long matched; + @SerializedName("next_cursor") protected String nextCursor; + protected LogPagination() {} + /** * Gets the nextUrl. * - * The URL that will return the next page of results, if any. + *

The URL that will return the next page of results, if any. * * @return the nextUrl */ @@ -40,7 +46,7 @@ public String getNextUrl() { /** * Gets the matched. * - * Reserved for future use. + *

Reserved for future use. * * @return the matched */ @@ -51,7 +57,7 @@ public Long getMatched() { /** * Gets the nextCursor. * - * A token identifying the next page of results. + *

A token identifying the next page of results. * * @return the nextCursor */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java index 454e8bbbb4b..f7dc287904a 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,36 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A mention of a contextual entity. - */ +/** A mention of a contextual entity. */ public class Mention extends GenericModel { protected String entity; protected List location; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String entity; private List location; + /** + * Instantiates a new Builder from an existing Mention instance. + * + * @param mention the instance to initialize the Builder with + */ private Builder(Mention mention) { this.entity = mention.entity; this.location = mention.location; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,21 +55,20 @@ public Builder(String entity, List location) { /** * Builds a Mention. * - * @return the mention + * @return the new Mention instance */ public Mention build() { return new Mention(this); } /** - * Adds an location to location. + * Adds a new element to location. * - * @param location the new location + * @param location the new element to be added * @return the Mention builder */ public Builder addLocation(Long location) { - com.ibm.cloud.sdk.core.util.Validator.notNull(location, - "location cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(location, "location cannot be null"); if (this.location == null) { this.location = new ArrayList(); } @@ -91,8 +88,7 @@ public Builder entity(String entity) { } /** - * Set the location. - * Existing location will be replaced. + * Set the location. Existing location will be replaced. * * @param location the location * @return the Mention builder @@ -103,11 +99,11 @@ public Builder location(List location) { } } + protected Mention() {} + protected Mention(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, - "entity cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.location, - "location cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.location, "location cannot be null"); entity = builder.entity; location = builder.location; } @@ -124,7 +120,7 @@ public Builder newBuilder() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -135,7 +131,8 @@ public String entity() { /** * Gets the location. * - * An array of zero-based character offsets that indicate where the entity mentions begin and end in the input text. + *

An array of zero-based character offsets that indicate where the entity mentions begin and + * end in the input text. * * @return the location */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java index 0eb967f7539..c661adf3aab 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,42 +10,42 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Metadata related to the message. - */ +/** Metadata related to the message. */ public class MessageContextMetadata extends GenericModel { protected String deployment; + @SerializedName("user_id") protected String userId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String deployment; private String userId; + /** + * Instantiates a new Builder from an existing MessageContextMetadata instance. + * + * @param messageContextMetadata the instance to initialize the Builder with + */ private Builder(MessageContextMetadata messageContextMetadata) { this.deployment = messageContextMetadata.deployment; this.userId = messageContextMetadata.userId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageContextMetadata. * - * @return the messageContextMetadata + * @return the new MessageContextMetadata instance */ public MessageContextMetadata build() { return new MessageContextMetadata(this); @@ -74,6 +74,8 @@ public Builder userId(String userId) { } } + protected MessageContextMetadata() {} + protected MessageContextMetadata(Builder builder) { deployment = builder.deployment; userId = builder.userId; @@ -91,8 +93,8 @@ public Builder newBuilder() { /** * Gets the deployment. * - * A label identifying the deployment environment, used for filtering log data. This string cannot contain carriage - * return, newline, or tab characters. + *

A label identifying the deployment environment, used for filtering log data. This string + * cannot contain carriage return, newline, or tab characters. * * @return the deployment */ @@ -103,10 +105,15 @@ public String deployment() { /** * Gets the userId. * - * A string value that identifies the user who is interacting with the workspace. The client must provide a unique - * identifier for each individual end user who accesses the application. For Plus and Premium plans, this user ID is - * used to identify unique users for billing purposes. This string cannot contain carriage return, newline, or tab - * characters. + *

A string value that identifies the user who is interacting with the workspace. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.conversation_id**. + * + *

**Note:** This property is the same as the **user_id** property at the root of the message + * body. If **user_id** is specified in both locations in a message request, the value specified + * at the root is used. * * @return the userId */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java index b091fb4bdb9..af19308b244 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,29 +10,145 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; /** * An input object that includes the input text. + * + *

This type supports additional properties of type Object. Any additional data included with the + * message input. */ public class MessageInput extends DynamicModel { @SerializedName("text") protected String text; + @SerializedName("spelling_suggestions") + protected Boolean spellingSuggestions; + + @SerializedName("spelling_auto_correct") + protected Boolean spellingAutoCorrect; + + @SerializedName("suggested_text") + protected String suggestedText; + + @SerializedName("original_text") + protected String originalText; + public MessageInput() { - super(new TypeToken() { - }); + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private String text; + private Boolean spellingSuggestions; + private Boolean spellingAutoCorrect; + private Map dynamicProperties; + + /** + * Instantiates a new Builder from an existing MessageInput instance. + * + * @param messageInput the instance to initialize the Builder with + */ + private Builder(MessageInput messageInput) { + this.text = messageInput.text; + this.spellingSuggestions = messageInput.spellingSuggestions; + this.spellingAutoCorrect = messageInput.spellingAutoCorrect; + this.dynamicProperties = messageInput.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageInput. + * + * @return the new MessageInput instance + */ + public MessageInput build() { + return new MessageInput(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the MessageInput builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the spellingSuggestions. + * + * @param spellingSuggestions the spellingSuggestions + * @return the MessageInput builder + */ + public Builder spellingSuggestions(Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + return this; + } + + /** + * Set the spellingAutoCorrect. + * + * @param spellingAutoCorrect the spellingAutoCorrect + * @return the MessageInput builder + */ + public Builder spellingAutoCorrect(Boolean spellingAutoCorrect) { + this.spellingAutoCorrect = spellingAutoCorrect; + return this; + } + + /** + * Add an arbitrary property. Any additional data included with the message input. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the MessageInput builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected MessageInput(Builder builder) { + super(new TypeToken() {}); + text = builder.text; + spellingSuggestions = builder.spellingSuggestions; + spellingAutoCorrect = builder.spellingAutoCorrect; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a MessageInput builder + */ + public Builder newBuilder() { + return new Builder(this); } /** * Gets the text. * - * The text of the user input. This string cannot contain carriage return, newline, or tab characters. + *

The text of the user input. This string cannot contain carriage return, newline, or tab + * characters. * * @return the text */ @@ -48,4 +164,74 @@ public String getText() { public void setText(final String text) { this.text = text; } + + /** + * Gets the spellingSuggestions. + * + *

Whether to use spelling correction when processing the input. This property overrides the + * value of the **spelling_suggestions** property in the workspace settings. + * + * @return the spellingSuggestions + */ + public Boolean isSpellingSuggestions() { + return this.spellingSuggestions; + } + + /** + * Sets the spellingSuggestions. + * + * @param spellingSuggestions the new spellingSuggestions + */ + public void setSpellingSuggestions(final Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + } + + /** + * Gets the spellingAutoCorrect. + * + *

Whether to use autocorrection when processing the input. If spelling correction is used and + * this property is `false`, any suggested corrections are returned in the **suggested_text** + * property of the message response. If this property is `true`, any corrections are automatically + * applied to the user input, and the original text is returned in the **original_text** property + * of the message response. This property overrides the value of the **spelling_auto_correct** + * property in the workspace settings. + * + * @return the spellingAutoCorrect + */ + public Boolean isSpellingAutoCorrect() { + return this.spellingAutoCorrect; + } + + /** + * Sets the spellingAutoCorrect. + * + * @param spellingAutoCorrect the new spellingAutoCorrect + */ + public void setSpellingAutoCorrect(final Boolean spellingAutoCorrect) { + this.spellingAutoCorrect = spellingAutoCorrect; + } + + /** + * Gets the suggestedText. + * + *

Any suggested corrections of the input text. This property is returned only if spelling + * correction is enabled and autocorrection is disabled. + * + * @return the suggestedText + */ + public String getSuggestedText() { + return this.suggestedText; + } + + /** + * Gets the originalText. + * + *

The original user input text. This property is returned only if autocorrection is enabled + * and the user input was corrected. + * + * @return the originalText + */ + public String getOriginalText() { + return this.originalText; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java index 8948473c6d1..7f7ea15a2cd 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The message options. - */ +/** The message options. */ public class MessageOptions extends GenericModel { protected String workspaceId; @@ -29,11 +27,10 @@ public class MessageOptions extends GenericModel { protected Boolean alternateIntents; protected Context context; protected OutputData output; + protected String userId; protected Boolean nodesVisitedDetails; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private MessageInput input; @@ -42,8 +39,14 @@ public static class Builder { private Boolean alternateIntents; private Context context; private OutputData output; + private String userId; private Boolean nodesVisitedDetails; + /** + * Instantiates a new Builder from an existing MessageOptions instance. + * + * @param messageOptions the instance to initialize the Builder with + */ private Builder(MessageOptions messageOptions) { this.workspaceId = messageOptions.workspaceId; this.input = messageOptions.input; @@ -52,14 +55,12 @@ private Builder(MessageOptions messageOptions) { this.alternateIntents = messageOptions.alternateIntents; this.context = messageOptions.context; this.output = messageOptions.output; + this.userId = messageOptions.userId; this.nodesVisitedDetails = messageOptions.nodesVisitedDetails; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -73,21 +74,20 @@ public Builder(String workspaceId) { /** * Builds a MessageOptions. * - * @return the messageOptions + * @return the new MessageOptions instance */ public MessageOptions build() { return new MessageOptions(this); } /** - * Adds an intent to intents. + * Adds a new element to intents. * - * @param intent the new intent + * @param intent the new element to be added * @return the MessageOptions builder */ public Builder addIntent(RuntimeIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, - "intent cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); if (this.intents == null) { this.intents = new ArrayList(); } @@ -96,14 +96,13 @@ public Builder addIntent(RuntimeIntent intent) { } /** - * Adds an entity to entities. + * Adds a new element to entities. * - * @param entity the new entity + * @param entity the new element to be added * @return the MessageOptions builder */ public Builder addEntity(RuntimeEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, - "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); if (this.entities == null) { this.entities = new ArrayList(); } @@ -134,8 +133,7 @@ public Builder input(MessageInput input) { } /** - * Set the intents. - * Existing intents will be replaced. + * Set the intents. Existing intents will be replaced. * * @param intents the intents * @return the MessageOptions builder @@ -146,8 +144,7 @@ public Builder intents(List intents) { } /** - * Set the entities. - * Existing entities will be replaced. + * Set the entities. Existing entities will be replaced. * * @param entities the entities * @return the MessageOptions builder @@ -190,6 +187,17 @@ public Builder output(OutputData output) { return this; } + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageOptions builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + /** * Set the nodesVisitedDetails. * @@ -214,13 +222,16 @@ public Builder messageRequest(MessageRequest messageRequest) { this.alternateIntents = messageRequest.alternateIntents(); this.context = messageRequest.context(); this.output = messageRequest.output(); + this.userId = messageRequest.userId(); return this; } } + protected MessageOptions() {} + protected MessageOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; input = builder.input; intents = builder.intents; @@ -228,6 +239,7 @@ protected MessageOptions(Builder builder) { alternateIntents = builder.alternateIntents; context = builder.context; output = builder.output; + userId = builder.userId; nodesVisitedDetails = builder.nodesVisitedDetails; } @@ -243,7 +255,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -254,7 +266,7 @@ public String workspaceId() { /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ @@ -265,8 +277,8 @@ public MessageInput input() { /** * Gets the intents. * - * Intents to use when evaluating the user input. Include intents from the previous response to continue using those - * intents rather than trying to recognize intents in the new input. + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. * * @return the intents */ @@ -277,8 +289,8 @@ public List intents() { /** * Gets the entities. * - * Entities to use when evaluating the message. Include entities from the previous response to continue using those - * entities rather than detecting entities in the new input. + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. * * @return the entities */ @@ -289,7 +301,8 @@ public List entities() { /** * Gets the alternateIntents. * - * Whether to return more than one intent. A value of `true` indicates that all matching intents are returned. + *

Whether to return more than one intent. A value of `true` indicates that all matching + * intents are returned. * * @return the alternateIntents */ @@ -300,7 +313,8 @@ public Boolean alternateIntents() { /** * Gets the context. * - * State information for the conversation. To maintain state, include the context from the previous response. + *

State information for the conversation. To maintain state, include the context from the + * previous response. * * @return the context */ @@ -311,8 +325,8 @@ public Context context() { /** * Gets the output. * - * An output object that includes the response to the user, the dialog nodes that were triggered, and messages from - * the log. + *

An output object that includes the response to the user, the dialog nodes that were + * triggered, and messages from the log. * * @return the output */ @@ -320,11 +334,30 @@ public OutputData output() { return output; } + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the workspace. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.conversation_id**. + * + *

**Note:** This property is the same as the **user_id** property in the context metadata. If + * **user_id** is specified in both locations in a message request, the value specified at the + * root is used. + * + * @return the userId + */ + public String userId() { + return userId; + } + /** * Gets the nodesVisitedDetails. * - * Whether to include additional diagnostic information about the dialog nodes that were visited during processing of - * the message. + *

Whether to include additional diagnostic information about the dialog nodes that were + * visited during processing of the message. * * @return the nodesVisitedDetails */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java index d73a8d5b943..13907a4831e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,31 +10,32 @@ * 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.assistant.v1.model; -import java.util.ArrayList; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; -/** - * A request sent to the workspace, including the user input and context. - */ +/** A request sent to the workspace, including the user input and context. */ public class MessageRequest extends GenericModel { protected MessageInput input; protected List intents; protected List entities; + @SerializedName("alternate_intents") protected Boolean alternateIntents; + protected Context context; protected OutputData output; protected List actions; - /** - * Builder. - */ + @SerializedName("user_id") + protected String userId; + + /** Builder. */ public static class Builder { private MessageInput input; private List intents; @@ -42,8 +43,13 @@ public static class Builder { private Boolean alternateIntents; private Context context; private OutputData output; - private List actions; + private String userId; + /** + * Instantiates a new Builder from an existing MessageRequest instance. + * + * @param messageRequest the instance to initialize the Builder with + */ private Builder(MessageRequest messageRequest) { this.input = messageRequest.input; this.intents = messageRequest.intents; @@ -51,33 +57,29 @@ private Builder(MessageRequest messageRequest) { this.alternateIntents = messageRequest.alternateIntents; this.context = messageRequest.context; this.output = messageRequest.output; - this.actions = messageRequest.actions; + this.userId = messageRequest.userId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageRequest. * - * @return the messageRequest + * @return the new MessageRequest instance */ public MessageRequest build() { return new MessageRequest(this); } /** - * Adds an intent to intents. + * Adds a new element to intents. * - * @param intent the new intent + * @param intent the new element to be added * @return the MessageRequest builder */ public Builder addIntent(RuntimeIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, - "intent cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); if (this.intents == null) { this.intents = new ArrayList(); } @@ -86,14 +88,13 @@ public Builder addIntent(RuntimeIntent intent) { } /** - * Adds an entity to entities. + * Adds a new element to entities. * - * @param entity the new entity + * @param entity the new element to be added * @return the MessageRequest builder */ public Builder addEntity(RuntimeEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, - "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); if (this.entities == null) { this.entities = new ArrayList(); } @@ -101,22 +102,6 @@ public Builder addEntity(RuntimeEntity entity) { return this; } - /** - * Adds an actions to actions. - * - * @param actions the new actions - * @return the MessageRequest builder - */ - public Builder addActions(DialogNodeAction actions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(actions, - "actions cannot be null"); - if (this.actions == null) { - this.actions = new ArrayList(); - } - this.actions.add(actions); - return this; - } - /** * Set the input. * @@ -129,8 +114,7 @@ public Builder input(MessageInput input) { } /** - * Set the intents. - * Existing intents will be replaced. + * Set the intents. Existing intents will be replaced. * * @param intents the intents * @return the MessageRequest builder @@ -141,8 +125,7 @@ public Builder intents(List intents) { } /** - * Set the entities. - * Existing entities will be replaced. + * Set the entities. Existing entities will be replaced. * * @param entities the entities * @return the MessageRequest builder @@ -186,18 +169,19 @@ public Builder output(OutputData output) { } /** - * Set the actions. - * Existing actions will be replaced. + * Set the userId. * - * @param actions the actions + * @param userId the userId * @return the MessageRequest builder */ - public Builder actions(List actions) { - this.actions = actions; + public Builder userId(String userId) { + this.userId = userId; return this; } } + protected MessageRequest() {} + protected MessageRequest(Builder builder) { input = builder.input; intents = builder.intents; @@ -205,7 +189,7 @@ protected MessageRequest(Builder builder) { alternateIntents = builder.alternateIntents; context = builder.context; output = builder.output; - actions = builder.actions; + userId = builder.userId; } /** @@ -220,7 +204,7 @@ public Builder newBuilder() { /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ @@ -231,8 +215,8 @@ public MessageInput input() { /** * Gets the intents. * - * Intents to use when evaluating the user input. Include intents from the previous response to continue using those - * intents rather than trying to recognize intents in the new input. + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. * * @return the intents */ @@ -243,8 +227,8 @@ public List intents() { /** * Gets the entities. * - * Entities to use when evaluating the message. Include entities from the previous response to continue using those - * entities rather than detecting entities in the new input. + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. * * @return the entities */ @@ -255,7 +239,8 @@ public List entities() { /** * Gets the alternateIntents. * - * Whether to return more than one intent. A value of `true` indicates that all matching intents are returned. + *

Whether to return more than one intent. A value of `true` indicates that all matching + * intents are returned. * * @return the alternateIntents */ @@ -266,7 +251,8 @@ public Boolean alternateIntents() { /** * Gets the context. * - * State information for the conversation. To maintain state, include the context from the previous response. + *

State information for the conversation. To maintain state, include the context from the + * previous response. * * @return the context */ @@ -277,8 +263,8 @@ public Context context() { /** * Gets the output. * - * An output object that includes the response to the user, the dialog nodes that were triggered, and messages from - * the log. + *

An output object that includes the response to the user, the dialog nodes that were + * triggered, and messages from the log. * * @return the output */ @@ -289,11 +275,30 @@ public OutputData output() { /** * Gets the actions. * - * An array of objects describing any actions requested by the dialog node. + *

An array of objects describing any actions requested by the dialog node. * * @return the actions */ public List actions() { return actions; } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the workspace. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.conversation_id**. + * + *

**Note:** This property is the same as the **user_id** property in the context metadata. If + * **user_id** is specified in both locations in a message request, the value specified at the + * root is used. + * + * @return the userId + */ + public String userId() { + return userId; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java index d05dfd84e69..bbee4e58033 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,31 +10,39 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; /** - * The response sent by the workspace, including the output text, detected intents and entities, and context. + * The response sent by the workspace, including the output text, detected intents and entities, and + * context. */ public class MessageResponse extends GenericModel { protected MessageInput input; protected List intents; protected List entities; + @SerializedName("alternate_intents") protected Boolean alternateIntents; + protected Context context; protected OutputData output; protected List actions; + @SerializedName("user_id") + protected String userId; + + protected MessageResponse() {} + /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ @@ -45,7 +53,7 @@ public MessageInput getInput() { /** * Gets the intents. * - * An array of intents recognized in the user input, sorted in descending order of confidence. + *

An array of intents recognized in the user input, sorted in descending order of confidence. * * @return the intents */ @@ -56,7 +64,7 @@ public List getIntents() { /** * Gets the entities. * - * An array of entities identified in the user input. + *

An array of entities identified in the user input. * * @return the entities */ @@ -67,7 +75,8 @@ public List getEntities() { /** * Gets the alternateIntents. * - * Whether to return more than one intent. A value of `true` indicates that all matching intents are returned. + *

Whether to return more than one intent. A value of `true` indicates that all matching + * intents are returned. * * @return the alternateIntents */ @@ -78,7 +87,8 @@ public Boolean isAlternateIntents() { /** * Gets the context. * - * State information for the conversation. To maintain state, include the context from the previous response. + *

State information for the conversation. To maintain state, include the context from the + * previous response. * * @return the context */ @@ -89,8 +99,8 @@ public Context getContext() { /** * Gets the output. * - * An output object that includes the response to the user, the dialog nodes that were triggered, and messages from - * the log. + *

An output object that includes the response to the user, the dialog nodes that were + * triggered, and messages from the log. * * @return the output */ @@ -101,11 +111,30 @@ public OutputData getOutput() { /** * Gets the actions. * - * An array of objects describing any actions requested by the dialog node. + *

An array of objects describing any actions requested by the dialog node. * * @return the actions */ public List getActions() { return actions; } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the workspace. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.conversation_id**. + * + *

**Note:** This property is the same as the **user_id** property in the context metadata. If + * **user_id** is specified in both locations in a message request, the value specified at the + * root is used. + * + * @return the userId + */ + public String getUserId() { + return userId; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java index 51b2423f49c..94bb544239c 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,41 +10,232 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * An output object that includes the response to the user, the dialog nodes that were triggered, and messages from the - * log. + * An output object that includes the response to the user, the dialog nodes that were triggered, + * and messages from the log. + * + *

This type supports additional properties of type Object. Any additional data included with the + * output. */ public class OutputData extends DynamicModel { @SerializedName("nodes_visited") protected List nodesVisited; + @SerializedName("nodes_visited_details") protected List nodesVisitedDetails; + @SerializedName("log_messages") protected List logMessages; - @SerializedName("text") - protected List text; + @SerializedName("generic") protected List generic; public OutputData() { - super(new TypeToken() { - }); + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private List nodesVisited; + private List nodesVisitedDetails; + private List logMessages; + private List generic; + private Map dynamicProperties; + + /** + * Instantiates a new Builder from an existing OutputData instance. + * + * @param outputData the instance to initialize the Builder with + */ + private Builder(OutputData outputData) { + this.nodesVisited = outputData.nodesVisited; + this.nodesVisitedDetails = outputData.nodesVisitedDetails; + this.logMessages = outputData.logMessages; + this.generic = outputData.generic; + this.dynamicProperties = outputData.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param logMessages the logMessages + */ + public Builder(List logMessages) { + this.logMessages = logMessages; + } + + /** + * Builds a OutputData. + * + * @return the new OutputData instance + */ + public OutputData build() { + return new OutputData(this); + } + + /** + * Adds a new element to nodesVisited. + * + * @param nodesVisited the new element to be added + * @return the OutputData builder + */ + public Builder addNodesVisited(String nodesVisited) { + com.ibm.cloud.sdk.core.util.Validator.notNull(nodesVisited, "nodesVisited cannot be null"); + if (this.nodesVisited == null) { + this.nodesVisited = new ArrayList(); + } + this.nodesVisited.add(nodesVisited); + return this; + } + + /** + * Adds a new element to nodesVisitedDetails. + * + * @param nodesVisitedDetails the new element to be added + * @return the OutputData builder + */ + public Builder addNodesVisitedDetails(DialogNodeVisitedDetails nodesVisitedDetails) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + nodesVisitedDetails, "nodesVisitedDetails cannot be null"); + if (this.nodesVisitedDetails == null) { + this.nodesVisitedDetails = new ArrayList(); + } + this.nodesVisitedDetails.add(nodesVisitedDetails); + return this; + } + + /** + * Adds a new element to logMessages. + * + * @param logMessages the new element to be added + * @return the OutputData builder + */ + public Builder addLogMessages(LogMessage logMessages) { + com.ibm.cloud.sdk.core.util.Validator.notNull(logMessages, "logMessages cannot be null"); + if (this.logMessages == null) { + this.logMessages = new ArrayList(); + } + this.logMessages.add(logMessages); + return this; + } + + /** + * Adds a new element to generic. + * + * @param generic the new element to be added + * @return the OutputData builder + */ + public Builder addGeneric(RuntimeResponseGeneric generic) { + com.ibm.cloud.sdk.core.util.Validator.notNull(generic, "generic cannot be null"); + if (this.generic == null) { + this.generic = new ArrayList(); + } + this.generic.add(generic); + return this; + } + + /** + * Set the nodesVisited. Existing nodesVisited will be replaced. + * + * @param nodesVisited the nodesVisited + * @return the OutputData builder + */ + public Builder nodesVisited(List nodesVisited) { + this.nodesVisited = nodesVisited; + return this; + } + + /** + * Set the nodesVisitedDetails. Existing nodesVisitedDetails will be replaced. + * + * @param nodesVisitedDetails the nodesVisitedDetails + * @return the OutputData builder + */ + public Builder nodesVisitedDetails(List nodesVisitedDetails) { + this.nodesVisitedDetails = nodesVisitedDetails; + return this; + } + + /** + * Set the logMessages. Existing logMessages will be replaced. + * + * @param logMessages the logMessages + * @return the OutputData builder + */ + public Builder logMessages(List logMessages) { + this.logMessages = logMessages; + return this; + } + + /** + * Set the generic. Existing generic will be replaced. + * + * @param generic the generic + * @return the OutputData builder + */ + public Builder generic(List generic) { + this.generic = generic; + return this; + } + + /** + * Add an arbitrary property. Any additional data included with the output. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the OutputData builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected OutputData(Builder builder) { + super(new TypeToken() {}); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.logMessages, "logMessages cannot be null"); + nodesVisited = builder.nodesVisited; + nodesVisitedDetails = builder.nodesVisitedDetails; + logMessages = builder.logMessages; + generic = builder.generic; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a OutputData builder + */ + public Builder newBuilder() { + return new Builder(this); } /** * Gets the nodesVisited. * - * An array of the nodes that were triggered to create the response, in the order in which they were visited. This - * information is useful for debugging and for tracing the path taken through the node tree. + *

An array of the nodes that were triggered to create the response, in the order in which they + * were visited. This information is useful for debugging and for tracing the path taken through + * the node tree. * * @return the nodesVisited */ @@ -64,9 +255,9 @@ public void setNodesVisited(final List nodesVisited) { /** * Gets the nodesVisitedDetails. * - * An array of objects containing detailed diagnostic information about the nodes that were triggered during - * processing of the input message. Included only if **nodes_visited_details** is set to `true` in the message - * request. + *

An array of objects containing detailed diagnostic information about the nodes that were + * triggered during processing of the input message. Included only if **nodes_visited_details** is + * set to `true` in the message request. * * @return the nodesVisitedDetails */ @@ -86,7 +277,7 @@ public void setNodesVisitedDetails(final List nodesVis /** * Gets the logMessages. * - * An array of up to 50 messages logged with the request. + *

An array of up to 50 messages logged with the request. * * @return the logMessages */ @@ -103,31 +294,11 @@ public void setLogMessages(final List logMessages) { this.logMessages = logMessages; } - /** - * Gets the text. - * - * An array of responses to the user. - * - * @return the text - */ - public List getText() { - return this.text; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final List text) { - this.text = text; - } - /** * Gets the generic. * - * Output intended for any channel. It is the responsibility of the client application to implement the supported - * response types. + *

Output intended for any channel. It is the responsibility of the client application to + * implement the supported response types. * * @return the generic */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java index 7d74a3b3a4e..e0f8b841fa2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,31 +10,39 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * The pagination data for the returned objects. + * The pagination data for the returned objects. For more information about using pagination, see + * [Pagination](#pagination). */ public class Pagination extends GenericModel { @SerializedName("refresh_url") protected String refreshUrl; + @SerializedName("next_url") protected String nextUrl; + protected Long total; protected Long matched; + @SerializedName("refresh_cursor") protected String refreshCursor; + @SerializedName("next_cursor") protected String nextCursor; + protected Pagination() {} + /** * Gets the refreshUrl. * - * The URL that will return the same page of results. + *

The URL that will return the same page of results. * * @return the refreshUrl */ @@ -45,7 +53,7 @@ public String getRefreshUrl() { /** * Gets the nextUrl. * - * The URL that will return the next page of results. + *

The URL that will return the next page of results. * * @return the nextUrl */ @@ -56,7 +64,8 @@ public String getNextUrl() { /** * Gets the total. * - * Reserved for future use. + *

The total number of objects that satisfy the request. This total includes all results, not + * just those included in the current page. * * @return the total */ @@ -67,7 +76,7 @@ public Long getTotal() { /** * Gets the matched. * - * Reserved for future use. + *

Reserved for future use. * * @return the matched */ @@ -78,7 +87,7 @@ public Long getMatched() { /** * Gets the refreshCursor. * - * A token identifying the current page of results. + *

A token identifying the current page of results. * * @return the refreshCursor */ @@ -89,7 +98,7 @@ public String getRefreshCursor() { /** * Gets the nextCursor. * - * A token identifying the next page of results. + *

A token identifying the next page of results. * * @return the nextCursor */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ResponseGenericChannel.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ResponseGenericChannel.java new file mode 100644 index 00000000000..93d0c289c49 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ResponseGenericChannel.java @@ -0,0 +1,109 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ResponseGenericChannel. */ +public class ResponseGenericChannel extends GenericModel { + + /** + * A channel for which the response is intended. + * + *

**Note:** On IBM Cloud Pak for Data, only `chat` is supported. + */ + public interface Channel { + /** chat. */ + String CHAT = "chat"; + /** facebook. */ + String FACEBOOK = "facebook"; + /** intercom. */ + String INTERCOM = "intercom"; + /** slack. */ + String SLACK = "slack"; + /** text_messaging. */ + String TEXT_MESSAGING = "text_messaging"; + /** voice_telephony. */ + String VOICE_TELEPHONY = "voice_telephony"; + /** whatsapp. */ + String WHATSAPP = "whatsapp"; + } + + protected String channel; + + /** Builder. */ + public static class Builder { + private String channel; + + /** + * Instantiates a new Builder from an existing ResponseGenericChannel instance. + * + * @param responseGenericChannel the instance to initialize the Builder with + */ + private Builder(ResponseGenericChannel responseGenericChannel) { + this.channel = responseGenericChannel.channel; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ResponseGenericChannel. + * + * @return the new ResponseGenericChannel instance + */ + public ResponseGenericChannel build() { + return new ResponseGenericChannel(this); + } + + /** + * Set the channel. + * + * @param channel the channel + * @return the ResponseGenericChannel builder + */ + public Builder channel(String channel) { + this.channel = channel; + return this; + } + } + + protected ResponseGenericChannel() {} + + protected ResponseGenericChannel(Builder builder) { + channel = builder.channel; + } + + /** + * New builder. + * + * @return a ResponseGenericChannel builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the channel. + * + *

A channel for which the response is intended. + * + *

**Note:** On IBM Cloud Pak for Data, only `chat` is supported. + * + * @return the channel + */ + public String channel() { + return channel; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java index 821c8416079..52aacfbebd0 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,89 +10,83 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import java.util.Map; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * A term from the request that was identified as an entity. - */ +/** A term from the request that was identified as an entity. */ public class RuntimeEntity extends GenericModel { protected String entity; protected List location; protected String value; protected Double confidence; - protected Map metadata; protected List groups; protected RuntimeEntityInterpretation interpretation; + protected List alternatives; protected RuntimeEntityRole role; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String entity; private List location; private String value; private Double confidence; - private Map metadata; private List groups; private RuntimeEntityInterpretation interpretation; + private List alternatives; private RuntimeEntityRole role; + /** + * Instantiates a new Builder from an existing RuntimeEntity instance. + * + * @param runtimeEntity the instance to initialize the Builder with + */ private Builder(RuntimeEntity runtimeEntity) { this.entity = runtimeEntity.entity; this.location = runtimeEntity.location; this.value = runtimeEntity.value; this.confidence = runtimeEntity.confidence; - this.metadata = runtimeEntity.metadata; this.groups = runtimeEntity.groups; this.interpretation = runtimeEntity.interpretation; + this.alternatives = runtimeEntity.alternatives; this.role = runtimeEntity.role; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param entity the entity - * @param location the location * @param value the value */ - public Builder(String entity, List location, String value) { + public Builder(String entity, String value) { this.entity = entity; - this.location = location; this.value = value; } /** * Builds a RuntimeEntity. * - * @return the runtimeEntity + * @return the new RuntimeEntity instance */ public RuntimeEntity build() { return new RuntimeEntity(this); } /** - * Adds an location to location. + * Adds a new element to location. * - * @param location the new location + * @param location the new element to be added * @return the RuntimeEntity builder */ public Builder addLocation(Long location) { - com.ibm.cloud.sdk.core.util.Validator.notNull(location, - "location cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(location, "location cannot be null"); if (this.location == null) { this.location = new ArrayList(); } @@ -101,14 +95,13 @@ public Builder addLocation(Long location) { } /** - * Adds an groups to groups. + * Adds a new element to groups. * - * @param groups the new groups + * @param groups the new element to be added * @return the RuntimeEntity builder */ public Builder addGroups(CaptureGroup groups) { - com.ibm.cloud.sdk.core.util.Validator.notNull(groups, - "groups cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(groups, "groups cannot be null"); if (this.groups == null) { this.groups = new ArrayList(); } @@ -116,6 +109,21 @@ public Builder addGroups(CaptureGroup groups) { return this; } + /** + * Adds a new element to alternatives. + * + * @param alternatives the new element to be added + * @return the RuntimeEntity builder + */ + public Builder addAlternatives(RuntimeEntityAlternative alternatives) { + com.ibm.cloud.sdk.core.util.Validator.notNull(alternatives, "alternatives cannot be null"); + if (this.alternatives == null) { + this.alternatives = new ArrayList(); + } + this.alternatives.add(alternatives); + return this; + } + /** * Set the entity. * @@ -128,8 +136,7 @@ public Builder entity(String entity) { } /** - * Set the location. - * Existing location will be replaced. + * Set the location. Existing location will be replaced. * * @param location the location * @return the RuntimeEntity builder @@ -162,19 +169,7 @@ public Builder confidence(Double confidence) { } /** - * Set the metadata. - * - * @param metadata the metadata - * @return the RuntimeEntity builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the groups. - * Existing groups will be replaced. + * Set the groups. Existing groups will be replaced. * * @param groups the groups * @return the RuntimeEntity builder @@ -195,6 +190,17 @@ public Builder interpretation(RuntimeEntityInterpretation interpretation) { return this; } + /** + * Set the alternatives. Existing alternatives will be replaced. + * + * @param alternatives the alternatives + * @return the RuntimeEntity builder + */ + public Builder alternatives(List alternatives) { + this.alternatives = alternatives; + return this; + } + /** * Set the role. * @@ -207,20 +213,18 @@ public Builder role(RuntimeEntityRole role) { } } + protected RuntimeEntity() {} + protected RuntimeEntity(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, - "entity cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.location, - "location cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); entity = builder.entity; location = builder.location; value = builder.value; confidence = builder.confidence; - metadata = builder.metadata; groups = builder.groups; interpretation = builder.interpretation; + alternatives = builder.alternatives; role = builder.role; } @@ -236,7 +240,7 @@ public Builder newBuilder() { /** * Gets the entity. * - * An entity detected in the input. + *

An entity detected in the input. * * @return the entity */ @@ -247,8 +251,8 @@ public String entity() { /** * Gets the location. * - * An array of zero-based character offsets that indicate where the detected entity values begin and end in the input - * text. + *

An array of zero-based character offsets that indicate where the detected entity values + * begin and end in the input text. * * @return the location */ @@ -259,7 +263,7 @@ public List location() { /** * Gets the value. * - * The entity value that was recognized in the user input. + *

The entity value that was recognized in the user input. * * @return the value */ @@ -270,7 +274,7 @@ public String value() { /** * Gets the confidence. * - * A decimal percentage that represents Watson's confidence in the recognized entity. + *

A decimal percentage that represents confidence in the recognized entity. * * @return the confidence */ @@ -278,21 +282,10 @@ public Double confidence() { return confidence; } - /** - * Gets the metadata. - * - * Any metadata for the entity. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - /** * Gets the groups. * - * The recognized capture groups for the entity, as defined by the entity pattern. + *

The recognized capture groups for the entity, as defined by the entity pattern. * * @return the groups */ @@ -303,11 +296,10 @@ public List groups() { /** * Gets the interpretation. * - * An object containing detailed information about the entity recognized in the user input. This property is included - * only if the new system entities are enabled for the workspace. + *

An object containing detailed information about the entity recognized in the user input. * - * For more information about how the new system entities are interpreted, see the - * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities). + *

For more information about how system entities are interpreted, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities). * * @return the interpretation */ @@ -315,12 +307,27 @@ public RuntimeEntityInterpretation interpretation() { return interpretation; } + /** + * Gets the alternatives. + * + *

An array of possible alternative values that the user might have intended instead of the + * value returned in the **value** property. This property is returned only for `@sys-time` and + * `@sys-date` entities when the user's input is ambiguous. + * + *

This property is included only if the new system entities are enabled for the workspace. + * + * @return the alternatives + */ + public List alternatives() { + return alternatives; + } + /** * Gets the role. * - * An object describing the role played by a system entity that is specifies the beginning or end of a range - * recognized in the user input. This property is included only if the new system entities are enabled for the - * workspace. + *

An object describing the role played by a system entity that is specifies the beginning or + * end of a range recognized in the user input. This property is included only if the new system + * entities are enabled for the workspace. * * @return the role */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java new file mode 100644 index 00000000000..eb7ce56abb3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java @@ -0,0 +1,111 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An alternative value for the recognized entity. */ +public class RuntimeEntityAlternative extends GenericModel { + + protected String value; + protected Double confidence; + + /** Builder. */ + public static class Builder { + private String value; + private Double confidence; + + /** + * Instantiates a new Builder from an existing RuntimeEntityAlternative instance. + * + * @param runtimeEntityAlternative the instance to initialize the Builder with + */ + private Builder(RuntimeEntityAlternative runtimeEntityAlternative) { + this.value = runtimeEntityAlternative.value; + this.confidence = runtimeEntityAlternative.confidence; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a RuntimeEntityAlternative. + * + * @return the new RuntimeEntityAlternative instance + */ + public RuntimeEntityAlternative build() { + return new RuntimeEntityAlternative(this); + } + + /** + * Set the value. + * + * @param value the value + * @return the RuntimeEntityAlternative builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the confidence. + * + * @param confidence the confidence + * @return the RuntimeEntityAlternative builder + */ + public Builder confidence(Double confidence) { + this.confidence = confidence; + return this; + } + } + + protected RuntimeEntityAlternative() {} + + protected RuntimeEntityAlternative(Builder builder) { + value = builder.value; + confidence = builder.confidence; + } + + /** + * New builder. + * + * @return a RuntimeEntityAlternative builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the value. + * + *

The entity value that was recognized in the user input. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the confidence. + * + *

A decimal percentage that represents confidence in the recognized entity. + * + * @return the confidence + */ + public Double confidence() { + return confidence; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java index c5eaee3c206..a4e654279bf 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2024. * * 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 @@ -10,18 +10,18 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * RuntimeEntityInterpretation. - */ +/** RuntimeEntityInterpretation. */ public class RuntimeEntityInterpretation extends GenericModel { /** - * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. + * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` + * entity. */ public interface Granularity { /** day. */ @@ -50,56 +50,78 @@ public interface Granularity { @SerializedName("calendar_type") protected String calendarType; + @SerializedName("datetime_link") protected String datetimeLink; + protected String festival; protected String granularity; + @SerializedName("range_link") protected String rangeLink; + @SerializedName("range_modifier") protected String rangeModifier; + @SerializedName("relative_day") protected Double relativeDay; + @SerializedName("relative_month") protected Double relativeMonth; + @SerializedName("relative_week") protected Double relativeWeek; + @SerializedName("relative_weekend") protected Double relativeWeekend; + @SerializedName("relative_year") protected Double relativeYear; + @SerializedName("specific_day") protected Double specificDay; + @SerializedName("specific_day_of_week") protected String specificDayOfWeek; + @SerializedName("specific_month") protected Double specificMonth; + @SerializedName("specific_quarter") protected Double specificQuarter; + @SerializedName("specific_year") protected Double specificYear; + @SerializedName("numeric_value") protected Double numericValue; + protected String subtype; + @SerializedName("part_of_day") protected String partOfDay; + @SerializedName("relative_hour") protected Double relativeHour; + @SerializedName("relative_minute") protected Double relativeMinute; + @SerializedName("relative_second") protected Double relativeSecond; + @SerializedName("specific_hour") protected Double specificHour; + @SerializedName("specific_minute") protected Double specificMinute; + @SerializedName("specific_second") protected Double specificSecond; + protected String timezone; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String calendarType; private String datetimeLink; @@ -128,6 +150,11 @@ public static class Builder { private Double specificSecond; private String timezone; + /** + * Instantiates a new Builder from an existing RuntimeEntityInterpretation instance. + * + * @param runtimeEntityInterpretation the instance to initialize the Builder with + */ private Builder(RuntimeEntityInterpretation runtimeEntityInterpretation) { this.calendarType = runtimeEntityInterpretation.calendarType; this.datetimeLink = runtimeEntityInterpretation.datetimeLink; @@ -157,16 +184,13 @@ private Builder(RuntimeEntityInterpretation runtimeEntityInterpretation) { this.timezone = runtimeEntityInterpretation.timezone; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a RuntimeEntityInterpretation. * - * @return the runtimeEntityInterpretation + * @return the new RuntimeEntityInterpretation instance */ public RuntimeEntityInterpretation build() { return new RuntimeEntityInterpretation(this); @@ -459,6 +483,8 @@ public Builder timezone(String timezone) { } } + protected RuntimeEntityInterpretation() {} + protected RuntimeEntityInterpretation(Builder builder) { calendarType = builder.calendarType; datetimeLink = builder.datetimeLink; @@ -500,7 +526,7 @@ public Builder newBuilder() { /** * Gets the calendarType. * - * The calendar used to represent a recognized date (for example, `Gregorian`). + *

The calendar used to represent a recognized date (for example, `Gregorian`). * * @return the calendarType */ @@ -511,9 +537,9 @@ public String calendarType() { /** * Gets the datetimeLink. * - * A unique identifier used to associate a recognized time and date. If the user input contains a date and time that - * are mentioned together (for example, `Today at 5`, the same **datetime_link** value is returned for both the - * `@sys-date` and `@sys-time` entities). + *

A unique identifier used to associate a recognized time and date. If the user input contains + * a date and time that are mentioned together (for example, `Today at 5`, the same + * **datetime_link** value is returned for both the `@sys-date` and `@sys-time` entities). * * @return the datetimeLink */ @@ -524,8 +550,8 @@ public String datetimeLink() { /** * Gets the festival. * - * A locale-specific holiday name (such as `thanksgiving` or `christmas`). This property is included when a - * `@sys-date` entity is recognized based on a holiday name in the user input. + *

A locale-specific holiday name (such as `thanksgiving` or `christmas`). This property is + * included when a `@sys-date` entity is recognized based on a holiday name in the user input. * * @return the festival */ @@ -536,7 +562,8 @@ public String festival() { /** * Gets the granularity. * - * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. + *

The precision or duration of a time range specified by a recognized `@sys-time` or + * `@sys-date` entity. * * @return the granularity */ @@ -547,9 +574,9 @@ public String granularity() { /** * Gets the rangeLink. * - * A unique identifier used to associate multiple recognized `@sys-date`, `@sys-time`, or `@sys-number` entities that - * are recognized as a range of values in the user's input (for example, `from July 4 until July 14` or `from 20 to - * 25`). + *

A unique identifier used to associate multiple recognized `@sys-date`, `@sys-time`, or + * `@sys-number` entities that are recognized as a range of values in the user's input (for + * example, `from July 4 until July 14` or `from 20 to 25`). * * @return the rangeLink */ @@ -560,8 +587,8 @@ public String rangeLink() { /** * Gets the rangeModifier. * - * The word in the user input that indicates that a `sys-date` or `sys-time` entity is part of an implied range where - * only one date or time is specified (for example, `since` or `until`). + *

The word in the user input that indicates that a `sys-date` or `sys-time` entity is part of + * an implied range where only one date or time is specified (for example, `since` or `until`). * * @return the rangeModifier */ @@ -572,8 +599,8 @@ public String rangeModifier() { /** * Gets the relativeDay. * - * A recognized mention of a relative day, represented numerically as an offset from the current date (for example, - * `-1` for `yesterday` or `10` for `in ten days`). + *

A recognized mention of a relative day, represented numerically as an offset from the + * current date (for example, `-1` for `yesterday` or `10` for `in ten days`). * * @return the relativeDay */ @@ -584,8 +611,8 @@ public Double relativeDay() { /** * Gets the relativeMonth. * - * A recognized mention of a relative month, represented numerically as an offset from the current month (for example, - * `1` for `next month` or `-3` for `three months ago`). + *

A recognized mention of a relative month, represented numerically as an offset from the + * current month (for example, `1` for `next month` or `-3` for `three months ago`). * * @return the relativeMonth */ @@ -596,8 +623,8 @@ public Double relativeMonth() { /** * Gets the relativeWeek. * - * A recognized mention of a relative week, represented numerically as an offset from the current week (for example, - * `2` for `in two weeks` or `-1` for `last week). + *

A recognized mention of a relative week, represented numerically as an offset from the + * current week (for example, `2` for `in two weeks` or `-1` for `last week). * * @return the relativeWeek */ @@ -608,8 +635,9 @@ public Double relativeWeek() { /** * Gets the relativeWeekend. * - * A recognized mention of a relative date range for a weekend, represented numerically as an offset from the current - * weekend (for example, `0` for `this weekend` or `-1` for `last weekend`). + *

A recognized mention of a relative date range for a weekend, represented numerically as an + * offset from the current weekend (for example, `0` for `this weekend` or `-1` for `last + * weekend`). * * @return the relativeWeekend */ @@ -620,8 +648,8 @@ public Double relativeWeekend() { /** * Gets the relativeYear. * - * A recognized mention of a relative year, represented numerically as an offset from the current year (for example, - * `1` for `next year` or `-5` for `five years ago`). + *

A recognized mention of a relative year, represented numerically as an offset from the + * current year (for example, `1` for `next year` or `-5` for `five years ago`). * * @return the relativeYear */ @@ -632,8 +660,8 @@ public Double relativeYear() { /** * Gets the specificDay. * - * A recognized mention of a specific date, represented numerically as the date within the month (for example, `30` - * for `June 30`.). + *

A recognized mention of a specific date, represented numerically as the date within the + * month (for example, `30` for `June 30`.). * * @return the specificDay */ @@ -644,7 +672,8 @@ public Double specificDay() { /** * Gets the specificDayOfWeek. * - * A recognized mention of a specific day of the week as a lowercase string (for example, `monday`). + *

A recognized mention of a specific day of the week as a lowercase string (for example, + * `monday`). * * @return the specificDayOfWeek */ @@ -655,7 +684,8 @@ public String specificDayOfWeek() { /** * Gets the specificMonth. * - * A recognized mention of a specific month, represented numerically (for example, `7` for `July`). + *

A recognized mention of a specific month, represented numerically (for example, `7` for + * `July`). * * @return the specificMonth */ @@ -666,7 +696,8 @@ public Double specificMonth() { /** * Gets the specificQuarter. * - * A recognized mention of a specific quarter, represented numerically (for example, `3` for `the third quarter`). + *

A recognized mention of a specific quarter, represented numerically (for example, `3` for + * `the third quarter`). * * @return the specificQuarter */ @@ -677,7 +708,7 @@ public Double specificQuarter() { /** * Gets the specificYear. * - * A recognized mention of a specific year (for example, `2016`). + *

A recognized mention of a specific year (for example, `2016`). * * @return the specificYear */ @@ -688,7 +719,7 @@ public Double specificYear() { /** * Gets the numericValue. * - * A recognized numeric value, represented as an integer or double. + *

A recognized numeric value, represented as an integer or double. * * @return the numericValue */ @@ -699,7 +730,7 @@ public Double numericValue() { /** * Gets the subtype. * - * The type of numeric value recognized in the user input (`integer` or `rational`). + *

The type of numeric value recognized in the user input (`integer` or `rational`). * * @return the subtype */ @@ -710,8 +741,8 @@ public String subtype() { /** * Gets the partOfDay. * - * A recognized term for a time that was mentioned as a part of the day in the user's input (for example, `morning` or - * `afternoon`). + *

A recognized term for a time that was mentioned as a part of the day in the user's input + * (for example, `morning` or `afternoon`). * * @return the partOfDay */ @@ -722,8 +753,8 @@ public String partOfDay() { /** * Gets the relativeHour. * - * A recognized mention of a relative hour, represented numerically as an offset from the current hour (for example, - * `3` for `in three hours` or `-1` for `an hour ago`). + *

A recognized mention of a relative hour, represented numerically as an offset from the + * current hour (for example, `3` for `in three hours` or `-1` for `an hour ago`). * * @return the relativeHour */ @@ -734,8 +765,9 @@ public Double relativeHour() { /** * Gets the relativeMinute. * - * A recognized mention of a relative time, represented numerically as an offset in minutes from the current time (for - * example, `5` for `in five minutes` or `-15` for `fifteen minutes ago`). + *

A recognized mention of a relative time, represented numerically as an offset in minutes + * from the current time (for example, `5` for `in five minutes` or `-15` for `fifteen minutes + * ago`). * * @return the relativeMinute */ @@ -746,8 +778,9 @@ public Double relativeMinute() { /** * Gets the relativeSecond. * - * A recognized mention of a relative time, represented numerically as an offset in seconds from the current time (for - * example, `10` for `in ten seconds` or `-30` for `thirty seconds ago`). + *

A recognized mention of a relative time, represented numerically as an offset in seconds + * from the current time (for example, `10` for `in ten seconds` or `-30` for `thirty seconds + * ago`). * * @return the relativeSecond */ @@ -758,7 +791,8 @@ public Double relativeSecond() { /** * Gets the specificHour. * - * A recognized specific hour mentioned as part of a time value (for example, `10` for `10:15 AM`.). + *

A recognized specific hour mentioned as part of a time value (for example, `10` for `10:15 + * AM`.). * * @return the specificHour */ @@ -769,7 +803,8 @@ public Double specificHour() { /** * Gets the specificMinute. * - * A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 AM`.). + *

A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 + * AM`.). * * @return the specificMinute */ @@ -780,7 +815,8 @@ public Double specificMinute() { /** * Gets the specificSecond. * - * A recognized specific second mentioned as part of a time value (for example, `30` for `10:15:30 AM`.). + *

A recognized specific second mentioned as part of a time value (for example, `30` for + * `10:15:30 AM`.). * * @return the specificSecond */ @@ -791,7 +827,7 @@ public Double specificSecond() { /** * Gets the timezone. * - * A recognized time zone mentioned as part of a time value (for example, `EST`). + *

A recognized time zone mentioned as part of a time value (for example, `EST`). * * @return the timezone */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java index f757dba01af..9ffe6b84276 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2024. * * 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 @@ -10,19 +10,19 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An object describing the role played by a system entity that is specifies the beginning or end of a range recognized - * in the user input. This property is included only if the new system entities are enabled for the workspace. + * An object describing the role played by a system entity that is specifies the beginning or end of + * a range recognized in the user input. This property is included only if the new system entities + * are enabled for the workspace. */ public class RuntimeEntityRole extends GenericModel { - /** - * The relationship of the entity to the range. - */ + /** The relationship of the entity to the range. */ public interface Type { /** date_from. */ String DATE_FROM = "date_from"; @@ -40,26 +40,26 @@ public interface Type { protected String type; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String type; + /** + * Instantiates a new Builder from an existing RuntimeEntityRole instance. + * + * @param runtimeEntityRole the instance to initialize the Builder with + */ private Builder(RuntimeEntityRole runtimeEntityRole) { this.type = runtimeEntityRole.type; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a RuntimeEntityRole. * - * @return the runtimeEntityRole + * @return the new RuntimeEntityRole instance */ public RuntimeEntityRole build() { return new RuntimeEntityRole(this); @@ -77,6 +77,8 @@ public Builder type(String type) { } } + protected RuntimeEntityRole() {} + protected RuntimeEntityRole(Builder builder) { type = builder.type; } @@ -93,7 +95,7 @@ public Builder newBuilder() { /** * Gets the type. * - * The relationship of the entity to the range. + *

The relationship of the entity to the range. * * @return the type */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java index c9abcab5035..c60fd8effc7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,51 +10,48 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An intent identified in the user input. - */ +/** An intent identified in the user input. */ public class RuntimeIntent extends GenericModel { protected String intent; protected Double confidence; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String intent; private Double confidence; + /** + * Instantiates a new Builder from an existing RuntimeIntent instance. + * + * @param runtimeIntent the instance to initialize the Builder with + */ private Builder(RuntimeIntent runtimeIntent) { this.intent = runtimeIntent.intent; this.confidence = runtimeIntent.confidence; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param intent the intent - * @param confidence the confidence */ - public Builder(String intent, Double confidence) { + public Builder(String intent) { this.intent = intent; - this.confidence = confidence; } /** * Builds a RuntimeIntent. * - * @return the runtimeIntent + * @return the new RuntimeIntent instance */ public RuntimeIntent build() { return new RuntimeIntent(this); @@ -83,11 +80,10 @@ public Builder confidence(Double confidence) { } } + protected RuntimeIntent() {} + protected RuntimeIntent(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, - "intent cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.confidence, - "confidence cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); intent = builder.intent; confidence = builder.confidence; } @@ -104,7 +100,7 @@ public Builder newBuilder() { /** * Gets the intent. * - * The name of the recognized intent. + *

The name of the recognized intent. * * @return the intent */ @@ -115,7 +111,8 @@ public String intent() { /** * Gets the confidence. * - * A decimal percentage that represents Watson's confidence in the intent. + *

A decimal percentage that represents confidence in the intent. If you are specifying an + * intent as part of a request, but you do not have a calculated confidence value, specify `1`. * * @return the confidence */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java index 8f4434da906..c9d96256a51 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,44 +10,52 @@ * 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.assistant.v1.model; -import java.util.ArrayList; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; /** * RuntimeResponseGeneric. + * + *

Classes which extend this class: - RuntimeResponseGenericRuntimeResponseTypeText - + * RuntimeResponseGenericRuntimeResponseTypePause - RuntimeResponseGenericRuntimeResponseTypeImage - + * RuntimeResponseGenericRuntimeResponseTypeOption - + * RuntimeResponseGenericRuntimeResponseTypeConnectToAgent - + * RuntimeResponseGenericRuntimeResponseTypeSuggestion - + * RuntimeResponseGenericRuntimeResponseTypeChannelTransfer - + * RuntimeResponseGenericRuntimeResponseTypeUserDefined - + * RuntimeResponseGenericRuntimeResponseTypeVideo - RuntimeResponseGenericRuntimeResponseTypeAudio - + * RuntimeResponseGenericRuntimeResponseTypeIframe */ public class RuntimeResponseGeneric extends GenericModel { - - /** - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for Plus - * and Premium users. - */ - public interface ResponseType { - /** text. */ - String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** suggestion. */ - String SUGGESTION = "suggestion"; + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "response_type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put("audio", RuntimeResponseGenericRuntimeResponseTypeAudio.class); + discriminatorMapping.put( + "channel_transfer", RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.class); + discriminatorMapping.put( + "connect_to_agent", RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.class); + discriminatorMapping.put("iframe", RuntimeResponseGenericRuntimeResponseTypeIframe.class); + discriminatorMapping.put("image", RuntimeResponseGenericRuntimeResponseTypeImage.class); + discriminatorMapping.put("option", RuntimeResponseGenericRuntimeResponseTypeOption.class); + discriminatorMapping.put( + "suggestion", RuntimeResponseGenericRuntimeResponseTypeSuggestion.class); + discriminatorMapping.put("pause", RuntimeResponseGenericRuntimeResponseTypePause.class); + discriminatorMapping.put("text", RuntimeResponseGenericRuntimeResponseTypeText.class); + discriminatorMapping.put( + "user_defined", RuntimeResponseGenericRuntimeResponseTypeUserDefined.class); + discriminatorMapping.put("video", RuntimeResponseGenericRuntimeResponseTypeVideo.class); } - - /** - * The preferred type of control to display. - */ + /** The preferred type of control to display. */ public interface Preference { /** dropdown. */ String DROPDOWN = "dropdown"; @@ -57,292 +65,56 @@ public interface Preference { @SerializedName("response_type") protected String responseType; + protected String text; + protected List channels; protected Long time; protected Boolean typing; protected String source; protected String title; protected String description; + + @SerializedName("alt_text") + protected String altText; + protected String preference; protected List options; + @SerializedName("message_to_human_agent") protected String messageToHumanAgent; + + @SerializedName("agent_available") + protected AgentAvailabilityMessage agentAvailable; + + @SerializedName("agent_unavailable") + protected AgentAvailabilityMessage agentUnavailable; + protected String topic; + @SerializedName("dialog_node") protected String dialogNode; + protected List suggestions; - /** - * Builder. - */ - public static class Builder { - private String responseType; - private String text; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String topic; - private String dialogNode; - private List suggestions; - - private Builder(RuntimeResponseGeneric runtimeResponseGeneric) { - this.responseType = runtimeResponseGeneric.responseType; - this.text = runtimeResponseGeneric.text; - this.time = runtimeResponseGeneric.time; - this.typing = runtimeResponseGeneric.typing; - this.source = runtimeResponseGeneric.source; - this.title = runtimeResponseGeneric.title; - this.description = runtimeResponseGeneric.description; - this.preference = runtimeResponseGeneric.preference; - this.options = runtimeResponseGeneric.options; - this.messageToHumanAgent = runtimeResponseGeneric.messageToHumanAgent; - this.topic = runtimeResponseGeneric.topic; - this.dialogNode = runtimeResponseGeneric.dialogNode; - this.suggestions = runtimeResponseGeneric.suggestions; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a RuntimeResponseGeneric. - * - * @return the runtimeResponseGeneric - */ - public RuntimeResponseGeneric build() { - return new RuntimeResponseGeneric(this); - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the RuntimeResponseGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, - "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Adds an suggestions to suggestions. - * - * @param suggestions the new suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder addSuggestions(DialogSuggestion suggestions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(suggestions, - "suggestions cannot be null"); - if (this.suggestions == null) { - this.suggestions = new ArrayList(); - } - this.suggestions.add(suggestions); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the RuntimeResponseGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the RuntimeResponseGeneric builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the RuntimeResponseGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the RuntimeResponseGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the RuntimeResponseGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the RuntimeResponseGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the RuntimeResponseGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the RuntimeResponseGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. - * Existing options will be replaced. - * - * @param options the options - * @return the RuntimeResponseGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the RuntimeResponseGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the topic. - * - * @param topic the topic - * @return the RuntimeResponseGeneric builder - */ - public Builder topic(String topic) { - this.topic = topic; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the RuntimeResponseGeneric builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the suggestions. - * Existing suggestions will be replaced. - * - * @param suggestions the suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder suggestions(List suggestions) { - this.suggestions = suggestions; - return this; - } - } + @SerializedName("message_to_user") + protected String messageToUser; - protected RuntimeResponseGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.responseType, - "responseType cannot be null"); - responseType = builder.responseType; - text = builder.text; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - topic = builder.topic; - dialogNode = builder.dialogNode; - suggestions = builder.suggestions; - } + @SerializedName("user_defined") + protected Map userDefined; - /** - * New builder. - * - * @return a RuntimeResponseGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } + @SerializedName("channel_options") + protected Map channelOptions; + + @SerializedName("image_url") + protected String imageUrl; + + protected RuntimeResponseGeneric() {} /** * Gets the responseType. * - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for Plus - * and Premium users. + *

The type of response returned by the dialog node. The specified response type must be + * supported by the client application or channel. * * @return the responseType */ @@ -353,7 +125,7 @@ public String responseType() { /** * Gets the text. * - * The text of the response. + *

The text of the response. * * @return the text */ @@ -361,10 +133,23 @@ public String text() { return text; } + /** + * Gets the channels. + * + *

An array of objects specifying channels for which the response is intended. If **channels** + * is present, the response is intended for a built-in integration and should not be handled by an + * API client. + * + * @return the channels + */ + public List channels() { + return channels; + } + /** * Gets the time. * - * How long to pause, in milliseconds. + *

How long to pause, in milliseconds. * * @return the time */ @@ -375,7 +160,7 @@ public Long time() { /** * Gets the typing. * - * Whether to send a "user is typing" event during the pause. + *

Whether to send a "user is typing" event during the pause. * * @return the typing */ @@ -386,7 +171,7 @@ public Boolean typing() { /** * Gets the source. * - * The URL of the image. + *

The `https:` URL of the image. * * @return the source */ @@ -397,7 +182,7 @@ public String source() { /** * Gets the title. * - * The title or introductory text to show before the response. + *

The title or introductory text to show before the response. * * @return the title */ @@ -408,7 +193,7 @@ public String title() { /** * Gets the description. * - * The description to show with the the response. + *

The description to show with the response. * * @return the description */ @@ -416,10 +201,22 @@ public String description() { return description; } + /** + * Gets the altText. + * + *

Descriptive text that can be used for screen readers or other situations where the image + * cannot be seen. + * + * @return the altText + */ + public String altText() { + return altText; + } + /** * Gets the preference. * - * The preferred type of control to display. + *

The preferred type of control to display. * * @return the preference */ @@ -430,7 +227,7 @@ public String preference() { /** * Gets the options. * - * An array of objects describing the options from which the user can choose. + *

An array of objects describing the options from which the user can choose. * * @return the options */ @@ -441,7 +238,7 @@ public List options() { /** * Gets the messageToHumanAgent. * - * A message to be sent to the human agent who will be taking over the conversation. + *

A message to be sent to the human agent who will be taking over the conversation. * * @return the messageToHumanAgent */ @@ -449,10 +246,35 @@ public String messageToHumanAgent() { return messageToHumanAgent; } + /** + * Gets the agentAvailable. + * + *

An optional message to be displayed to the user to indicate that the conversation will be + * transferred to the next available agent. + * + * @return the agentAvailable + */ + public AgentAvailabilityMessage agentAvailable() { + return agentAvailable; + } + + /** + * Gets the agentUnavailable. + * + *

An optional message to be displayed to the user to indicate that no online agent is + * available to take over the conversation. + * + * @return the agentUnavailable + */ + public AgentAvailabilityMessage agentUnavailable() { + return agentUnavailable; + } + /** * Gets the topic. * - * A label identifying the topic of the conversation, derived from the **user_label** property of the relevant node. + *

A label identifying the topic of the conversation, derived from the **title** property of + * the relevant node or the **topic** property of the dialog node response. * * @return the topic */ @@ -463,8 +285,8 @@ public String topic() { /** * Gets the dialogNode. * - * The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated using the - * value of the dialog node's **user_label** property. + *

The unique ID of the dialog node that the **topic** property is taken from. The **topic** + * property is populated using the value of the dialog node's **title** property. * * @return the dialogNode */ @@ -475,14 +297,56 @@ public String dialogNode() { /** * Gets the suggestions. * - * An array of objects describing the possible matching dialog nodes from which the user can choose. - * - * **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for Plus and - * Premium users. + *

An array of objects describing the possible matching dialog nodes from which the user can + * choose. * * @return the suggestions */ public List suggestions() { return suggestions; } + + /** + * Gets the messageToUser. + * + *

The message to display to the user when initiating a channel transfer. + * + * @return the messageToUser + */ + public String messageToUser() { + return messageToUser; + } + + /** + * Gets the userDefined. + * + *

An object containing any properties for the user-defined response type. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the channelOptions. + * + *

For internal use only. + * + * @return the channelOptions + */ + public Map channelOptions() { + return channelOptions; + } + + /** + * Gets the imageUrl. + * + *

The URL of an image that shows a preview of the embedded content. + * + * @return the imageUrl + */ + public String imageUrl() { + return imageUrl; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeAudio.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeAudio.java new file mode 100644 index 00000000000..927428615f7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeAudio.java @@ -0,0 +1,189 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** RuntimeResponseGenericRuntimeResponseTypeAudio. */ +public class RuntimeResponseGenericRuntimeResponseTypeAudio extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private List channels; + private Map channelOptions; + private String altText; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypeAudio + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeAudio the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeAudio) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeAudio.responseType; + this.source = runtimeResponseGenericRuntimeResponseTypeAudio.source; + this.title = runtimeResponseGenericRuntimeResponseTypeAudio.title; + this.description = runtimeResponseGenericRuntimeResponseTypeAudio.description; + this.channels = runtimeResponseGenericRuntimeResponseTypeAudio.channels; + this.channelOptions = runtimeResponseGenericRuntimeResponseTypeAudio.channelOptions; + this.altText = runtimeResponseGenericRuntimeResponseTypeAudio.altText; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeAudio. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeAudio instance + */ + public RuntimeResponseGenericRuntimeResponseTypeAudio build() { + return new RuntimeResponseGenericRuntimeResponseTypeAudio(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the channelOptions. + * + * @param channelOptions the channelOptions + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder channelOptions(Map channelOptions) { + this.channelOptions = channelOptions; + return this; + } + + /** + * Set the altText. + * + * @param altText the altText + * @return the RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder altText(String altText) { + this.altText = altText; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeAudio() {} + + protected RuntimeResponseGenericRuntimeResponseTypeAudio(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + channels = builder.channels; + channelOptions = builder.channelOptions; + altText = builder.altText; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeAudio builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.java new file mode 100644 index 00000000000..4c110f4f96f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.java @@ -0,0 +1,169 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeChannelTransfer. */ +public class RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + extends RuntimeResponseGeneric { + + @SerializedName("transfer_info") + protected ChannelTransferInfo transferInfo; + + /** Builder. */ + public static class Builder { + private String responseType; + private String messageToUser; + private ChannelTransferInfo transferInfo; + private List channels; + + /** + * Instantiates a new Builder from an existing + * RuntimeResponseGenericRuntimeResponseTypeChannelTransfer instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeChannelTransfer the instance to initialize + * the Builder with + */ + public Builder( + RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + runtimeResponseGenericRuntimeResponseTypeChannelTransfer) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeChannelTransfer.responseType; + this.messageToUser = runtimeResponseGenericRuntimeResponseTypeChannelTransfer.messageToUser; + this.transferInfo = runtimeResponseGenericRuntimeResponseTypeChannelTransfer.transferInfo; + this.channels = runtimeResponseGenericRuntimeResponseTypeChannelTransfer.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param messageToUser the messageToUser + * @param transferInfo the transferInfo + */ + public Builder(String responseType, String messageToUser, ChannelTransferInfo transferInfo) { + this.responseType = responseType; + this.messageToUser = messageToUser; + this.transferInfo = transferInfo; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeChannelTransfer. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeChannelTransfer instance + */ + public RuntimeResponseGenericRuntimeResponseTypeChannelTransfer build() { + return new RuntimeResponseGenericRuntimeResponseTypeChannelTransfer(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the messageToUser. + * + * @param messageToUser the messageToUser + * @return the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer builder + */ + public Builder messageToUser(String messageToUser) { + this.messageToUser = messageToUser; + return this; + } + + /** + * Set the transferInfo. + * + * @param transferInfo the transferInfo + * @return the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer builder + */ + public Builder transferInfo(ChannelTransferInfo transferInfo) { + this.transferInfo = transferInfo; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeChannelTransfer() {} + + protected RuntimeResponseGenericRuntimeResponseTypeChannelTransfer(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.messageToUser, "messageToUser cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.transferInfo, "transferInfo cannot be null"); + responseType = builder.responseType; + messageToUser = builder.messageToUser; + transferInfo = builder.transferInfo; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeChannelTransfer builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public ChannelTransferInfo transferInfo() { + return transferInfo; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java new file mode 100644 index 00000000000..ed4198fcae2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java @@ -0,0 +1,219 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeConnectToAgent. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + extends RuntimeResponseGeneric { + + @SerializedName("transfer_info") + protected DialogNodeOutputConnectToAgentTransferInfo transferInfo; + + /** Builder. */ + public static class Builder { + private String responseType; + private String messageToHumanAgent; + private AgentAvailabilityMessage agentAvailable; + private AgentAvailabilityMessage agentUnavailable; + private DialogNodeOutputConnectToAgentTransferInfo transferInfo; + private String topic; + private String dialogNode; + private List channels; + + /** + * Instantiates a new Builder from an existing + * RuntimeResponseGenericRuntimeResponseTypeConnectToAgent instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeConnectToAgent the instance to initialize the + * Builder with + */ + public Builder( + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgent) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.responseType; + this.messageToHumanAgent = + runtimeResponseGenericRuntimeResponseTypeConnectToAgent.messageToHumanAgent; + this.agentAvailable = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.agentAvailable; + this.agentUnavailable = + runtimeResponseGenericRuntimeResponseTypeConnectToAgent.agentUnavailable; + this.transferInfo = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.transferInfo; + this.topic = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.topic; + this.dialogNode = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.dialogNode; + this.channels = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + */ + public Builder(String responseType) { + this.responseType = responseType; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeConnectToAgent. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent instance + */ + public RuntimeResponseGenericRuntimeResponseTypeConnectToAgent build() { + return new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the messageToHumanAgent. + * + * @param messageToHumanAgent the messageToHumanAgent + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder messageToHumanAgent(String messageToHumanAgent) { + this.messageToHumanAgent = messageToHumanAgent; + return this; + } + + /** + * Set the agentAvailable. + * + * @param agentAvailable the agentAvailable + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder agentAvailable(AgentAvailabilityMessage agentAvailable) { + this.agentAvailable = agentAvailable; + return this; + } + + /** + * Set the agentUnavailable. + * + * @param agentUnavailable the agentUnavailable + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder agentUnavailable(AgentAvailabilityMessage agentUnavailable) { + this.agentUnavailable = agentUnavailable; + return this; + } + + /** + * Set the transferInfo. + * + * @param transferInfo the transferInfo + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder transferInfo(DialogNodeOutputConnectToAgentTransferInfo transferInfo) { + this.transferInfo = transferInfo; + return this; + } + + /** + * Set the topic. + * + * @param topic the topic + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder topic(String topic) { + this.topic = topic; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeConnectToAgent() {} + + protected RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + responseType = builder.responseType; + messageToHumanAgent = builder.messageToHumanAgent; + agentAvailable = builder.agentAvailable; + agentUnavailable = builder.agentUnavailable; + transferInfo = builder.transferInfo; + topic = builder.topic; + dialogNode = builder.dialogNode; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public DialogNodeOutputConnectToAgentTransferInfo transferInfo() { + return transferInfo; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeIframe.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeIframe.java new file mode 100644 index 00000000000..b5e957ea026 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeIframe.java @@ -0,0 +1,174 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeIframe. */ +public class RuntimeResponseGenericRuntimeResponseTypeIframe extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private String imageUrl; + private List channels; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypeIframe + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeIframe the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeIframe) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeIframe.responseType; + this.source = runtimeResponseGenericRuntimeResponseTypeIframe.source; + this.title = runtimeResponseGenericRuntimeResponseTypeIframe.title; + this.description = runtimeResponseGenericRuntimeResponseTypeIframe.description; + this.imageUrl = runtimeResponseGenericRuntimeResponseTypeIframe.imageUrl; + this.channels = runtimeResponseGenericRuntimeResponseTypeIframe.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeIframe. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeIframe instance + */ + public RuntimeResponseGenericRuntimeResponseTypeIframe build() { + return new RuntimeResponseGenericRuntimeResponseTypeIframe(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the imageUrl. + * + * @param imageUrl the imageUrl + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder imageUrl(String imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeIframe() {} + + protected RuntimeResponseGenericRuntimeResponseTypeIframe(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + imageUrl = builder.imageUrl; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeIframe builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImage.java new file mode 100644 index 00000000000..92932326b25 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImage.java @@ -0,0 +1,174 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeImage. */ +public class RuntimeResponseGenericRuntimeResponseTypeImage extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private List channels; + private String altText; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypeImage + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeImage the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeImage) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeImage.responseType; + this.source = runtimeResponseGenericRuntimeResponseTypeImage.source; + this.title = runtimeResponseGenericRuntimeResponseTypeImage.title; + this.description = runtimeResponseGenericRuntimeResponseTypeImage.description; + this.channels = runtimeResponseGenericRuntimeResponseTypeImage.channels; + this.altText = runtimeResponseGenericRuntimeResponseTypeImage.altText; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeImage. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeImage instance + */ + public RuntimeResponseGenericRuntimeResponseTypeImage build() { + return new RuntimeResponseGenericRuntimeResponseTypeImage(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the altText. + * + * @param altText the altText + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder altText(String altText) { + this.altText = altText; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeImage() {} + + protected RuntimeResponseGenericRuntimeResponseTypeImage(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + channels = builder.channels; + altText = builder.altText; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOption.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOption.java new file mode 100644 index 00000000000..b087b49a816 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOption.java @@ -0,0 +1,201 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeOption. */ +public class RuntimeResponseGenericRuntimeResponseTypeOption extends RuntimeResponseGeneric { + + /** The preferred type of control to display. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String title; + private String description; + private String preference; + private List options; + private List channels; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypeOption + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeOption the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeOption) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeOption.responseType; + this.title = runtimeResponseGenericRuntimeResponseTypeOption.title; + this.description = runtimeResponseGenericRuntimeResponseTypeOption.description; + this.preference = runtimeResponseGenericRuntimeResponseTypeOption.preference; + this.options = runtimeResponseGenericRuntimeResponseTypeOption.options; + this.channels = runtimeResponseGenericRuntimeResponseTypeOption.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param title the title + * @param options the options + */ + public Builder( + String responseType, String title, List options) { + this.responseType = responseType; + this.title = title; + this.options = options; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeOption. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeOption instance + */ + public RuntimeResponseGenericRuntimeResponseTypeOption build() { + return new RuntimeResponseGenericRuntimeResponseTypeOption(this); + } + + /** + * Adds a new element to options. + * + * @param options the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder addOptions(DialogNodeOutputOptionsElement options) { + com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); + if (this.options == null) { + this.options = new ArrayList(); + } + this.options.add(options); + return this; + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the preference. + * + * @param preference the preference + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder preference(String preference) { + this.preference = preference; + return this; + } + + /** + * Set the options. Existing options will be replaced. + * + * @param options the options + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder options(List options) { + this.options = options; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeOption() {} + + protected RuntimeResponseGenericRuntimeResponseTypeOption(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.options, "options cannot be null"); + responseType = builder.responseType; + title = builder.title; + description = builder.description; + preference = builder.preference; + options = builder.options; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePause.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePause.java new file mode 100644 index 00000000000..be94efe951a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePause.java @@ -0,0 +1,146 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypePause. */ +public class RuntimeResponseGenericRuntimeResponseTypePause extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private Long time; + private Boolean typing; + private List channels; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypePause + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypePause the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypePause) { + this.responseType = runtimeResponseGenericRuntimeResponseTypePause.responseType; + this.time = runtimeResponseGenericRuntimeResponseTypePause.time; + this.typing = runtimeResponseGenericRuntimeResponseTypePause.typing; + this.channels = runtimeResponseGenericRuntimeResponseTypePause.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param time the time + */ + public Builder(String responseType, Long time) { + this.responseType = responseType; + this.time = time; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypePause. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypePause instance + */ + public RuntimeResponseGenericRuntimeResponseTypePause build() { + return new RuntimeResponseGenericRuntimeResponseTypePause(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the time. + * + * @param time the time + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder time(long time) { + this.time = time; + return this; + } + + /** + * Set the typing. + * + * @param typing the typing + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder typing(Boolean typing) { + this.typing = typing; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypePause() {} + + protected RuntimeResponseGenericRuntimeResponseTypePause(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.time, "time cannot be null"); + responseType = builder.responseType; + time = builder.time; + typing = builder.typing; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java new file mode 100644 index 00000000000..d3554705d77 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeSuggestion. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestion extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String title; + private List suggestions; + private List channels; + + /** + * Instantiates a new Builder from an existing + * RuntimeResponseGenericRuntimeResponseTypeSuggestion instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeSuggestion the instance to initialize the + * Builder with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeSuggestion) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeSuggestion.responseType; + this.title = runtimeResponseGenericRuntimeResponseTypeSuggestion.title; + this.suggestions = runtimeResponseGenericRuntimeResponseTypeSuggestion.suggestions; + this.channels = runtimeResponseGenericRuntimeResponseTypeSuggestion.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param title the title + * @param suggestions the suggestions + */ + public Builder(String responseType, String title, List suggestions) { + this.responseType = responseType; + this.title = title; + this.suggestions = suggestions; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeSuggestion. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeSuggestion instance + */ + public RuntimeResponseGenericRuntimeResponseTypeSuggestion build() { + return new RuntimeResponseGenericRuntimeResponseTypeSuggestion(this); + } + + /** + * Adds a new element to suggestions. + * + * @param suggestions the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder addSuggestions(DialogSuggestion suggestions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(suggestions, "suggestions cannot be null"); + if (this.suggestions == null) { + this.suggestions = new ArrayList(); + } + this.suggestions.add(suggestions); + return this; + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the suggestions. Existing suggestions will be replaced. + * + * @param suggestions the suggestions + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder suggestions(List suggestions) { + this.suggestions = suggestions; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeSuggestion() {} + + protected RuntimeResponseGenericRuntimeResponseTypeSuggestion(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.suggestions, "suggestions cannot be null"); + responseType = builder.responseType; + title = builder.title; + suggestions = builder.suggestions; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeText.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeText.java new file mode 100644 index 00000000000..af0a6ca0a55 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeText.java @@ -0,0 +1,132 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** RuntimeResponseGenericRuntimeResponseTypeText. */ +public class RuntimeResponseGenericRuntimeResponseTypeText extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String text; + private List channels; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypeText + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeText the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeText) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeText.responseType; + this.text = runtimeResponseGenericRuntimeResponseTypeText.text; + this.channels = runtimeResponseGenericRuntimeResponseTypeText.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param text the text + */ + public Builder(String responseType, String text) { + this.responseType = responseType; + this.text = text; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeText. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeText instance + */ + public RuntimeResponseGenericRuntimeResponseTypeText build() { + return new RuntimeResponseGenericRuntimeResponseTypeText(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeText() {} + + protected RuntimeResponseGenericRuntimeResponseTypeText(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + responseType = builder.responseType; + text = builder.text; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeUserDefined.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeUserDefined.java new file mode 100644 index 00000000000..ec17b5eee82 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeUserDefined.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** RuntimeResponseGenericRuntimeResponseTypeUserDefined. */ +public class RuntimeResponseGenericRuntimeResponseTypeUserDefined extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private Map userDefined; + private List channels; + + /** + * Instantiates a new Builder from an existing + * RuntimeResponseGenericRuntimeResponseTypeUserDefined instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeUserDefined the instance to initialize the + * Builder with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeUserDefined) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeUserDefined.responseType; + this.userDefined = runtimeResponseGenericRuntimeResponseTypeUserDefined.userDefined; + this.channels = runtimeResponseGenericRuntimeResponseTypeUserDefined.channels; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param userDefined the userDefined + */ + public Builder(String responseType, Map userDefined) { + this.responseType = responseType; + this.userDefined = userDefined; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeUserDefined. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeUserDefined instance + */ + public RuntimeResponseGenericRuntimeResponseTypeUserDefined build() { + return new RuntimeResponseGenericRuntimeResponseTypeUserDefined(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeUserDefined builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeUserDefined builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the RuntimeResponseGenericRuntimeResponseTypeUserDefined builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeUserDefined builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeUserDefined() {} + + protected RuntimeResponseGenericRuntimeResponseTypeUserDefined(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.userDefined, "userDefined cannot be null"); + responseType = builder.responseType; + userDefined = builder.userDefined; + channels = builder.channels; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeUserDefined builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeVideo.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeVideo.java new file mode 100644 index 00000000000..ce94e813f28 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeVideo.java @@ -0,0 +1,189 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** RuntimeResponseGenericRuntimeResponseTypeVideo. */ +public class RuntimeResponseGenericRuntimeResponseTypeVideo extends RuntimeResponseGeneric { + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + private List channels; + private Map channelOptions; + private String altText; + + /** + * Instantiates a new Builder from an existing RuntimeResponseGenericRuntimeResponseTypeVideo + * instance. + * + * @param runtimeResponseGenericRuntimeResponseTypeVideo the instance to initialize the Builder + * with + */ + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeVideo) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeVideo.responseType; + this.source = runtimeResponseGenericRuntimeResponseTypeVideo.source; + this.title = runtimeResponseGenericRuntimeResponseTypeVideo.title; + this.description = runtimeResponseGenericRuntimeResponseTypeVideo.description; + this.channels = runtimeResponseGenericRuntimeResponseTypeVideo.channels; + this.channelOptions = runtimeResponseGenericRuntimeResponseTypeVideo.channelOptions; + this.altText = runtimeResponseGenericRuntimeResponseTypeVideo.altText; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeVideo. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeVideo instance + */ + public RuntimeResponseGenericRuntimeResponseTypeVideo build() { + return new RuntimeResponseGenericRuntimeResponseTypeVideo(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder addChannels(ResponseGenericChannel channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the channels. Existing channels will be replaced. + * + * @param channels the channels + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the channelOptions. + * + * @param channelOptions the channelOptions + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder channelOptions(Map channelOptions) { + this.channelOptions = channelOptions; + return this; + } + + /** + * Set the altText. + * + * @param altText the altText + * @return the RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder altText(String altText) { + this.altText = altText; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeVideo() {} + + protected RuntimeResponseGenericRuntimeResponseTypeVideo(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + channels = builder.channels; + channelOptions = builder.channelOptions; + altText = builder.altText; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeVideo builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/StatusError.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/StatusError.java new file mode 100644 index 00000000000..68a23b7e88d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/StatusError.java @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object describing an error that occurred during processing of an asynchronous operation. */ +public class StatusError extends GenericModel { + + protected String message; + + /** Builder. */ + public static class Builder { + private String message; + + /** + * Instantiates a new Builder from an existing StatusError instance. + * + * @param statusError the instance to initialize the Builder with + */ + private Builder(StatusError statusError) { + this.message = statusError.message; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatusError. + * + * @return the new StatusError instance + */ + public StatusError build() { + return new StatusError(this); + } + + /** + * Set the message. + * + * @param message the message + * @return the StatusError builder + */ + public Builder message(String message) { + this.message = message; + return this; + } + } + + protected StatusError() {} + + protected StatusError(Builder builder) { + message = builder.message; + } + + /** + * New builder. + * + * @return a StatusError builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the message. + * + *

The text of the error message. + * + * @return the message + */ + public String message() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java index f637345763e..6860d79e61e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,40 +10,34 @@ * 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.assistant.v1.model; -import java.util.Date; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; -/** - * Synonym. - */ +/** Synonym. */ public class Synonym extends GenericModel { protected String synonym; protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String synonym; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing Synonym instance. + * + * @param synonym the instance to initialize the Builder with + */ private Builder(Synonym synonym) { this.synonym = synonym.synonym; - this.created = synonym.created; - this.updated = synonym.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,7 +51,7 @@ public Builder(String synonym) { /** * Builds a Synonym. * - * @return the synonym + * @return the new Synonym instance */ public Synonym build() { return new Synonym(this); @@ -73,36 +67,13 @@ public Builder synonym(String synonym) { this.synonym = synonym; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Synonym builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Synonym builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected Synonym() {} + protected Synonym(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.synonym, - "synonym cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.synonym, "synonym cannot be null"); synonym = builder.synonym; - created = builder.created; - updated = builder.updated; } /** @@ -117,9 +88,9 @@ public Builder newBuilder() { /** * Gets the synonym. * - * The text of the synonym. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the synonym. This string must conform to the following restrictions: - It cannot + * contain carriage return, newline, or tab characters. - It cannot consist of only whitespace + * characters. * * @return the synonym */ @@ -130,7 +101,7 @@ public String synonym() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -141,7 +112,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java index 9a8571c9b20..54f547936b8 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * SynonymCollection. - */ +/** SynonymCollection. */ public class SynonymCollection extends GenericModel { protected List synonyms; protected Pagination pagination; + protected SynonymCollection() {} + /** * Gets the synonyms. * - * An array of synonyms. + *

An array of synonyms. * * @return the synonyms */ @@ -38,7 +38,8 @@ public List getSynonyms() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SystemResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SystemResponse.java deleted file mode 100644 index 82f988db403..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SystemResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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.assistant.v1.model; - -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; - -/** - * For internal use only. - */ -public class SystemResponse extends DynamicModel { - - public SystemResponse() { - super(new TypeToken() { - }); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java index 2dd7b9099d4..accef10adc3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The updateCounterexample options. - */ +/** The updateCounterexample options. */ public class UpdateCounterexampleOptions extends GenericModel { protected String workspaceId; @@ -24,15 +23,18 @@ public class UpdateCounterexampleOptions extends GenericModel { protected String newText; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String text; private String newText; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateCounterexampleOptions instance. + * + * @param updateCounterexampleOptions the instance to initialize the Builder with + */ private Builder(UpdateCounterexampleOptions updateCounterexampleOptions) { this.workspaceId = updateCounterexampleOptions.workspaceId; this.text = updateCounterexampleOptions.text; @@ -40,11 +42,8 @@ private Builder(UpdateCounterexampleOptions updateCounterexampleOptions) { this.includeAudit = updateCounterexampleOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -60,7 +59,7 @@ public Builder(String workspaceId, String text) { /** * Builds a UpdateCounterexampleOptions. * - * @return the updateCounterexampleOptions + * @return the new UpdateCounterexampleOptions instance */ public UpdateCounterexampleOptions build() { return new UpdateCounterexampleOptions(this); @@ -111,11 +110,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateCounterexampleOptions() {} + protected UpdateCounterexampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, - "text cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, "text cannot be empty"); workspaceId = builder.workspaceId; text = builder.text; newText = builder.newText; @@ -134,7 +134,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -145,7 +145,7 @@ public String workspaceId() { /** * Gets the text. * - * The text of a user input counterexample (for example, `What are you wearing?`). + *

The text of a user input counterexample (for example, `What are you wearing?`). * * @return the text */ @@ -156,9 +156,9 @@ public String text() { /** * Gets the newText. * - * The text of a user input marked as irrelevant input. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of a user input marked as irrelevant input. This string must conform to the + * following restrictions: - It cannot contain carriage return, newline, or tab characters. - It + * cannot consist of only whitespace characters. * * @return the newText */ @@ -169,7 +169,8 @@ public String newText() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java new file mode 100644 index 00000000000..68ea6392c24 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java @@ -0,0 +1,728 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** UpdateDialogNode. */ +public class UpdateDialogNode extends GenericModel { + + /** How the dialog node is processed. */ + public interface Type { + /** standard. */ + String STANDARD = "standard"; + /** event_handler. */ + String EVENT_HANDLER = "event_handler"; + /** frame. */ + String FRAME = "frame"; + /** slot. */ + String SLOT = "slot"; + /** response_condition. */ + String RESPONSE_CONDITION = "response_condition"; + /** folder. */ + String FOLDER = "folder"; + } + + /** How an `event_handler` node is processed. */ + public interface EventName { + /** focus. */ + String FOCUS = "focus"; + /** input. */ + String INPUT = "input"; + /** filled. */ + String FILLED = "filled"; + /** validate. */ + String VALIDATE = "validate"; + /** filled_multiple. */ + String FILLED_MULTIPLE = "filled_multiple"; + /** generic. */ + String GENERIC = "generic"; + /** nomatch. */ + String NOMATCH = "nomatch"; + /** nomatch_responses_depleted. */ + String NOMATCH_RESPONSES_DEPLETED = "nomatch_responses_depleted"; + /** digression_return_prompt. */ + String DIGRESSION_RETURN_PROMPT = "digression_return_prompt"; + } + + /** Whether this top-level dialog node can be digressed into. */ + public interface DigressIn { + /** not_available. */ + String NOT_AVAILABLE = "not_available"; + /** returns. */ + String RETURNS = "returns"; + /** does_not_return. */ + String DOES_NOT_RETURN = "does_not_return"; + } + + /** Whether this dialog node can be returned to after a digression. */ + public interface DigressOut { + /** allow_returning. */ + String ALLOW_RETURNING = "allow_returning"; + /** allow_all. */ + String ALLOW_ALL = "allow_all"; + /** allow_all_never_return. */ + String ALLOW_ALL_NEVER_RETURN = "allow_all_never_return"; + } + + /** Whether the user can digress to top-level nodes while filling out slots. */ + public interface DigressOutSlots { + /** not_allowed. */ + String NOT_ALLOWED = "not_allowed"; + /** allow_returning. */ + String ALLOW_RETURNING = "allow_returning"; + /** allow_all. */ + String ALLOW_ALL = "allow_all"; + } + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String description; + protected String conditions; + protected String parent; + + @SerializedName("previous_sibling") + protected String previousSibling; + + protected DialogNodeOutput output; + protected DialogNodeContext context; + protected Map metadata; + + @SerializedName("next_step") + protected DialogNodeNextStep nextStep; + + protected String title; + protected String type; + + @SerializedName("event_name") + protected String eventName; + + protected String variable; + protected List actions; + + @SerializedName("digress_in") + protected String digressIn; + + @SerializedName("digress_out") + protected String digressOut; + + @SerializedName("digress_out_slots") + protected String digressOutSlots; + + @SerializedName("user_label") + protected String userLabel; + + @SerializedName("disambiguation_opt_out") + protected Boolean disambiguationOptOut; + + protected Boolean disabled; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String dialogNode; + private String description; + private String conditions; + private String parent; + private String previousSibling; + private DialogNodeOutput output; + private DialogNodeContext context; + private Map metadata; + private DialogNodeNextStep nextStep; + private String title; + private String type; + private String eventName; + private String variable; + private List actions; + private String digressIn; + private String digressOut; + private String digressOutSlots; + private String userLabel; + private Boolean disambiguationOptOut; + + private Builder(UpdateDialogNode updateDialogNode) { + this.dialogNode = updateDialogNode.dialogNode; + this.description = updateDialogNode.description; + this.conditions = updateDialogNode.conditions; + this.parent = updateDialogNode.parent; + this.previousSibling = updateDialogNode.previousSibling; + this.output = updateDialogNode.output; + this.context = updateDialogNode.context; + this.metadata = updateDialogNode.metadata; + this.nextStep = updateDialogNode.nextStep; + this.title = updateDialogNode.title; + this.type = updateDialogNode.type; + this.eventName = updateDialogNode.eventName; + this.variable = updateDialogNode.variable; + this.actions = updateDialogNode.actions; + this.digressIn = updateDialogNode.digressIn; + this.digressOut = updateDialogNode.digressOut; + this.digressOutSlots = updateDialogNode.digressOutSlots; + this.userLabel = updateDialogNode.userLabel; + this.disambiguationOptOut = updateDialogNode.disambiguationOptOut; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a UpdateDialogNode. + * + * @return the new UpdateDialogNode instance + */ + public UpdateDialogNode build() { + return new UpdateDialogNode(this); + } + + /** + * Adds an actions to actions. + * + * @param actions the new actions + * @return the UpdateDialogNode builder + */ + public Builder addActions(DialogNodeAction actions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(actions, "actions cannot be null"); + if (this.actions == null) { + this.actions = new ArrayList(); + } + this.actions.add(actions); + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the UpdateDialogNode builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateDialogNode builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the conditions. + * + * @param conditions the conditions + * @return the UpdateDialogNode builder + */ + public Builder conditions(String conditions) { + this.conditions = conditions; + return this; + } + + /** + * Set the parent. + * + * @param parent the parent + * @return the UpdateDialogNode builder + */ + public Builder parent(String parent) { + this.parent = parent; + return this; + } + + /** + * Set the previousSibling. + * + * @param previousSibling the previousSibling + * @return the UpdateDialogNode builder + */ + public Builder previousSibling(String previousSibling) { + this.previousSibling = previousSibling; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the UpdateDialogNode builder + */ + public Builder output(DialogNodeOutput output) { + this.output = output; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the UpdateDialogNode builder + */ + public Builder context(DialogNodeContext context) { + this.context = context; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the UpdateDialogNode builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the nextStep. + * + * @param nextStep the nextStep + * @return the UpdateDialogNode builder + */ + public Builder nextStep(DialogNodeNextStep nextStep) { + this.nextStep = nextStep; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the UpdateDialogNode builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the UpdateDialogNode builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the eventName. + * + * @param eventName the eventName + * @return the UpdateDialogNode builder + */ + public Builder eventName(String eventName) { + this.eventName = eventName; + return this; + } + + /** + * Set the variable. + * + * @param variable the variable + * @return the UpdateDialogNode builder + */ + public Builder variable(String variable) { + this.variable = variable; + return this; + } + + /** + * Set the actions. Existing actions will be replaced. + * + * @param actions the actions + * @return the UpdateDialogNode builder + */ + public Builder actions(List actions) { + this.actions = actions; + return this; + } + + /** + * Set the digressIn. + * + * @param digressIn the digressIn + * @return the UpdateDialogNode builder + */ + public Builder digressIn(String digressIn) { + this.digressIn = digressIn; + return this; + } + + /** + * Set the digressOut. + * + * @param digressOut the digressOut + * @return the UpdateDialogNode builder + */ + public Builder digressOut(String digressOut) { + this.digressOut = digressOut; + return this; + } + + /** + * Set the digressOutSlots. + * + * @param digressOutSlots the digressOutSlots + * @return the UpdateDialogNode builder + */ + public Builder digressOutSlots(String digressOutSlots) { + this.digressOutSlots = digressOutSlots; + return this; + } + + /** + * Set the userLabel. + * + * @param userLabel the userLabel + * @return the UpdateDialogNode builder + */ + public Builder userLabel(String userLabel) { + this.userLabel = userLabel; + return this; + } + + /** + * Set the disambiguationOptOut. + * + * @param disambiguationOptOut the disambiguationOptOut + * @return the UpdateDialogNode builder + */ + public Builder disambiguationOptOut(Boolean disambiguationOptOut) { + this.disambiguationOptOut = disambiguationOptOut; + return this; + } + } + + protected UpdateDialogNode(Builder builder) { + dialogNode = builder.dialogNode; + description = builder.description; + conditions = builder.conditions; + parent = builder.parent; + previousSibling = builder.previousSibling; + output = builder.output; + context = builder.context; + metadata = builder.metadata; + nextStep = builder.nextStep; + title = builder.title; + type = builder.type; + eventName = builder.eventName; + variable = builder.variable; + actions = builder.actions; + digressIn = builder.digressIn; + digressOut = builder.digressOut; + digressOutSlots = builder.digressOutSlots; + userLabel = builder.userLabel; + disambiguationOptOut = builder.disambiguationOptOut; + } + + /** + * New builder. + * + * @return a UpdateDialogNode builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the dialogNode. + * + *

The unique ID of the dialog node. This is an internal identifier used to refer to the dialog + * node from other dialog nodes and in the diagnostic information included with message responses. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. + * + * @return the dialogNode + */ + public String dialogNode() { + return dialogNode; + } + + /** + * Gets the description. + * + *

The description of the dialog node. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the conditions. + * + *

The condition that will trigger the dialog node. This string cannot contain carriage return, + * newline, or tab characters. + * + * @return the conditions + */ + public String conditions() { + return conditions; + } + + /** + * Gets the parent. + * + *

The unique ID of the parent dialog node. This property is omitted if the dialog node has no + * parent. + * + * @return the parent + */ + public String parent() { + return parent; + } + + /** + * Gets the previousSibling. + * + *

The unique ID of the previous sibling dialog node. This property is omitted if the dialog + * node has no previous sibling. + * + * @return the previousSibling + */ + public String previousSibling() { + return previousSibling; + } + + /** + * Gets the output. + * + *

The output of the dialog node. For more information about how to specify dialog node output, + * see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). + * + * @return the output + */ + public DialogNodeOutput output() { + return output; + } + + /** + * Gets the context. + * + *

The context for the dialog node. + * + * @return the context + */ + public DialogNodeContext context() { + return context; + } + + /** + * Gets the metadata. + * + *

The metadata for the dialog node. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the nextStep. + * + *

The next step to execute following this dialog node. + * + * @return the nextStep + */ + public DialogNodeNextStep nextStep() { + return nextStep; + } + + /** + * Gets the title. + * + *

A human-readable name for the dialog node. If the node is included in disambiguation, this + * title is used to populate the **label** property of the corresponding suggestion in the + * `suggestion` response type (unless it is overridden by the **user_label** property). The title + * is also used to populate the **topic** property in the `connect_to_agent` response type. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. + * + * @return the title + */ + public String title() { + return title; + } + + /** + * Gets the type. + * + *

How the dialog node is processed. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the eventName. + * + *

How an `event_handler` node is processed. + * + * @return the eventName + */ + public String eventName() { + return eventName; + } + + /** + * Gets the variable. + * + *

The location in the dialog context where output is stored. + * + * @return the variable + */ + public String variable() { + return variable; + } + + /** + * Gets the actions. + * + *

An array of objects describing any actions to be invoked by the dialog node. + * + * @return the actions + */ + public List actions() { + return actions; + } + + /** + * Gets the digressIn. + * + *

Whether this top-level dialog node can be digressed into. + * + * @return the digressIn + */ + public String digressIn() { + return digressIn; + } + + /** + * Gets the digressOut. + * + *

Whether this dialog node can be returned to after a digression. + * + * @return the digressOut + */ + public String digressOut() { + return digressOut; + } + + /** + * Gets the digressOutSlots. + * + *

Whether the user can digress to top-level nodes while filling out slots. + * + * @return the digressOutSlots + */ + public String digressOutSlots() { + return digressOutSlots; + } + + /** + * Gets the userLabel. + * + *

A label that can be displayed externally to describe the purpose of the node to users. If + * set, this label is used to identify the node in disambiguation responses (overriding the value + * of the **title** property). + * + * @return the userLabel + */ + public String userLabel() { + return userLabel; + } + + /** + * Gets the disambiguationOptOut. + * + *

Whether the dialog node should be excluded from disambiguation suggestions. Valid only when + * **type**=`standard` or `frame`. + * + * @return the disambiguationOptOut + */ + public Boolean disambiguationOptOut() { + return disambiguationOptOut; + } + + /** + * Gets the disabled. + * + *

For internal use only. + * + * @return the disabled + */ + public Boolean disabled() { + return disabled; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date created() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date updated() { + return updated; + } + + /** + * Construct a JSON merge-patch from the UpdateDialogNode. + * + *

Note that properties of the UpdateDialogNode with null values are not represented in the + * constructed JSON merge-patch object, but can be explicitly set afterward to signify a property + * delete. + * + * @return a JSON merge-patch for the UpdateDialogNode + */ + public Map asPatch() { + return GsonSingleton.getGsonWithSerializeNulls().fromJson(this.toString(), Map.class); + } + + public String toString() { + return GsonSingleton.getGsonWithSerializeNulls().toJson(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java new file mode 100644 index 00000000000..336e522358e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java @@ -0,0 +1,181 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** The updateDialogNodeNullable options. */ +public class UpdateDialogNodeNullableOptions extends GenericModel { + + protected String workspaceId; + protected String dialogNode; + protected Map body; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String dialogNode; + private Map body; + private Boolean includeAudit; + + private Builder(UpdateDialogNodeNullableOptions updateDialogNodeNullableOptions) { + this.workspaceId = updateDialogNodeNullableOptions.workspaceId; + this.dialogNode = updateDialogNodeNullableOptions.dialogNode; + this.body = updateDialogNodeNullableOptions.body; + this.includeAudit = updateDialogNodeNullableOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param dialogNode the dialogNode + * @param body the body + */ + public Builder(String workspaceId, String dialogNode, Map body) { + this.workspaceId = workspaceId; + this.dialogNode = dialogNode; + this.body = body; + } + + /** + * Builds a UpdateDialogNodeNullableOptions. + * + * @return the new UpdateDialogNodeNullableOptions instance + */ + public UpdateDialogNodeNullableOptions build() { + return new UpdateDialogNodeNullableOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the body. + * + * @param body the body + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder body(Map body) { + this.body = body; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected UpdateDialogNodeNullableOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.dialogNode, "dialogNode cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.body, "body cannot be null"); + workspaceId = builder.workspaceId; + dialogNode = builder.dialogNode; + body = builder.body; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateDialogNodeNullableOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the dialogNode. + * + *

The dialog node ID (for example, `node_1_1479323581900`). + * + * @return the dialogNode + */ + public String dialogNode() { + return dialogNode; + } + + /** + * Gets the body. + * + *

The updated content of the dialog node. + * + *

Any elements included in the new data will completely replace the equivalent existing + * elements, including all subelements. (Previously existing subelements are not retained unless + * they are also included in the new data.) For example, if you update the actions for a dialog + * node, the previously existing actions are discarded and replaced with the new actions specified + * in the update. + * + * @return the body + */ + public Map body() { + return body; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java index 1576799b35a..a0a29569b51 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,22 +10,18 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateDialogNode options. - */ +/** The updateDialogNode options. */ public class UpdateDialogNodeOptions extends GenericModel { - /** - * How the dialog node is processed. - */ + /** How the dialog node is processed. */ public interface NewType { /** standard. */ String STANDARD = "standard"; @@ -41,9 +37,7 @@ public interface NewType { String FOLDER = "folder"; } - /** - * How an `event_handler` node is processed. - */ + /** How an `event_handler` node is processed. */ public interface NewEventName { /** focus. */ String FOCUS = "focus"; @@ -65,9 +59,7 @@ public interface NewEventName { String DIGRESSION_RETURN_PROMPT = "digression_return_prompt"; } - /** - * Whether this top-level dialog node can be digressed into. - */ + /** Whether this top-level dialog node can be digressed into. */ public interface NewDigressIn { /** not_available. */ String NOT_AVAILABLE = "not_available"; @@ -77,9 +69,7 @@ public interface NewDigressIn { String DOES_NOT_RETURN = "does_not_return"; } - /** - * Whether this dialog node can be returned to after a digression. - */ + /** Whether this dialog node can be returned to after a digression. */ public interface NewDigressOut { /** allow_returning. */ String ALLOW_RETURNING = "allow_returning"; @@ -89,9 +79,7 @@ public interface NewDigressOut { String ALLOW_ALL_NEVER_RETURN = "allow_all_never_return"; } - /** - * Whether the user can digress to top-level nodes while filling out slots. - */ + /** Whether the user can digress to top-level nodes while filling out slots. */ public interface NewDigressOutSlots { /** not_allowed. */ String NOT_ALLOWED = "not_allowed"; @@ -109,7 +97,7 @@ public interface NewDigressOutSlots { protected String newParent; protected String newPreviousSibling; protected DialogNodeOutput newOutput; - protected Map newContext; + protected DialogNodeContext newContext; protected Map newMetadata; protected DialogNodeNextStep newNextStep; protected String newTitle; @@ -124,9 +112,7 @@ public interface NewDigressOutSlots { protected Boolean newDisambiguationOptOut; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String dialogNode; @@ -136,7 +122,7 @@ public static class Builder { private String newParent; private String newPreviousSibling; private DialogNodeOutput newOutput; - private Map newContext; + private DialogNodeContext newContext; private Map newMetadata; private DialogNodeNextStep newNextStep; private String newTitle; @@ -151,6 +137,11 @@ public static class Builder { private Boolean newDisambiguationOptOut; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateDialogNodeOptions instance. + * + * @param updateDialogNodeOptions the instance to initialize the Builder with + */ private Builder(UpdateDialogNodeOptions updateDialogNodeOptions) { this.workspaceId = updateDialogNodeOptions.workspaceId; this.dialogNode = updateDialogNodeOptions.dialogNode; @@ -176,11 +167,8 @@ private Builder(UpdateDialogNodeOptions updateDialogNodeOptions) { this.includeAudit = updateDialogNodeOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -196,21 +184,20 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a UpdateDialogNodeOptions. * - * @return the updateDialogNodeOptions + * @return the new UpdateDialogNodeOptions instance */ public UpdateDialogNodeOptions build() { return new UpdateDialogNodeOptions(this); } /** - * Adds an newActions to newActions. + * Adds a new element to newActions. * - * @param newActions the new newActions + * @param newActions the new element to be added * @return the UpdateDialogNodeOptions builder */ public Builder addNewActions(DialogNodeAction newActions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(newActions, - "newActions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(newActions, "newActions cannot be null"); if (this.newActions == null) { this.newActions = new ArrayList(); } @@ -312,7 +299,7 @@ public Builder newOutput(DialogNodeOutput newOutput) { * @param newContext the newContext * @return the UpdateDialogNodeOptions builder */ - public Builder newContext(Map newContext) { + public Builder newContext(DialogNodeContext newContext) { this.newContext = newContext; return this; } @@ -384,8 +371,7 @@ public Builder newVariable(String newVariable) { } /** - * Set the newActions. - * Existing newActions will be replaced. + * Set the newActions. Existing newActions will be replaced. * * @param newActions the newActions * @return the UpdateDialogNodeOptions builder @@ -462,11 +448,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateDialogNodeOptions() {} + protected UpdateDialogNodeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.dialogNode, - "dialogNode cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.dialogNode, "dialogNode cannot be empty"); workspaceId = builder.workspaceId; dialogNode = builder.dialogNode; newDialogNode = builder.newDialogNode; @@ -503,7 +491,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -514,7 +502,7 @@ public String workspaceId() { /** * Gets the dialogNode. * - * The dialog node ID (for example, `get_order`). + *

The dialog node ID (for example, `node_1_1479323581900`). * * @return the dialogNode */ @@ -525,8 +513,11 @@ public String dialogNode() { /** * Gets the newDialogNode. * - * The dialog node ID. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. + *

The unique ID of the dialog node. This is an internal identifier used to refer to the dialog + * node from other dialog nodes and in the diagnostic information included with message responses. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. * * @return the newDialogNode */ @@ -537,7 +528,8 @@ public String newDialogNode() { /** * Gets the newDescription. * - * The description of the dialog node. This string cannot contain carriage return, newline, or tab characters. + *

The description of the dialog node. This string cannot contain carriage return, newline, or + * tab characters. * * @return the newDescription */ @@ -548,8 +540,8 @@ public String newDescription() { /** * Gets the newConditions. * - * The condition that will trigger the dialog node. This string cannot contain carriage return, newline, or tab - * characters. + *

The condition that will trigger the dialog node. This string cannot contain carriage return, + * newline, or tab characters. * * @return the newConditions */ @@ -560,7 +552,8 @@ public String newConditions() { /** * Gets the newParent. * - * The ID of the parent dialog node. This property is omitted if the dialog node has no parent. + *

The unique ID of the parent dialog node. This property is omitted if the dialog node has no + * parent. * * @return the newParent */ @@ -571,7 +564,8 @@ public String newParent() { /** * Gets the newPreviousSibling. * - * The ID of the previous sibling dialog node. This property is omitted if the dialog node has no previous sibling. + *

The unique ID of the previous sibling dialog node. This property is omitted if the dialog + * node has no previous sibling. * * @return the newPreviousSibling */ @@ -582,7 +576,8 @@ public String newPreviousSibling() { /** * Gets the newOutput. * - * The output of the dialog node. For more information about how to specify dialog node output, see the + *

The output of the dialog node. For more information about how to specify dialog node output, + * see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). * * @return the newOutput @@ -594,18 +589,18 @@ public DialogNodeOutput newOutput() { /** * Gets the newContext. * - * The context for the dialog node. + *

The context for the dialog node. * * @return the newContext */ - public Map newContext() { + public DialogNodeContext newContext() { return newContext; } /** * Gets the newMetadata. * - * The metadata for the dialog node. + *

The metadata for the dialog node. * * @return the newMetadata */ @@ -616,7 +611,7 @@ public Map newMetadata() { /** * Gets the newNextStep. * - * The next step to execute following this dialog node. + *

The next step to execute following this dialog node. * * @return the newNextStep */ @@ -627,8 +622,13 @@ public DialogNodeNextStep newNextStep() { /** * Gets the newTitle. * - * The alias used to identify the dialog node. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. + *

A human-readable name for the dialog node. If the node is included in disambiguation, this + * title is used to populate the **label** property of the corresponding suggestion in the + * `suggestion` response type (unless it is overridden by the **user_label** property). The title + * is also used to populate the **topic** property in the `connect_to_agent` response type. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. * * @return the newTitle */ @@ -639,7 +639,7 @@ public String newTitle() { /** * Gets the newType. * - * How the dialog node is processed. + *

How the dialog node is processed. * * @return the newType */ @@ -650,7 +650,7 @@ public String newType() { /** * Gets the newEventName. * - * How an `event_handler` node is processed. + *

How an `event_handler` node is processed. * * @return the newEventName */ @@ -661,7 +661,7 @@ public String newEventName() { /** * Gets the newVariable. * - * The location in the dialog context where output is stored. + *

The location in the dialog context where output is stored. * * @return the newVariable */ @@ -672,7 +672,7 @@ public String newVariable() { /** * Gets the newActions. * - * An array of objects describing any actions to be invoked by the dialog node. + *

An array of objects describing any actions to be invoked by the dialog node. * * @return the newActions */ @@ -683,7 +683,7 @@ public List newActions() { /** * Gets the newDigressIn. * - * Whether this top-level dialog node can be digressed into. + *

Whether this top-level dialog node can be digressed into. * * @return the newDigressIn */ @@ -694,7 +694,7 @@ public String newDigressIn() { /** * Gets the newDigressOut. * - * Whether this dialog node can be returned to after a digression. + *

Whether this dialog node can be returned to after a digression. * * @return the newDigressOut */ @@ -705,7 +705,7 @@ public String newDigressOut() { /** * Gets the newDigressOutSlots. * - * Whether the user can digress to top-level nodes while filling out slots. + *

Whether the user can digress to top-level nodes while filling out slots. * * @return the newDigressOutSlots */ @@ -716,7 +716,9 @@ public String newDigressOutSlots() { /** * Gets the newUserLabel. * - * A label that can be displayed externally to describe the purpose of the node to users. + *

A label that can be displayed externally to describe the purpose of the node to users. If + * set, this label is used to identify the node in disambiguation responses (overriding the value + * of the **title** property). * * @return the newUserLabel */ @@ -727,7 +729,8 @@ public String newUserLabel() { /** * Gets the newDisambiguationOptOut. * - * Whether the dialog node should be excluded from disambiguation suggestions. + *

Whether the dialog node should be excluded from disambiguation suggestions. Valid only when + * **type**=`standard` or `frame`. * * @return the newDisambiguationOptOut */ @@ -738,7 +741,8 @@ public Boolean newDisambiguationOptOut() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java index ca5cf87c327..5adcc616330 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,17 +10,15 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateEntity options. - */ +/** The updateEntity options. */ public class UpdateEntityOptions extends GenericModel { protected String workspaceId; @@ -33,9 +31,7 @@ public class UpdateEntityOptions extends GenericModel { protected Boolean append; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -47,6 +43,11 @@ public static class Builder { private Boolean append; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateEntityOptions instance. + * + * @param updateEntityOptions the instance to initialize the Builder with + */ private Builder(UpdateEntityOptions updateEntityOptions) { this.workspaceId = updateEntityOptions.workspaceId; this.entity = updateEntityOptions.entity; @@ -59,11 +60,8 @@ private Builder(UpdateEntityOptions updateEntityOptions) { this.includeAudit = updateEntityOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -79,21 +77,20 @@ public Builder(String workspaceId, String entity) { /** * Builds a UpdateEntityOptions. * - * @return the updateEntityOptions + * @return the new UpdateEntityOptions instance */ public UpdateEntityOptions build() { return new UpdateEntityOptions(this); } /** - * Adds an value to newValues. + * Adds a new element to newValues. * - * @param value the new value + * @param value the new element to be added * @return the UpdateEntityOptions builder */ public Builder addValue(CreateValue value) { - com.ibm.cloud.sdk.core.util.Validator.notNull(value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(value, "value cannot be null"); if (this.newValues == null) { this.newValues = new ArrayList(); } @@ -168,8 +165,7 @@ public Builder newFuzzyMatch(Boolean newFuzzyMatch) { } /** - * Set the newValues. - * Existing newValues will be replaced. + * Set the newValues. Existing newValues will be replaced. * * @param newValues the newValues * @return the UpdateEntityOptions builder @@ -202,11 +198,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateEntityOptions() {} + protected UpdateEntityOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; newEntity = builder.newEntity; @@ -230,7 +227,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -241,7 +238,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -252,9 +249,9 @@ public String entity() { /** * Gets the newEntity. * - * The name of the entity. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, and hyphen characters. - * - It cannot begin with the reserved prefix `sys-`. + *

The name of the entity. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, and hyphen characters. - It cannot begin with + * the reserved prefix `sys-`. * * @return the newEntity */ @@ -265,7 +262,8 @@ public String newEntity() { /** * Gets the newDescription. * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters. + *

The description of the entity. This string cannot contain carriage return, newline, or tab + * characters. * * @return the newDescription */ @@ -276,7 +274,7 @@ public String newDescription() { /** * Gets the newMetadata. * - * Any metadata related to the entity. + *

Any metadata related to the entity. * * @return the newMetadata */ @@ -287,7 +285,7 @@ public Map newMetadata() { /** * Gets the newFuzzyMatch. * - * Whether to use fuzzy matching for the entity. + *

Whether to use fuzzy matching for the entity. * * @return the newFuzzyMatch */ @@ -298,7 +296,7 @@ public Boolean newFuzzyMatch() { /** * Gets the newValues. * - * An array of objects describing the entity values. + *

An array of objects describing the entity values. * * @return the newValues */ @@ -309,13 +307,14 @@ public List newValues() { /** * Gets the append. * - * Whether the new data is to be appended to the existing data in the entity. If **append**=`false`, elements included - * in the new data completely replace the corresponding existing elements, including all subelements. For example, if - * the new data for the entity includes **values** and **append**=`false`, all existing values for the entity are - * discarded and replaced with the new values. + *

Whether the new data is to be appended to the existing data in the entity. If + * **append**=`false`, elements included in the new data completely replace the corresponding + * existing elements, including all subelements. For example, if the new data for the entity + * includes **values** and **append**=`false`, all existing values for the entity are discarded + * and replaced with the new values. * - * If **append**=`true`, existing elements are preserved, and the new elements are added. If any elements in the new - * data collide with existing elements, the update request fails. + *

If **append**=`true`, existing elements are preserved, and the new elements are added. If + * any elements in the new data collide with existing elements, the update request fails. * * @return the append */ @@ -326,7 +325,8 @@ public Boolean append() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java index 104e3712b0e..8de7bd36e55 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateExample options. - */ +/** The updateExample options. */ public class UpdateExampleOptions extends GenericModel { protected String workspaceId; @@ -29,9 +27,7 @@ public class UpdateExampleOptions extends GenericModel { protected List newMentions; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; @@ -40,6 +36,11 @@ public static class Builder { private List newMentions; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateExampleOptions instance. + * + * @param updateExampleOptions the instance to initialize the Builder with + */ private Builder(UpdateExampleOptions updateExampleOptions) { this.workspaceId = updateExampleOptions.workspaceId; this.intent = updateExampleOptions.intent; @@ -49,11 +50,8 @@ private Builder(UpdateExampleOptions updateExampleOptions) { this.includeAudit = updateExampleOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -71,21 +69,20 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a UpdateExampleOptions. * - * @return the updateExampleOptions + * @return the new UpdateExampleOptions instance */ public UpdateExampleOptions build() { return new UpdateExampleOptions(this); } /** - * Adds an newMentions to newMentions. + * Adds a new element to newMentions. * - * @param newMentions the new newMentions + * @param newMentions the new element to be added * @return the UpdateExampleOptions builder */ public Builder addNewMentions(Mention newMentions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(newMentions, - "newMentions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(newMentions, "newMentions cannot be null"); if (this.newMentions == null) { this.newMentions = new ArrayList(); } @@ -138,8 +135,7 @@ public Builder newText(String newText) { } /** - * Set the newMentions. - * Existing newMentions will be replaced. + * Set the newMentions. Existing newMentions will be replaced. * * @param newMentions the newMentions * @return the UpdateExampleOptions builder @@ -161,13 +157,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateExampleOptions() {} + protected UpdateExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, - "text cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.text, "text cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; text = builder.text; @@ -188,7 +184,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -199,7 +195,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -210,7 +206,7 @@ public String intent() { /** * Gets the text. * - * The text of the user input example. + *

The text of the user input example. * * @return the text */ @@ -221,9 +217,9 @@ public String text() { /** * Gets the newText. * - * The text of the user input example. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the user input example. This string must conform to the following restrictions: + * - It cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the newText */ @@ -234,7 +230,7 @@ public String newText() { /** * Gets the newMentions. * - * An array of contextual entity mentions. + *

An array of contextual entity mentions. * * @return the newMentions */ @@ -245,7 +241,8 @@ public List newMentions() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java index 1c555934e67..8a0247e3539 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateIntent options. - */ +/** The updateIntent options. */ public class UpdateIntentOptions extends GenericModel { protected String workspaceId; @@ -30,9 +28,7 @@ public class UpdateIntentOptions extends GenericModel { protected Boolean append; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String intent; @@ -42,6 +38,11 @@ public static class Builder { private Boolean append; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateIntentOptions instance. + * + * @param updateIntentOptions the instance to initialize the Builder with + */ private Builder(UpdateIntentOptions updateIntentOptions) { this.workspaceId = updateIntentOptions.workspaceId; this.intent = updateIntentOptions.intent; @@ -52,11 +53,8 @@ private Builder(UpdateIntentOptions updateIntentOptions) { this.includeAudit = updateIntentOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -72,21 +70,20 @@ public Builder(String workspaceId, String intent) { /** * Builds a UpdateIntentOptions. * - * @return the updateIntentOptions + * @return the new UpdateIntentOptions instance */ public UpdateIntentOptions build() { return new UpdateIntentOptions(this); } /** - * Adds an example to newExamples. + * Adds a new element to newExamples. * - * @param example the new example + * @param example the new element to be added * @return the UpdateIntentOptions builder */ public Builder addExample(Example example) { - com.ibm.cloud.sdk.core.util.Validator.notNull(example, - "example cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(example, "example cannot be null"); if (this.newExamples == null) { this.newExamples = new ArrayList(); } @@ -139,8 +136,7 @@ public Builder newDescription(String newDescription) { } /** - * Set the newExamples. - * Existing newExamples will be replaced. + * Set the newExamples. Existing newExamples will be replaced. * * @param newExamples the newExamples * @return the UpdateIntentOptions builder @@ -173,11 +169,12 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateIntentOptions() {} + protected UpdateIntentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, - "intent cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.intent, "intent cannot be empty"); workspaceId = builder.workspaceId; intent = builder.intent; newIntent = builder.newIntent; @@ -199,7 +196,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -210,7 +207,7 @@ public String workspaceId() { /** * Gets the intent. * - * The intent name. + *

The intent name. * * @return the intent */ @@ -221,9 +218,9 @@ public String intent() { /** * Gets the newIntent. * - * The name of the intent. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - * - It cannot begin with the reserved prefix `sys-`. + *

The name of the intent. This string must conform to the following restrictions: - It can + * contain only Unicode alphanumeric, underscore, hyphen, and dot characters. - It cannot begin + * with the reserved prefix `sys-`. * * @return the newIntent */ @@ -234,7 +231,8 @@ public String newIntent() { /** * Gets the newDescription. * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters. + *

The description of the intent. This string cannot contain carriage return, newline, or tab + * characters. * * @return the newDescription */ @@ -245,7 +243,7 @@ public String newDescription() { /** * Gets the newExamples. * - * An array of user input examples for the intent. + *

An array of user input examples for the intent. * * @return the newExamples */ @@ -256,13 +254,14 @@ public List newExamples() { /** * Gets the append. * - * Whether the new data is to be appended to the existing data in the object. If **append**=`false`, elements included - * in the new data completely replace the corresponding existing elements, including all subelements. For example, if - * the new data for the intent includes **examples** and **append**=`false`, all existing examples for the intent are + *

Whether the new data is to be appended to the existing data in the object. If + * **append**=`false`, elements included in the new data completely replace the corresponding + * existing elements, including all subelements. For example, if the new data for the intent + * includes **examples** and **append**=`false`, all existing examples for the intent are * discarded and replaced with the new examples. * - * If **append**=`true`, existing elements are preserved, and the new elements are added. If any elements in the new - * data collide with existing elements, the update request fails. + *

If **append**=`true`, existing elements are preserved, and the new elements are added. If + * any elements in the new data collide with existing elements, the update request fails. * * @return the append */ @@ -273,7 +272,8 @@ public Boolean append() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java index b7ccebce613..7af939d7037 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The updateSynonym options. - */ +/** The updateSynonym options. */ public class UpdateSynonymOptions extends GenericModel { protected String workspaceId; @@ -26,9 +25,7 @@ public class UpdateSynonymOptions extends GenericModel { protected String newSynonym; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -37,6 +34,11 @@ public static class Builder { private String newSynonym; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateSynonymOptions instance. + * + * @param updateSynonymOptions the instance to initialize the Builder with + */ private Builder(UpdateSynonymOptions updateSynonymOptions) { this.workspaceId = updateSynonymOptions.workspaceId; this.entity = updateSynonymOptions.entity; @@ -46,11 +48,8 @@ private Builder(UpdateSynonymOptions updateSynonymOptions) { this.includeAudit = updateSynonymOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -70,7 +69,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a UpdateSynonymOptions. * - * @return the updateSynonymOptions + * @return the new UpdateSynonymOptions instance */ public UpdateSynonymOptions build() { return new UpdateSynonymOptions(this); @@ -143,15 +142,14 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateSynonymOptions() {} + protected UpdateSynonymOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.synonym, - "synonym cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.synonym, "synonym cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -172,7 +170,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -183,7 +181,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -194,7 +192,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -205,7 +203,7 @@ public String value() { /** * Gets the synonym. * - * The text of the synonym. + *

The text of the synonym. * * @return the synonym */ @@ -216,9 +214,9 @@ public String synonym() { /** * Gets the newSynonym. * - * The text of the synonym. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the synonym. This string must conform to the following restrictions: - It cannot + * contain carriage return, newline, or tab characters. - It cannot consist of only whitespace + * characters. * * @return the newSynonym */ @@ -229,7 +227,8 @@ public String newSynonym() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java index 440ee8d60d2..40583789789 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,22 +10,18 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateValue options. - */ +/** The updateValue options. */ public class UpdateValueOptions extends GenericModel { - /** - * Specifies the type of entity value. - */ + /** Specifies the type of entity value. */ public interface NewType { /** synonyms. */ String SYNONYMS = "synonyms"; @@ -44,9 +40,7 @@ public interface NewType { protected Boolean append; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String entity; @@ -59,6 +53,11 @@ public static class Builder { private Boolean append; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateValueOptions instance. + * + * @param updateValueOptions the instance to initialize the Builder with + */ private Builder(UpdateValueOptions updateValueOptions) { this.workspaceId = updateValueOptions.workspaceId; this.entity = updateValueOptions.entity; @@ -72,11 +71,8 @@ private Builder(UpdateValueOptions updateValueOptions) { this.includeAudit = updateValueOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -94,21 +90,20 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a UpdateValueOptions. * - * @return the updateValueOptions + * @return the new UpdateValueOptions instance */ public UpdateValueOptions build() { return new UpdateValueOptions(this); } /** - * Adds an synonym to newSynonyms. + * Adds a new element to newSynonyms. * - * @param synonym the new synonym + * @param synonym the new element to be added * @return the UpdateValueOptions builder */ public Builder addSynonym(String synonym) { - com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, - "synonym cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, "synonym cannot be null"); if (this.newSynonyms == null) { this.newSynonyms = new ArrayList(); } @@ -117,14 +112,13 @@ public Builder addSynonym(String synonym) { } /** - * Adds an pattern to newPatterns. + * Adds a new element to newPatterns. * - * @param pattern the new pattern + * @param pattern the new element to be added * @return the UpdateValueOptions builder */ public Builder addPattern(String pattern) { - com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, - "pattern cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, "pattern cannot be null"); if (this.newPatterns == null) { this.newPatterns = new ArrayList(); } @@ -199,8 +193,7 @@ public Builder newType(String newType) { } /** - * Set the newSynonyms. - * Existing newSynonyms will be replaced. + * Set the newSynonyms. Existing newSynonyms will be replaced. * * @param newSynonyms the newSynonyms * @return the UpdateValueOptions builder @@ -211,8 +204,7 @@ public Builder newSynonyms(List newSynonyms) { } /** - * Set the newPatterns. - * Existing newPatterns will be replaced. + * Set the newPatterns. Existing newPatterns will be replaced. * * @param newPatterns the newPatterns * @return the UpdateValueOptions builder @@ -245,13 +237,13 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateValueOptions() {} + protected UpdateValueOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, - "entity cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, - "value cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.entity, "entity cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.value, "value cannot be empty"); workspaceId = builder.workspaceId; entity = builder.entity; value = builder.value; @@ -276,7 +268,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -287,7 +279,7 @@ public String workspaceId() { /** * Gets the entity. * - * The name of the entity. + *

The name of the entity. * * @return the entity */ @@ -298,7 +290,7 @@ public String entity() { /** * Gets the value. * - * The text of the entity value. + *

The text of the entity value. * * @return the value */ @@ -309,9 +301,9 @@ public String value() { /** * Gets the newValue. * - * The text of the entity value. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the entity value. This string must conform to the following restrictions: - It + * cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the newValue */ @@ -322,7 +314,7 @@ public String newValue() { /** * Gets the newMetadata. * - * Any metadata related to the entity value. + *

Any metadata related to the entity value. * * @return the newMetadata */ @@ -333,7 +325,7 @@ public Map newMetadata() { /** * Gets the newType. * - * Specifies the type of entity value. + *

Specifies the type of entity value. * * @return the newType */ @@ -344,10 +336,10 @@ public String newType() { /** * Gets the newSynonyms. * - * An array of synonyms for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A synonym must conform to the following resrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

An array of synonyms for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A synonym must conform to the following + * resrictions: - It cannot contain carriage return, newline, or tab characters. - It cannot + * consist of only whitespace characters. * * @return the newSynonyms */ @@ -358,9 +350,9 @@ public List newSynonyms() { /** * Gets the newPatterns. * - * An array of patterns for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A pattern is a regular expression; for more information about how to specify a pattern, see - * the + *

An array of patterns for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A pattern is a regular expression; for more + * information about how to specify a pattern, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). * * @return the newPatterns @@ -372,13 +364,14 @@ public List newPatterns() { /** * Gets the append. * - * Whether the new data is to be appended to the existing data in the entity value. If **append**=`false`, elements - * included in the new data completely replace the corresponding existing elements, including all subelements. For - * example, if the new data for the entity value includes **synonyms** and **append**=`false`, all existing synonyms - * for the entity value are discarded and replaced with the new synonyms. + *

Whether the new data is to be appended to the existing data in the entity value. If + * **append**=`false`, elements included in the new data completely replace the corresponding + * existing elements, including all subelements. For example, if the new data for the entity value + * includes **synonyms** and **append**=`false`, all existing synonyms for the entity value are + * discarded and replaced with the new synonyms. * - * If **append**=`true`, existing elements are preserved, and the new elements are added. If any elements in the new - * data collide with existing elements, the update request fails. + *

If **append**=`true`, existing elements are preserved, and the new elements are added. If + * any elements in the new data collide with existing elements, the update request fails. * * @return the append */ @@ -389,7 +382,8 @@ public Boolean append() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceAsyncOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceAsyncOptions.java new file mode 100644 index 00000000000..fb6d5e2cb75 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceAsyncOptions.java @@ -0,0 +1,496 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** The updateWorkspaceAsync options. */ +public class UpdateWorkspaceAsyncOptions extends GenericModel { + + protected String workspaceId; + protected String name; + protected String description; + protected String language; + protected List dialogNodes; + protected List counterexamples; + protected Map metadata; + protected Boolean learningOptOut; + protected WorkspaceSystemSettings systemSettings; + protected List webhooks; + protected List intents; + protected List entities; + protected Boolean append; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String name; + private String description; + private String language; + private List dialogNodes; + private List counterexamples; + private Map metadata; + private Boolean learningOptOut; + private WorkspaceSystemSettings systemSettings; + private List webhooks; + private List intents; + private List entities; + private Boolean append; + + /** + * Instantiates a new Builder from an existing UpdateWorkspaceAsyncOptions instance. + * + * @param updateWorkspaceAsyncOptions the instance to initialize the Builder with + */ + private Builder(UpdateWorkspaceAsyncOptions updateWorkspaceAsyncOptions) { + this.workspaceId = updateWorkspaceAsyncOptions.workspaceId; + this.name = updateWorkspaceAsyncOptions.name; + this.description = updateWorkspaceAsyncOptions.description; + this.language = updateWorkspaceAsyncOptions.language; + this.dialogNodes = updateWorkspaceAsyncOptions.dialogNodes; + this.counterexamples = updateWorkspaceAsyncOptions.counterexamples; + this.metadata = updateWorkspaceAsyncOptions.metadata; + this.learningOptOut = updateWorkspaceAsyncOptions.learningOptOut; + this.systemSettings = updateWorkspaceAsyncOptions.systemSettings; + this.webhooks = updateWorkspaceAsyncOptions.webhooks; + this.intents = updateWorkspaceAsyncOptions.intents; + this.entities = updateWorkspaceAsyncOptions.entities; + this.append = updateWorkspaceAsyncOptions.append; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a UpdateWorkspaceAsyncOptions. + * + * @return the new UpdateWorkspaceAsyncOptions instance + */ + public UpdateWorkspaceAsyncOptions build() { + return new UpdateWorkspaceAsyncOptions(this); + } + + /** + * Adds a new element to dialogNodes. + * + * @param dialogNode the new element to be added + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder addDialogNode(DialogNode dialogNode) { + com.ibm.cloud.sdk.core.util.Validator.notNull(dialogNode, "dialogNode cannot be null"); + if (this.dialogNodes == null) { + this.dialogNodes = new ArrayList(); + } + this.dialogNodes.add(dialogNode); + return this; + } + + /** + * Adds a new element to counterexamples. + * + * @param counterexample the new element to be added + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder addCounterexample(Counterexample counterexample) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + counterexample, "counterexample cannot be null"); + if (this.counterexamples == null) { + this.counterexamples = new ArrayList(); + } + this.counterexamples.add(counterexample); + return this; + } + + /** + * Adds a new element to webhooks. + * + * @param webhooks the new element to be added + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder addWebhooks(Webhook webhooks) { + com.ibm.cloud.sdk.core.util.Validator.notNull(webhooks, "webhooks cannot be null"); + if (this.webhooks == null) { + this.webhooks = new ArrayList(); + } + this.webhooks.add(webhooks); + return this; + } + + /** + * Adds a new element to intents. + * + * @param intent the new element to be added + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder addIntent(CreateIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity the new element to be added + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder addEntity(CreateEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the dialogNodes. Existing dialogNodes will be replaced. + * + * @param dialogNodes the dialogNodes + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder dialogNodes(List dialogNodes) { + this.dialogNodes = dialogNodes; + return this; + } + + /** + * Set the counterexamples. Existing counterexamples will be replaced. + * + * @param counterexamples the counterexamples + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the learningOptOut. + * + * @param learningOptOut the learningOptOut + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; + return this; + } + + /** + * Set the systemSettings. + * + * @param systemSettings the systemSettings + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder systemSettings(WorkspaceSystemSettings systemSettings) { + this.systemSettings = systemSettings; + return this; + } + + /** + * Set the webhooks. Existing webhooks will be replaced. + * + * @param webhooks the webhooks + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder webhooks(List webhooks) { + this.webhooks = webhooks; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder intents(List intents) { + this.intents = intents; + return this; + } + + /** + * Set the entities. Existing entities will be replaced. + * + * @param entities the entities + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the append. + * + * @param append the append + * @return the UpdateWorkspaceAsyncOptions builder + */ + public Builder append(Boolean append) { + this.append = append; + return this; + } + } + + protected UpdateWorkspaceAsyncOptions() {} + + protected UpdateWorkspaceAsyncOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + name = builder.name; + description = builder.description; + language = builder.language; + dialogNodes = builder.dialogNodes; + counterexamples = builder.counterexamples; + metadata = builder.metadata; + learningOptOut = builder.learningOptOut; + systemSettings = builder.systemSettings; + webhooks = builder.webhooks; + intents = builder.intents; + entities = builder.entities; + append = builder.append; + } + + /** + * New builder. + * + * @return a UpdateWorkspaceAsyncOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the name. + * + *

The name of the workspace. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the workspace. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the language. + * + *

The language of the workspace. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List dialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List counterexamples() { + return counterexamples; + } + + /** + * Gets the metadata. + * + *

Any metadata related to the workspace. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the learningOptOut. + * + *

Whether training data from the workspace (including artifacts such as intents and entities) + * can be used by IBM for general service improvements. `true` indicates that workspace training + * data is not to be used. + * + * @return the learningOptOut + */ + public Boolean learningOptOut() { + return learningOptOut; + } + + /** + * Gets the systemSettings. + * + *

Global settings for the workspace. + * + * @return the systemSettings + */ + public WorkspaceSystemSettings systemSettings() { + return systemSettings; + } + + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List webhooks() { + return webhooks; + } + + /** + * Gets the intents. + * + *

An array of objects defining the intents for the workspace. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of objects describing the entities for the workspace. + * + * @return the entities + */ + public List entities() { + return entities; + } + + /** + * Gets the append. + * + *

Whether the new data is to be appended to the existing data in the object. If + * **append**=`false`, elements included in the new data completely replace the corresponding + * existing elements, including all subelements. For example, if the new data for a workspace + * includes **entities** and **append**=`false`, all existing entities in the workspace are + * discarded and replaced with the new entities. + * + *

If **append**=`true`, existing elements are preserved, and the new elements are added. If + * any elements in the new data collide with existing elements, the update request fails. + * + * @return the append + */ + public Boolean append() { + return append; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java index fa3dcaeebf7..a1c069de5f1 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,75 +10,73 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateWorkspace options. - */ +/** The updateWorkspace options. */ public class UpdateWorkspaceOptions extends GenericModel { protected String workspaceId; protected String name; protected String description; protected String language; + protected List dialogNodes; + protected List counterexamples; protected Map metadata; protected Boolean learningOptOut; protected WorkspaceSystemSettings systemSettings; + protected List webhooks; protected List intents; protected List entities; - protected List dialogNodes; - protected List counterexamples; - protected List webhooks; protected Boolean append; protected Boolean includeAudit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String workspaceId; private String name; private String description; private String language; + private List dialogNodes; + private List counterexamples; private Map metadata; private Boolean learningOptOut; private WorkspaceSystemSettings systemSettings; + private List webhooks; private List intents; private List entities; - private List dialogNodes; - private List counterexamples; - private List webhooks; private Boolean append; private Boolean includeAudit; + /** + * Instantiates a new Builder from an existing UpdateWorkspaceOptions instance. + * + * @param updateWorkspaceOptions the instance to initialize the Builder with + */ private Builder(UpdateWorkspaceOptions updateWorkspaceOptions) { this.workspaceId = updateWorkspaceOptions.workspaceId; this.name = updateWorkspaceOptions.name; this.description = updateWorkspaceOptions.description; this.language = updateWorkspaceOptions.language; + this.dialogNodes = updateWorkspaceOptions.dialogNodes; + this.counterexamples = updateWorkspaceOptions.counterexamples; this.metadata = updateWorkspaceOptions.metadata; this.learningOptOut = updateWorkspaceOptions.learningOptOut; this.systemSettings = updateWorkspaceOptions.systemSettings; + this.webhooks = updateWorkspaceOptions.webhooks; this.intents = updateWorkspaceOptions.intents; this.entities = updateWorkspaceOptions.entities; - this.dialogNodes = updateWorkspaceOptions.dialogNodes; - this.counterexamples = updateWorkspaceOptions.counterexamples; - this.webhooks = updateWorkspaceOptions.webhooks; this.append = updateWorkspaceOptions.append; this.includeAudit = updateWorkspaceOptions.includeAudit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -92,89 +90,85 @@ public Builder(String workspaceId) { /** * Builds a UpdateWorkspaceOptions. * - * @return the updateWorkspaceOptions + * @return the new UpdateWorkspaceOptions instance */ public UpdateWorkspaceOptions build() { return new UpdateWorkspaceOptions(this); } /** - * Adds an intent to intents. + * Adds a new element to dialogNodes. * - * @param intent the new intent + * @param dialogNode the new element to be added * @return the UpdateWorkspaceOptions builder */ - public Builder addIntent(CreateIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, - "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); + public Builder addDialogNode(DialogNode dialogNode) { + com.ibm.cloud.sdk.core.util.Validator.notNull(dialogNode, "dialogNode cannot be null"); + if (this.dialogNodes == null) { + this.dialogNodes = new ArrayList(); } - this.intents.add(intent); + this.dialogNodes.add(dialogNode); return this; } /** - * Adds an entity to entities. + * Adds a new element to counterexamples. * - * @param entity the new entity + * @param counterexample the new element to be added * @return the UpdateWorkspaceOptions builder */ - public Builder addEntity(CreateEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, - "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); + public Builder addCounterexample(Counterexample counterexample) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + counterexample, "counterexample cannot be null"); + if (this.counterexamples == null) { + this.counterexamples = new ArrayList(); } - this.entities.add(entity); + this.counterexamples.add(counterexample); return this; } /** - * Adds an dialogNode to dialogNodes. + * Adds a new element to webhooks. * - * @param dialogNode the new dialogNode + * @param webhooks the new element to be added * @return the UpdateWorkspaceOptions builder */ - public Builder addDialogNode(DialogNode dialogNode) { - com.ibm.cloud.sdk.core.util.Validator.notNull(dialogNode, - "dialogNode cannot be null"); - if (this.dialogNodes == null) { - this.dialogNodes = new ArrayList(); + public Builder addWebhooks(Webhook webhooks) { + com.ibm.cloud.sdk.core.util.Validator.notNull(webhooks, "webhooks cannot be null"); + if (this.webhooks == null) { + this.webhooks = new ArrayList(); } - this.dialogNodes.add(dialogNode); + this.webhooks.add(webhooks); return this; } /** - * Adds an counterexample to counterexamples. + * Adds a new element to intents. * - * @param counterexample the new counterexample + * @param intent the new element to be added * @return the UpdateWorkspaceOptions builder */ - public Builder addCounterexample(Counterexample counterexample) { - com.ibm.cloud.sdk.core.util.Validator.notNull(counterexample, - "counterexample cannot be null"); - if (this.counterexamples == null) { - this.counterexamples = new ArrayList(); + public Builder addIntent(CreateIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); } - this.counterexamples.add(counterexample); + this.intents.add(intent); return this; } /** - * Adds an webhooks to webhooks. + * Adds a new element to entities. * - * @param webhooks the new webhooks + * @param entity the new element to be added * @return the UpdateWorkspaceOptions builder */ - public Builder addWebhooks(Webhook webhooks) { - com.ibm.cloud.sdk.core.util.Validator.notNull(webhooks, - "webhooks cannot be null"); - if (this.webhooks == null) { - this.webhooks = new ArrayList(); + public Builder addEntity(CreateEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); } - this.webhooks.add(webhooks); + this.entities.add(entity); return this; } @@ -223,95 +217,90 @@ public Builder language(String language) { } /** - * Set the metadata. + * Set the dialogNodes. Existing dialogNodes will be replaced. * - * @param metadata the metadata + * @param dialogNodes the dialogNodes * @return the UpdateWorkspaceOptions builder */ - public Builder metadata(Map metadata) { - this.metadata = metadata; + public Builder dialogNodes(List dialogNodes) { + this.dialogNodes = dialogNodes; return this; } /** - * Set the learningOptOut. + * Set the counterexamples. Existing counterexamples will be replaced. * - * @param learningOptOut the learningOptOut + * @param counterexamples the counterexamples * @return the UpdateWorkspaceOptions builder */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; return this; } /** - * Set the systemSettings. + * Set the metadata. * - * @param systemSettings the systemSettings + * @param metadata the metadata * @return the UpdateWorkspaceOptions builder */ - public Builder systemSettings(WorkspaceSystemSettings systemSettings) { - this.systemSettings = systemSettings; + public Builder metadata(Map metadata) { + this.metadata = metadata; return this; } /** - * Set the intents. - * Existing intents will be replaced. + * Set the learningOptOut. * - * @param intents the intents + * @param learningOptOut the learningOptOut * @return the UpdateWorkspaceOptions builder */ - public Builder intents(List intents) { - this.intents = intents; + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; return this; } /** - * Set the entities. - * Existing entities will be replaced. + * Set the systemSettings. * - * @param entities the entities + * @param systemSettings the systemSettings * @return the UpdateWorkspaceOptions builder */ - public Builder entities(List entities) { - this.entities = entities; + public Builder systemSettings(WorkspaceSystemSettings systemSettings) { + this.systemSettings = systemSettings; return this; } /** - * Set the dialogNodes. - * Existing dialogNodes will be replaced. + * Set the webhooks. Existing webhooks will be replaced. * - * @param dialogNodes the dialogNodes + * @param webhooks the webhooks * @return the UpdateWorkspaceOptions builder */ - public Builder dialogNodes(List dialogNodes) { - this.dialogNodes = dialogNodes; + public Builder webhooks(List webhooks) { + this.webhooks = webhooks; return this; } /** - * Set the counterexamples. - * Existing counterexamples will be replaced. + * Set the intents. Existing intents will be replaced. * - * @param counterexamples the counterexamples + * @param intents the intents * @return the UpdateWorkspaceOptions builder */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; + public Builder intents(List intents) { + this.intents = intents; return this; } /** - * Set the webhooks. - * Existing webhooks will be replaced. + * Set the entities. Existing entities will be replaced. * - * @param webhooks the webhooks + * @param entities the entities * @return the UpdateWorkspaceOptions builder */ - public Builder webhooks(List webhooks) { - this.webhooks = webhooks; + public Builder entities(List entities) { + this.entities = entities; return this; } @@ -338,21 +327,23 @@ public Builder includeAudit(Boolean includeAudit) { } } + protected UpdateWorkspaceOptions() {} + protected UpdateWorkspaceOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.workspaceId, - "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; name = builder.name; description = builder.description; language = builder.language; + dialogNodes = builder.dialogNodes; + counterexamples = builder.counterexamples; metadata = builder.metadata; learningOptOut = builder.learningOptOut; systemSettings = builder.systemSettings; + webhooks = builder.webhooks; intents = builder.intents; entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - webhooks = builder.webhooks; append = builder.append; includeAudit = builder.includeAudit; } @@ -369,7 +360,7 @@ public Builder newBuilder() { /** * Gets the workspaceId. * - * Unique identifier of the workspace. + *

Unique identifier of the workspace. * * @return the workspaceId */ @@ -380,7 +371,8 @@ public String workspaceId() { /** * Gets the name. * - * The name of the workspace. This string cannot contain carriage return, newline, or tab characters. + *

The name of the workspace. This string cannot contain carriage return, newline, or tab + * characters. * * @return the name */ @@ -391,7 +383,8 @@ public String name() { /** * Gets the description. * - * The description of the workspace. This string cannot contain carriage return, newline, or tab characters. + *

The description of the workspace. This string cannot contain carriage return, newline, or + * tab characters. * * @return the description */ @@ -402,7 +395,7 @@ public String description() { /** * Gets the language. * - * The language of the workspace. + *

The language of the workspace. * * @return the language */ @@ -410,10 +403,32 @@ public String language() { return language; } + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List dialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List counterexamples() { + return counterexamples; + } + /** * Gets the metadata. * - * Any metadata related to the workspace. + *

Any metadata related to the workspace. * * @return the metadata */ @@ -424,8 +439,9 @@ public Map metadata() { /** * Gets the learningOptOut. * - * Whether training data from the workspace (including artifacts such as intents and entities) can be used by IBM for - * general service improvements. `true` indicates that workspace training data is not to be used. + *

Whether training data from the workspace (including artifacts such as intents and entities) + * can be used by IBM for general service improvements. `true` indicates that workspace training + * data is not to be used. * * @return the learningOptOut */ @@ -436,7 +452,7 @@ public Boolean learningOptOut() { /** * Gets the systemSettings. * - * Global settings for the workspace. + *

Global settings for the workspace. * * @return the systemSettings */ @@ -444,10 +460,19 @@ public WorkspaceSystemSettings systemSettings() { return systemSettings; } + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List webhooks() { + return webhooks; + } + /** * Gets the intents. * - * An array of objects defining the intents for the workspace. + *

An array of objects defining the intents for the workspace. * * @return the intents */ @@ -458,7 +483,7 @@ public List intents() { /** * Gets the entities. * - * An array of objects describing the entities for the workspace. + *

An array of objects describing the entities for the workspace. * * @return the entities */ @@ -466,47 +491,17 @@ public List entities() { return entities; } - /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List dialogNodes() { - return dialogNodes; - } - - /** - * Gets the counterexamples. - * - * An array of objects defining input examples that have been marked as irrelevant input. - * - * @return the counterexamples - */ - public List counterexamples() { - return counterexamples; - } - - /** - * Gets the webhooks. - * - * @return the webhooks - */ - public List webhooks() { - return webhooks; - } - /** * Gets the append. * - * Whether the new data is to be appended to the existing data in the object. If **append**=`false`, elements included - * in the new data completely replace the corresponding existing elements, including all subelements. For example, if - * the new data for a workspace includes **entities** and **append**=`false`, all existing entities in the workspace - * are discarded and replaced with the new entities. + *

Whether the new data is to be appended to the existing data in the object. If + * **append**=`false`, elements included in the new data completely replace the corresponding + * existing elements, including all subelements. For example, if the new data for a workspace + * includes **entities** and **append**=`false`, all existing entities in the workspace are + * discarded and replaced with the new entities. * - * If **append**=`true`, existing elements are preserved, and the new elements are added. If any elements in the new - * data collide with existing elements, the update request fails. + *

If **append**=`true`, existing elements are preserved, and the new elements are added. If + * any elements in the new data collide with existing elements, the update request fails. * * @return the append */ @@ -517,7 +512,8 @@ public Boolean append() { /** * Gets the includeAudit. * - * Whether to include the audit properties (`created` and `updated` timestamps) in the response. + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. * * @return the includeAudit */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java index 1618e097c7b..c5385865995 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,23 +10,19 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Value. - */ +/** Value. */ public class Value extends GenericModel { - /** - * Specifies the type of entity value. - */ + /** Specifies the type of entity value. */ public interface Type { /** synonyms. */ String SYNONYMS = "synonyms"; @@ -42,33 +38,29 @@ public interface Type { protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String value; private Map metadata; private String type; private List synonyms; private List patterns; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing Value instance. + * + * @param value the instance to initialize the Builder with + */ private Builder(Value value) { this.value = value.value; this.metadata = value.metadata; this.type = value.type; this.synonyms = value.synonyms; this.patterns = value.patterns; - this.created = value.created; - this.updated = value.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -84,21 +76,20 @@ public Builder(String value, String type) { /** * Builds a Value. * - * @return the value + * @return the new Value instance */ public Value build() { return new Value(this); } /** - * Adds an synonym to synonyms. + * Adds a new element to synonyms. * - * @param synonym the new synonym + * @param synonym the new element to be added * @return the Value builder */ public Builder addSynonym(String synonym) { - com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, - "synonym cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(synonym, "synonym cannot be null"); if (this.synonyms == null) { this.synonyms = new ArrayList(); } @@ -107,14 +98,13 @@ public Builder addSynonym(String synonym) { } /** - * Adds an pattern to patterns. + * Adds a new element to patterns. * - * @param pattern the new pattern + * @param pattern the new element to be added * @return the Value builder */ public Builder addPattern(String pattern) { - com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, - "pattern cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(pattern, "pattern cannot be null"); if (this.patterns == null) { this.patterns = new ArrayList(); } @@ -156,8 +146,7 @@ public Builder type(String type) { } /** - * Set the synonyms. - * Existing synonyms will be replaced. + * Set the synonyms. Existing synonyms will be replaced. * * @param synonyms the synonyms * @return the Value builder @@ -168,8 +157,7 @@ public Builder synonyms(List synonyms) { } /** - * Set the patterns. - * Existing patterns will be replaced. + * Set the patterns. Existing patterns will be replaced. * * @param patterns the patterns * @return the Value builder @@ -178,42 +166,18 @@ public Builder patterns(List patterns) { this.patterns = patterns; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Value builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Value builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected Value() {} + protected Value(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, - "type cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, "type cannot be null"); value = builder.value; metadata = builder.metadata; type = builder.type; synonyms = builder.synonyms; patterns = builder.patterns; - created = builder.created; - updated = builder.updated; } /** @@ -228,9 +192,9 @@ public Builder newBuilder() { /** * Gets the value. * - * The text of the entity value. This string must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

The text of the entity value. This string must conform to the following restrictions: - It + * cannot contain carriage return, newline, or tab characters. - It cannot consist of only + * whitespace characters. * * @return the value */ @@ -241,7 +205,7 @@ public String value() { /** * Gets the metadata. * - * Any metadata related to the entity value. + *

Any metadata related to the entity value. * * @return the metadata */ @@ -252,7 +216,7 @@ public Map metadata() { /** * Gets the type. * - * Specifies the type of entity value. + *

Specifies the type of entity value. * * @return the type */ @@ -263,10 +227,10 @@ public String type() { /** * Gets the synonyms. * - * An array of synonyms for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A synonym must conform to the following resrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. + *

An array of synonyms for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A synonym must conform to the following + * resrictions: - It cannot contain carriage return, newline, or tab characters. - It cannot + * consist of only whitespace characters. * * @return the synonyms */ @@ -277,9 +241,9 @@ public List synonyms() { /** * Gets the patterns. * - * An array of patterns for the entity value. A value can specify either synonyms or patterns (depending on the value - * type), but not both. A pattern is a regular expression; for more information about how to specify a pattern, see - * the + *

An array of patterns for the entity value. A value can specify either synonyms or patterns + * (depending on the value type), but not both. A pattern is a regular expression; for more + * information about how to specify a pattern, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). * * @return the patterns @@ -291,7 +255,7 @@ public List patterns() { /** * Gets the created. * - * The timestamp for creation of the object. + *

The timestamp for creation of the object. * * @return the created */ @@ -302,7 +266,7 @@ public Date created() { /** * Gets the updated. * - * The timestamp for the most recent update to the object. + *

The timestamp for the most recent update to the object. * * @return the updated */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java index 100adff11e3..869b0a07027 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * ValueCollection. - */ +/** ValueCollection. */ public class ValueCollection extends GenericModel { protected List values; protected Pagination pagination; + protected ValueCollection() {} + /** * Gets the values. * - * An array of entity values. + *

An array of entity values. * * @return the values */ @@ -38,7 +38,8 @@ public List getValues() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java index c9b5bd6f8c0..7a9efcf30b5 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,17 +10,17 @@ * 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.assistant.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - /** * A webhook that can be used by dialog nodes to make programmatic calls to an external function. * - * **Note:** Currently, only a single webhook named `main_webhook` is supported. + *

**Note:** Currently, only a single webhook named `main_webhook` is supported. */ public class Webhook extends GenericModel { @@ -28,25 +28,25 @@ public class Webhook extends GenericModel { protected String name; protected List headers; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String url; private String name; private List headers; + /** + * Instantiates a new Builder from an existing Webhook instance. + * + * @param webhook the instance to initialize the Builder with + */ private Builder(Webhook webhook) { this.url = webhook.url; this.name = webhook.name; this.headers = webhook.headers; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -62,21 +62,20 @@ public Builder(String url, String name) { /** * Builds a Webhook. * - * @return the webhook + * @return the new Webhook instance */ public Webhook build() { return new Webhook(this); } /** - * Adds an headers to headers. + * Adds a new element to headers. * - * @param headers the new headers + * @param headers the new element to be added * @return the Webhook builder */ public Builder addHeaders(WebhookHeader headers) { - com.ibm.cloud.sdk.core.util.Validator.notNull(headers, - "headers cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(headers, "headers cannot be null"); if (this.headers == null) { this.headers = new ArrayList(); } @@ -107,8 +106,7 @@ public Builder name(String name) { } /** - * Set the headers. - * Existing headers will be replaced. + * Set the headers. Existing headers will be replaced. * * @param headers the headers * @return the Webhook builder @@ -119,11 +117,11 @@ public Builder headers(List headers) { } } + protected Webhook() {} + protected Webhook(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, - "url cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, "url cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); url = builder.url; name = builder.name; headers = builder.headers; @@ -141,7 +139,8 @@ public Builder newBuilder() { /** * Gets the url. * - * The URL for the external service or application to which you want to send HTTP POST requests. + *

The URL for the external service or application to which you want to send HTTP POST + * requests. * * @return the url */ @@ -152,7 +151,7 @@ public String url() { /** * Gets the name. * - * The name of the webhook. Currently, `main_webhook` is the only supported value. + *

The name of the webhook. Currently, `main_webhook` is the only supported value. * * @return the name */ @@ -163,7 +162,7 @@ public String name() { /** * Gets the headers. * - * An optional array of HTTP headers to pass with the HTTP request. + *

An optional array of HTTP headers to pass with the HTTP request. * * @return the headers */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java index 33a7a3e3e43..436bfb87b63 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * A key/value pair defining an HTTP header and a value. - */ +/** A key/value pair defining an HTTP header and a value. */ public class WebhookHeader extends GenericModel { protected String name; protected String value; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String name; private String value; + /** + * Instantiates a new Builder from an existing WebhookHeader instance. + * + * @param webhookHeader the instance to initialize the Builder with + */ private Builder(WebhookHeader webhookHeader) { this.name = webhookHeader.name; this.value = webhookHeader.value; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String name, String value) { /** * Builds a WebhookHeader. * - * @return the webhookHeader + * @return the new WebhookHeader instance */ public WebhookHeader build() { return new WebhookHeader(this); @@ -83,11 +82,11 @@ public Builder value(String value) { } } + protected WebhookHeader() {} + protected WebhookHeader(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); name = builder.name; value = builder.value; } @@ -104,7 +103,7 @@ public Builder newBuilder() { /** * Gets the name. * - * The name of an HTTP header (for example, `Authorization`). + *

The name of an HTTP header (for example, `Authorization`). * * @return the name */ @@ -115,7 +114,7 @@ public String name() { /** * Gets the value. * - * The value of an HTTP header. + *

The value of an HTTP header. * * @return the value */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java index ff9cccd15ea..4fc9c506a78 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,32 +10,36 @@ * 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.assistant.v1.model; +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.Date; import java.util.List; import java.util.Map; -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Workspace. - */ +/** Workspace. */ public class Workspace extends GenericModel { /** - * The current status of the workspace. + * The current status of the workspace: - **Available**: The workspace is available and ready to + * process messages. - **Failed**: An asynchronous operation has failed. See the **status_errors** + * property for more information about the cause of the failure. - **Non Existent**: The workspace + * does not exist. - **Processing**: An asynchronous operation has not yet completed. - + * **Training**: The workspace is training based on new data such as intents or examples. */ public interface Status { + /** Available. */ + String AVAILABLE = "Available"; + /** Failed. */ + String FAILED = "Failed"; /** Non Existent. */ String NON_EXISTENT = "Non Existent"; + /** Processing. */ + String PROCESSING = "Processing"; /** Training. */ String TRAINING = "Training"; - /** Failed. */ - String FAILED = "Failed"; - /** Available. */ - String AVAILABLE = "Available"; /** Unavailable. */ String UNAVAILABLE = "Unavailable"; } @@ -43,27 +47,41 @@ public interface Status { protected String name; protected String description; protected String language; + + @SerializedName("workspace_id") + protected String workspaceId; + + @SerializedName("dialog_nodes") + protected List dialogNodes; + + protected List counterexamples; + protected Date created; + protected Date updated; protected Map metadata; + @SerializedName("learning_opt_out") protected Boolean learningOptOut; + @SerializedName("system_settings") protected WorkspaceSystemSettings systemSettings; - @SerializedName("workspace_id") - protected String workspaceId; + protected String status; - protected Date created; - protected Date updated; + + @SerializedName("status_errors") + protected List statusErrors; + + protected List webhooks; protected List intents; protected List entities; - @SerializedName("dialog_nodes") - protected List dialogNodes; - protected List counterexamples; - protected List webhooks; + protected WorkspaceCounts counts; + + protected Workspace() {} /** * Gets the name. * - * The name of the workspace. This string cannot contain carriage return, newline, or tab characters. + *

The name of the workspace. This string cannot contain carriage return, newline, or tab + * characters. * * @return the name */ @@ -74,7 +92,8 @@ public String getName() { /** * Gets the description. * - * The description of the workspace. This string cannot contain carriage return, newline, or tab characters. + *

The description of the workspace. This string cannot contain carriage return, newline, or + * tab characters. * * @return the description */ @@ -85,7 +104,7 @@ public String getDescription() { /** * Gets the language. * - * The language of the workspace. + *

The language of the workspace. * * @return the language */ @@ -93,10 +112,65 @@ public String getLanguage() { return language; } + /** + * Gets the workspaceId. + * + *

The workspace ID of the workspace. + * + * @return the workspaceId + */ + public String getWorkspaceId() { + return workspaceId; + } + + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List getDialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List getCounterexamples() { + return counterexamples; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } + /** * Gets the metadata. * - * Any metadata related to the workspace. + *

Any metadata related to the workspace. * * @return the metadata */ @@ -107,8 +181,9 @@ public Map getMetadata() { /** * Gets the learningOptOut. * - * Whether training data from the workspace (including artifacts such as intents and entities) can be used by IBM for - * general service improvements. `true` indicates that workspace training data is not to be used. + *

Whether training data from the workspace (including artifacts such as intents and entities) + * can be used by IBM for general service improvements. `true` indicates that workspace training + * data is not to be used. * * @return the learningOptOut */ @@ -119,7 +194,7 @@ public Boolean isLearningOptOut() { /** * Gets the systemSettings. * - * Global settings for the workspace. + *

Global settings for the workspace. * * @return the systemSettings */ @@ -127,21 +202,15 @@ public WorkspaceSystemSettings getSystemSettings() { return systemSettings; } - /** - * Gets the workspaceId. - * - * The workspace ID of the workspace. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - /** * Gets the status. * - * The current status of the workspace. + *

The current status of the workspace: - **Available**: The workspace is available and ready + * to process messages. - **Failed**: An asynchronous operation has failed. See the + * **status_errors** property for more information about the cause of the failure. - **Non + * Existent**: The workspace does not exist. - **Processing**: An asynchronous operation has not + * yet completed. - **Training**: The workspace is training based on new data such as intents or + * examples. * * @return the status */ @@ -150,31 +219,29 @@ public String getStatus() { } /** - * Gets the created. + * Gets the statusErrors. * - * The timestamp for creation of the object. + *

An array of messages about errors that caused an asynchronous operation to fail. * - * @return the created + * @return the statusErrors */ - public Date getCreated() { - return created; + public List getStatusErrors() { + return statusErrors; } /** - * Gets the updated. - * - * The timestamp for the most recent update to the object. + * Gets the webhooks. * - * @return the updated + * @return the webhooks */ - public Date getUpdated() { - return updated; + public List getWebhooks() { + return webhooks; } /** * Gets the intents. * - * An array of intents. + *

An array of intents. * * @return the intents */ @@ -185,7 +252,7 @@ public List getIntents() { /** * Gets the entities. * - * An array of objects describing the entities for the workspace. + *

An array of objects describing the entities for the workspace. * * @return the entities */ @@ -194,33 +261,16 @@ public List getEntities() { } /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List getDialogNodes() { - return dialogNodes; - } - - /** - * Gets the counterexamples. + * Gets the counts. * - * An array of counterexamples. + *

An object containing properties that indicate how many intents, entities, and dialog nodes + * are defined in the workspace. This property is included only in responses from the **Export + * workspace asynchronously** method, and only when the **verbose** query parameter is set to + * `true`. * - * @return the counterexamples + * @return the counts */ - public List getCounterexamples() { - return counterexamples; - } - - /** - * Gets the webhooks. - * - * @return the webhooks - */ - public List getWebhooks() { - return webhooks; + public WorkspaceCounts getCounts() { + return counts; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java index bf2f269dc31..6c98c577cc4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.assistant.v1.model; -import java.util.List; +package com.ibm.watson.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * WorkspaceCollection. - */ +/** WorkspaceCollection. */ public class WorkspaceCollection extends GenericModel { protected List workspaces; protected Pagination pagination; + protected WorkspaceCollection() {} + /** * Gets the workspaces. * - * An array of objects describing the workspaces associated with the service instance. + *

An array of objects describing the workspaces associated with the service instance. * * @return the workspaces */ @@ -38,7 +38,8 @@ public List getWorkspaces() { /** * Gets the pagination. * - * The pagination data for the returned objects. + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). * * @return the pagination */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCounts.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCounts.java new file mode 100644 index 00000000000..6545cf2d078 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCounts.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object containing properties that indicate how many intents, entities, and dialog nodes are + * defined in the workspace. This property is included only in responses from the **Export workspace + * asynchronously** method, and only when the **verbose** query parameter is set to `true`. + */ +public class WorkspaceCounts extends GenericModel { + + protected Long intent; + protected Long entity; + protected Long node; + + protected WorkspaceCounts() {} + + /** + * Gets the intent. + * + *

The number of intents defined in the workspace. + * + * @return the intent + */ + public Long getIntent() { + return intent; + } + + /** + * Gets the entity. + * + *

The number of entities defined in the workspace. + * + * @return the entity + */ + public Long getEntity() { + return entity; + } + + /** + * Gets the node. + * + *

The number of nodes defined in the workspace. + * + * @return the node + */ + public Long getNode() { + return node; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java index 36ba20e4e58..ccab1bbf8f6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,55 +10,86 @@ * 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.assistant.v1.model; -import java.util.Map; +package com.ibm.watson.assistant.v1.model; import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; +import com.google.gson.reflect.TypeToken; +import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; /** * Global settings for the workspace. + * + *

This type supports additional properties of type Object. For internal use only. */ -public class WorkspaceSystemSettings extends GenericModel { +public class WorkspaceSystemSettings extends DynamicModel { + @SerializedName("tooling") protected WorkspaceSystemSettingsTooling tooling; + + @SerializedName("disambiguation") protected WorkspaceSystemSettingsDisambiguation disambiguation; + @SerializedName("human_agent_assist") protected Map humanAgentAssist; + + @SerializedName("spelling_suggestions") + protected Boolean spellingSuggestions; + + @SerializedName("spelling_auto_correct") + protected Boolean spellingAutoCorrect; + @SerializedName("system_entities") protected WorkspaceSystemSettingsSystemEntities systemEntities; + @SerializedName("off_topic") protected WorkspaceSystemSettingsOffTopic offTopic; - /** - * Builder. - */ + @SerializedName("nlp") + protected WorkspaceSystemSettingsNlp nlp; + + public WorkspaceSystemSettings() { + super(new TypeToken() {}); + } + + /** Builder. */ public static class Builder { private WorkspaceSystemSettingsTooling tooling; private WorkspaceSystemSettingsDisambiguation disambiguation; private Map humanAgentAssist; + private Boolean spellingSuggestions; + private Boolean spellingAutoCorrect; private WorkspaceSystemSettingsSystemEntities systemEntities; private WorkspaceSystemSettingsOffTopic offTopic; + private WorkspaceSystemSettingsNlp nlp; + private Map dynamicProperties; + /** + * Instantiates a new Builder from an existing WorkspaceSystemSettings instance. + * + * @param workspaceSystemSettings the instance to initialize the Builder with + */ private Builder(WorkspaceSystemSettings workspaceSystemSettings) { this.tooling = workspaceSystemSettings.tooling; this.disambiguation = workspaceSystemSettings.disambiguation; this.humanAgentAssist = workspaceSystemSettings.humanAgentAssist; + this.spellingSuggestions = workspaceSystemSettings.spellingSuggestions; + this.spellingAutoCorrect = workspaceSystemSettings.spellingAutoCorrect; this.systemEntities = workspaceSystemSettings.systemEntities; this.offTopic = workspaceSystemSettings.offTopic; + this.nlp = workspaceSystemSettings.nlp; + this.dynamicProperties = workspaceSystemSettings.getProperties(); } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a WorkspaceSystemSettings. * - * @return the workspaceSystemSettings + * @return the new WorkspaceSystemSettings instance */ public WorkspaceSystemSettings build() { return new WorkspaceSystemSettings(this); @@ -97,6 +128,28 @@ public Builder humanAgentAssist(Map humanAgentAssist) { return this; } + /** + * Set the spellingSuggestions. + * + * @param spellingSuggestions the spellingSuggestions + * @return the WorkspaceSystemSettings builder + */ + public Builder spellingSuggestions(Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + return this; + } + + /** + * Set the spellingAutoCorrect. + * + * @param spellingAutoCorrect the spellingAutoCorrect + * @return the WorkspaceSystemSettings builder + */ + public Builder spellingAutoCorrect(Boolean spellingAutoCorrect) { + this.spellingAutoCorrect = spellingAutoCorrect; + return this; + } + /** * Set the systemEntities. * @@ -118,14 +171,46 @@ public Builder offTopic(WorkspaceSystemSettingsOffTopic offTopic) { this.offTopic = offTopic; return this; } + + /** + * Set the nlp. + * + * @param nlp the nlp + * @return the WorkspaceSystemSettings builder + */ + public Builder nlp(WorkspaceSystemSettingsNlp nlp) { + this.nlp = nlp; + return this; + } + + /** + * Add an arbitrary property. For internal use only. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the WorkspaceSystemSettings builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } } protected WorkspaceSystemSettings(Builder builder) { + super(new TypeToken() {}); tooling = builder.tooling; disambiguation = builder.disambiguation; humanAgentAssist = builder.humanAgentAssist; + spellingSuggestions = builder.spellingSuggestions; + spellingAutoCorrect = builder.spellingAutoCorrect; systemEntities = builder.systemEntities; offTopic = builder.offTopic; + nlp = builder.nlp; + this.setProperties(builder.dynamicProperties); } /** @@ -140,57 +225,165 @@ public Builder newBuilder() { /** * Gets the tooling. * - * Workspace settings related to the Watson Assistant user interface. + *

Workspace settings related to the Watson Assistant user interface. * * @return the tooling */ - public WorkspaceSystemSettingsTooling tooling() { - return tooling; + public WorkspaceSystemSettingsTooling getTooling() { + return this.tooling; } /** - * Gets the disambiguation. + * Sets the tooling. * - * Workspace settings related to the disambiguation feature. + * @param tooling the new tooling + */ + public void setTooling(final WorkspaceSystemSettingsTooling tooling) { + this.tooling = tooling; + } + + /** + * Gets the disambiguation. * - * **Note:** This feature is available only to Plus and Premium users. + *

Workspace settings related to the disambiguation feature. * * @return the disambiguation */ - public WorkspaceSystemSettingsDisambiguation disambiguation() { - return disambiguation; + public WorkspaceSystemSettingsDisambiguation getDisambiguation() { + return this.disambiguation; + } + + /** + * Sets the disambiguation. + * + * @param disambiguation the new disambiguation + */ + public void setDisambiguation(final WorkspaceSystemSettingsDisambiguation disambiguation) { + this.disambiguation = disambiguation; } /** * Gets the humanAgentAssist. * - * For internal use only. + *

For internal use only. * * @return the humanAgentAssist */ - public Map humanAgentAssist() { - return humanAgentAssist; + public Map getHumanAgentAssist() { + return this.humanAgentAssist; + } + + /** + * Sets the humanAgentAssist. + * + * @param humanAgentAssist the new humanAgentAssist + */ + public void setHumanAgentAssist(final Map humanAgentAssist) { + this.humanAgentAssist = humanAgentAssist; + } + + /** + * Gets the spellingSuggestions. + * + *

Whether spelling correction is enabled for the workspace. + * + * @return the spellingSuggestions + */ + public Boolean isSpellingSuggestions() { + return this.spellingSuggestions; + } + + /** + * Sets the spellingSuggestions. + * + * @param spellingSuggestions the new spellingSuggestions + */ + public void setSpellingSuggestions(final Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + } + + /** + * Gets the spellingAutoCorrect. + * + *

Whether autocorrection is enabled for the workspace. If spelling correction is enabled and + * this property is `false`, any suggested corrections are returned in the **suggested_text** + * property of the message response. If this property is `true`, any corrections are automatically + * applied to the user input, and the original text is returned in the **original_text** property + * of the message response. + * + * @return the spellingAutoCorrect + */ + public Boolean isSpellingAutoCorrect() { + return this.spellingAutoCorrect; + } + + /** + * Sets the spellingAutoCorrect. + * + * @param spellingAutoCorrect the new spellingAutoCorrect + */ + public void setSpellingAutoCorrect(final Boolean spellingAutoCorrect) { + this.spellingAutoCorrect = spellingAutoCorrect; } /** * Gets the systemEntities. * - * Workspace settings related to the behavior of system entities. + *

Workspace settings related to the behavior of system entities. * * @return the systemEntities */ - public WorkspaceSystemSettingsSystemEntities systemEntities() { - return systemEntities; + public WorkspaceSystemSettingsSystemEntities getSystemEntities() { + return this.systemEntities; + } + + /** + * Sets the systemEntities. + * + * @param systemEntities the new systemEntities + */ + public void setSystemEntities(final WorkspaceSystemSettingsSystemEntities systemEntities) { + this.systemEntities = systemEntities; } /** * Gets the offTopic. * - * Workspace settings related to detection of irrelevant input. + *

Workspace settings related to detection of irrelevant input. * * @return the offTopic */ - public WorkspaceSystemSettingsOffTopic offTopic() { - return offTopic; + public WorkspaceSystemSettingsOffTopic getOffTopic() { + return this.offTopic; + } + + /** + * Sets the offTopic. + * + * @param offTopic the new offTopic + */ + public void setOffTopic(final WorkspaceSystemSettingsOffTopic offTopic) { + this.offTopic = offTopic; + } + + /** + * Gets the nlp. + * + *

Workspace settings related to the version of the training algorithms currently used by the + * skill. + * + * @return the nlp + */ + public WorkspaceSystemSettingsNlp getNlp() { + return this.nlp; + } + + /** + * Sets the nlp. + * + * @param nlp the new nlp + */ + public void setNlp(final WorkspaceSystemSettingsNlp nlp) { + this.nlp = nlp; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java index 8337d5336b0..80f3d6c563d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,43 +10,51 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Workspace settings related to the disambiguation feature. - * - * **Note:** This feature is available only to Plus and Premium users. - */ +/** Workspace settings related to the disambiguation feature. */ public class WorkspaceSystemSettingsDisambiguation extends GenericModel { /** - * The sensitivity of the disambiguation feature to intent detection conflicts. Set to **high** if you want the - * disambiguation feature to be triggered more often. This can be useful for testing or demonstration purposes. + * The sensitivity of the disambiguation feature to intent detection uncertainty. Higher + * sensitivity means that the disambiguation feature is triggered more often and includes more + * choices. */ public interface Sensitivity { /** auto. */ String AUTO = "auto"; /** high. */ String HIGH = "high"; + /** medium_high. */ + String MEDIUM_HIGH = "medium_high"; + /** medium. */ + String MEDIUM = "medium"; + /** medium_low. */ + String MEDIUM_LOW = "medium_low"; + /** low. */ + String LOW = "low"; } protected String prompt; + @SerializedName("none_of_the_above_prompt") protected String noneOfTheAbovePrompt; + protected Boolean enabled; protected String sensitivity; protected Boolean randomize; + @SerializedName("max_suggestions") protected Long maxSuggestions; + @SerializedName("suggestion_text_policy") protected String suggestionTextPolicy; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String prompt; private String noneOfTheAbovePrompt; @@ -56,6 +64,11 @@ public static class Builder { private Long maxSuggestions; private String suggestionTextPolicy; + /** + * Instantiates a new Builder from an existing WorkspaceSystemSettingsDisambiguation instance. + * + * @param workspaceSystemSettingsDisambiguation the instance to initialize the Builder with + */ private Builder(WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguation) { this.prompt = workspaceSystemSettingsDisambiguation.prompt; this.noneOfTheAbovePrompt = workspaceSystemSettingsDisambiguation.noneOfTheAbovePrompt; @@ -66,16 +79,13 @@ private Builder(WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDis this.suggestionTextPolicy = workspaceSystemSettingsDisambiguation.suggestionTextPolicy; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a WorkspaceSystemSettingsDisambiguation. * - * @return the workspaceSystemSettingsDisambiguation + * @return the new WorkspaceSystemSettingsDisambiguation instance */ public WorkspaceSystemSettingsDisambiguation build() { return new WorkspaceSystemSettingsDisambiguation(this); @@ -159,6 +169,8 @@ public Builder suggestionTextPolicy(String suggestionTextPolicy) { } } + protected WorkspaceSystemSettingsDisambiguation() {} + protected WorkspaceSystemSettingsDisambiguation(Builder builder) { prompt = builder.prompt; noneOfTheAbovePrompt = builder.noneOfTheAbovePrompt; @@ -181,7 +193,8 @@ public Builder newBuilder() { /** * Gets the prompt. * - * The text of the introductory prompt that accompanies disambiguation options presented to the user. + *

The text of the introductory prompt that accompanies disambiguation options presented to the + * user. * * @return the prompt */ @@ -192,8 +205,8 @@ public String prompt() { /** * Gets the noneOfTheAbovePrompt. * - * The user-facing label for the option users can select if none of the suggested options is correct. If no value is - * specified for this property, this option does not appear. + *

The user-facing label for the option users can select if none of the suggested options is + * correct. If no value is specified for this property, this option does not appear. * * @return the noneOfTheAbovePrompt */ @@ -204,7 +217,7 @@ public String noneOfTheAbovePrompt() { /** * Gets the enabled. * - * Whether the disambiguation feature is enabled for the workspace. + *

Whether the disambiguation feature is enabled for the workspace. * * @return the enabled */ @@ -215,8 +228,9 @@ public Boolean enabled() { /** * Gets the sensitivity. * - * The sensitivity of the disambiguation feature to intent detection conflicts. Set to **high** if you want the - * disambiguation feature to be triggered more often. This can be useful for testing or demonstration purposes. + *

The sensitivity of the disambiguation feature to intent detection uncertainty. Higher + * sensitivity means that the disambiguation feature is triggered more often and includes more + * choices. * * @return the sensitivity */ @@ -227,8 +241,8 @@ public String sensitivity() { /** * Gets the randomize. * - * Whether the order in which disambiguation suggestions are presented should be randomized (but still influenced by - * relative confidence). + *

Whether the order in which disambiguation suggestions are presented should be randomized + * (but still influenced by relative confidence). * * @return the randomize */ @@ -239,7 +253,8 @@ public Boolean randomize() { /** * Gets the maxSuggestions. * - * The maximum number of disambigation suggestions that can be included in a `suggestion` response. + *

The maximum number of disambigation suggestions that can be included in a `suggestion` + * response. * * @return the maxSuggestions */ @@ -250,7 +265,7 @@ public Long maxSuggestions() { /** * Gets the suggestionTextPolicy. * - * For internal use only. + *

For internal use only. * * @return the suggestionTextPolicy */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsNlp.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsNlp.java new file mode 100644 index 00000000000..ea83778cf94 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsNlp.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Workspace settings related to the version of the training algorithms currently used by the skill. + */ +public class WorkspaceSystemSettingsNlp extends GenericModel { + + protected String model; + + /** Builder. */ + public static class Builder { + private String model; + + /** + * Instantiates a new Builder from an existing WorkspaceSystemSettingsNlp instance. + * + * @param workspaceSystemSettingsNlp the instance to initialize the Builder with + */ + private Builder(WorkspaceSystemSettingsNlp workspaceSystemSettingsNlp) { + this.model = workspaceSystemSettingsNlp.model; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a WorkspaceSystemSettingsNlp. + * + * @return the new WorkspaceSystemSettingsNlp instance + */ + public WorkspaceSystemSettingsNlp build() { + return new WorkspaceSystemSettingsNlp(this); + } + + /** + * Set the model. + * + * @param model the model + * @return the WorkspaceSystemSettingsNlp builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + protected WorkspaceSystemSettingsNlp() {} + + protected WorkspaceSystemSettingsNlp(Builder builder) { + model = builder.model; + } + + /** + * New builder. + * + * @return a WorkspaceSystemSettingsNlp builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the model. + * + *

The policy the skill follows for selecting the algorithm version to use. For more + * information, see the + * [documentation](/docs/watson-assistant?topic=watson-assistant-algorithm-version). + * + *

On IBM Cloud, you can specify `latest`, `previous`, or `beta`. + * + *

On IBM Cloud Pak for Data, you can specify either `beta` or the date of the version you want + * to use, in `YYYY-MM-DD` format. + * + * @return the model + */ + public String model() { + return model; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java index ab770c032a5..f948dc2ecf3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,37 +10,36 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Workspace settings related to detection of irrelevant input. - */ +/** Workspace settings related to detection of irrelevant input. */ public class WorkspaceSystemSettingsOffTopic extends GenericModel { protected Boolean enabled; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean enabled; + /** + * Instantiates a new Builder from an existing WorkspaceSystemSettingsOffTopic instance. + * + * @param workspaceSystemSettingsOffTopic the instance to initialize the Builder with + */ private Builder(WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopic) { this.enabled = workspaceSystemSettingsOffTopic.enabled; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a WorkspaceSystemSettingsOffTopic. * - * @return the workspaceSystemSettingsOffTopic + * @return the new WorkspaceSystemSettingsOffTopic instance */ public WorkspaceSystemSettingsOffTopic build() { return new WorkspaceSystemSettingsOffTopic(this); @@ -58,6 +57,8 @@ public Builder enabled(Boolean enabled) { } } + protected WorkspaceSystemSettingsOffTopic() {} + protected WorkspaceSystemSettingsOffTopic(Builder builder) { enabled = builder.enabled; } @@ -74,7 +75,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - * Whether enhanced irrelevance detection is enabled for the workspace. + *

Whether enhanced irrelevance detection is enabled for the workspace. * * @return the enabled */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java index fdd10fb286c..2cb0a99a5dc 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2024. * * 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 @@ -10,37 +10,36 @@ * 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.assistant.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Workspace settings related to the behavior of system entities. - */ +/** Workspace settings related to the behavior of system entities. */ public class WorkspaceSystemSettingsSystemEntities extends GenericModel { protected Boolean enabled; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean enabled; + /** + * Instantiates a new Builder from an existing WorkspaceSystemSettingsSystemEntities instance. + * + * @param workspaceSystemSettingsSystemEntities the instance to initialize the Builder with + */ private Builder(WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntities) { this.enabled = workspaceSystemSettingsSystemEntities.enabled; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a WorkspaceSystemSettingsSystemEntities. * - * @return the workspaceSystemSettingsSystemEntities + * @return the new WorkspaceSystemSettingsSystemEntities instance */ public WorkspaceSystemSettingsSystemEntities build() { return new WorkspaceSystemSettingsSystemEntities(this); @@ -58,6 +57,8 @@ public Builder enabled(Boolean enabled) { } } + protected WorkspaceSystemSettingsSystemEntities() {} + protected WorkspaceSystemSettingsSystemEntities(Builder builder) { enabled = builder.enabled; } @@ -74,7 +75,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - * Whether the new system entities are enabled for the workspace. + *

Whether the new system entities are enabled for the workspace. * * @return the enabled */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java index 886d5c2cb72..b4e0484f734 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,39 +10,38 @@ * 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.assistant.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Workspace settings related to the Watson Assistant user interface. - */ +/** Workspace settings related to the Watson Assistant user interface. */ public class WorkspaceSystemSettingsTooling extends GenericModel { @SerializedName("store_generic_responses") protected Boolean storeGenericResponses; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean storeGenericResponses; + /** + * Instantiates a new Builder from an existing WorkspaceSystemSettingsTooling instance. + * + * @param workspaceSystemSettingsTooling the instance to initialize the Builder with + */ private Builder(WorkspaceSystemSettingsTooling workspaceSystemSettingsTooling) { this.storeGenericResponses = workspaceSystemSettingsTooling.storeGenericResponses; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a WorkspaceSystemSettingsTooling. * - * @return the workspaceSystemSettingsTooling + * @return the new WorkspaceSystemSettingsTooling instance */ public WorkspaceSystemSettingsTooling build() { return new WorkspaceSystemSettingsTooling(this); @@ -60,6 +59,8 @@ public Builder storeGenericResponses(Boolean storeGenericResponses) { } } + protected WorkspaceSystemSettingsTooling() {} + protected WorkspaceSystemSettingsTooling(Builder builder) { storeGenericResponses = builder.storeGenericResponses; } @@ -76,7 +77,7 @@ public Builder newBuilder() { /** * Gets the storeGenericResponses. * - * Whether the dialog JSON editor displays text responses within the `output.generic` object. + *

Whether the dialog JSON editor displays text responses within the `output.generic` object. * * @return the storeGenericResponses */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java index 12f9f08112a..2c201294c43 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,7 +10,6 @@ * 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. */ -/** - * Watson Assistant v1 v1. - */ + +/** Watson Assistant v1 v1. */ package com.ibm.watson.assistant.v1; diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java index ee6465d2215..0316d173cb7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2025. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116 + */ + package com.ibm.watson.assistant.v2; import com.google.gson.JsonObject; @@ -20,178 +25,1621 @@ import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import com.ibm.watson.assistant.v2.model.AssistantCollection; +import com.ibm.watson.assistant.v2.model.AssistantData; +import com.ibm.watson.assistant.v2.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v2.model.BulkClassifyResponse; +import com.ibm.watson.assistant.v2.model.CreateAssistantOptions; +import com.ibm.watson.assistant.v2.model.CreateAssistantReleaseImportResponse; +import com.ibm.watson.assistant.v2.model.CreateProviderOptions; +import com.ibm.watson.assistant.v2.model.CreateReleaseExportOptions; +import com.ibm.watson.assistant.v2.model.CreateReleaseExportWithStatusErrors; +import com.ibm.watson.assistant.v2.model.CreateReleaseImportOptions; +import com.ibm.watson.assistant.v2.model.CreateReleaseOptions; import com.ibm.watson.assistant.v2.model.CreateSessionOptions; +import com.ibm.watson.assistant.v2.model.DeleteAssistantOptions; +import com.ibm.watson.assistant.v2.model.DeleteReleaseOptions; import com.ibm.watson.assistant.v2.model.DeleteSessionOptions; +import com.ibm.watson.assistant.v2.model.DeleteUserDataOptions; +import com.ibm.watson.assistant.v2.model.DeployReleaseOptions; +import com.ibm.watson.assistant.v2.model.DownloadReleaseExportOptions; +import com.ibm.watson.assistant.v2.model.Environment; +import com.ibm.watson.assistant.v2.model.EnvironmentCollection; +import com.ibm.watson.assistant.v2.model.ExportSkillsOptions; +import com.ibm.watson.assistant.v2.model.GetEnvironmentOptions; +import com.ibm.watson.assistant.v2.model.GetReleaseImportStatusOptions; +import com.ibm.watson.assistant.v2.model.GetReleaseOptions; +import com.ibm.watson.assistant.v2.model.GetSkillOptions; +import com.ibm.watson.assistant.v2.model.ImportSkillsOptions; +import com.ibm.watson.assistant.v2.model.ImportSkillsStatusOptions; +import com.ibm.watson.assistant.v2.model.ListAssistantsOptions; +import com.ibm.watson.assistant.v2.model.ListEnvironmentsOptions; +import com.ibm.watson.assistant.v2.model.ListLogsOptions; +import com.ibm.watson.assistant.v2.model.ListProvidersOptions; +import com.ibm.watson.assistant.v2.model.ListReleasesOptions; +import com.ibm.watson.assistant.v2.model.LogCollection; import com.ibm.watson.assistant.v2.model.MessageOptions; -import com.ibm.watson.assistant.v2.model.MessageResponse; +import com.ibm.watson.assistant.v2.model.MessageStatelessOptions; +import com.ibm.watson.assistant.v2.model.MessageStreamOptions; +import com.ibm.watson.assistant.v2.model.MessageStreamStatelessOptions; +import com.ibm.watson.assistant.v2.model.MonitorAssistantReleaseImportArtifactResponse; +import com.ibm.watson.assistant.v2.model.ProviderCollection; +import com.ibm.watson.assistant.v2.model.ProviderResponse; +import com.ibm.watson.assistant.v2.model.Release; +import com.ibm.watson.assistant.v2.model.ReleaseCollection; import com.ibm.watson.assistant.v2.model.SessionResponse; +import com.ibm.watson.assistant.v2.model.Skill; +import com.ibm.watson.assistant.v2.model.SkillsAsyncRequestStatus; +import com.ibm.watson.assistant.v2.model.SkillsExport; +import com.ibm.watson.assistant.v2.model.StatefulMessageResponse; +import com.ibm.watson.assistant.v2.model.StatelessMessageResponse; +import com.ibm.watson.assistant.v2.model.UpdateEnvironmentOptions; +import com.ibm.watson.assistant.v2.model.UpdateProviderOptions; +import com.ibm.watson.assistant.v2.model.UpdateSkillOptions; import com.ibm.watson.common.SdkCommon; +import java.io.InputStream; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; /** - * The IBM Watson™ Assistant service combines machine learning, natural language understanding, and an integrated - * dialog editor to create conversation flows between your apps and your users. + * The IBM&reg; watsonx&trade; Assistant service combines machine learning, natural language + * understanding, and an integrated dialog editor to create conversation flows between your apps and + * your users. * - * The Assistant v2 API provides runtime methods your client application can use to send user input to an assistant and - * receive a response. + *

The Assistant v2 API provides runtime methods your client application can use to send user + * input to an assistant and receive a response. * - * @version v2 - * @see Assistant + *

You need a paid Plus plan or higher to use the watsonx Assistant v2 API. + * + *

API Version: 2.0 See: https://cloud.ibm.com/docs/assistant */ public class Assistant extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "assistant"; + /** Default service name used when configuring the `Assistant` client. */ + public static final String DEFAULT_SERVICE_NAME = "assistant"; - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/assistant/api"; + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.assistant.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `Assistant` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Assistant` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2024-08-25`. */ - public Assistant(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + public Assistant(String version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Assistant` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. + * Constructs an instance of the `Assistant` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2024-08-25`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Assistant(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Assistant` client with the specified serviceName. + * Constructs an instance of the `Assistant` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2024-08-25`. + * @param serviceName the service name to be used when configuring the client instance */ - public Assistant(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Assistant(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Assistant` client with the specified Authenticator - * and serviceName. + * Constructs an instance of the `Assistant` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2024-08-25`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, String serviceName, Authenticator authenticator) { + public Assistant(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2024-08-25`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + + /** + * Create a conversational skill provider. + * + *

Create a new conversational skill provider. + * + * @param createProviderOptions the {@link CreateProviderOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ProviderResponse} + */ + public ServiceCall createProvider(CreateProviderOptions createProviderOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createProviderOptions, "createProviderOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/providers")); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "createProvider"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("provider_id", createProviderOptions.providerId()); + contentJson.add( + "specification", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createProviderOptions.specification())); + contentJson.add( + "private", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createProviderOptions.xPrivate())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List conversational skill providers. + * + *

List the conversational skill providers associated with a Watson Assistant service instance. + * + * @param listProvidersOptions the {@link ListProvidersOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ProviderCollection} + */ + public ServiceCall listProviders(ListProvidersOptions listProvidersOptions) { + if (listProvidersOptions == null) { + listProvidersOptions = new ListProvidersOptions.Builder().build(); + } + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/providers")); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "listProviders"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listProvidersOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listProvidersOptions.pageLimit())); + } + if (listProvidersOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listProvidersOptions.includeCount())); + } + if (listProvidersOptions.sort() != null) { + builder.query("sort", String.valueOf(listProvidersOptions.sort())); + } + if (listProvidersOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listProvidersOptions.cursor())); + } + if (listProvidersOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(listProvidersOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List conversational skill providers. + * + *

List the conversational skill providers associated with a Watson Assistant service instance. + * + * @return a {@link ServiceCall} with a result of type {@link ProviderCollection} + */ + public ServiceCall listProviders() { + return listProviders(null); + } + + /** + * Update a conversational skill provider. + * + *

Update a new conversational skill provider. + * + * @param updateProviderOptions the {@link UpdateProviderOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ProviderResponse} + */ + public ServiceCall updateProvider(UpdateProviderOptions updateProviderOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateProviderOptions, "updateProviderOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("provider_id", updateProviderOptions.providerId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/providers/{provider_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "updateProvider"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.add( + "specification", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateProviderOptions.specification())); + contentJson.add( + "private", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateProviderOptions.xPrivate())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create an assistant. + * + *

Create a new assistant. + * + * @param createAssistantOptions the {@link CreateAssistantOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link AssistantData} + */ + public ServiceCall createAssistant(CreateAssistantOptions createAssistantOptions) { + boolean skipBody = false; + if (createAssistantOptions == null) { + createAssistantOptions = new CreateAssistantOptions.Builder().build(); + skipBody = true; + } + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/assistants")); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "createAssistant"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (!skipBody) { + final JsonObject contentJson = new JsonObject(); + if (createAssistantOptions.name() != null) { + contentJson.addProperty("name", createAssistantOptions.name()); + } + if (createAssistantOptions.description() != null) { + contentJson.addProperty("description", createAssistantOptions.description()); + } + if (createAssistantOptions.language() != null) { + contentJson.addProperty("language", createAssistantOptions.language()); + } + builder.bodyJson(contentJson); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create an assistant. + * + *

Create a new assistant. + * + * @return a {@link ServiceCall} with a result of type {@link AssistantData} + */ + public ServiceCall createAssistant() { + return createAssistant(null); + } + + /** + * List assistants. + * + *

List the assistants associated with a watsonx Assistant service instance. + * + * @param listAssistantsOptions the {@link ListAssistantsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link AssistantCollection} + */ + public ServiceCall listAssistants( + ListAssistantsOptions listAssistantsOptions) { + if (listAssistantsOptions == null) { + listAssistantsOptions = new ListAssistantsOptions.Builder().build(); + } + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/assistants")); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "listAssistants"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listAssistantsOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listAssistantsOptions.pageLimit())); + } + if (listAssistantsOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listAssistantsOptions.includeCount())); + } + if (listAssistantsOptions.sort() != null) { + builder.query("sort", String.valueOf(listAssistantsOptions.sort())); + } + if (listAssistantsOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listAssistantsOptions.cursor())); + } + if (listAssistantsOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(listAssistantsOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List assistants. + * + *

List the assistants associated with a watsonx Assistant service instance. + * + * @return a {@link ServiceCall} with a result of type {@link AssistantCollection} + */ + public ServiceCall listAssistants() { + return listAssistants(null); + } + + /** + * Delete assistant. + * + *

Delete an assistant. + * + * @param deleteAssistantOptions the {@link DeleteAssistantOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteAssistant(DeleteAssistantOptions deleteAssistantOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteAssistantOptions, "deleteAssistantOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", deleteAssistantOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "deleteAssistant"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + /** * Create a session. * - * Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the - * state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. - * (For more information, see the - * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings). + *

Create a new session. A session is used to send user input to a skill and receive responses. + * It also maintains the state of the conversation. A session persists until it is deleted, or + * until it times out because of inactivity. (For more information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings).). * - * @param createSessionOptions the {@link CreateSessionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SessionResponse} + * @param createSessionOptions the {@link CreateSessionOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link SessionResponse} */ public ServiceCall createSession(CreateSessionOptions createSessionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createSessionOptions, - "createSessionOptions cannot be null"); - String[] pathSegments = { "v2/assistants", "sessions" }; - String[] pathParameters = { createSessionOptions.assistantId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "createSession"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createSessionOptions, "createSessionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", createSessionOptions.assistantId()); + pathParamsMap.put("environment_id", createSessionOptions.environmentId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}/sessions", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "createSession"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (createSessionOptions.analytics() != null) { + contentJson.add( + "analytics", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createSessionOptions.analytics())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete session. * - * Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see - * the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings)). + *

Deletes a session explicitly before it times out. (For more information about the session + * inactivity timeout, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings)). * - * @param deleteSessionOptions the {@link DeleteSessionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteSessionOptions the {@link DeleteSessionOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteSession(DeleteSessionOptions deleteSessionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteSessionOptions, - "deleteSessionOptions cannot be null"); - String[] pathSegments = { "v2/assistants", "sessions" }; - String[] pathParameters = { deleteSessionOptions.assistantId(), deleteSessionOptions.sessionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "deleteSession"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteSessionOptions, "deleteSessionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", deleteSessionOptions.assistantId()); + pathParamsMap.put("environment_id", deleteSessionOptions.environmentId()); + pathParamsMap.put("session_id", deleteSessionOptions.sessionId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}/sessions/{session_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "deleteSession"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } /** - * Send user input to assistant. + * Send user input to assistant (stateful). * - * Send user input to an assistant and receive a response. - * - * There is no rate limit for this operation. + *

Send user input to an assistant and receive a response, with conversation state (including + * context data) stored by watsonx Assistant for the duration of the session. * * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponse} + * @return a {@link ServiceCall} with a result of type {@link StatefulMessageResponse} */ - public ServiceCall message(MessageOptions messageOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, - "messageOptions cannot be null"); - String[] pathSegments = { "v2/assistants", "sessions", "message" }; - String[] pathParameters = { messageOptions.assistantId(), messageOptions.sessionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "message"); + public ServiceCall message(MessageOptions messageOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, "messageOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", messageOptions.assistantId()); + pathParamsMap.put("environment_id", messageOptions.environmentId()); + pathParamsMap.put("session_id", messageOptions.sessionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}/sessions/{session_id}/message", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "message"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (messageOptions.input() != null) { - contentJson.add("input", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.input())); + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.input())); } if (messageOptions.context() != null) { - contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions - .context())); + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(messageOptions.context())); + } + if (messageOptions.userId() != null) { + contentJson.addProperty("user_id", messageOptions.userId()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Send user input to assistant (stateless). + * + *

Send user input to an assistant and receive a response, with conversation state (including + * context data) managed by your application. + * + * @param messageStatelessOptions the {@link MessageStatelessOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link StatelessMessageResponse} + */ + public ServiceCall messageStateless( + MessageStatelessOptions messageStatelessOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + messageStatelessOptions, "messageStatelessOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", messageStatelessOptions.assistantId()); + pathParamsMap.put("environment_id", messageStatelessOptions.environmentId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}/message", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "messageStateless"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (messageStatelessOptions.input() != null) { + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageStatelessOptions.input())); + } + if (messageStatelessOptions.context() != null) { + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageStatelessOptions.context())); + } + if (messageStatelessOptions.userId() != null) { + contentJson.addProperty("user_id", messageStatelessOptions.userId()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Send user input to assistant (stateful). + * + *

Send user input to an assistant and receive a streamed response, with conversation state + * (including context data) stored by watsonx Assistant for the duration of the session. + * + * @param messageStreamOptions the {@link MessageStreamOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link InputStream} + */ + public ServiceCall messageStream(MessageStreamOptions messageStreamOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + messageStreamOptions, "messageStreamOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", messageStreamOptions.assistantId()); + pathParamsMap.put("environment_id", messageStreamOptions.environmentId()); + pathParamsMap.put("session_id", messageStreamOptions.sessionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}/sessions/{session_id}/message_stream", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "messageStream"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "text/event-stream"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (messageStreamOptions.input() != null) { + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageStreamOptions.input())); + } + if (messageStreamOptions.context() != null) { + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageStreamOptions.context())); + } + if (messageStreamOptions.userId() != null) { + contentJson.addProperty("user_id", messageStreamOptions.userId()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Send user input to assistant (stateless). + * + *

Send user input to an assistant and receive a response, with conversation state (including + * context data) managed by your application. + * + * @param messageStreamStatelessOptions the {@link MessageStreamStatelessOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} + */ + public ServiceCall messageStreamStateless( + MessageStreamStatelessOptions messageStreamStatelessOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + messageStreamStatelessOptions, "messageStreamStatelessOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", messageStreamStatelessOptions.assistantId()); + pathParamsMap.put("environment_id", messageStreamStatelessOptions.environmentId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}/message_stream", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "messageStreamStateless"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "text/event-stream"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (messageStreamStatelessOptions.input() != null) { + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageStreamStatelessOptions.input())); + } + if (messageStreamStatelessOptions.context() != null) { + contentJson.add( + "context", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(messageStreamStatelessOptions.context())); + } + if (messageStreamStatelessOptions.userId() != null) { + contentJson.addProperty("user_id", messageStreamStatelessOptions.userId()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Identify intents and entities in multiple user utterances. + * + *

Send multiple user inputs to a dialog skill in a single request and receive information + * about the intents and entities recognized in each input. This method is useful for testing and + * comparing the performance of different skills or skill versions. + * + *

This method is available only with Enterprise with Data Isolation plans. + * + * @param bulkClassifyOptions the {@link BulkClassifyOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link BulkClassifyResponse} + */ + public ServiceCall bulkClassify(BulkClassifyOptions bulkClassifyOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + bulkClassifyOptions, "bulkClassifyOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("skill_id", bulkClassifyOptions.skillId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/skills/{skill_id}/workspace/bulk_classify", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "bulkClassify"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(bulkClassifyOptions.input())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List log events for an assistant. + * + *

List the events from the log of an assistant. + * + *

This method requires Manager access. + * + *

**Note:** If you use the **cursor** parameter to retrieve results one page at a time, + * subsequent requests must be no more than 5 minutes apart. Any returned value for the **cursor** + * parameter becomes invalid after 5 minutes. For more information about using pagination, see + * [Pagination](#pagination). + * + * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link LogCollection} + */ + public ServiceCall listLogs(ListLogsOptions listLogsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listLogsOptions, "listLogsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", listLogsOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/logs", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "listLogs"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listLogsOptions.sort() != null) { + builder.query("sort", String.valueOf(listLogsOptions.sort())); + } + if (listLogsOptions.filter() != null) { + builder.query("filter", String.valueOf(listLogsOptions.filter())); + } + if (listLogsOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit())); + } + if (listLogsOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listLogsOptions.cursor())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete labeled data. + * + *

Deletes all data associated with a specified customer ID. The method has no effect if no + * data is associated with the customer ID. + * + *

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/assistant?topic=assistant-information-security#information-security). + * + *

**Note:** This operation is intended only for deleting data associated with a single + * specific customer, not for deleting data associated with multiple customers or for any other + * purpose. For more information, see [Labeling and deleting data in watsonx + * Assistant](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security-gdpr-wa). + * + * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteUserDataOptions, "deleteUserDataOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/user_data")); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "deleteUserData"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List environments. + * + *

List the environments associated with an assistant. + * + * @param listEnvironmentsOptions the {@link ListEnvironmentsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link EnvironmentCollection} + */ + public ServiceCall listEnvironments( + ListEnvironmentsOptions listEnvironmentsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listEnvironmentsOptions, "listEnvironmentsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", listEnvironmentsOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/environments", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "listEnvironments"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listEnvironmentsOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listEnvironmentsOptions.pageLimit())); + } + if (listEnvironmentsOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listEnvironmentsOptions.includeCount())); } + if (listEnvironmentsOptions.sort() != null) { + builder.query("sort", String.valueOf(listEnvironmentsOptions.sort())); + } + if (listEnvironmentsOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listEnvironmentsOptions.cursor())); + } + if (listEnvironmentsOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(listEnvironmentsOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get environment. + * + *

Get information about an environment. For more information about environments, see + * [Environments](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-publish-overview#environments). + * + * @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Environment} + */ + public ServiceCall getEnvironment(GetEnvironmentOptions getEnvironmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getEnvironmentOptions, "getEnvironmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", getEnvironmentOptions.assistantId()); + pathParamsMap.put("environment_id", getEnvironmentOptions.environmentId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "getEnvironment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (getEnvironmentOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(getEnvironmentOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update environment. + * + *

Update an environment with new or modified data. For more information about environments, + * see + * [Environments](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-publish-overview#environments). + * + * @param updateEnvironmentOptions the {@link UpdateEnvironmentOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Environment} + */ + public ServiceCall updateEnvironment( + UpdateEnvironmentOptions updateEnvironmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateEnvironmentOptions, "updateEnvironmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", updateEnvironmentOptions.assistantId()); + pathParamsMap.put("environment_id", updateEnvironmentOptions.environmentId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/environments/{environment_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "updateEnvironment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (updateEnvironmentOptions.name() != null) { + contentJson.addProperty("name", updateEnvironmentOptions.name()); + } + if (updateEnvironmentOptions.description() != null) { + contentJson.addProperty("description", updateEnvironmentOptions.description()); + } + if (updateEnvironmentOptions.orchestration() != null) { + contentJson.add( + "orchestration", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateEnvironmentOptions.orchestration())); + } + if (updateEnvironmentOptions.sessionTimeout() != null) { + contentJson.addProperty("session_timeout", updateEnvironmentOptions.sessionTimeout()); + } + if (updateEnvironmentOptions.skillReferences() != null) { + contentJson.add( + "skill_references", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateEnvironmentOptions.skillReferences())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create release. + * + *

Create a new release using the current content of the dialog and action skills in the draft + * environment. (In the watsonx Assistant user interface, a release is called a *version*.). + * + * @param createReleaseOptions the {@link CreateReleaseOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Release} + */ + public ServiceCall createRelease(CreateReleaseOptions createReleaseOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createReleaseOptions, "createReleaseOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", createReleaseOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/releases", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "createRelease"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (createReleaseOptions.description() != null) { + contentJson.addProperty("description", createReleaseOptions.description()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List releases. + * + *

List the releases associated with an assistant. (In the watsonx Assistant user interface, a + * release is called a *version*.). + * + * @param listReleasesOptions the {@link ListReleasesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ReleaseCollection} + */ + public ServiceCall listReleases(ListReleasesOptions listReleasesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listReleasesOptions, "listReleasesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", listReleasesOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/releases", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "listReleases"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listReleasesOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listReleasesOptions.pageLimit())); + } + if (listReleasesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listReleasesOptions.includeCount())); + } + if (listReleasesOptions.sort() != null) { + builder.query("sort", String.valueOf(listReleasesOptions.sort())); + } + if (listReleasesOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listReleasesOptions.cursor())); + } + if (listReleasesOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(listReleasesOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get release. + * + *

Get information about a release. + * + *

Release data is not available until publishing of the release completes. If publishing is + * still in progress, you can continue to poll by calling the same request again and checking the + * value of the **status** property. When processing has completed, the request returns the + * release data. + * + * @param getReleaseOptions the {@link GetReleaseOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Release} + */ + public ServiceCall getRelease(GetReleaseOptions getReleaseOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getReleaseOptions, "getReleaseOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", getReleaseOptions.assistantId()); + pathParamsMap.put("release", getReleaseOptions.release()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/releases/{release}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "getRelease"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (getReleaseOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(getReleaseOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete release. + * + *

Delete a release. (In the watsonx Assistant user interface, a release is called a + * *version*.). + * + * @param deleteReleaseOptions the {@link DeleteReleaseOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteRelease(DeleteReleaseOptions deleteReleaseOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteReleaseOptions, "deleteReleaseOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", deleteReleaseOptions.assistantId()); + pathParamsMap.put("release", deleteReleaseOptions.release()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/releases/{release}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "deleteRelease"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Deploy release. + * + *

Update the environment with the content of the release. All snapshots saved as part of the + * release become active in the environment. + * + * @param deployReleaseOptions the {@link DeployReleaseOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Environment} + */ + public ServiceCall deployRelease(DeployReleaseOptions deployReleaseOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deployReleaseOptions, "deployReleaseOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", deployReleaseOptions.assistantId()); + pathParamsMap.put("release", deployReleaseOptions.release()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/releases/{release}/deploy", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "deployRelease"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (deployReleaseOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(deployReleaseOptions.includeAudit())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("environment_id", deployReleaseOptions.environmentId()); builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } + /** + * Create release export. + * + *

Initiate an asynchronous process which will create a downloadable Zip file artifact + * (/package) for an assistant release. This artifact will contain Action and/or Dialog skills + * that are part of the release. The Dialog skill will only be included in the event that + * coexistence is enabled on the assistant. The expected workflow with the use of Release Export + * endpoint is to first initiate the creation of the artifact with the POST endpoint and then poll + * the GET endpoint to retrieve the artifact. Once the artifact has been created, it will last for + * the duration (/scope) of the release. + * + * @param createReleaseExportOptions the {@link CreateReleaseExportOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link CreateReleaseExportWithStatusErrors} + */ + public ServiceCall createReleaseExport( + CreateReleaseExportOptions createReleaseExportOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createReleaseExportOptions, "createReleaseExportOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", createReleaseExportOptions.assistantId()); + pathParamsMap.put("release", createReleaseExportOptions.release()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/releases/{release}/export", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "createReleaseExport"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (createReleaseExportOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(createReleaseExportOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken< + CreateReleaseExportWithStatusErrors>() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get release export. + * + *

A dual function endpoint to either retrieve the Zip file artifact that is associated with an + * assistant release or, retrieve the status of the artifact's creation. It is assumed that the + * artifact creation was already initiated prior to calling this endpoint. In the event that the + * artifact is not yet created and ready for download, this endpoint can be used to poll the + * system until the creation is completed or has failed. On the other hand, if the artifact is + * created, this endpoint will return the Zip file artifact as an octet stream. Once the artifact + * has been created, it will last for the duration (/scope) of the release. <br /><br + * /> When you will have downloaded the Zip file artifact, you have one of three ways to import + * it into an assistant's draft environment. These are as follows. <br + * /><ol><li>Import the zip package in Tooling via <var>"Assistant Settings" + * -> "Download/Upload files" -> "Upload" -> "Assistant + * only"</var>.</li><li>Import the zip package via "Create release import" + * endpoint using the APIs.</li><li>Extract the contents of the Zip file artifact and + * individually import the skill JSONs via skill update endpoints.</li></ol>. + * + * @param downloadReleaseExportOptions the {@link DownloadReleaseExportOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link CreateReleaseExportWithStatusErrors} + */ + public ServiceCall downloadReleaseExport( + DownloadReleaseExportOptions downloadReleaseExportOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + downloadReleaseExportOptions, "downloadReleaseExportOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", downloadReleaseExportOptions.assistantId()); + pathParamsMap.put("release", downloadReleaseExportOptions.release()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/releases/{release}/export", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "downloadReleaseExport"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (downloadReleaseExportOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(downloadReleaseExportOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken< + CreateReleaseExportWithStatusErrors>() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get release export as stream. + * + *

A dual function endpoint to either retrieve the Zip file artifact that is associated with an + * assistant release or, retrieve the status of the artifact's creation. It is assumed that the + * artifact creation was already initiated prior to calling this endpoint. In the event that the + * artifact is not yet created and ready for download, this endpoint can be used to poll the + * system until the creation is completed or has failed. On the other hand, if the artifact is + * created, this endpoint will return the Zip file artifact as an octet stream. Once the artifact + * has been created, it will last for the duration (/scope) of the release. <br /><br + * /> When you will have downloaded the Zip file artifact, you have one of three ways to import + * it into an assistant's draft environment. These are as follows. <br + * /><ol><li>Import the zip package in Tooling via <var>"Assistant Settings" + * -> "Download/Upload files" -> "Upload" -> "Assistant + * only"</var>.</li><li>Import the zip package via "Create release import" + * endpoint using the APIs.</li><li>Extract the contents of the Zip file artifact and + * individually import the skill JSONs via skill update endpoints.</li></ol>. + * + * @param downloadReleaseExportOptions the {@link DownloadReleaseExportOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} + */ + public ServiceCall downloadReleaseExportAsStream( + DownloadReleaseExportOptions downloadReleaseExportOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + downloadReleaseExportOptions, "downloadReleaseExportOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", downloadReleaseExportOptions.assistantId()); + pathParamsMap.put("release", downloadReleaseExportOptions.release()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/releases/{release}/export", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "downloadReleaseExportAsStream"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/octet-stream"); + builder.query("version", String.valueOf(this.version)); + if (downloadReleaseExportOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(downloadReleaseExportOptions.includeAudit())); + } + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create release import. + * + *

Import a previously exported assistant release Zip file artifact (/package) into an + * assistant. This endpoint creates (/initiates) an asynchronous task (/job) in the background + * which will import the artifact contents into the draft environment of the assistant on which + * this endpoint is called. Specifically, the asynchronous operation will override the action + * and/or dialog skills in the assistant. It will be worth noting that when the artifact that is + * provided to this endpoint is from an assistant release which has coexistence enabled (i.e., it + * has both action and dialog skills), the import process will automatically enable coexistence, + * if not already enabled, on the assistant into which said artifact is being uploaded to. On the + * other hand, if the artifact package being imported only has action skill in it, the import + * asynchronous process will only override the draft environment's action skill, regardless of + * whether coexistence is enabled on the assistant into which the package is being imported. + * Lastly, the system will only run one asynchronous import at a time on an assistant. As such, + * consecutive imports will override previous import's updates to the skills in the draft + * environment. Once created, you may poll the completion of the import via the "Get release + * import Status" endpoint. + * + * @param createReleaseImportOptions the {@link CreateReleaseImportOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link + * CreateAssistantReleaseImportResponse} + */ + public ServiceCall createReleaseImport( + CreateReleaseImportOptions createReleaseImportOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createReleaseImportOptions, "createReleaseImportOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", createReleaseImportOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/import", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "createReleaseImport"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (createReleaseImportOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(createReleaseImportOptions.includeAudit())); + } + builder.bodyContent(createReleaseImportOptions.body(), "application/octet-stream"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken< + CreateAssistantReleaseImportResponse>() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get release import Status. + * + *

Monitor the status of an assistant release import. You may poll this endpoint until the + * status of the import has either succeeded or failed. + * + * @param getReleaseImportStatusOptions the {@link GetReleaseImportStatusOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link + * MonitorAssistantReleaseImportArtifactResponse} + */ + public ServiceCall getReleaseImportStatus( + GetReleaseImportStatusOptions getReleaseImportStatusOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getReleaseImportStatusOptions, "getReleaseImportStatusOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", getReleaseImportStatusOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/import", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "getReleaseImportStatus"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (getReleaseImportStatusOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(getReleaseImportStatusOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken< + MonitorAssistantReleaseImportArtifactResponse>() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get skill. + * + *

Get information about a skill. + * + * @param getSkillOptions the {@link GetSkillOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Skill} + */ + public ServiceCall getSkill(GetSkillOptions getSkillOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getSkillOptions, "getSkillOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", getSkillOptions.assistantId()); + pathParamsMap.put("skill_id", getSkillOptions.skillId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/skills/{skill_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "getSkill"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update skill. + * + *

Update a skill with new or modified data. + * + *

**Note:** The update is performed asynchronously; you can see the status of the update by + * calling the **Get skill** method and checking the value of the **status** property. + * + * @param updateSkillOptions the {@link UpdateSkillOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Skill} + */ + public ServiceCall updateSkill(UpdateSkillOptions updateSkillOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateSkillOptions, "updateSkillOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", updateSkillOptions.assistantId()); + pathParamsMap.put("skill_id", updateSkillOptions.skillId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/skills/{skill_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "updateSkill"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (updateSkillOptions.name() != null) { + contentJson.addProperty("name", updateSkillOptions.name()); + } + if (updateSkillOptions.description() != null) { + contentJson.addProperty("description", updateSkillOptions.description()); + } + if (updateSkillOptions.workspace() != null) { + contentJson.add( + "workspace", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateSkillOptions.workspace())); + } + if (updateSkillOptions.dialogSettings() != null) { + contentJson.add( + "dialog_settings", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateSkillOptions.dialogSettings())); + } + if (updateSkillOptions.searchSettings() != null) { + contentJson.add( + "search_settings", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateSkillOptions.searchSettings())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Export skills. + * + *

Asynchronously export the action skill and dialog skill (if enabled) for the assistant. Use + * this method to save all skill data from the draft environment so that you can import it to a + * different assistant using the **Import skills** method. Use `assistant_id` instead of + * `environment_id` to call this endpoint. + * + *

A successful call to this method only initiates an asynchronous export. The exported JSON + * data is not available until processing completes. + * + *

After the initial request is submitted, you can poll the status of the operation by calling + * the same request again and checking the value of the **status** property. If an error occurs + * (indicated by a **status** value of `Failed`), the `status_description` property provides more + * information about the error, and the `status_errors` property contains an array of error + * messages that caused the failure. + * + *

When processing has completed, the request returns the exported JSON data. Remember that the + * usual rate limits apply. + * + * @param exportSkillsOptions the {@link ExportSkillsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SkillsExport} + */ + public ServiceCall exportSkills(ExportSkillsOptions exportSkillsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + exportSkillsOptions, "exportSkillsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", exportSkillsOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/skills_export", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "exportSkills"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (exportSkillsOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(exportSkillsOptions.includeAudit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Import skills. + * + *

Asynchronously import skills into an existing assistant from a previously exported file. + * This method only imports assistants into a draft environment. Use `assistant_id` instead of + * `environment_id` to call this endpoint. + * + *

The request body for this method should contain the response data that was received from a + * previous call to the **Export skills** method, without modification. + * + *

A successful call to this method initiates an asynchronous import. The updated skills + * belonging to the assistant are not available until processing completes. To check the status of + * the asynchronous import operation, use the **Get status of skills import** method. + * + * @param importSkillsOptions the {@link ImportSkillsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SkillsAsyncRequestStatus} + */ + public ServiceCall importSkills( + ImportSkillsOptions importSkillsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + importSkillsOptions, "importSkillsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", importSkillsOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/skills_import", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("assistant", "v2", "importSkills"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (importSkillsOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(importSkillsOptions.includeAudit())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.add( + "assistant_skills", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(importSkillsOptions.assistantSkills())); + contentJson.add( + "assistant_state", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(importSkillsOptions.assistantState())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get status of skills import. + * + *

Retrieve the status of an asynchronous import operation previously initiated by using the + * **Import skills** method. + * + * @param importSkillsStatusOptions the {@link ImportSkillsStatusOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link SkillsAsyncRequestStatus} + */ + public ServiceCall importSkillsStatus( + ImportSkillsStatusOptions importSkillsStatusOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + importSkillsStatusOptions, "importSkillsStatusOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", importSkillsStatusOptions.assistantId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/skills_import/status", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("assistant", "v2", "importSkillsStatus"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AgentAvailabilityMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AgentAvailabilityMessage.java new file mode 100644 index 00000000000..a5ad57a6d03 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AgentAvailabilityMessage.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** AgentAvailabilityMessage. */ +public class AgentAvailabilityMessage extends GenericModel { + + protected String message; + + protected AgentAvailabilityMessage() {} + + /** + * Gets the message. + * + *

The text of the message. + * + * @return the message + */ + public String getMessage() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantCollection.java new file mode 100644 index 00000000000..a58601d0c33 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantCollection.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** AssistantCollection. */ +public class AssistantCollection extends GenericModel { + + protected List assistants; + protected Pagination pagination; + + protected AssistantCollection() {} + + /** + * Gets the assistants. + * + *

An array of objects describing the assistants associated with the instance. + * + * @return the assistants + */ + public List getAssistants() { + return assistants; + } + + /** + * Gets the pagination. + * + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). + * + * @return the pagination + */ + public Pagination getPagination() { + return pagination; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantData.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantData.java new file mode 100644 index 00000000000..c8c471f9ab3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantData.java @@ -0,0 +1,193 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** AssistantData. */ +public class AssistantData extends GenericModel { + + @SerializedName("assistant_id") + protected String assistantId; + + protected String name; + protected String description; + protected String language; + + @SerializedName("assistant_skills") + protected List assistantSkills; + + @SerializedName("assistant_environments") + protected List assistantEnvironments; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private String language; + + /** + * Instantiates a new Builder from an existing AssistantData instance. + * + * @param assistantData the instance to initialize the Builder with + */ + private Builder(AssistantData assistantData) { + this.name = assistantData.name; + this.description = assistantData.description; + this.language = assistantData.language; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param language the language + */ + public Builder(String language) { + this.language = language; + } + + /** + * Builds a AssistantData. + * + * @return the new AssistantData instance + */ + public AssistantData build() { + return new AssistantData(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the AssistantData builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the AssistantData builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the AssistantData builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + } + + protected AssistantData() {} + + protected AssistantData(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + name = builder.name; + description = builder.description; + language = builder.language; + } + + /** + * New builder. + * + * @return a AssistantData builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

The unique identifier of the assistant. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the name. + * + *

The name of the assistant. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the assistant. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the language. + * + *

The language of the assistant. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the assistantSkills. + * + *

An array of skill references identifying the skills associated with the assistant. + * + * @return the assistantSkills + */ + public List assistantSkills() { + return assistantSkills; + } + + /** + * Gets the assistantEnvironments. + * + *

An array of objects describing the environments defined for the assistant. + * + * @return the assistantEnvironments + */ + public List assistantEnvironments() { + return assistantEnvironments; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantSkill.java new file mode 100644 index 00000000000..ed7e27d76d7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantSkill.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** AssistantSkill. */ +public class AssistantSkill extends GenericModel { + + /** The type of the skill. */ + public interface Type { + /** dialog. */ + String DIALOG = "dialog"; + /** action. */ + String ACTION = "action"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("skill_id") + protected String skillId; + + protected String type; + + /** Builder. */ + public static class Builder { + private String skillId; + private String type; + + /** + * Instantiates a new Builder from an existing AssistantSkill instance. + * + * @param assistantSkill the instance to initialize the Builder with + */ + private Builder(AssistantSkill assistantSkill) { + this.skillId = assistantSkill.skillId; + this.type = assistantSkill.type; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param skillId the skillId + */ + public Builder(String skillId) { + this.skillId = skillId; + } + + /** + * Builds a AssistantSkill. + * + * @return the new AssistantSkill instance + */ + public AssistantSkill build() { + return new AssistantSkill(this); + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the AssistantSkill builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the AssistantSkill builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + } + + protected AssistantSkill() {} + + protected AssistantSkill(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.skillId, "skillId cannot be null"); + skillId = builder.skillId; + type = builder.type; + } + + /** + * New builder. + * + * @return a AssistantSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the type. + * + *

The type of the skill. + * + * @return the type + */ + public String type() { + return type; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantState.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantState.java new file mode 100644 index 00000000000..ec42a9ab0b7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/AssistantState.java @@ -0,0 +1,133 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Status information about the skills for the assistant. Included in responses only if + * **status**=`Available`. + */ +public class AssistantState extends GenericModel { + + @SerializedName("action_disabled") + protected Boolean actionDisabled; + + @SerializedName("dialog_disabled") + protected Boolean dialogDisabled; + + /** Builder. */ + public static class Builder { + private Boolean actionDisabled; + private Boolean dialogDisabled; + + /** + * Instantiates a new Builder from an existing AssistantState instance. + * + * @param assistantState the instance to initialize the Builder with + */ + private Builder(AssistantState assistantState) { + this.actionDisabled = assistantState.actionDisabled; + this.dialogDisabled = assistantState.dialogDisabled; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param actionDisabled the actionDisabled + * @param dialogDisabled the dialogDisabled + */ + public Builder(Boolean actionDisabled, Boolean dialogDisabled) { + this.actionDisabled = actionDisabled; + this.dialogDisabled = dialogDisabled; + } + + /** + * Builds a AssistantState. + * + * @return the new AssistantState instance + */ + public AssistantState build() { + return new AssistantState(this); + } + + /** + * Set the actionDisabled. + * + * @param actionDisabled the actionDisabled + * @return the AssistantState builder + */ + public Builder actionDisabled(Boolean actionDisabled) { + this.actionDisabled = actionDisabled; + return this; + } + + /** + * Set the dialogDisabled. + * + * @param dialogDisabled the dialogDisabled + * @return the AssistantState builder + */ + public Builder dialogDisabled(Boolean dialogDisabled) { + this.dialogDisabled = dialogDisabled; + return this; + } + } + + protected AssistantState() {} + + protected AssistantState(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.actionDisabled, "actionDisabled cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.dialogDisabled, "dialogDisabled cannot be null"); + actionDisabled = builder.actionDisabled; + dialogDisabled = builder.dialogDisabled; + } + + /** + * New builder. + * + * @return a AssistantState builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the actionDisabled. + * + *

Whether the action skill is disabled in the draft environment. + * + * @return the actionDisabled + */ + public Boolean actionDisabled() { + return actionDisabled; + } + + /** + * Gets the dialogDisabled. + * + *

Whether the dialog skill is disabled in the draft environment. + * + * @return the dialogDisabled + */ + public Boolean dialogDisabled() { + return dialogDisabled; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentOrchestration.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentOrchestration.java new file mode 100644 index 00000000000..99c91f1939b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentOrchestration.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The search skill orchestration settings for the environment. */ +public class BaseEnvironmentOrchestration extends GenericModel { + + @SerializedName("search_skill_fallback") + protected Boolean searchSkillFallback; + + protected BaseEnvironmentOrchestration() {} + + /** + * Gets the searchSkillFallback. + * + *

Whether to fall back to a search skill when responding to messages that do not match any + * intent or action defined in dialog or action skills. (If no search skill is configured for the + * environment, this property is ignored.). + * + * @return the searchSkillFallback + */ + public Boolean isSearchSkillFallback() { + return searchSkillFallback; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentReleaseReference.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentReleaseReference.java new file mode 100644 index 00000000000..83988680d4a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentReleaseReference.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object describing the release that is currently deployed in the environment. */ +public class BaseEnvironmentReleaseReference extends GenericModel { + + protected String release; + + protected BaseEnvironmentReleaseReference() {} + + /** + * Gets the release. + * + *

The name of the deployed release. + * + * @return the release + */ + public String getRelease() { + return release; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptions.java new file mode 100644 index 00000000000..3e09becf3a1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptions.java @@ -0,0 +1,144 @@ +/* + * (C) Copyright IBM Corp. 2020, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The bulkClassify options. */ +public class BulkClassifyOptions extends GenericModel { + + protected String skillId; + protected List input; + + /** Builder. */ + public static class Builder { + private String skillId; + private List input; + + /** + * Instantiates a new Builder from an existing BulkClassifyOptions instance. + * + * @param bulkClassifyOptions the instance to initialize the Builder with + */ + private Builder(BulkClassifyOptions bulkClassifyOptions) { + this.skillId = bulkClassifyOptions.skillId; + this.input = bulkClassifyOptions.input; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param skillId the skillId + * @param input the input + */ + public Builder(String skillId, List input) { + this.skillId = skillId; + this.input = input; + } + + /** + * Builds a BulkClassifyOptions. + * + * @return the new BulkClassifyOptions instance + */ + public BulkClassifyOptions build() { + return new BulkClassifyOptions(this); + } + + /** + * Adds a new element to input. + * + * @param input the new element to be added + * @return the BulkClassifyOptions builder + */ + public Builder addInput(BulkClassifyUtterance input) { + com.ibm.cloud.sdk.core.util.Validator.notNull(input, "input cannot be null"); + if (this.input == null) { + this.input = new ArrayList(); + } + this.input.add(input); + return this; + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the BulkClassifyOptions builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + + /** + * Set the input. Existing input will be replaced. + * + * @param input the input + * @return the BulkClassifyOptions builder + */ + public Builder input(List input) { + this.input = input; + return this; + } + } + + protected BulkClassifyOptions() {} + + protected BulkClassifyOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.skillId, "skillId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.input, "input cannot be null"); + skillId = builder.skillId; + input = builder.input; + } + + /** + * New builder. + * + * @return a BulkClassifyOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the skillId. + * + *

Unique identifier of the skill. To find the action or dialog skill ID in the watsonx + * Assistant user interface, open the skill settings and click **API Details**. To find the search + * skill ID, use the Get environment API to retrieve the skill references for an environment and + * it will include the search skill info, if available. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the input. + * + *

An array of input utterances to classify. + * + * @return the input + */ + public List input() { + return input; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutput.java new file mode 100644 index 00000000000..e40425a7c58 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutput.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** BulkClassifyOutput. */ +public class BulkClassifyOutput extends GenericModel { + + protected BulkClassifyUtterance input; + protected List entities; + protected List intents; + + protected BulkClassifyOutput() {} + + /** + * Gets the input. + * + *

The user input utterance to classify. + * + * @return the input + */ + public BulkClassifyUtterance getInput() { + return input; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the utterance. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the utterance. + * + * @return the intents + */ + public List getIntents() { + return intents; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponse.java new file mode 100644 index 00000000000..f9b8bf8734c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponse.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** BulkClassifyResponse. */ +public class BulkClassifyResponse extends GenericModel { + + protected List output; + + protected BulkClassifyResponse() {} + + /** + * Gets the output. + * + *

An array of objects that contain classification information for the submitted input + * utterances. + * + * @return the output + */ + public List getOutput() { + return output; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtterance.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtterance.java new file mode 100644 index 00000000000..7c18e41109b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtterance.java @@ -0,0 +1,95 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The user input utterance to classify. */ +public class BulkClassifyUtterance extends GenericModel { + + protected String text; + + /** Builder. */ + public static class Builder { + private String text; + + /** + * Instantiates a new Builder from an existing BulkClassifyUtterance instance. + * + * @param bulkClassifyUtterance the instance to initialize the Builder with + */ + private Builder(BulkClassifyUtterance bulkClassifyUtterance) { + this.text = bulkClassifyUtterance.text; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param text the text + */ + public Builder(String text) { + this.text = text; + } + + /** + * Builds a BulkClassifyUtterance. + * + * @return the new BulkClassifyUtterance instance + */ + public BulkClassifyUtterance build() { + return new BulkClassifyUtterance(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the BulkClassifyUtterance builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected BulkClassifyUtterance() {} + + protected BulkClassifyUtterance(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + } + + /** + * New builder. + * + * @return a BulkClassifyUtterance builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the text. + * + *

The text of the input utterance. + * + * @return the text + */ + public String text() { + return text; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java index ee4262d0cc1..4b040d9d8ff 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,36 @@ * 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.assistant.v2.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * CaptureGroup. - */ +/** CaptureGroup. */ public class CaptureGroup extends GenericModel { protected String group; protected List location; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String group; private List location; + /** + * Instantiates a new Builder from an existing CaptureGroup instance. + * + * @param captureGroup the instance to initialize the Builder with + */ private Builder(CaptureGroup captureGroup) { this.group = captureGroup.group; this.location = captureGroup.location; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -55,21 +53,20 @@ public Builder(String group) { /** * Builds a CaptureGroup. * - * @return the captureGroup + * @return the new CaptureGroup instance */ public CaptureGroup build() { return new CaptureGroup(this); } /** - * Adds an location to location. + * Adds a new element to location. * - * @param location the new location + * @param location the new element to be added * @return the CaptureGroup builder */ public Builder addLocation(Long location) { - com.ibm.cloud.sdk.core.util.Validator.notNull(location, - "location cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(location, "location cannot be null"); if (this.location == null) { this.location = new ArrayList(); } @@ -89,8 +86,7 @@ public Builder group(String group) { } /** - * Set the location. - * Existing location will be replaced. + * Set the location. Existing location will be replaced. * * @param location the location * @return the CaptureGroup builder @@ -101,9 +97,10 @@ public Builder location(List location) { } } + protected CaptureGroup() {} + protected CaptureGroup(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.group, - "group cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.group, "group cannot be null"); group = builder.group; location = builder.location; } @@ -120,7 +117,7 @@ public Builder newBuilder() { /** * Gets the group. * - * A recognized capture group for the entity. + *

A recognized capture group for the entity. * * @return the group */ @@ -131,7 +128,8 @@ public String group() { /** * Gets the location. * - * Zero-based character offsets that indicate where the entity value begins and ends in the input text. + *

Zero-based character offsets that indicate where the entity value begins and ends in the + * input text. * * @return the location */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferInfo.java new file mode 100644 index 00000000000..64b78d77730 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferInfo.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information used by an integration to transfer the conversation to a different channel. */ +public class ChannelTransferInfo extends GenericModel { + + protected ChannelTransferTarget target; + + protected ChannelTransferInfo() {} + + /** + * Gets the target. + * + *

An object specifying target channels available for the transfer. Each property of this + * object represents an available transfer target. Currently, the only supported property is + * **chat**, representing the web chat integration. + * + * @return the target + */ + public ChannelTransferTarget getTarget() { + return target; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferTarget.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferTarget.java new file mode 100644 index 00000000000..21b3b7ff1c1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferTarget.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object specifying target channels available for the transfer. Each property of this object + * represents an available transfer target. Currently, the only supported property is **chat**, + * representing the web chat integration. + */ +public class ChannelTransferTarget extends GenericModel { + + protected ChannelTransferTargetChat chat; + + protected ChannelTransferTarget() {} + + /** + * Gets the chat. + * + *

Information for transferring to the web chat integration. + * + * @return the chat + */ + public ChannelTransferTargetChat getChat() { + return chat; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetChat.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetChat.java new file mode 100644 index 00000000000..ff4ebb0f5a8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetChat.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information for transferring to the web chat integration. */ +public class ChannelTransferTargetChat extends GenericModel { + + protected String url; + + protected ChannelTransferTargetChat() {} + + /** + * Gets the url. + * + *

The URL of the target web chat. + * + * @return the url + */ + public String getUrl() { + return url; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ClientAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ClientAction.java new file mode 100644 index 00000000000..545719b8b78 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ClientAction.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** ClientAction. */ +public class ClientAction extends GenericModel { + + /** The skill that is requesting the action. Included only if **type**=`client`. */ + public interface Skill { + /** main skill. */ + String MAIN_SKILL = "main skill"; + /** actions skill. */ + String ACTIONS_SKILL = "actions skill"; + } + + protected String name; + + @SerializedName("result_variable") + protected String resultVariable; + + protected String type; + protected String skill; + protected Map parameters; + + protected ClientAction() {} + + /** + * Gets the name. + * + *

The name of the client action. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the resultVariable. + * + *

The name of the variable that the results are stored in. + * + * @return the resultVariable + */ + public String getResultVariable() { + return resultVariable; + } + + /** + * Gets the type. + * + *

The type of turn event. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the skill. + * + *

The skill that is requesting the action. Included only if **type**=`client`. + * + * @return the skill + */ + public String getSkill() { + return skill; + } + + /** + * Gets the parameters. + * + *

An object containing arbitrary variables that are included in the turn event. + * + * @return the parameters + */ + public Map getParameters() { + return parameters; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ClientActionParameters.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ClientActionParameters.java new file mode 100644 index 00000000000..26d01270d8b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ClientActionParameters.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ClientActionParameters. */ +public class ClientActionParameters extends GenericModel { + + @SerializedName("account_id") + protected String accountId; + + protected String hash; + protected String alias; + + protected ClientActionParameters() {} + + /** + * Gets the accountId. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } + + /** + * Gets the hash. + * + * @return the hash + */ + public String getHash() { + return hash; + } + + /** + * Gets the alias. + * + * @return the alias + */ + public String getAlias() { + return alias; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CompleteItem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CompleteItem.java new file mode 100644 index 00000000000..ecb728734cb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CompleteItem.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; + +/** CompleteItem. */ +public class CompleteItem extends RuntimeResponseGeneric { + + /** The preferred type of control to display. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + @SerializedName("streaming_metadata") + protected Metadata streamingMetadata; + + protected CompleteItem() {} + + /** + * Gets the streamingMetadata. + * + * @return the streamingMetadata + */ + public Metadata getStreamingMetadata() { + return streamingMetadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateAssistantOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateAssistantOptions.java new file mode 100644 index 00000000000..be3c309ab64 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateAssistantOptions.java @@ -0,0 +1,152 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The createAssistant options. */ +public class CreateAssistantOptions extends GenericModel { + + protected String name; + protected String description; + protected String language; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private String language; + + /** + * Instantiates a new Builder from an existing CreateAssistantOptions instance. + * + * @param createAssistantOptions the instance to initialize the Builder with + */ + private Builder(CreateAssistantOptions createAssistantOptions) { + this.name = createAssistantOptions.name; + this.description = createAssistantOptions.description; + this.language = createAssistantOptions.language; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a CreateAssistantOptions. + * + * @return the new CreateAssistantOptions instance + */ + public CreateAssistantOptions build() { + return new CreateAssistantOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateAssistantOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateAssistantOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateAssistantOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the assistantData. + * + * @param assistantData the assistantData + * @return the CreateAssistantOptions builder + */ + public Builder assistantData(AssistantData assistantData) { + this.name = assistantData.name(); + this.description = assistantData.description(); + this.language = assistantData.language(); + return this; + } + } + + protected CreateAssistantOptions() {} + + protected CreateAssistantOptions(Builder builder) { + name = builder.name; + description = builder.description; + language = builder.language; + } + + /** + * New builder. + * + * @return a CreateAssistantOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of the assistant. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the assistant. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the language. + * + *

The language of the assistant. + * + * @return the language + */ + public String language() { + return language; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateAssistantReleaseImportResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateAssistantReleaseImportResponse.java new file mode 100644 index 00000000000..64909e1bca8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateAssistantReleaseImportResponse.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; + +/** CreateAssistantReleaseImportResponse. */ +public class CreateAssistantReleaseImportResponse extends GenericModel { + + /** + * The current status of the artifact import process: - **Failed**: The asynchronous artifact + * import process has failed. - **Processing**: An asynchronous operation to import artifact is + * underway and not yet completed. + */ + public interface Status { + /** Failed. */ + String FAILED = "Failed"; + /** Processing. */ + String PROCESSING = "Processing"; + } + + /** The type of the skill in the draft environment. */ + public interface SkillImpactInDraft { + /** action. */ + String ACTION = "action"; + /** dialog. */ + String DIALOG = "dialog"; + } + + protected String status; + + @SerializedName("task_id") + protected String taskId; + + @SerializedName("assistant_id") + protected String assistantId; + + @SerializedName("skill_impact_in_draft") + protected List skillImpactInDraft; + + protected Date created; + protected Date updated; + + protected CreateAssistantReleaseImportResponse() {} + + /** + * Gets the status. + * + *

The current status of the artifact import process: - **Failed**: The asynchronous artifact + * import process has failed. - **Processing**: An asynchronous operation to import artifact is + * underway and not yet completed. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the taskId. + * + *

A unique identifier for a background asynchronous task that is executing or has executed the + * operation. + * + * @return the taskId + */ + public String getTaskId() { + return taskId; + } + + /** + * Gets the assistantId. + * + *

The ID of the assistant to which the release belongs. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the skillImpactInDraft. + * + *

An array of skill types in the draft environment which will be overridden with skills from + * the artifact being imported. + * + * @return the skillImpactInDraft + */ + public List getSkillImpactInDraft() { + return skillImpactInDraft; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateProviderOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateProviderOptions.java new file mode 100644 index 00000000000..70a3b6527f6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateProviderOptions.java @@ -0,0 +1,155 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The createProvider options. */ +public class CreateProviderOptions extends GenericModel { + + protected String providerId; + protected ProviderSpecification specification; + protected ProviderPrivate xPrivate; + + /** Builder. */ + public static class Builder { + private String providerId; + private ProviderSpecification specification; + private ProviderPrivate xPrivate; + + /** + * Instantiates a new Builder from an existing CreateProviderOptions instance. + * + * @param createProviderOptions the instance to initialize the Builder with + */ + private Builder(CreateProviderOptions createProviderOptions) { + this.providerId = createProviderOptions.providerId; + this.specification = createProviderOptions.specification; + this.xPrivate = createProviderOptions.xPrivate; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param providerId the providerId + * @param specification the specification + * @param xPrivate the xPrivate + */ + public Builder( + String providerId, ProviderSpecification specification, ProviderPrivate xPrivate) { + this.providerId = providerId; + this.specification = specification; + this.xPrivate = xPrivate; + } + + /** + * Builds a CreateProviderOptions. + * + * @return the new CreateProviderOptions instance + */ + public CreateProviderOptions build() { + return new CreateProviderOptions(this); + } + + /** + * Set the providerId. + * + * @param providerId the providerId + * @return the CreateProviderOptions builder + */ + public Builder providerId(String providerId) { + this.providerId = providerId; + return this; + } + + /** + * Set the specification. + * + * @param specification the specification + * @return the CreateProviderOptions builder + */ + public Builder specification(ProviderSpecification specification) { + this.specification = specification; + return this; + } + + /** + * Set the xPrivate. + * + * @param xPrivate the xPrivate + * @return the CreateProviderOptions builder + */ + public Builder xPrivate(ProviderPrivate xPrivate) { + this.xPrivate = xPrivate; + return this; + } + } + + protected CreateProviderOptions() {} + + protected CreateProviderOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.providerId, "providerId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.specification, "specification cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.xPrivate, "xPrivate cannot be null"); + providerId = builder.providerId; + specification = builder.specification; + xPrivate = builder.xPrivate; + } + + /** + * New builder. + * + * @return a CreateProviderOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the providerId. + * + *

The unique identifier of the provider. + * + * @return the providerId + */ + public String providerId() { + return providerId; + } + + /** + * Gets the specification. + * + *

The specification of the provider. + * + * @return the specification + */ + public ProviderSpecification specification() { + return specification; + } + + /** + * Gets the xPrivate. + * + *

Private information of the provider. + * + * @return the xPrivate + */ + public ProviderPrivate xPrivate() { + return xPrivate; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportOptions.java new file mode 100644 index 00000000000..cc42660eec9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportOptions.java @@ -0,0 +1,154 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The createReleaseExport options. */ +public class CreateReleaseExportOptions extends GenericModel { + + protected String assistantId; + protected String release; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String release; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing CreateReleaseExportOptions instance. + * + * @param createReleaseExportOptions the instance to initialize the Builder with + */ + private Builder(CreateReleaseExportOptions createReleaseExportOptions) { + this.assistantId = createReleaseExportOptions.assistantId; + this.release = createReleaseExportOptions.release; + this.includeAudit = createReleaseExportOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param release the release + */ + public Builder(String assistantId, String release) { + this.assistantId = assistantId; + this.release = release; + } + + /** + * Builds a CreateReleaseExportOptions. + * + * @return the new CreateReleaseExportOptions instance + */ + public CreateReleaseExportOptions build() { + return new CreateReleaseExportOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the CreateReleaseExportOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the release. + * + * @param release the release + * @return the CreateReleaseExportOptions builder + */ + public Builder release(String release) { + this.release = release; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateReleaseExportOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected CreateReleaseExportOptions() {} + + protected CreateReleaseExportOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.release, "release cannot be empty"); + assistantId = builder.assistantId; + release = builder.release; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateReleaseExportOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the release. + * + *

Unique identifier of the release. + * + * @return the release + */ + public String release() { + return release; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportWithStatusErrors.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportWithStatusErrors.java new file mode 100644 index 00000000000..7e7353f9790 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportWithStatusErrors.java @@ -0,0 +1,151 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; + +/** CreateReleaseExportWithStatusErrors. */ +public class CreateReleaseExportWithStatusErrors extends GenericModel { + + /** + * The current status of the release export creation process: - **Available**: The release export + * package is available for download. - **Failed**: The asynchronous release export package + * creation process has failed. - **Processing**: An asynchronous operation to create the release + * export package is underway and not yet completed. + */ + public interface Status { + /** Available. */ + String AVAILABLE = "Available"; + /** Failed. */ + String FAILED = "Failed"; + /** Processing. */ + String PROCESSING = "Processing"; + } + + protected String status; + + @SerializedName("task_id") + protected String taskId; + + @SerializedName("assistant_id") + protected String assistantId; + + protected String release; + protected Date created; + protected Date updated; + + @SerializedName("status_errors") + protected List statusErrors; + + @SerializedName("status_description") + protected String statusDescription; + + protected CreateReleaseExportWithStatusErrors() {} + + /** + * Gets the status. + * + *

The current status of the release export creation process: - **Available**: The release + * export package is available for download. - **Failed**: The asynchronous release export package + * creation process has failed. - **Processing**: An asynchronous operation to create the release + * export package is underway and not yet completed. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the taskId. + * + *

A unique identifier for a background asynchronous task that is executing or has executed the + * operation. + * + * @return the taskId + */ + public String getTaskId() { + return taskId; + } + + /** + * Gets the assistantId. + * + *

The ID of the assistant to which the release belongs. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the release. + * + *

The name of the release. The name is the version number (an integer), returned as a string. + * + * @return the release + */ + public String getRelease() { + return release; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } + + /** + * Gets the statusErrors. + * + *

An array of messages about errors that caused an asynchronous operation to fail. Included + * only if **status**=`Failed`. + * + * @return the statusErrors + */ + public List getStatusErrors() { + return statusErrors; + } + + /** + * Gets the statusDescription. + * + *

The description of the failed asynchronous operation. Included only if **status**=`Failed`. + * + * @return the statusDescription + */ + public String getStatusDescription() { + return statusDescription; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseImportOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseImportOptions.java new file mode 100644 index 00000000000..71c8f968a35 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseImportOptions.java @@ -0,0 +1,170 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The createReleaseImport options. */ +public class CreateReleaseImportOptions extends GenericModel { + + protected String assistantId; + protected InputStream body; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private InputStream body; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing CreateReleaseImportOptions instance. + * + * @param createReleaseImportOptions the instance to initialize the Builder with + */ + private Builder(CreateReleaseImportOptions createReleaseImportOptions) { + this.assistantId = createReleaseImportOptions.assistantId; + this.body = createReleaseImportOptions.body; + this.includeAudit = createReleaseImportOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param body the body + */ + public Builder(String assistantId, InputStream body) { + this.assistantId = assistantId; + this.body = body; + } + + /** + * Builds a CreateReleaseImportOptions. + * + * @return the new CreateReleaseImportOptions instance + */ + public CreateReleaseImportOptions build() { + return new CreateReleaseImportOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the CreateReleaseImportOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the body. + * + * @param body the body + * @return the CreateReleaseImportOptions builder + */ + public Builder body(InputStream body) { + this.body = body; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateReleaseImportOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the body. + * + * @param body the body + * @return the CreateReleaseImportOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder body(File body) throws FileNotFoundException { + this.body = new FileInputStream(body); + return this; + } + } + + protected CreateReleaseImportOptions() {} + + protected CreateReleaseImportOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.body, "body cannot be null"); + assistantId = builder.assistantId; + body = builder.body; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateReleaseImportOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the body. + * + *

Request body is an Octet-stream of the artifact Zip file that is being imported. + * + * @return the body + */ + public InputStream body() { + return body; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseOptions.java new file mode 100644 index 00000000000..f107baaae37 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateReleaseOptions.java @@ -0,0 +1,135 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The createRelease options. */ +public class CreateReleaseOptions extends GenericModel { + + protected String assistantId; + protected String description; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String description; + + /** + * Instantiates a new Builder from an existing CreateReleaseOptions instance. + * + * @param createReleaseOptions the instance to initialize the Builder with + */ + private Builder(CreateReleaseOptions createReleaseOptions) { + this.assistantId = createReleaseOptions.assistantId; + this.description = createReleaseOptions.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a CreateReleaseOptions. + * + * @return the new CreateReleaseOptions instance + */ + public CreateReleaseOptions build() { + return new CreateReleaseOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the CreateReleaseOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateReleaseOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the release. + * + * @param release the release + * @return the CreateReleaseOptions builder + */ + public Builder release(Release release) { + this.description = release.description(); + return this; + } + } + + protected CreateReleaseOptions() {} + + protected CreateReleaseOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + description = builder.description; + } + + /** + * New builder. + * + * @return a CreateReleaseOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the description. + * + *

The description of the release. + * + * @return the description + */ + public String description() { + return description; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java index f8ee70dccb0..2cd69d28c8e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,46 +10,53 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The createSession options. - */ +/** The createSession options. */ public class CreateSessionOptions extends GenericModel { protected String assistantId; + protected String environmentId; + protected RequestAnalytics analytics; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String assistantId; + private String environmentId; + private RequestAnalytics analytics; + /** + * Instantiates a new Builder from an existing CreateSessionOptions instance. + * + * @param createSessionOptions the instance to initialize the Builder with + */ private Builder(CreateSessionOptions createSessionOptions) { this.assistantId = createSessionOptions.assistantId; + this.environmentId = createSessionOptions.environmentId; + this.analytics = createSessionOptions.analytics; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param assistantId the assistantId + * @param environmentId the environmentId */ - public Builder(String assistantId) { + public Builder(String assistantId, String environmentId) { this.assistantId = assistantId; + this.environmentId = environmentId; } /** * Builds a CreateSessionOptions. * - * @return the createSessionOptions + * @return the new CreateSessionOptions instance */ public CreateSessionOptions build() { return new CreateSessionOptions(this); @@ -65,12 +72,40 @@ public Builder assistantId(String assistantId) { this.assistantId = assistantId; return this; } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the CreateSessionOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the analytics. + * + * @param analytics the analytics + * @return the CreateSessionOptions builder + */ + public Builder analytics(RequestAnalytics analytics) { + this.analytics = analytics; + return this; + } } + protected CreateSessionOptions() {} + protected CreateSessionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assistantId, - "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); assistantId = builder.assistantId; + environmentId = builder.environmentId; + analytics = builder.analytics; } /** @@ -85,15 +120,38 @@ public Builder newBuilder() { /** * Gets the assistantId. * - * Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the - * assistant settings and click **API Details**. For information about creating assistants, see the - * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). - * - * **Note:** Currently, the v2 API does not support creating assistants. + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. * * @return the assistantId */ public String assistantId() { return assistantId; } + + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the analytics. + * + *

An optional object containing analytics data. Currently, this data is used only for events + * sent to the Segment extension. + * + * @return the analytics + */ + public RequestAnalytics analytics() { + return analytics; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteAssistantOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteAssistantOptions.java new file mode 100644 index 00000000000..a1b71e51e1c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteAssistantOptions.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteAssistant options. */ +public class DeleteAssistantOptions extends GenericModel { + + protected String assistantId; + + /** Builder. */ + public static class Builder { + private String assistantId; + + /** + * Instantiates a new Builder from an existing DeleteAssistantOptions instance. + * + * @param deleteAssistantOptions the instance to initialize the Builder with + */ + private Builder(DeleteAssistantOptions deleteAssistantOptions) { + this.assistantId = deleteAssistantOptions.assistantId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a DeleteAssistantOptions. + * + * @return the new DeleteAssistantOptions instance + */ + public DeleteAssistantOptions build() { + return new DeleteAssistantOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the DeleteAssistantOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + } + + protected DeleteAssistantOptions() {} + + protected DeleteAssistantOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + } + + /** + * New builder. + * + * @return a DeleteAssistantOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteReleaseOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteReleaseOptions.java new file mode 100644 index 00000000000..afbcd5264a0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteReleaseOptions.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteRelease options. */ +public class DeleteReleaseOptions extends GenericModel { + + protected String assistantId; + protected String release; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String release; + + /** + * Instantiates a new Builder from an existing DeleteReleaseOptions instance. + * + * @param deleteReleaseOptions the instance to initialize the Builder with + */ + private Builder(DeleteReleaseOptions deleteReleaseOptions) { + this.assistantId = deleteReleaseOptions.assistantId; + this.release = deleteReleaseOptions.release; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param release the release + */ + public Builder(String assistantId, String release) { + this.assistantId = assistantId; + this.release = release; + } + + /** + * Builds a DeleteReleaseOptions. + * + * @return the new DeleteReleaseOptions instance + */ + public DeleteReleaseOptions build() { + return new DeleteReleaseOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the DeleteReleaseOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the release. + * + * @param release the release + * @return the DeleteReleaseOptions builder + */ + public Builder release(String release) { + this.release = release; + return this; + } + } + + protected DeleteReleaseOptions() {} + + protected DeleteReleaseOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.release, "release cannot be empty"); + assistantId = builder.assistantId; + release = builder.release; + } + + /** + * New builder. + * + * @return a DeleteReleaseOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the release. + * + *

Unique identifier of the release. + * + * @return the release + */ + public String release() { + return release; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java index 971718486be..e0dac574a86 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,51 +10,55 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteSession options. - */ +/** The deleteSession options. */ public class DeleteSessionOptions extends GenericModel { protected String assistantId; + protected String environmentId; protected String sessionId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String assistantId; + private String environmentId; private String sessionId; + /** + * Instantiates a new Builder from an existing DeleteSessionOptions instance. + * + * @param deleteSessionOptions the instance to initialize the Builder with + */ private Builder(DeleteSessionOptions deleteSessionOptions) { this.assistantId = deleteSessionOptions.assistantId; + this.environmentId = deleteSessionOptions.environmentId; this.sessionId = deleteSessionOptions.sessionId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param assistantId the assistantId + * @param environmentId the environmentId * @param sessionId the sessionId */ - public Builder(String assistantId, String sessionId) { + public Builder(String assistantId, String environmentId, String sessionId) { this.assistantId = assistantId; + this.environmentId = environmentId; this.sessionId = sessionId; } /** * Builds a DeleteSessionOptions. * - * @return the deleteSessionOptions + * @return the new DeleteSessionOptions instance */ public DeleteSessionOptions build() { return new DeleteSessionOptions(this); @@ -71,6 +75,17 @@ public Builder assistantId(String assistantId) { return this; } + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the DeleteSessionOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + /** * Set the sessionId. * @@ -83,12 +98,16 @@ public Builder sessionId(String sessionId) { } } + protected DeleteSessionOptions() {} + protected DeleteSessionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assistantId, - "assistantId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.sessionId, - "sessionId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.sessionId, "sessionId cannot be empty"); assistantId = builder.assistantId; + environmentId = builder.environmentId; sessionId = builder.sessionId; } @@ -104,11 +123,9 @@ public Builder newBuilder() { /** * Gets the assistantId. * - * Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the - * assistant settings and click **API Details**. For information about creating assistants, see the - * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). - * - * **Note:** Currently, the v2 API does not support creating assistants. + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. * * @return the assistantId */ @@ -116,10 +133,23 @@ public String assistantId() { return assistantId; } + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + /** * Gets the sessionId. * - * Unique identifier of the session. + *

Unique identifier of the session. * * @return the sessionId */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java new file mode 100644 index 00000000000..ab31e077f93 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java @@ -0,0 +1,95 @@ +/* + * (C) Copyright IBM Corp. 2018, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteUserData options. */ +public class DeleteUserDataOptions extends GenericModel { + + protected String customerId; + + /** Builder. */ + public static class Builder { + private String customerId; + + /** + * Instantiates a new Builder from an existing DeleteUserDataOptions instance. + * + * @param deleteUserDataOptions the instance to initialize the Builder with + */ + private Builder(DeleteUserDataOptions deleteUserDataOptions) { + this.customerId = deleteUserDataOptions.customerId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customerId the customerId + */ + public Builder(String customerId) { + this.customerId = customerId; + } + + /** + * Builds a DeleteUserDataOptions. + * + * @return the new DeleteUserDataOptions instance + */ + public DeleteUserDataOptions build() { + return new DeleteUserDataOptions(this); + } + + /** + * Set the customerId. + * + * @param customerId the customerId + * @return the DeleteUserDataOptions builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + } + + protected DeleteUserDataOptions() {} + + protected DeleteUserDataOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, "customerId cannot be null"); + customerId = builder.customerId; + } + + /** + * New builder. + * + * @return a DeleteUserDataOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customerId. + * + *

The customer ID for which all data is to be deleted. + * + * @return the customerId + */ + public String customerId() { + return customerId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeployReleaseOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeployReleaseOptions.java new file mode 100644 index 00000000000..f7a94727177 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeployReleaseOptions.java @@ -0,0 +1,184 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deployRelease options. */ +public class DeployReleaseOptions extends GenericModel { + + protected String assistantId; + protected String release; + protected String environmentId; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String release; + private String environmentId; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing DeployReleaseOptions instance. + * + * @param deployReleaseOptions the instance to initialize the Builder with + */ + private Builder(DeployReleaseOptions deployReleaseOptions) { + this.assistantId = deployReleaseOptions.assistantId; + this.release = deployReleaseOptions.release; + this.environmentId = deployReleaseOptions.environmentId; + this.includeAudit = deployReleaseOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param release the release + * @param environmentId the environmentId + */ + public Builder(String assistantId, String release, String environmentId) { + this.assistantId = assistantId; + this.release = release; + this.environmentId = environmentId; + } + + /** + * Builds a DeployReleaseOptions. + * + * @return the new DeployReleaseOptions instance + */ + public DeployReleaseOptions build() { + return new DeployReleaseOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the DeployReleaseOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the release. + * + * @param release the release + * @return the DeployReleaseOptions builder + */ + public Builder release(String release) { + this.release = release; + return this; + } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the DeployReleaseOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the DeployReleaseOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected DeployReleaseOptions() {} + + protected DeployReleaseOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.release, "release cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.environmentId, "environmentId cannot be null"); + assistantId = builder.assistantId; + release = builder.release; + environmentId = builder.environmentId; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a DeployReleaseOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the release. + * + *

Unique identifier of the release. + * + * @return the release + */ + public String release() { + return release; + } + + /** + * Gets the environmentId. + * + *

The environment ID of the environment where the release is to be deployed. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java index a3c0ae0ffff..b8233f14bc7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,18 +10,15 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Dialog log message details. - */ +/** Dialog log message details. */ public class DialogLogMessage extends GenericModel { - /** - * The severity of the log message. - */ + /** The severity of the log message. */ public interface Level { /** info. */ String INFO = "info"; @@ -33,11 +30,15 @@ public interface Level { protected String level; protected String message; + protected String code; + protected LogMessageSource source; + + protected DialogLogMessage() {} /** * Gets the level. * - * The severity of the log message. + *

The severity of the log message. * * @return the level */ @@ -48,11 +49,33 @@ public String getLevel() { /** * Gets the message. * - * The text of the log message. + *

The text of the log message. * * @return the message */ public String getMessage() { return message; } + + /** + * Gets the code. + * + *

A code that indicates the category to which the error message belongs. + * + * @return the code + */ + public String getCode() { + return code; + } + + /** + * Gets the source. + * + *

An object that identifies the dialog element that generated the error message. + * + * @return the source + */ + public LogMessageSource getSource() { + return source; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java index c8eb7857b99..2a9ef0237d4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,21 +10,17 @@ * 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.assistant.v2.model; -import java.util.Map; +package com.ibm.watson.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; -/** - * DialogNodeAction. - */ +/** DialogNodeAction. */ public class DialogNodeAction extends GenericModel { - /** - * The type of action to invoke. - */ + /** The type of action to invoke. */ public interface Type { /** client. */ String CLIENT = "client"; @@ -39,14 +35,18 @@ public interface Type { protected String name; protected String type; protected Map parameters; + @SerializedName("result_variable") protected String resultVariable; + protected String credentials; + protected DialogNodeAction() {} + /** * Gets the name. * - * The name of the action. + *

The name of the action. * * @return the name */ @@ -57,7 +57,7 @@ public String getName() { /** * Gets the type. * - * The type of action to invoke. + *

The type of action to invoke. * * @return the type */ @@ -68,7 +68,7 @@ public String getType() { /** * Gets the parameters. * - * A map of key/value pairs to be provided to the action. + *

A map of key/value pairs to be provided to the action. * * @return the parameters */ @@ -79,7 +79,7 @@ public Map getParameters() { /** * Gets the resultVariable. * - * The location in the dialog context where the result of the action is stored. + *

The location in the dialog context where the result of the action is stored. * * @return the resultVariable */ @@ -90,7 +90,8 @@ public String getResultVariable() { /** * Gets the credentials. * - * The name of the context variable that the client application will use to pass in credentials for the action. + *

The name of the context variable that the client application will use to pass in credentials + * for the action. * * @return the credentials */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfo.java new file mode 100644 index 00000000000..d2d9ac173a0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfo.java @@ -0,0 +1,34 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Routing or other contextual information to be used by target service desk systems. */ +public class DialogNodeOutputConnectToAgentTransferInfo extends GenericModel { + + protected Map> target; + + protected DialogNodeOutputConnectToAgentTransferInfo() {} + + /** + * Gets the target. + * + * @return the target + */ + public Map> getTarget() { + return target; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java index 9cdc124fc4a..812e7fe1451 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,22 +10,23 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * DialogNodeOutputOptionsElement. - */ +/** DialogNodeOutputOptionsElement. */ public class DialogNodeOutputOptionsElement extends GenericModel { protected String label; protected DialogNodeOutputOptionsElementValue value; + protected DialogNodeOutputOptionsElement() {} + /** * Gets the label. * - * The user-facing label for the option. + *

The user-facing label for the option. * * @return the label */ @@ -36,7 +37,8 @@ public String getLabel() { /** * Gets the value. * - * An object defining the message input to be sent to the assistant if the user selects the corresponding option. + *

An object defining the message input to be sent to the assistant if the user selects the + * corresponding option. * * @return the value */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java index e7904d2a9b7..46c1e983f75 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,21 +10,25 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An object defining the message input to be sent to the assistant if the user selects the corresponding option. + * An object defining the message input to be sent to the assistant if the user selects the + * corresponding option. */ public class DialogNodeOutputOptionsElementValue extends GenericModel { protected MessageInput input; + protected DialogNodeOutputOptionsElementValue() {} + /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeVisited.java new file mode 100644 index 00000000000..081831d5904 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeVisited.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An objects containing detailed diagnostic information about a dialog node that was visited during + * processing of the input message. + */ +public class DialogNodeVisited extends GenericModel { + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String title; + protected String conditions; + + protected DialogNodeVisited() {} + + /** + * Gets the dialogNode. + * + *

A dialog node that was visited during processing of the input message. + * + * @return the dialogNode + */ + public String getDialogNode() { + return dialogNode; + } + + /** + * Gets the title. + * + *

The title of the dialog node. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the conditions. + * + *

The conditions that trigger the dialog node. + * + * @return the conditions + */ + public String getConditions() { + return conditions; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java deleted file mode 100644 index 1e65319a0bc..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.assistant.v2.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * DialogNodesVisited. - */ -public class DialogNodesVisited extends GenericModel { - - @SerializedName("dialog_node") - protected String dialogNode; - protected String title; - protected String conditions; - - /** - * Gets the dialogNode. - * - * A dialog node that was triggered during processing of the input message. - * - * @return the dialogNode - */ - public String getDialogNode() { - return dialogNode; - } - - /** - * Gets the title. - * - * The title of the dialog node. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the conditions. - * - * The conditions that trigger the dialog node. - * - * @return the conditions - */ - public String getConditions() { - return conditions; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java index 21351439ff4..eb1c29b233f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,26 +10,27 @@ * 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.assistant.v2.model; -import java.util.Map; +package com.ibm.watson.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; -/** - * DialogSuggestion. - */ +/** DialogSuggestion. */ public class DialogSuggestion extends GenericModel { protected String label; protected DialogSuggestionValue value; protected Map output; + protected DialogSuggestion() {} + /** * Gets the label. * - * The user-facing label for the disambiguation option. This label is taken from the **title** or **user_label** - * property of the corresponding dialog node, depending on the disambiguation options. + *

The user-facing label for the suggestion. This label is taken from the **title** or + * **user_label** property of the corresponding dialog node, depending on the disambiguation + * options. * * @return the label */ @@ -40,8 +41,11 @@ public String getLabel() { /** * Gets the value. * - * An object defining the message input to be sent to the assistant if the user selects the corresponding - * disambiguation option. + *

An object defining the message input to be sent to the assistant if the user selects the + * corresponding disambiguation option. + * + *

**Note:** This entire message input object must be included in the request body of the next + * message sent to the assistant. Do not modify or remove any of the included properties. * * @return the value */ @@ -52,8 +56,8 @@ public DialogSuggestionValue getValue() { /** * Gets the output. * - * The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding - * option. + *

The dialog output that will be returned from the watsonx Assistant service if the user + * selects the corresponding option. * * @return the output */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java index c4828656dc4..fb3208180fb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,22 +10,28 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An object defining the message input to be sent to the assistant if the user selects the corresponding disambiguation - * option. + * An object defining the message input to be sent to the assistant if the user selects the + * corresponding disambiguation option. + * + *

**Note:** This entire message input object must be included in the request body of the next + * message sent to the assistant. Do not modify or remove any of the included properties. */ public class DialogSuggestionValue extends GenericModel { protected MessageInput input; + protected DialogSuggestionValue() {} + /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DownloadReleaseExportOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DownloadReleaseExportOptions.java new file mode 100644 index 00000000000..46a66525a0c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DownloadReleaseExportOptions.java @@ -0,0 +1,154 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The downloadReleaseExport options. */ +public class DownloadReleaseExportOptions extends GenericModel { + + protected String assistantId; + protected String release; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String release; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing DownloadReleaseExportOptions instance. + * + * @param downloadReleaseExportOptions the instance to initialize the Builder with + */ + private Builder(DownloadReleaseExportOptions downloadReleaseExportOptions) { + this.assistantId = downloadReleaseExportOptions.assistantId; + this.release = downloadReleaseExportOptions.release; + this.includeAudit = downloadReleaseExportOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param release the release + */ + public Builder(String assistantId, String release) { + this.assistantId = assistantId; + this.release = release; + } + + /** + * Builds a DownloadReleaseExportOptions. + * + * @return the new DownloadReleaseExportOptions instance + */ + public DownloadReleaseExportOptions build() { + return new DownloadReleaseExportOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the DownloadReleaseExportOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the release. + * + * @param release the release + * @return the DownloadReleaseExportOptions builder + */ + public Builder release(String release) { + this.release = release; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the DownloadReleaseExportOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected DownloadReleaseExportOptions() {} + + protected DownloadReleaseExportOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.release, "release cannot be empty"); + assistantId = builder.assistantId; + release = builder.release; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a DownloadReleaseExportOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the release. + * + *

Unique identifier of the release. + * + * @return the release + */ + public String release() { + return release; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfo.java new file mode 100644 index 00000000000..572d8c758bb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfo.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** DtmfCommandInfo. */ +public class DtmfCommandInfo extends GenericModel { + + /** Specifies the type of DTMF command for the phone integration. */ + public interface Type { + /** collect. */ + String COLLECT = "collect"; + /** disable_barge_in. */ + String DISABLE_BARGE_IN = "disable_barge_in"; + /** enable_barge_in. */ + String ENABLE_BARGE_IN = "enable_barge_in"; + /** send. */ + String SEND = "send"; + } + + protected String type; + protected Map parameters; + + protected DtmfCommandInfo() {} + + /** + * Gets the type. + * + *

Specifies the type of DTMF command for the phone integration. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the parameters. + * + *

Parameters specified by the command type. + * + * @return the parameters + */ + public Map getParameters() { + return parameters; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Environment.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Environment.java new file mode 100644 index 00000000000..76f418cc8ec --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Environment.java @@ -0,0 +1,187 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; + +/** Environment. */ +public class Environment extends GenericModel { + + protected String name; + protected String description; + + @SerializedName("assistant_id") + protected String assistantId; + + @SerializedName("environment_id") + protected String environmentId; + + protected String environment; + + @SerializedName("release_reference") + protected BaseEnvironmentReleaseReference releaseReference; + + protected BaseEnvironmentOrchestration orchestration; + + @SerializedName("session_timeout") + protected Long sessionTimeout; + + @SerializedName("integration_references") + protected List integrationReferences; + + @SerializedName("skill_references") + protected List skillReferences; + + protected Date created; + protected Date updated; + + protected Environment() {} + + /** + * Gets the name. + * + *

The name of the environment. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

The description of the environment. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the assistantId. + * + *

The assistant ID of the assistant the environment is associated with. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the environmentId. + * + *

The environment ID of the environment. + * + * @return the environmentId + */ + public String getEnvironmentId() { + return environmentId; + } + + /** + * Gets the environment. + * + *

The type of the environment. All environments other than the `draft` and `live` environments + * have the type `staging`. + * + * @return the environment + */ + public String getEnvironment() { + return environment; + } + + /** + * Gets the releaseReference. + * + *

An object describing the release that is currently deployed in the environment. + * + * @return the releaseReference + */ + public BaseEnvironmentReleaseReference getReleaseReference() { + return releaseReference; + } + + /** + * Gets the orchestration. + * + *

The search skill orchestration settings for the environment. + * + * @return the orchestration + */ + public BaseEnvironmentOrchestration getOrchestration() { + return orchestration; + } + + /** + * Gets the sessionTimeout. + * + *

The session inactivity timeout setting for the environment (in seconds). + * + * @return the sessionTimeout + */ + public Long getSessionTimeout() { + return sessionTimeout; + } + + /** + * Gets the integrationReferences. + * + *

An array of objects describing the integrations that exist in the environment. + * + * @return the integrationReferences + */ + public List getIntegrationReferences() { + return integrationReferences; + } + + /** + * Gets the skillReferences. + * + *

An array of objects identifying the skills (such as action and dialog) that exist in the + * environment. + * + * @return the skillReferences + */ + public List getSkillReferences() { + return skillReferences; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentCollection.java new file mode 100644 index 00000000000..e4b387f144c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentCollection.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** EnvironmentCollection. */ +public class EnvironmentCollection extends GenericModel { + + protected List environments; + protected Pagination pagination; + + protected EnvironmentCollection() {} + + /** + * Gets the environments. + * + *

An array of objects describing the environments associated with an assistant. + * + * @return the environments + */ + public List getEnvironments() { + return environments; + } + + /** + * Gets the pagination. + * + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). + * + * @return the pagination + */ + public Pagination getPagination() { + return pagination; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentOrchestration.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentOrchestration.java new file mode 100644 index 00000000000..b3883a9768e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentOrchestration.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The search skill orchestration settings for the environment. */ +public class EnvironmentOrchestration extends GenericModel { + + @SerializedName("search_skill_fallback") + protected Boolean searchSkillFallback; + + /** + * Gets the searchSkillFallback. + * + *

Whether assistants deployed to the environment fall back to a search skill when responding + * to messages that do not match any intent. If no search skill is configured for the assistant, + * this property is ignored. + * + * @return the searchSkillFallback + */ + public Boolean isSearchSkillFallback() { + return searchSkillFallback; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentReference.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentReference.java new file mode 100644 index 00000000000..987a43cb75d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentReference.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** EnvironmentReference. */ +public class EnvironmentReference extends GenericModel { + + /** + * The type of the environment. All environments other than the draft and live environments have + * the type `staging`. + */ + public interface Environment { + /** draft. */ + String DRAFT = "draft"; + /** live. */ + String LIVE = "live"; + /** staging. */ + String STAGING = "staging"; + } + + protected String name; + + @SerializedName("environment_id") + protected String environmentId; + + protected String environment; + + /** Builder. */ + public static class Builder { + private String name; + + /** + * Instantiates a new Builder from an existing EnvironmentReference instance. + * + * @param environmentReference the instance to initialize the Builder with + */ + private Builder(EnvironmentReference environmentReference) { + this.name = environmentReference.name; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a EnvironmentReference. + * + * @return the new EnvironmentReference instance + */ + public EnvironmentReference build() { + return new EnvironmentReference(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the EnvironmentReference builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + } + + protected EnvironmentReference() {} + + protected EnvironmentReference(Builder builder) { + name = builder.name; + } + + /** + * New builder. + * + * @return a EnvironmentReference builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of the environment. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the environmentId. + * + *

The unique identifier of the environment. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the environment. + * + *

The type of the environment. All environments other than the draft and live environments + * have the type `staging`. + * + * @return the environment + */ + public String environment() { + return environment; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentReleaseReference.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentReleaseReference.java new file mode 100644 index 00000000000..22f269690b0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentReleaseReference.java @@ -0,0 +1,32 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object describing the release that is currently deployed in the environment. */ +public class EnvironmentReleaseReference extends GenericModel { + + protected String release; + + /** + * Gets the release. + * + *

The name of the deployed release. + * + * @return the release + */ + public String getRelease() { + return release; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentSkill.java new file mode 100644 index 00000000000..8514538fca3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/EnvironmentSkill.java @@ -0,0 +1,217 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** EnvironmentSkill. */ +public class EnvironmentSkill extends GenericModel { + + /** The type of the skill. */ + public interface Type { + /** dialog. */ + String DIALOG = "dialog"; + /** action. */ + String ACTION = "action"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("skill_id") + protected String skillId; + + protected String type; + protected Boolean disabled; + protected String snapshot; + + @SerializedName("skill_reference") + protected String skillReference; + + /** Builder. */ + public static class Builder { + private String skillId; + private String type; + private Boolean disabled; + private String snapshot; + private String skillReference; + + /** + * Instantiates a new Builder from an existing EnvironmentSkill instance. + * + * @param environmentSkill the instance to initialize the Builder with + */ + private Builder(EnvironmentSkill environmentSkill) { + this.skillId = environmentSkill.skillId; + this.type = environmentSkill.type; + this.disabled = environmentSkill.disabled; + this.snapshot = environmentSkill.snapshot; + this.skillReference = environmentSkill.skillReference; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param skillId the skillId + */ + public Builder(String skillId) { + this.skillId = skillId; + } + + /** + * Builds a EnvironmentSkill. + * + * @return the new EnvironmentSkill instance + */ + public EnvironmentSkill build() { + return new EnvironmentSkill(this); + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the EnvironmentSkill builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the EnvironmentSkill builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the disabled. + * + * @param disabled the disabled + * @return the EnvironmentSkill builder + */ + public Builder disabled(Boolean disabled) { + this.disabled = disabled; + return this; + } + + /** + * Set the snapshot. + * + * @param snapshot the snapshot + * @return the EnvironmentSkill builder + */ + public Builder snapshot(String snapshot) { + this.snapshot = snapshot; + return this; + } + + /** + * Set the skillReference. + * + * @param skillReference the skillReference + * @return the EnvironmentSkill builder + */ + public Builder skillReference(String skillReference) { + this.skillReference = skillReference; + return this; + } + } + + protected EnvironmentSkill() {} + + protected EnvironmentSkill(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.skillId, "skillId cannot be null"); + skillId = builder.skillId; + type = builder.type; + disabled = builder.disabled; + snapshot = builder.snapshot; + skillReference = builder.skillReference; + } + + /** + * New builder. + * + * @return a EnvironmentSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the type. + * + *

The type of the skill. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the disabled. + * + *

Whether the skill is disabled. A disabled skill in the draft environment does not handle any + * messages at run time, and it is not included in saved releases. + * + * @return the disabled + */ + public Boolean disabled() { + return disabled; + } + + /** + * Gets the snapshot. + * + *

The name of the skill snapshot that is deployed to the environment (for example, `draft` or + * `1`). + * + * @return the snapshot + */ + public String snapshot() { + return snapshot; + } + + /** + * Gets the skillReference. + * + *

The type of skill identified by the skill reference. The possible values are `main skill` + * (for a dialog skill), `actions skill`, and `search skill`. + * + * @return the skillReference + */ + public String skillReference() { + return skillReference; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ExportSkillsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ExportSkillsOptions.java new file mode 100644 index 00000000000..272f6c448af --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ExportSkillsOptions.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The exportSkills options. */ +public class ExportSkillsOptions extends GenericModel { + + protected String assistantId; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing ExportSkillsOptions instance. + * + * @param exportSkillsOptions the instance to initialize the Builder with + */ + private Builder(ExportSkillsOptions exportSkillsOptions) { + this.assistantId = exportSkillsOptions.assistantId; + this.includeAudit = exportSkillsOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a ExportSkillsOptions. + * + * @return the new ExportSkillsOptions instance + */ + public ExportSkillsOptions build() { + return new ExportSkillsOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the ExportSkillsOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ExportSkillsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ExportSkillsOptions() {} + + protected ExportSkillsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ExportSkillsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/FinalResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/FinalResponse.java new file mode 100644 index 00000000000..b2e923a9e9a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/FinalResponse.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Message final response content. */ +public class FinalResponse extends GenericModel { + + protected FinalResponseOutput output; + protected MessageContext context; + + @SerializedName("user_id") + protected String userId; + + @SerializedName("masked_output") + protected MessageOutput maskedOutput; + + @SerializedName("masked_input") + protected MessageInput maskedInput; + + protected FinalResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. + * + * @return the output + */ + public FinalResponseOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is stored by the assistant on a per-session basis. + * + *

**Note:** The context is included in message responses only if **return_context**=`true` in + * the message request. Full context is always included in logs. + * + * @return the context + */ + public MessageContext getContext() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } + + /** + * Gets the maskedOutput. + * + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + * + * @return the maskedOutput + */ + public MessageOutput getMaskedOutput() { + return maskedOutput; + } + + /** + * Gets the maskedInput. + * + *

An input object that includes the input text. All private data is masked or removed. + * + * @return the maskedInput + */ + public MessageInput getMaskedInput() { + return maskedInput; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/FinalResponseOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/FinalResponseOutput.java new file mode 100644 index 00000000000..9be7231d5bc --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/FinalResponseOutput.java @@ -0,0 +1,144 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** Assistant output to be rendered or processed by the client. */ +public class FinalResponseOutput extends GenericModel { + + protected List generic; + protected List intents; + protected List entities; + protected List actions; + protected MessageOutputDebug debug; + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageOutputSpelling spelling; + + @SerializedName("llm_metadata") + protected List llmMetadata; + + @SerializedName("streaming_metadata") + protected MessageStreamMetadata streamingMetadata; + + protected FinalResponseOutput() {} + + /** + * Gets the generic. + * + *

Output intended for any channel. It is the responsibility of the client application to + * implement the supported response types. + * + * @return the generic + */ + public List getGeneric() { + return generic; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the user input, sorted in descending order of confidence. + * + * @return the intents + */ + public List getIntents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the user input. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the actions. + * + *

An array of objects describing any actions requested by the dialog node. + * + * @return the actions + */ + public List getActions() { + return actions; + } + + /** + * Gets the debug. + * + *

Additional detailed information about a message response and how it was generated. + * + * @return the debug + */ + public MessageOutputDebug getDebug() { + return debug; + } + + /** + * Gets the userDefined. + * + *

An object containing any custom properties included in the response. This object includes + * any arbitrary properties defined in the dialog JSON editor as part of the dialog node output. + * + * @return the userDefined + */ + public Map getUserDefined() { + return userDefined; + } + + /** + * Gets the spelling. + * + *

Properties describing any spelling corrections in the user input that was received. + * + * @return the spelling + */ + public MessageOutputSpelling getSpelling() { + return spelling; + } + + /** + * Gets the llmMetadata. + * + *

An array of objects that provide information about calls to large language models that + * occured as part of handling this message. + * + * @return the llmMetadata + */ + public List getLlmMetadata() { + return llmMetadata; + } + + /** + * Gets the streamingMetadata. + * + *

Contains meta-information about the item(s) being streamed. + * + * @return the streamingMetadata + */ + public MessageStreamMetadata getStreamingMetadata() { + return streamingMetadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITask.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITask.java new file mode 100644 index 00000000000..50c36ad9310 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITask.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * GenerativeAITask. + * + *

Classes which extend this class: - GenerativeAITaskContentGroundedAnswering - + * GenerativeAITaskGeneralPurposeAnswering + */ +public class GenerativeAITask extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "task"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "content_grounded_answering", GenerativeAITaskContentGroundedAnswering.class); + discriminatorMapping.put( + "general_purpose_answering", GenerativeAITaskGeneralPurposeAnswering.class); + } + + protected String task; + + @SerializedName("is_idk_response") + protected Boolean isIdkResponse; + + @SerializedName("is_hap_detected") + protected Boolean isHapDetected; + + @SerializedName("confidence_scores") + protected GenerativeAITaskConfidenceScores confidenceScores; + + @SerializedName("original_response") + protected String originalResponse; + + @SerializedName("inferred_query") + protected String inferredQuery; + + protected GenerativeAITask() {} + + /** + * Gets the task. + * + *

The type of generative ai task. + * + * @return the task + */ + public String getTask() { + return task; + } + + /** + * Gets the isIdkResponse. + * + *

Whether response was an idk response. + * + * @return the isIdkResponse + */ + public Boolean isIsIdkResponse() { + return isIdkResponse; + } + + /** + * Gets the isHapDetected. + * + *

Whether response was a hap response. + * + * @return the isHapDetected + */ + public Boolean isIsHapDetected() { + return isHapDetected; + } + + /** + * Gets the confidenceScores. + * + *

The confidence scores for determining whether to show the generated response or an “I don't + * know” response. + * + * @return the confidenceScores + */ + public GenerativeAITaskConfidenceScores getConfidenceScores() { + return confidenceScores; + } + + /** + * Gets the originalResponse. + * + *

The original response returned by the generative ai. + * + * @return the originalResponse + */ + public String getOriginalResponse() { + return originalResponse; + } + + /** + * Gets the inferredQuery. + * + *

Generated from the input text after auto-correction. If this field is not present, the input + * text was used as the query to the generative ai. + * + * @return the inferredQuery + */ + public String getInferredQuery() { + return inferredQuery; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskConfidenceScores.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskConfidenceScores.java new file mode 100644 index 00000000000..de1b45eb174 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskConfidenceScores.java @@ -0,0 +1,86 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The confidence scores for determining whether to show the generated response or an “I don't know” + * response. + */ +public class GenerativeAITaskConfidenceScores extends GenericModel { + + @SerializedName("pre_gen") + protected Double preGen; + + @SerializedName("pre_gen_threshold") + protected Double preGenThreshold; + + @SerializedName("post_gen") + protected Double postGen; + + @SerializedName("post_gen_threshold") + protected Double postGenThreshold; + + protected GenerativeAITaskConfidenceScores() {} + + /** + * Gets the preGen. + * + *

The confidence score based on user query and search results. + * + * @return the preGen + */ + public Double getPreGen() { + return preGen; + } + + /** + * Gets the preGenThreshold. + * + *

The pre_gen confidence score threshold. If the pre_gen score is below this threshold, it + * shows an “I don't know” response instead of the generated response. Shown in the conversational + * search skill UI as the “Retrieval Confidence threshold”. + * + * @return the preGenThreshold + */ + public Double getPreGenThreshold() { + return preGenThreshold; + } + + /** + * Gets the postGen. + * + *

The confidence score based on user query, search results, and the generated response. + * + * @return the postGen + */ + public Double getPostGen() { + return postGen; + } + + /** + * Gets the postGenThreshold. + * + *

The post_gen confidence score threshold. If the post_gen score is below this threshold, it + * shows an “I don't know” response instead of the generated response. Shown in the conversational + * search skill UI as the “Response Confidence threshold”. + * + * @return the postGenThreshold + */ + public Double getPostGenThreshold() { + return postGenThreshold; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskContentGroundedAnswering.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskContentGroundedAnswering.java new file mode 100644 index 00000000000..4c96b78743c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskContentGroundedAnswering.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** GenerativeAITaskContentGroundedAnswering. */ +public class GenerativeAITaskContentGroundedAnswering extends GenerativeAITask { + + protected GenerativeAITaskContentGroundedAnswering() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskGeneralPurposeAnswering.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskGeneralPurposeAnswering.java new file mode 100644 index 00000000000..08be88ad80f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskGeneralPurposeAnswering.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** GenerativeAITaskGeneralPurposeAnswering. */ +public class GenerativeAITaskGeneralPurposeAnswering extends GenerativeAITask { + + protected GenerativeAITaskGeneralPurposeAnswering() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetEnvironmentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetEnvironmentOptions.java new file mode 100644 index 00000000000..25d0a589a37 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetEnvironmentOptions.java @@ -0,0 +1,157 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getEnvironment options. */ +public class GetEnvironmentOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String environmentId; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing GetEnvironmentOptions instance. + * + * @param getEnvironmentOptions the instance to initialize the Builder with + */ + private Builder(GetEnvironmentOptions getEnvironmentOptions) { + this.assistantId = getEnvironmentOptions.assistantId; + this.environmentId = getEnvironmentOptions.environmentId; + this.includeAudit = getEnvironmentOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param environmentId the environmentId + */ + public Builder(String assistantId, String environmentId) { + this.assistantId = assistantId; + this.environmentId = environmentId; + } + + /** + * Builds a GetEnvironmentOptions. + * + * @return the new GetEnvironmentOptions instance + */ + public GetEnvironmentOptions build() { + return new GetEnvironmentOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the GetEnvironmentOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the GetEnvironmentOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetEnvironmentOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected GetEnvironmentOptions() {} + + protected GetEnvironmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + assistantId = builder.assistantId; + environmentId = builder.environmentId; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetEnvironmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetReleaseImportStatusOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetReleaseImportStatusOptions.java new file mode 100644 index 00000000000..817935985ec --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetReleaseImportStatusOptions.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getReleaseImportStatus options. */ +public class GetReleaseImportStatusOptions extends GenericModel { + + protected String assistantId; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing GetReleaseImportStatusOptions instance. + * + * @param getReleaseImportStatusOptions the instance to initialize the Builder with + */ + private Builder(GetReleaseImportStatusOptions getReleaseImportStatusOptions) { + this.assistantId = getReleaseImportStatusOptions.assistantId; + this.includeAudit = getReleaseImportStatusOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a GetReleaseImportStatusOptions. + * + * @return the new GetReleaseImportStatusOptions instance + */ + public GetReleaseImportStatusOptions build() { + return new GetReleaseImportStatusOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the GetReleaseImportStatusOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetReleaseImportStatusOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected GetReleaseImportStatusOptions() {} + + protected GetReleaseImportStatusOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetReleaseImportStatusOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetReleaseOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetReleaseOptions.java new file mode 100644 index 00000000000..7d845af4424 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetReleaseOptions.java @@ -0,0 +1,154 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getRelease options. */ +public class GetReleaseOptions extends GenericModel { + + protected String assistantId; + protected String release; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String release; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing GetReleaseOptions instance. + * + * @param getReleaseOptions the instance to initialize the Builder with + */ + private Builder(GetReleaseOptions getReleaseOptions) { + this.assistantId = getReleaseOptions.assistantId; + this.release = getReleaseOptions.release; + this.includeAudit = getReleaseOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param release the release + */ + public Builder(String assistantId, String release) { + this.assistantId = assistantId; + this.release = release; + } + + /** + * Builds a GetReleaseOptions. + * + * @return the new GetReleaseOptions instance + */ + public GetReleaseOptions build() { + return new GetReleaseOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the GetReleaseOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the release. + * + * @param release the release + * @return the GetReleaseOptions builder + */ + public Builder release(String release) { + this.release = release; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetReleaseOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected GetReleaseOptions() {} + + protected GetReleaseOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.release, "release cannot be empty"); + assistantId = builder.assistantId; + release = builder.release; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetReleaseOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the release. + * + *

Unique identifier of the release. + * + * @return the release + */ + public String release() { + return release; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetSkillOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetSkillOptions.java new file mode 100644 index 00000000000..a5583560b34 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/GetSkillOptions.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getSkill options. */ +public class GetSkillOptions extends GenericModel { + + protected String assistantId; + protected String skillId; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String skillId; + + /** + * Instantiates a new Builder from an existing GetSkillOptions instance. + * + * @param getSkillOptions the instance to initialize the Builder with + */ + private Builder(GetSkillOptions getSkillOptions) { + this.assistantId = getSkillOptions.assistantId; + this.skillId = getSkillOptions.skillId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param skillId the skillId + */ + public Builder(String assistantId, String skillId) { + this.assistantId = assistantId; + this.skillId = skillId; + } + + /** + * Builds a GetSkillOptions. + * + * @return the new GetSkillOptions instance + */ + public GetSkillOptions build() { + return new GetSkillOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the GetSkillOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the GetSkillOptions builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + } + + protected GetSkillOptions() {} + + protected GetSkillOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.skillId, "skillId cannot be empty"); + assistantId = builder.assistantId; + skillId = builder.skillId; + } + + /** + * New builder. + * + * @return a GetSkillOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the skillId. + * + *

Unique identifier of the skill. To find the action or dialog skill ID in the watsonx + * Assistant user interface, open the skill settings and click **API Details**. To find the search + * skill ID, use the Get environment API to retrieve the skill references for an environment and + * it will include the search skill info, if available. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ImportSkillsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ImportSkillsOptions.java new file mode 100644 index 00000000000..1be9935e5b7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ImportSkillsOptions.java @@ -0,0 +1,206 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The importSkills options. */ +public class ImportSkillsOptions extends GenericModel { + + protected String assistantId; + protected List assistantSkills; + protected AssistantState assistantState; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private List assistantSkills; + private AssistantState assistantState; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing ImportSkillsOptions instance. + * + * @param importSkillsOptions the instance to initialize the Builder with + */ + private Builder(ImportSkillsOptions importSkillsOptions) { + this.assistantId = importSkillsOptions.assistantId; + this.assistantSkills = importSkillsOptions.assistantSkills; + this.assistantState = importSkillsOptions.assistantState; + this.includeAudit = importSkillsOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param assistantSkills the assistantSkills + * @param assistantState the assistantState + */ + public Builder( + String assistantId, List assistantSkills, AssistantState assistantState) { + this.assistantId = assistantId; + this.assistantSkills = assistantSkills; + this.assistantState = assistantState; + } + + /** + * Builds a ImportSkillsOptions. + * + * @return the new ImportSkillsOptions instance + */ + public ImportSkillsOptions build() { + return new ImportSkillsOptions(this); + } + + /** + * Adds a new element to assistantSkills. + * + * @param assistantSkills the new element to be added + * @return the ImportSkillsOptions builder + */ + public Builder addAssistantSkills(SkillImport assistantSkills) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + assistantSkills, "assistantSkills cannot be null"); + if (this.assistantSkills == null) { + this.assistantSkills = new ArrayList(); + } + this.assistantSkills.add(assistantSkills); + return this; + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the ImportSkillsOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the assistantSkills. Existing assistantSkills will be replaced. + * + * @param assistantSkills the assistantSkills + * @return the ImportSkillsOptions builder + */ + public Builder assistantSkills(List assistantSkills) { + this.assistantSkills = assistantSkills; + return this; + } + + /** + * Set the assistantState. + * + * @param assistantState the assistantState + * @return the ImportSkillsOptions builder + */ + public Builder assistantState(AssistantState assistantState) { + this.assistantState = assistantState; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ImportSkillsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ImportSkillsOptions() {} + + protected ImportSkillsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.assistantSkills, "assistantSkills cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.assistantState, "assistantState cannot be null"); + assistantId = builder.assistantId; + assistantSkills = builder.assistantSkills; + assistantState = builder.assistantState; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ImportSkillsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the assistantSkills. + * + *

An array of objects describing the skills for the assistant. Included in responses only if + * **status**=`Available`. + * + * @return the assistantSkills + */ + public List assistantSkills() { + return assistantSkills; + } + + /** + * Gets the assistantState. + * + *

Status information about the skills for the assistant. Included in responses only if + * **status**=`Available`. + * + * @return the assistantState + */ + public AssistantState assistantState() { + return assistantState; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ImportSkillsStatusOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ImportSkillsStatusOptions.java new file mode 100644 index 00000000000..b2a6efdcb87 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ImportSkillsStatusOptions.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The importSkillsStatus options. */ +public class ImportSkillsStatusOptions extends GenericModel { + + protected String assistantId; + + /** Builder. */ + public static class Builder { + private String assistantId; + + /** + * Instantiates a new Builder from an existing ImportSkillsStatusOptions instance. + * + * @param importSkillsStatusOptions the instance to initialize the Builder with + */ + private Builder(ImportSkillsStatusOptions importSkillsStatusOptions) { + this.assistantId = importSkillsStatusOptions.assistantId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a ImportSkillsStatusOptions. + * + * @return the new ImportSkillsStatusOptions instance + */ + public ImportSkillsStatusOptions build() { + return new ImportSkillsStatusOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the ImportSkillsStatusOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + } + + protected ImportSkillsStatusOptions() {} + + protected ImportSkillsStatusOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + } + + /** + * New builder. + * + * @return a ImportSkillsStatusOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/InputStreamConnectStrategy.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/InputStreamConnectStrategy.java new file mode 100644 index 00000000000..2bfc27623f7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/InputStreamConnectStrategy.java @@ -0,0 +1,124 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.launchdarkly.eventsource.ConnectStrategy; +import com.launchdarkly.eventsource.StreamException; +import com.launchdarkly.logging.LDLogger; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; + +public class InputStreamConnectStrategy extends ConnectStrategy { + + protected InputStream inputStream; + + /** Builder. */ + public static class Builder { + private InputStream inputStream; + + /** + * Instantiates a new Builder from an existing InputStreamConnectStrategy instance. + * + * @param inputStreamConnectStrategy the instance to initialize the Builder with + */ + private Builder(InputStreamConnectStrategy inputStreamConnectStrategy) { + this.inputStream = inputStreamConnectStrategy.inputStream; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param inputStream the inputStream + */ + public Builder(InputStream inputStream) { + this.inputStream = inputStream; + } + + /** + * Builds a InputStreamConnectStrategy. + * + * @return the new InputStreamConnectStrategy instance + */ + public InputStreamConnectStrategy build() { + return new InputStreamConnectStrategy(this); + } + + /** + * Set the inputStream. + * + * @param inputStream the inputStream + * @return the InputStreamConnectStrategy builder + */ + public Builder inputStream(InputStream inputStream) { + this.inputStream = inputStream; + return this; + } + } + + protected InputStreamConnectStrategy() {} + + protected InputStreamConnectStrategy(Builder builder) { + inputStream = builder.inputStream; + } + + /** + * New builder. + * + * @return a InputStreamConnectStrategy builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the inputStream. + * + * @return the inputStream + */ + public InputStream inputStream() { + return inputStream; + } + + @Override + public Client createClient(LDLogger ldLogger) { + Client client = + new Client() { + @Override + public Result connect(String s) throws StreamException { + Result result = new Result(inputStream, null, inputStream); + return result; + } + + @Override + public boolean awaitClosed(long l) throws InterruptedException { + return false; + } + + @Override + public URI getOrigin() { + return null; + } + + @Override + public void close() throws IOException { + inputStream.close(); + } + }; + return client; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/IntegrationReference.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/IntegrationReference.java new file mode 100644 index 00000000000..d2fa6f8874a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/IntegrationReference.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** IntegrationReference. */ +public class IntegrationReference extends GenericModel { + + @SerializedName("integration_id") + protected String integrationId; + + protected String type; + + /** Builder. */ + public static class Builder { + private String integrationId; + private String type; + + /** + * Instantiates a new Builder from an existing IntegrationReference instance. + * + * @param integrationReference the instance to initialize the Builder with + */ + private Builder(IntegrationReference integrationReference) { + this.integrationId = integrationReference.integrationId; + this.type = integrationReference.type; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a IntegrationReference. + * + * @return the new IntegrationReference instance + */ + public IntegrationReference build() { + return new IntegrationReference(this); + } + + /** + * Set the integrationId. + * + * @param integrationId the integrationId + * @return the IntegrationReference builder + */ + public Builder integrationId(String integrationId) { + this.integrationId = integrationId; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the IntegrationReference builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + } + + protected IntegrationReference() {} + + protected IntegrationReference(Builder builder) { + integrationId = builder.integrationId; + type = builder.type; + } + + /** + * New builder. + * + * @return a IntegrationReference builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the integrationId. + * + *

The integration ID of the integration. + * + * @return the integrationId + */ + public String integrationId() { + return integrationId; + } + + /** + * Gets the type. + * + *

The type of the integration. + * + * @return the type + */ + public String type() { + return type; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListAssistantsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListAssistantsOptions.java new file mode 100644 index 00000000000..5eabe3c0a62 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListAssistantsOptions.java @@ -0,0 +1,204 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listAssistants options. */ +public class ListAssistantsOptions extends GenericModel { + + /** + * The attribute by which returned assistants will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). + */ + public interface Sort { + /** name. */ + String NAME = "name"; + /** updated. */ + String UPDATED = "updated"; + } + + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private Long pageLimit; + private Boolean includeCount; + private String sort; + private String cursor; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing ListAssistantsOptions instance. + * + * @param listAssistantsOptions the instance to initialize the Builder with + */ + private Builder(ListAssistantsOptions listAssistantsOptions) { + this.pageLimit = listAssistantsOptions.pageLimit; + this.includeCount = listAssistantsOptions.includeCount; + this.sort = listAssistantsOptions.sort; + this.cursor = listAssistantsOptions.cursor; + this.includeAudit = listAssistantsOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ListAssistantsOptions. + * + * @return the new ListAssistantsOptions instance + */ + public ListAssistantsOptions build() { + return new ListAssistantsOptions(this); + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListAssistantsOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListAssistantsOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListAssistantsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListAssistantsOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListAssistantsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListAssistantsOptions() {} + + protected ListAssistantsOptions(Builder builder) { + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListAssistantsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the pageLimit. + * + *

The number of records to return in each page of results. + * + * @return the pageLimit + */ + public Long pageLimit() { + return pageLimit; + } + + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + + /** + * Gets the sort. + * + *

The attribute by which returned assistants will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the cursor. + * + *

A token identifying the page of results to retrieve. + * + * @return the cursor + */ + public String cursor() { + return cursor; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListEnvironmentsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListEnvironmentsOptions.java new file mode 100644 index 00000000000..aec63eec277 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListEnvironmentsOptions.java @@ -0,0 +1,243 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listEnvironments options. */ +public class ListEnvironmentsOptions extends GenericModel { + + /** + * The attribute by which returned environments will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). + */ + public interface Sort { + /** name. */ + String NAME = "name"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String assistantId; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private Long pageLimit; + private Boolean includeCount; + private String sort; + private String cursor; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing ListEnvironmentsOptions instance. + * + * @param listEnvironmentsOptions the instance to initialize the Builder with + */ + private Builder(ListEnvironmentsOptions listEnvironmentsOptions) { + this.assistantId = listEnvironmentsOptions.assistantId; + this.pageLimit = listEnvironmentsOptions.pageLimit; + this.includeCount = listEnvironmentsOptions.includeCount; + this.sort = listEnvironmentsOptions.sort; + this.cursor = listEnvironmentsOptions.cursor; + this.includeAudit = listEnvironmentsOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a ListEnvironmentsOptions. + * + * @return the new ListEnvironmentsOptions instance + */ + public ListEnvironmentsOptions build() { + return new ListEnvironmentsOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the ListEnvironmentsOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListEnvironmentsOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListEnvironmentsOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListEnvironmentsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListEnvironmentsOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListEnvironmentsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListEnvironmentsOptions() {} + + protected ListEnvironmentsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListEnvironmentsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the pageLimit. + * + *

The number of records to return in each page of results. + * + * @return the pageLimit + */ + public Long pageLimit() { + return pageLimit; + } + + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + + /** + * Gets the sort. + * + *

The attribute by which returned environments will be sorted. To reverse the sort order, + * prefix the value with a minus sign (`-`). + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the cursor. + * + *

A token identifying the page of results to retrieve. + * + * @return the cursor + */ + public String cursor() { + return cursor; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java new file mode 100644 index 00000000000..40657673ba1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java @@ -0,0 +1,221 @@ +/* + * (C) Copyright IBM Corp. 2020, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listLogs options. */ +public class ListLogsOptions extends GenericModel { + + protected String assistantId; + protected String sort; + protected String filter; + protected Long pageLimit; + protected String cursor; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String sort; + private String filter; + private Long pageLimit; + private String cursor; + + /** + * Instantiates a new Builder from an existing ListLogsOptions instance. + * + * @param listLogsOptions the instance to initialize the Builder with + */ + private Builder(ListLogsOptions listLogsOptions) { + this.assistantId = listLogsOptions.assistantId; + this.sort = listLogsOptions.sort; + this.filter = listLogsOptions.filter; + this.pageLimit = listLogsOptions.pageLimit; + this.cursor = listLogsOptions.cursor; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a ListLogsOptions. + * + * @return the new ListLogsOptions instance + */ + public ListLogsOptions build() { + return new ListLogsOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the ListLogsOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListLogsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the ListLogsOptions builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListLogsOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListLogsOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + } + + protected ListLogsOptions() {} + + protected ListLogsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + sort = builder.sort; + filter = builder.filter; + pageLimit = builder.pageLimit; + cursor = builder.cursor; + } + + /** + * New builder. + * + * @return a ListLogsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

The assistant ID or the environment ID of the environment where the assistant is deployed. + * Set the value for this ID depending on the type of request: + * + *

- For message, session, and log requests, specify the environment ID of the environment + * where the assistant is deployed. + * + *

- For all other requests, specify the assistant ID of the assistant. + * + *

To get the **assistant ID** and **environment ID** in the watsonx Assistant interface, open + * the **Assistant settings** page, and scroll to the **Assistant IDs and API details** section + * and click **View Details**. + * + *

**Note:** If you are using the classic Watson Assistant experience, always use the assistant + * ID. + * + *

To find the **assistant ID** in the user interface, open the **Assistant settings** and + * click **API Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the sort. + * + *

How to sort the returned log events. You can sort by **request_timestamp**. To reverse the + * sort order, prefix the parameter value with a minus sign (`-`). + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the filter. + * + *

A cacheable parameter that limits the results to those matching the specified filter. For + * more information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-reference#filter-reference). + * + * @return the filter + */ + public String filter() { + return filter; + } + + /** + * Gets the pageLimit. + * + *

The number of records to return in each page of results. + * + *

**Note:** If the API is not returning your data, try lowering the page_limit value. + * + * @return the pageLimit + */ + public Long pageLimit() { + return pageLimit; + } + + /** + * Gets the cursor. + * + *

A token identifying the page of results to retrieve. + * + * @return the cursor + */ + public String cursor() { + return cursor; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListProvidersOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListProvidersOptions.java new file mode 100644 index 00000000000..56f04a797bb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListProvidersOptions.java @@ -0,0 +1,204 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listProviders options. */ +public class ListProvidersOptions extends GenericModel { + + /** + * The attribute by which returned conversational skill providers will be sorted. To reverse the + * sort order, prefix the value with a minus sign (`-`). + */ + public interface Sort { + /** name. */ + String NAME = "name"; + /** updated. */ + String UPDATED = "updated"; + } + + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private Long pageLimit; + private Boolean includeCount; + private String sort; + private String cursor; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing ListProvidersOptions instance. + * + * @param listProvidersOptions the instance to initialize the Builder with + */ + private Builder(ListProvidersOptions listProvidersOptions) { + this.pageLimit = listProvidersOptions.pageLimit; + this.includeCount = listProvidersOptions.includeCount; + this.sort = listProvidersOptions.sort; + this.cursor = listProvidersOptions.cursor; + this.includeAudit = listProvidersOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ListProvidersOptions. + * + * @return the new ListProvidersOptions instance + */ + public ListProvidersOptions build() { + return new ListProvidersOptions(this); + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListProvidersOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListProvidersOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListProvidersOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListProvidersOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListProvidersOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListProvidersOptions() {} + + protected ListProvidersOptions(Builder builder) { + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListProvidersOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the pageLimit. + * + *

The number of records to return in each page of results. + * + * @return the pageLimit + */ + public Long pageLimit() { + return pageLimit; + } + + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + + /** + * Gets the sort. + * + *

The attribute by which returned conversational skill providers will be sorted. To reverse + * the sort order, prefix the value with a minus sign (`-`). + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the cursor. + * + *

A token identifying the page of results to retrieve. + * + * @return the cursor + */ + public String cursor() { + return cursor; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListReleasesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListReleasesOptions.java new file mode 100644 index 00000000000..b4c71a028b7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListReleasesOptions.java @@ -0,0 +1,243 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listReleases options. */ +public class ListReleasesOptions extends GenericModel { + + /** + * The attribute by which returned workspaces will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). + */ + public interface Sort { + /** name. */ + String NAME = "name"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String assistantId; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String assistantId; + private Long pageLimit; + private Boolean includeCount; + private String sort; + private String cursor; + private Boolean includeAudit; + + /** + * Instantiates a new Builder from an existing ListReleasesOptions instance. + * + * @param listReleasesOptions the instance to initialize the Builder with + */ + private Builder(ListReleasesOptions listReleasesOptions) { + this.assistantId = listReleasesOptions.assistantId; + this.pageLimit = listReleasesOptions.pageLimit; + this.includeCount = listReleasesOptions.includeCount; + this.sort = listReleasesOptions.sort; + this.cursor = listReleasesOptions.cursor; + this.includeAudit = listReleasesOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + */ + public Builder(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Builds a ListReleasesOptions. + * + * @return the new ListReleasesOptions instance + */ + public ListReleasesOptions build() { + return new ListReleasesOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the ListReleasesOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListReleasesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListReleasesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListReleasesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListReleasesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListReleasesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListReleasesOptions() {} + + protected ListReleasesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + assistantId = builder.assistantId; + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListReleasesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the pageLimit. + * + *

The number of records to return in each page of results. + * + * @return the pageLimit + */ + public Long pageLimit() { + return pageLimit; + } + + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + + /** + * Gets the sort. + * + *

The attribute by which returned workspaces will be sorted. To reverse the sort order, prefix + * the value with a minus sign (`-`). + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the cursor. + * + *

A token identifying the page of results to retrieve. + * + * @return the cursor + */ + public String cursor() { + return cursor; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java new file mode 100644 index 00000000000..167d3c57992 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java @@ -0,0 +1,173 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Log. */ +public class Log extends GenericModel { + + @SerializedName("log_id") + protected String logId; + + protected LogRequest request; + protected LogResponse response; + + @SerializedName("assistant_id") + protected String assistantId; + + @SerializedName("session_id") + protected String sessionId; + + @SerializedName("skill_id") + protected String skillId; + + protected String snapshot; + + @SerializedName("request_timestamp") + protected String requestTimestamp; + + @SerializedName("response_timestamp") + protected String responseTimestamp; + + protected String language; + + @SerializedName("customer_id") + protected String customerId; + + protected Log() {} + + /** + * Gets the logId. + * + *

A unique identifier for the logged event. + * + * @return the logId + */ + public String getLogId() { + return logId; + } + + /** + * Gets the request. + * + *

A message request formatted for the watsonx Assistant service. + * + * @return the request + */ + public LogRequest getRequest() { + return request; + } + + /** + * Gets the response. + * + *

A response from the watsonx Assistant service. + * + * @return the response + */ + public LogResponse getResponse() { + return response; + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the sessionId. + * + *

The ID of the session the message was part of. + * + * @return the sessionId + */ + public String getSessionId() { + return sessionId; + } + + /** + * Gets the skillId. + * + *

The unique identifier of the skill that responded to the message. + * + * @return the skillId + */ + public String getSkillId() { + return skillId; + } + + /** + * Gets the snapshot. + * + *

The name of the snapshot (dialog skill version) that responded to the message (for example, + * `draft`). + * + * @return the snapshot + */ + public String getSnapshot() { + return snapshot; + } + + /** + * Gets the requestTimestamp. + * + *

The timestamp for receipt of the message. + * + * @return the requestTimestamp + */ + public String getRequestTimestamp() { + return requestTimestamp; + } + + /** + * Gets the responseTimestamp. + * + *

The timestamp for the system response to the message. + * + * @return the responseTimestamp + */ + public String getResponseTimestamp() { + return responseTimestamp; + } + + /** + * Gets the language. + * + *

The language of the assistant to which the message request was made. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the customerId. + * + *

The customer ID specified for the message, if any. + * + * @return the customerId + */ + public String getCustomerId() { + return customerId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogCollection.java new file mode 100644 index 00000000000..ff6347d16d4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogCollection.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** LogCollection. */ +public class LogCollection extends GenericModel { + + protected List logs; + protected LogPagination pagination; + + protected LogCollection() {} + + /** + * Gets the logs. + * + *

An array of objects describing log events. + * + * @return the logs + */ + public List getLogs() { + return logs; + } + + /** + * Gets the pagination. + * + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). + * + * @return the pagination + */ + public LogPagination getPagination() { + return pagination; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSource.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSource.java new file mode 100644 index 00000000000..94fdb6326dc --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSource.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object that identifies the dialog element that generated the error message. + * + *

Classes which extend this class: - LogMessageSourceDialogNode - LogMessageSourceAction - + * LogMessageSourceStep - LogMessageSourceHandler + */ +public class LogMessageSource extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put("dialog_node", LogMessageSourceDialogNode.class); + discriminatorMapping.put("action", LogMessageSourceAction.class); + discriminatorMapping.put("step", LogMessageSourceStep.class); + discriminatorMapping.put("handler", LogMessageSourceHandler.class); + } + + protected String type; + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String action; + protected String step; + protected String handler; + + protected LogMessageSource() {} + + /** + * Gets the type. + * + *

A string that indicates the type of dialog element that generated the error message. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the dialogNode. + * + *

The unique identifier of the dialog node that generated the error message. + * + * @return the dialogNode + */ + public String getDialogNode() { + return dialogNode; + } + + /** + * Gets the action. + * + *

The unique identifier of the action that generated the error message. + * + * @return the action + */ + public String getAction() { + return action; + } + + /** + * Gets the step. + * + *

The unique identifier of the step that generated the error message. + * + * @return the step + */ + public String getStep() { + return step; + } + + /** + * Gets the handler. + * + *

The unique identifier of the handler that generated the error message. + * + * @return the handler + */ + public String getHandler() { + return handler; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceAction.java new file mode 100644 index 00000000000..48abb2199d5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceAction.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +/** An object that identifies the dialog element that generated the error message. */ +public class LogMessageSourceAction extends LogMessageSource { + + protected LogMessageSourceAction() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceDialogNode.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceDialogNode.java new file mode 100644 index 00000000000..b9d86634e19 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceDialogNode.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +/** An object that identifies the dialog element that generated the error message. */ +public class LogMessageSourceDialogNode extends LogMessageSource { + + protected LogMessageSourceDialogNode() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceHandler.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceHandler.java new file mode 100644 index 00000000000..ee561518196 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceHandler.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +/** An object that identifies the dialog element that generated the error message. */ +public class LogMessageSourceHandler extends LogMessageSource { + + protected LogMessageSourceHandler() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceStep.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceStep.java new file mode 100644 index 00000000000..0d9f650e2d9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogMessageSourceStep.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +/** An object that identifies the dialog element that generated the error message. */ +public class LogMessageSourceStep extends LogMessageSource { + + protected LogMessageSourceStep() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogPagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogPagination.java new file mode 100644 index 00000000000..139dfe1a7ff --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogPagination.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The pagination data for the returned objects. For more information about using pagination, see + * [Pagination](#pagination). + */ +public class LogPagination extends GenericModel { + + @SerializedName("next_url") + protected String nextUrl; + + protected Long matched; + + @SerializedName("next_cursor") + protected String nextCursor; + + protected LogPagination() {} + + /** + * Gets the nextUrl. + * + *

The URL that will return the next page of results, if any. + * + * @return the nextUrl + */ + public String getNextUrl() { + return nextUrl; + } + + /** + * Gets the matched. + * + *

Reserved for future use. + * + * @return the matched + */ + public Long getMatched() { + return matched; + } + + /** + * Gets the nextCursor. + * + *

A token identifying the next page of results. + * + * @return the nextCursor + */ + public String getNextCursor() { + return nextCursor; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequest.java new file mode 100644 index 00000000000..57212bb192f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequest.java @@ -0,0 +1,75 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A message request formatted for the watsonx Assistant service. */ +public class LogRequest extends GenericModel { + + protected LogRequestInput input; + protected MessageContext context; + + @SerializedName("user_id") + protected String userId; + + protected LogRequest() {} + + /** + * Gets the input. + * + *

An input object that includes the input text. All private data is masked or removed. + * + * @return the input + */ + public LogRequestInput getInput() { + return input; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to set or modify context + * variables, which can also be accessed by dialog nodes. The context is stored by the assistant + * on a per-session basis. + * + *

**Note:** The total size of the context data stored for a stateful session cannot exceed + * 100KB. + * + * @return the context + */ + public MessageContext getContext() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. If **user_id** is specified in both locations, the value specified at the root is + * used. + * + * @return the userId + */ + public String getUserId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequestInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequestInput.java new file mode 100644 index 00000000000..ec17a513f17 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequestInput.java @@ -0,0 +1,349 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** An input object that includes the input text. All private data is masked or removed. */ +public class LogRequestInput extends GenericModel { + + /** + * The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + */ + public interface MessageType { + /** text. */ + String TEXT = "text"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("message_type") + protected String messageType; + + protected String text; + protected List intents; + protected List entities; + + @SerializedName("suggestion_id") + protected String suggestionId; + + protected List attachments; + protected RequestAnalytics analytics; + protected MessageInputOptions options; + + /** Builder. */ + public static class Builder { + private String messageType; + private String text; + private List intents; + private List entities; + private String suggestionId; + private List attachments; + private RequestAnalytics analytics; + private MessageInputOptions options; + + /** + * Instantiates a new Builder from an existing LogRequestInput instance. + * + * @param logRequestInput the instance to initialize the Builder with + */ + private Builder(LogRequestInput logRequestInput) { + this.messageType = logRequestInput.messageType; + this.text = logRequestInput.text; + this.intents = logRequestInput.intents; + this.entities = logRequestInput.entities; + this.suggestionId = logRequestInput.suggestionId; + this.attachments = logRequestInput.attachments; + this.analytics = logRequestInput.analytics; + this.options = logRequestInput.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a LogRequestInput. + * + * @return the new LogRequestInput instance + */ + public LogRequestInput build() { + return new LogRequestInput(this); + } + + /** + * Adds a new element to intents. + * + * @param intent the new element to be added + * @return the LogRequestInput builder + */ + public Builder addIntent(RuntimeIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity the new element to be added + * @return the LogRequestInput builder + */ + public Builder addEntity(RuntimeEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + + /** + * Adds a new element to attachments. + * + * @param attachments the new element to be added + * @return the LogRequestInput builder + */ + public Builder addAttachments(MessageInputAttachment attachments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attachments, "attachments cannot be null"); + if (this.attachments == null) { + this.attachments = new ArrayList(); + } + this.attachments.add(attachments); + return this; + } + + /** + * Set the messageType. + * + * @param messageType the messageType + * @return the LogRequestInput builder + */ + public Builder messageType(String messageType) { + this.messageType = messageType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the LogRequestInput builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the LogRequestInput builder + */ + public Builder intents(List intents) { + this.intents = intents; + return this; + } + + /** + * Set the entities. Existing entities will be replaced. + * + * @param entities the entities + * @return the LogRequestInput builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the suggestionId. + * + * @param suggestionId the suggestionId + * @return the LogRequestInput builder + */ + public Builder suggestionId(String suggestionId) { + this.suggestionId = suggestionId; + return this; + } + + /** + * Set the attachments. Existing attachments will be replaced. + * + * @param attachments the attachments + * @return the LogRequestInput builder + */ + public Builder attachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Set the analytics. + * + * @param analytics the analytics + * @return the LogRequestInput builder + */ + public Builder analytics(RequestAnalytics analytics) { + this.analytics = analytics; + return this; + } + + /** + * Set the options. + * + * @param options the options + * @return the LogRequestInput builder + */ + public Builder options(MessageInputOptions options) { + this.options = options; + return this; + } + } + + protected LogRequestInput() {} + + protected LogRequestInput(Builder builder) { + messageType = builder.messageType; + text = builder.text; + intents = builder.intents; + entities = builder.entities; + suggestionId = builder.suggestionId; + attachments = builder.attachments; + analytics = builder.analytics; + options = builder.options; + } + + /** + * New builder. + * + * @return a LogRequestInput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the messageType. + * + *

The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + * + * @return the messageType + */ + public String messageType() { + return messageType; + } + + /** + * Gets the text. + * + *

The text of the user input. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the intents. + * + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. + * + * @return the entities + */ + public List entities() { + return entities; + } + + /** + * Gets the suggestionId. + * + *

For internal use only. + * + * @return the suggestionId + */ + public String suggestionId() { + return suggestionId; + } + + /** + * Gets the attachments. + * + *

An array of multimedia attachments to be sent with the message. Attachments are not + * processed by the assistant itself, but can be sent to external services by webhooks. + * + *

**Note:** Attachments are not supported on IBM Cloud Pak for Data. + * + * @return the attachments + */ + public List attachments() { + return attachments; + } + + /** + * Gets the analytics. + * + *

An optional object containing analytics data. Currently, this data is used only for events + * sent to the Segment extension. + * + * @return the analytics + */ + public RequestAnalytics analytics() { + return analytics; + } + + /** + * Gets the options. + * + *

Optional properties that control how the assistant responds. + * + * @return the options + */ + public MessageInputOptions options() { + return options; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponse.java new file mode 100644 index 00000000000..9ee1ca07382 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponse.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A response from the watsonx Assistant service. */ +public class LogResponse extends GenericModel { + + protected LogResponseOutput output; + protected MessageContext context; + + @SerializedName("user_id") + protected String userId; + + protected LogResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + * + * @return the output + */ + public LogResponseOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is stored by the assistant on a per-session basis. + * + *

**Note:** The context is included in message responses only if **return_context**=`true` in + * the message request. Full context is always included in logs. + * + * @return the context + */ + public MessageContext getContext() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponseOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponseOutput.java new file mode 100644 index 00000000000..52a26671bee --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponseOutput.java @@ -0,0 +1,133 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** + * Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + */ +public class LogResponseOutput extends GenericModel { + + protected List generic; + protected List intents; + protected List entities; + protected List actions; + protected MessageOutputDebug debug; + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageOutputSpelling spelling; + + @SerializedName("llm_metadata") + protected List llmMetadata; + + protected LogResponseOutput() {} + + /** + * Gets the generic. + * + *

Output intended for any channel. It is the responsibility of the client application to + * implement the supported response types. + * + * @return the generic + */ + public List getGeneric() { + return generic; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the user input, sorted in descending order of confidence. + * + * @return the intents + */ + public List getIntents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the user input. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the actions. + * + *

An array of objects describing any actions requested by the dialog node. + * + * @return the actions + */ + public List getActions() { + return actions; + } + + /** + * Gets the debug. + * + *

Additional detailed information about a message response and how it was generated. + * + * @return the debug + */ + public MessageOutputDebug getDebug() { + return debug; + } + + /** + * Gets the userDefined. + * + *

An object containing any custom properties included in the response. This object includes + * any arbitrary properties defined in the dialog JSON editor as part of the dialog node output. + * + * @return the userDefined + */ + public Map getUserDefined() { + return userDefined; + } + + /** + * Gets the spelling. + * + *

Properties describing any spelling corrections in the user input that was received. + * + * @return the spelling + */ + public MessageOutputSpelling getSpelling() { + return spelling; + } + + /** + * Gets the llmMetadata. + * + *

An array of objects that provide information about calls to large language models that + * occured as part of handling this message. + * + * @return the llmMetadata + */ + public List getLlmMetadata() { + return llmMetadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java index 64feee6882c..9554af80fae 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,40 +10,43 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; -/** - * MessageContext. - */ +/** MessageContext. */ public class MessageContext extends GenericModel { protected MessageContextGlobal global; protected MessageContextSkills skills; + protected Map integrations; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private MessageContextGlobal global; private MessageContextSkills skills; + private Map integrations; + /** + * Instantiates a new Builder from an existing MessageContext instance. + * + * @param messageContext the instance to initialize the Builder with + */ private Builder(MessageContext messageContext) { this.global = messageContext.global; this.skills = messageContext.skills; + this.integrations = messageContext.integrations; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageContext. * - * @return the messageContext + * @return the new MessageContext instance */ public MessageContext build() { return new MessageContext(this); @@ -70,11 +73,25 @@ public Builder skills(MessageContextSkills skills) { this.skills = skills; return this; } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the MessageContext builder + */ + public Builder integrations(Map integrations) { + this.integrations = integrations; + return this; + } } + protected MessageContext() {} + protected MessageContext(Builder builder) { global = builder.global; skills = builder.skills; + integrations = builder.integrations; } /** @@ -89,7 +106,7 @@ public Builder newBuilder() { /** * Gets the global. * - * Information that is shared by all skills used by the Assistant. + *

Session context data that is shared by all skills used by the assistant. * * @return the global */ @@ -100,14 +117,24 @@ public MessageContextGlobal global() { /** * Gets the skills. * - * Information specific to particular skills used by the Assistant. - * - * **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that - * apply to the dialog skill used by the assistant. + *

Context data specific to particular skills used by the assistant. * * @return the skills */ public MessageContextSkills skills() { return skills; } + + /** + * Gets the integrations. + * + *

An object containing context data that is specific to particular integrations. For more + * information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations). + * + * @return the integrations + */ + public Map integrations() { + return integrations; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkill.java new file mode 100644 index 00000000000..1075b69a5c2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkill.java @@ -0,0 +1,178 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** + * Context variables that are used by the action skill. Private variables are persisted, but not + * shown. + */ +public class MessageContextActionSkill extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + @SerializedName("action_variables") + protected Map actionVariables; + + @SerializedName("skill_variables") + protected Map skillVariables; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + private Map actionVariables; + private Map skillVariables; + + /** + * Instantiates a new Builder from an existing MessageContextActionSkill instance. + * + * @param messageContextActionSkill the instance to initialize the Builder with + */ + private Builder(MessageContextActionSkill messageContextActionSkill) { + this.userDefined = messageContextActionSkill.userDefined; + this.system = messageContextActionSkill.system; + this.actionVariables = messageContextActionSkill.actionVariables; + this.skillVariables = messageContextActionSkill.skillVariables; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextActionSkill. + * + * @return the new MessageContextActionSkill instance + */ + public MessageContextActionSkill build() { + return new MessageContextActionSkill(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the MessageContextActionSkill builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextActionSkill builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + + /** + * Set the actionVariables. + * + * @param actionVariables the actionVariables + * @return the MessageContextActionSkill builder + */ + public Builder actionVariables(Map actionVariables) { + this.actionVariables = actionVariables; + return this; + } + + /** + * Set the skillVariables. + * + * @param skillVariables the skillVariables + * @return the MessageContextActionSkill builder + */ + public Builder skillVariables(Map skillVariables) { + this.skillVariables = skillVariables; + return this; + } + } + + protected MessageContextActionSkill() {} + + protected MessageContextActionSkill(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + actionVariables = builder.actionVariables; + skillVariables = builder.skillVariables; + } + + /** + * New builder. + * + * @return a MessageContextActionSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } + + /** + * Gets the actionVariables. + * + *

An object containing action variables. Action variables can be accessed only by steps in the + * same action, and do not persist after the action ends. + * + * @return the actionVariables + */ + public Map actionVariables() { + return actionVariables; + } + + /** + * Gets the skillVariables. + * + *

An object containing skill variables. (In the watsonx Assistant user interface, skill + * variables are called _session variables_.) Skill variables can be accessed by any action and + * persist for the duration of the session. + * + * @return the skillVariables + */ + public Map skillVariables() { + return skillVariables; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkill.java new file mode 100644 index 00000000000..1f414becb16 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkill.java @@ -0,0 +1,116 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Context variables that are used by the dialog skill. */ +public class MessageContextDialogSkill extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + + /** + * Instantiates a new Builder from an existing MessageContextDialogSkill instance. + * + * @param messageContextDialogSkill the instance to initialize the Builder with + */ + private Builder(MessageContextDialogSkill messageContextDialogSkill) { + this.userDefined = messageContextDialogSkill.userDefined; + this.system = messageContextDialogSkill.system; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextDialogSkill. + * + * @return the new MessageContextDialogSkill instance + */ + public MessageContextDialogSkill build() { + return new MessageContextDialogSkill(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the MessageContextDialogSkill builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextDialogSkill builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + } + + protected MessageContextDialogSkill() {} + + protected MessageContextDialogSkill(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + } + + /** + * New builder. + * + * @return a MessageContextDialogSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java index f5e553c95d2..66d65e00a15 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,37 +10,40 @@ * 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.assistant.v2.model; +import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information that is shared by all skills used by the Assistant. - */ +/** Session context data that is shared by all skills used by the assistant. */ public class MessageContextGlobal extends GenericModel { protected MessageContextGlobalSystem system; - /** - * Builder. - */ + @SerializedName("session_id") + protected String sessionId; + + /** Builder. */ public static class Builder { private MessageContextGlobalSystem system; + /** + * Instantiates a new Builder from an existing MessageContextGlobal instance. + * + * @param messageContextGlobal the instance to initialize the Builder with + */ private Builder(MessageContextGlobal messageContextGlobal) { this.system = messageContextGlobal.system; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageContextGlobal. * - * @return the messageContextGlobal + * @return the new MessageContextGlobal instance */ public MessageContextGlobal build() { return new MessageContextGlobal(this); @@ -58,6 +61,8 @@ public Builder system(MessageContextGlobalSystem system) { } } + protected MessageContextGlobal() {} + protected MessageContextGlobal(Builder builder) { system = builder.system; } @@ -74,11 +79,22 @@ public Builder newBuilder() { /** * Gets the system. * - * Built-in system properties that apply to all skills used by the assistant. + *

Built-in system properties that apply to all skills used by the assistant. * * @return the system */ public MessageContextGlobalSystem system() { return system; } + + /** + * Gets the sessionId. + * + *

The session ID. + * + * @return the sessionId + */ + public String sessionId() { + return sessionId; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java new file mode 100644 index 00000000000..c296c40c4b2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java @@ -0,0 +1,113 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Session context data that is shared by all skills used by the assistant. */ +public class MessageContextGlobalStateless extends GenericModel { + + protected MessageContextGlobalSystem system; + + @SerializedName("session_id") + protected String sessionId; + + /** Builder. */ + public static class Builder { + private MessageContextGlobalSystem system; + private String sessionId; + + /** + * Instantiates a new Builder from an existing MessageContextGlobalStateless instance. + * + * @param messageContextGlobalStateless the instance to initialize the Builder with + */ + private Builder(MessageContextGlobalStateless messageContextGlobalStateless) { + this.system = messageContextGlobalStateless.system; + this.sessionId = messageContextGlobalStateless.sessionId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextGlobalStateless. + * + * @return the new MessageContextGlobalStateless instance + */ + public MessageContextGlobalStateless build() { + return new MessageContextGlobalStateless(this); + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextGlobalStateless builder + */ + public Builder system(MessageContextGlobalSystem system) { + this.system = system; + return this; + } + + /** + * Set the sessionId. + * + * @param sessionId the sessionId + * @return the MessageContextGlobalStateless builder + */ + public Builder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + } + + protected MessageContextGlobalStateless() {} + + protected MessageContextGlobalStateless(Builder builder) { + system = builder.system; + sessionId = builder.sessionId; + } + + /** + * New builder. + * + * @return a MessageContextGlobalStateless builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the system. + * + *

Built-in system properties that apply to all skills used by the assistant. + * + * @return the system + */ + public MessageContextGlobalSystem system() { + return system; + } + + /** + * Gets the sessionId. + * + *

The unique identifier of the session. + * + * @return the sessionId + */ + public String sessionId() { + return sessionId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java index 93db85d426b..97b18271d41 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,22 +10,22 @@ * 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.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Built-in system properties that apply to all skills used by the assistant. - */ +/** Built-in system properties that apply to all skills used by the assistant. */ public class MessageContextGlobalSystem extends GenericModel { /** - * The language code for localization in the user input. The specified locale overrides the default for the assistant, - * and is used for interpreting entity values in user input such as date values. For example, `04/03/2018` might be - * interpreted either as April 3 or March 4, depending on the locale. + * The language code for localization in the user input. The specified locale overrides the + * default for the assistant, and is used for interpreting entity values in user input such as + * date values. For example, `04/03/2018` might be interpreted either as April 3 or March 4, + * depending on the locale. * - * This property is included only if the new system entities are enabled for the skill. + *

This property is included only if the new system entities are enabled for the skill. */ public interface Locale { /** en-us. */ @@ -61,42 +61,60 @@ public interface Locale { } protected String timezone; + @SerializedName("user_id") protected String userId; + @SerializedName("turn_count") protected Long turnCount; + protected String locale; + @SerializedName("reference_time") protected String referenceTime; - /** - * Builder. - */ + @SerializedName("session_start_time") + protected String sessionStartTime; + + protected String state; + + @SerializedName("skip_user_input") + protected Boolean skipUserInput; + + /** Builder. */ public static class Builder { private String timezone; private String userId; private Long turnCount; private String locale; private String referenceTime; + private String sessionStartTime; + private String state; + private Boolean skipUserInput; + /** + * Instantiates a new Builder from an existing MessageContextGlobalSystem instance. + * + * @param messageContextGlobalSystem the instance to initialize the Builder with + */ private Builder(MessageContextGlobalSystem messageContextGlobalSystem) { this.timezone = messageContextGlobalSystem.timezone; this.userId = messageContextGlobalSystem.userId; this.turnCount = messageContextGlobalSystem.turnCount; this.locale = messageContextGlobalSystem.locale; this.referenceTime = messageContextGlobalSystem.referenceTime; + this.sessionStartTime = messageContextGlobalSystem.sessionStartTime; + this.state = messageContextGlobalSystem.state; + this.skipUserInput = messageContextGlobalSystem.skipUserInput; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageContextGlobalSystem. * - * @return the messageContextGlobalSystem + * @return the new MessageContextGlobalSystem instance */ public MessageContextGlobalSystem build() { return new MessageContextGlobalSystem(this); @@ -156,14 +174,52 @@ public Builder referenceTime(String referenceTime) { this.referenceTime = referenceTime; return this; } + + /** + * Set the sessionStartTime. + * + * @param sessionStartTime the sessionStartTime + * @return the MessageContextGlobalSystem builder + */ + public Builder sessionStartTime(String sessionStartTime) { + this.sessionStartTime = sessionStartTime; + return this; + } + + /** + * Set the state. + * + * @param state the state + * @return the MessageContextGlobalSystem builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + + /** + * Set the skipUserInput. + * + * @param skipUserInput the skipUserInput + * @return the MessageContextGlobalSystem builder + */ + public Builder skipUserInput(Boolean skipUserInput) { + this.skipUserInput = skipUserInput; + return this; + } } + protected MessageContextGlobalSystem() {} + protected MessageContextGlobalSystem(Builder builder) { timezone = builder.timezone; userId = builder.userId; turnCount = builder.turnCount; locale = builder.locale; referenceTime = builder.referenceTime; + sessionStartTime = builder.sessionStartTime; + state = builder.state; + skipUserInput = builder.skipUserInput; } /** @@ -178,7 +234,8 @@ public Builder newBuilder() { /** * Gets the timezone. * - * The user time zone. The assistant uses the time zone to correctly resolve relative time references. + *

The user time zone. The assistant uses the time zone to correctly resolve relative time + * references. * * @return the timezone */ @@ -189,10 +246,15 @@ public String timezone() { /** * Gets the userId. * - * A string value that identifies the user who is interacting with the assistant. The client must provide a unique - * identifier for each individual end user who accesses the application. For Plus and Premium plans, this user ID is - * used to identify unique users for billing purposes. This string cannot contain carriage return, newline, or tab - * characters. + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property at the root of the message + * body. If **user_id** is specified in both locations in a message request, the value specified + * at the root is used. * * @return the userId */ @@ -203,9 +265,9 @@ public String userId() { /** * Gets the turnCount. * - * A counter that is automatically incremented with each turn of the conversation. A value of 1 indicates that this is - * the the first turn of a new conversation, which can affect the behavior of some skills (for example, triggering the - * start node of a dialog). + *

A counter that is automatically incremented with each turn of the conversation. A value of 1 + * indicates that this is the the first turn of a new conversation, which can affect the behavior + * of some skills (for example, triggering the start node of a dialog). * * @return the turnCount */ @@ -216,11 +278,12 @@ public Long turnCount() { /** * Gets the locale. * - * The language code for localization in the user input. The specified locale overrides the default for the assistant, - * and is used for interpreting entity values in user input such as date values. For example, `04/03/2018` might be - * interpreted either as April 3 or March 4, depending on the locale. + *

The language code for localization in the user input. The specified locale overrides the + * default for the assistant, and is used for interpreting entity values in user input such as + * date values. For example, `04/03/2018` might be interpreted either as April 3 or March 4, + * depending on the locale. * - * This property is included only if the new system entities are enabled for the skill. + *

This property is included only if the new system entities are enabled for the skill. * * @return the locale */ @@ -231,19 +294,62 @@ public String locale() { /** * Gets the referenceTime. * - * The base time for interpreting any relative time mentions in the user input. The specified time overrides the - * current server time, and is used to calculate times mentioned in relative terms such as `now` or `tomorrow`. This - * can be useful for simulating past or future times for testing purposes, or when analyzing documents such as news - * articles. + *

The base time for interpreting any relative time mentions in the user input. The specified + * time overrides the current server time, and is used to calculate times mentioned in relative + * terms such as `now` or `tomorrow`. This can be useful for simulating past or future times for + * testing purposes, or when analyzing documents such as news articles. * - * This value must be a UTC time value formatted according to ISO 8601 (for example, `2019-06-26T12:00:00Z` for noon - * on 26 June 2019. + *

This value must be a UTC time value formatted according to ISO 8601 (for example, + * `2021-06-26T12:00:00Z` for noon UTC on 26 June 2021). * - * This property is included only if the new system entities are enabled for the skill. + *

This property is included only if the new system entities are enabled for the skill. * * @return the referenceTime */ public String referenceTime() { return referenceTime; } + + /** + * Gets the sessionStartTime. + * + *

The time at which the session started. With the stateful `message` method, the start time is + * always present, and is set by the service based on the time the session was created. With the + * stateless `message` method, the start time is set by the service in the response to the first + * message, and should be returned as part of the context with each subsequent message in the + * session. + * + *

This value is a UTC time value formatted according to ISO 8601 (for example, + * `2021-06-26T12:00:00Z` for noon UTC on 26 June 2021). + * + * @return the sessionStartTime + */ + public String sessionStartTime() { + return sessionStartTime; + } + + /** + * Gets the state. + * + *

An encoded string that represents the configuration state of the assistant at the beginning + * of the conversation. If you are using the stateless `message` method, save this value and then + * send it in the context of the subsequent message request to avoid disruptions if there are + * configuration changes during the conversation (such as a change to a skill the assistant uses). + * + * @return the state + */ + public String state() { + return state; + } + + /** + * Gets the skipUserInput. + * + *

For internal use only. + * + * @return the skipUserInput + */ + public Boolean skipUserInput() { + return skipUserInput; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java deleted file mode 100644 index f375fcd99b5..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.assistant.v2.model; - -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Contains information specific to a particular skill used by the Assistant. - */ -public class MessageContextSkill extends GenericModel { - - @SerializedName("user_defined") - protected Map userDefined; - protected Map system; - - /** - * Builder. - */ - public static class Builder { - private Map userDefined; - private Map system; - - private Builder(MessageContextSkill messageContextSkill) { - this.userDefined = messageContextSkill.userDefined; - this.system = messageContextSkill.system; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a MessageContextSkill. - * - * @return the messageContextSkill - */ - public MessageContextSkill build() { - return new MessageContextSkill(this); - } - - /** - * Set the userDefined. - * - * @param userDefined the userDefined - * @return the MessageContextSkill builder - */ - public Builder userDefined(Map userDefined) { - this.userDefined = userDefined; - return this; - } - - /** - * Set the system. - * - * @param system the system - * @return the MessageContextSkill builder - */ - public Builder system(Map system) { - this.system = system; - return this; - } - } - - protected MessageContextSkill(Builder builder) { - userDefined = builder.userDefined; - system = builder.system; - } - - /** - * New builder. - * - * @return a MessageContextSkill builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the userDefined. - * - * Arbitrary variables that can be read and written by a particular skill. - * - * @return the userDefined - */ - public Map userDefined() { - return userDefined; - } - - /** - * Gets the system. - * - * For internal use only. - * - * @return the system - */ - public Map system() { - return system; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillAction.java new file mode 100644 index 00000000000..199bebea720 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillAction.java @@ -0,0 +1,174 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Context variables that are used by the action skill. */ +public class MessageContextSkillAction extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + @SerializedName("action_variables") + protected Map actionVariables; + + @SerializedName("skill_variables") + protected Map skillVariables; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + private Map actionVariables; + private Map skillVariables; + + /** + * Instantiates a new Builder from an existing MessageContextSkillAction instance. + * + * @param messageContextSkillAction the instance to initialize the Builder with + */ + private Builder(MessageContextSkillAction messageContextSkillAction) { + this.userDefined = messageContextSkillAction.userDefined; + this.system = messageContextSkillAction.system; + this.actionVariables = messageContextSkillAction.actionVariables; + this.skillVariables = messageContextSkillAction.skillVariables; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextSkillAction. + * + * @return the new MessageContextSkillAction instance + */ + public MessageContextSkillAction build() { + return new MessageContextSkillAction(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the MessageContextSkillAction builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextSkillAction builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + + /** + * Set the actionVariables. + * + * @param actionVariables the actionVariables + * @return the MessageContextSkillAction builder + */ + public Builder actionVariables(Map actionVariables) { + this.actionVariables = actionVariables; + return this; + } + + /** + * Set the skillVariables. + * + * @param skillVariables the skillVariables + * @return the MessageContextSkillAction builder + */ + public Builder skillVariables(Map skillVariables) { + this.skillVariables = skillVariables; + return this; + } + } + + protected MessageContextSkillAction() {} + + protected MessageContextSkillAction(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + actionVariables = builder.actionVariables; + skillVariables = builder.skillVariables; + } + + /** + * New builder. + * + * @return a MessageContextSkillAction builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } + + /** + * Gets the actionVariables. + * + *

An object containing action variables. Action variables can be accessed only by steps in the + * same action, and do not persist after the action ends. + * + * @return the actionVariables + */ + public Map actionVariables() { + return actionVariables; + } + + /** + * Gets the skillVariables. + * + *

An object containing skill variables. (In the Watson Assistant user interface, skill + * variables are called _session variables_.) Skill variables can be accessed by any action and + * persist for the duration of the session. + * + * @return the skillVariables + */ + public Map skillVariables() { + return skillVariables; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillDialog.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillDialog.java new file mode 100644 index 00000000000..8cc5e41fb47 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillDialog.java @@ -0,0 +1,115 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Context variables that are used by the dialog skill. */ +public class MessageContextSkillDialog extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + + /** + * Instantiates a new Builder from an existing MessageContextSkillDialog instance. + * + * @param messageContextSkillDialog the instance to initialize the Builder with + */ + private Builder(MessageContextSkillDialog messageContextSkillDialog) { + this.userDefined = messageContextSkillDialog.userDefined; + this.system = messageContextSkillDialog.system; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextSkillDialog. + * + * @return the new MessageContextSkillDialog instance + */ + public MessageContextSkillDialog build() { + return new MessageContextSkillDialog(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the MessageContextSkillDialog builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextSkillDialog builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + } + + protected MessageContextSkillDialog() {} + + protected MessageContextSkillDialog(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + } + + /** + * New builder. + * + * @return a MessageContextSkillDialog builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java new file mode 100644 index 00000000000..8c9d6d467ec --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; + +/** + * System context data used by the skill. + * + *

This type supports additional properties of type Object. For internal use only. + */ +public class MessageContextSkillSystem extends DynamicModel { + + @SerializedName("state") + protected String state; + + public MessageContextSkillSystem() { + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private String state; + private Map dynamicProperties; + + /** + * Instantiates a new Builder from an existing MessageContextSkillSystem instance. + * + * @param messageContextSkillSystem the instance to initialize the Builder with + */ + private Builder(MessageContextSkillSystem messageContextSkillSystem) { + this.state = messageContextSkillSystem.state; + this.dynamicProperties = messageContextSkillSystem.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextSkillSystem. + * + * @return the new MessageContextSkillSystem instance + */ + public MessageContextSkillSystem build() { + return new MessageContextSkillSystem(this); + } + + /** + * Set the state. + * + * @param state the state + * @return the MessageContextSkillSystem builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + + /** + * Add an arbitrary property. For internal use only. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the MessageContextSkillSystem builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected MessageContextSkillSystem(Builder builder) { + super(new TypeToken() {}); + state = builder.state; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a MessageContextSkillSystem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the state. + * + *

An encoded string that represents the current conversation state. By saving this value and + * then sending it in the context of a subsequent message request, you can return to an earlier + * point in the conversation. If you are using stateful sessions, you can also use a stored state + * value to restore a paused conversation whose session is expired. + * + * @return the state + */ + public String getState() { + return this.state; + } + + /** + * Sets the state. + * + * @param state the new state + */ + public void setState(final String state) { + this.state = state; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java index 16a72b30f57..659eaba8ab7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,21 +10,107 @@ * 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.assistant.v2.model; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information specific to particular skills used by the Assistant. - * - * **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that - * apply to the dialog skill used by the assistant. - */ -public class MessageContextSkills extends DynamicModel { +/** Context data specific to particular skills used by the assistant. */ +public class MessageContextSkills extends GenericModel { + + @SerializedName("main skill") + protected MessageContextDialogSkill mainSkill; + + @SerializedName("actions skill") + protected MessageContextActionSkill actionsSkill; + + /** Builder. */ + public static class Builder { + private MessageContextDialogSkill mainSkill; + private MessageContextActionSkill actionsSkill; + + /** + * Instantiates a new Builder from an existing MessageContextSkills instance. + * + * @param messageContextSkills the instance to initialize the Builder with + */ + private Builder(MessageContextSkills messageContextSkills) { + this.mainSkill = messageContextSkills.mainSkill; + this.actionsSkill = messageContextSkills.actionsSkill; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextSkills. + * + * @return the new MessageContextSkills instance + */ + public MessageContextSkills build() { + return new MessageContextSkills(this); + } + + /** + * Set the mainSkill. + * + * @param mainSkill the mainSkill + * @return the MessageContextSkills builder + */ + public Builder mainSkill(MessageContextDialogSkill mainSkill) { + this.mainSkill = mainSkill; + return this; + } + + /** + * Set the actionsSkill. + * + * @param actionsSkill the actionsSkill + * @return the MessageContextSkills builder + */ + public Builder actionsSkill(MessageContextActionSkill actionsSkill) { + this.actionsSkill = actionsSkill; + return this; + } + } + + protected MessageContextSkills() {} + + protected MessageContextSkills(Builder builder) { + mainSkill = builder.mainSkill; + actionsSkill = builder.actionsSkill; + } + + /** + * New builder. + * + * @return a MessageContextSkills builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the mainSkill. + * + *

Context variables that are used by the dialog skill. + * + * @return the mainSkill + */ + public MessageContextDialogSkill mainSkill() { + return mainSkill; + } - public MessageContextSkills() { - super(new TypeToken() { - }); + /** + * Gets the actionsSkill. + * + *

Context variables that are used by the action skill. Private variables are persisted, but + * not shown. + * + * @return the actionsSkill + */ + public MessageContextActionSkill actionsSkill() { + return actionsSkill; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java new file mode 100644 index 00000000000..61b906bc664 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java @@ -0,0 +1,137 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.Gson; +import com.launchdarkly.eventsource.EventSource; +import com.launchdarkly.eventsource.MessageEvent; +import java.io.InputStream; +import java.util.Iterator; + +public class MessageEventDeserializer extends MessageStreamResponse { + + protected EventSource eventSource; + + /** Builder. */ + public static class Builder { + private EventSource eventSource; + + /** + * Instantiates a new Builder from an existing MessageEventDeserializer instance. + * + * @param messageEventDeserializer the instance to initialize the Builder with + */ + private Builder(MessageEventDeserializer messageEventDeserializer) { + this.eventSource = messageEventDeserializer.eventSource; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param inputStream the inputStream + */ + public Builder(InputStream inputStream) { + InputStreamConnectStrategy inputStreamConnectStrategy = + new InputStreamConnectStrategy.Builder().inputStream(inputStream).build(); + this.eventSource = new EventSource.Builder(inputStreamConnectStrategy).build(); + } + + /** + * Builds a MessageEventDeserializer. + * + * @return the new MessageEventDeserializer instance + */ + public MessageEventDeserializer build() { + return new MessageEventDeserializer(this); + } + + /** + * Set the inputStream. + * + * @param inputStream the inputStream + * @return the MessageEventDeserializer builder + */ + public MessageEventDeserializer.Builder inputStream(InputStream inputStream) { + InputStreamConnectStrategy inputStreamConnectStrategy = + new InputStreamConnectStrategy.Builder().inputStream(inputStream).build(); + this.eventSource = new EventSource.Builder(inputStreamConnectStrategy).build(); + return this; + } + } + + protected MessageEventDeserializer() {} + + protected MessageEventDeserializer(MessageEventDeserializer.Builder builder) { + eventSource = builder.eventSource; + } + + /** + * New builder. + * + * @return a MessageEventDeserializer builder + */ + public MessageEventDeserializer.Builder newBuilder() { + return new MessageEventDeserializer.Builder(this); + } + + public Iterable messages() { + return () -> new IteratorImpl<>(eventSource.messages()); + } + + public Iterable statelessMessages() { + return () -> new StatelessIteratorImpl<>(eventSource.messages()); + } + + private class IteratorImpl implements Iterator { + private final Iterable messageEvents; + + IteratorImpl(Iterable messageEvents) { + this.messageEvents = messageEvents; + } + + public boolean hasNext() { + return messageEvents.iterator().hasNext(); + } + + public T next() { + Gson gson = new Gson(); + MessageEvent messageEvent = messageEvents.iterator().next(); + T item = (T) gson.fromJson(messageEvent.getData(), MessageStreamResponse.class); + return item; + } + } + + private class StatelessIteratorImpl + implements Iterator { + private final Iterable messageEvents; + + StatelessIteratorImpl(Iterable messageEvents) { + this.messageEvents = messageEvents; + } + + public boolean hasNext() { + return messageEvents.iterator().hasNext(); + } + + public T next() { + Gson gson = new Gson(); + MessageEvent messageEvent = messageEvents.iterator().next(); + T item = (T) gson.fromJson(messageEvent.getData(), StatelessMessageStreamResponse.class); + return item; + } + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java index 63d49ccf8b7..eb816d5fb97 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,80 +10,94 @@ * 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.assistant.v2.model; -import java.util.ArrayList; -import java.util.List; +package com.ibm.watson.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; -/** - * An input object that includes the input text. - */ +/** An input object that includes the input text. */ public class MessageInput extends GenericModel { /** - * The type of user input. Currently, only text input is supported. + * The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. */ public interface MessageType { /** text. */ String TEXT = "text"; + /** search. */ + String SEARCH = "search"; } @SerializedName("message_type") protected String messageType; + protected String text; - protected MessageInputOptions options; protected List intents; protected List entities; + @SerializedName("suggestion_id") protected String suggestionId; - /** - * Builder. - */ + protected List attachments; + protected RequestAnalytics analytics; + protected MessageInputOptions options; + + /** Builder. */ public static class Builder { private String messageType; private String text; - private MessageInputOptions options; private List intents; private List entities; private String suggestionId; + private List attachments; + private RequestAnalytics analytics; + private MessageInputOptions options; + /** + * Instantiates a new Builder from an existing MessageInput instance. + * + * @param messageInput the instance to initialize the Builder with + */ private Builder(MessageInput messageInput) { this.messageType = messageInput.messageType; this.text = messageInput.text; - this.options = messageInput.options; this.intents = messageInput.intents; this.entities = messageInput.entities; this.suggestionId = messageInput.suggestionId; + this.attachments = messageInput.attachments; + this.analytics = messageInput.analytics; + this.options = messageInput.options; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageInput. * - * @return the messageInput + * @return the new MessageInput instance */ public MessageInput build() { return new MessageInput(this); } /** - * Adds an intent to intents. + * Adds a new element to intents. * - * @param intent the new intent + * @param intent the new element to be added * @return the MessageInput builder */ public Builder addIntent(RuntimeIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, - "intent cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); if (this.intents == null) { this.intents = new ArrayList(); } @@ -92,14 +106,13 @@ public Builder addIntent(RuntimeIntent intent) { } /** - * Adds an entity to entities. + * Adds a new element to entities. * - * @param entity the new entity + * @param entity the new element to be added * @return the MessageInput builder */ public Builder addEntity(RuntimeEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, - "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); if (this.entities == null) { this.entities = new ArrayList(); } @@ -107,6 +120,21 @@ public Builder addEntity(RuntimeEntity entity) { return this; } + /** + * Adds a new element to attachments. + * + * @param attachments the new element to be added + * @return the MessageInput builder + */ + public Builder addAttachments(MessageInputAttachment attachments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attachments, "attachments cannot be null"); + if (this.attachments == null) { + this.attachments = new ArrayList(); + } + this.attachments.add(attachments); + return this; + } + /** * Set the messageType. * @@ -130,19 +158,7 @@ public Builder text(String text) { } /** - * Set the options. - * - * @param options the options - * @return the MessageInput builder - */ - public Builder options(MessageInputOptions options) { - this.options = options; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. + * Set the intents. Existing intents will be replaced. * * @param intents the intents * @return the MessageInput builder @@ -153,8 +169,7 @@ public Builder intents(List intents) { } /** - * Set the entities. - * Existing entities will be replaced. + * Set the entities. Existing entities will be replaced. * * @param entities the entities * @return the MessageInput builder @@ -174,15 +189,52 @@ public Builder suggestionId(String suggestionId) { this.suggestionId = suggestionId; return this; } + + /** + * Set the attachments. Existing attachments will be replaced. + * + * @param attachments the attachments + * @return the MessageInput builder + */ + public Builder attachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Set the analytics. + * + * @param analytics the analytics + * @return the MessageInput builder + */ + public Builder analytics(RequestAnalytics analytics) { + this.analytics = analytics; + return this; + } + + /** + * Set the options. + * + * @param options the options + * @return the MessageInput builder + */ + public Builder options(MessageInputOptions options) { + this.options = options; + return this; + } } + protected MessageInput() {} + protected MessageInput(Builder builder) { messageType = builder.messageType; text = builder.text; - options = builder.options; intents = builder.intents; entities = builder.entities; suggestionId = builder.suggestionId; + attachments = builder.attachments; + analytics = builder.analytics; + options = builder.options; } /** @@ -197,7 +249,13 @@ public Builder newBuilder() { /** * Gets the messageType. * - * The type of user input. Currently, only text input is supported. + *

The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. * * @return the messageType */ @@ -208,7 +266,8 @@ public String messageType() { /** * Gets the text. * - * The text of the user input. This string cannot contain carriage return, newline, or tab characters. + *

The text of the user input. This string cannot contain carriage return, newline, or tab + * characters. * * @return the text */ @@ -216,22 +275,11 @@ public String text() { return text; } - /** - * Gets the options. - * - * Optional properties that control how the assistant responds. - * - * @return the options - */ - public MessageInputOptions options() { - return options; - } - /** * Gets the intents. * - * Intents to use when evaluating the user input. Include intents from the previous response to continue using those - * intents rather than trying to recognize intents in the new input. + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. * * @return the intents */ @@ -242,8 +290,8 @@ public List intents() { /** * Gets the entities. * - * Entities to use when evaluating the message. Include entities from the previous response to continue using those - * entities rather than detecting entities in the new input. + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. * * @return the entities */ @@ -254,11 +302,48 @@ public List entities() { /** * Gets the suggestionId. * - * For internal use only. + *

For internal use only. * * @return the suggestionId */ public String suggestionId() { return suggestionId; } + + /** + * Gets the attachments. + * + *

An array of multimedia attachments to be sent with the message. Attachments are not + * processed by the assistant itself, but can be sent to external services by webhooks. + * + *

**Note:** Attachments are not supported on IBM Cloud Pak for Data. + * + * @return the attachments + */ + public List attachments() { + return attachments; + } + + /** + * Gets the analytics. + * + *

An optional object containing analytics data. Currently, this data is used only for events + * sent to the Segment extension. + * + * @return the analytics + */ + public RequestAnalytics analytics() { + return analytics; + } + + /** + * Gets the options. + * + *

Optional properties that control how the assistant responds. + * + * @return the options + */ + public MessageInputOptions options() { + return options; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputAttachment.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputAttachment.java new file mode 100644 index 00000000000..6a3e4017b12 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputAttachment.java @@ -0,0 +1,124 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A reference to a media file to be sent as an attachment with the message. */ +public class MessageInputAttachment extends GenericModel { + + protected String url; + + @SerializedName("media_type") + protected String mediaType; + + /** Builder. */ + public static class Builder { + private String url; + private String mediaType; + + /** + * Instantiates a new Builder from an existing MessageInputAttachment instance. + * + * @param messageInputAttachment the instance to initialize the Builder with + */ + private Builder(MessageInputAttachment messageInputAttachment) { + this.url = messageInputAttachment.url; + this.mediaType = messageInputAttachment.mediaType; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param url the url + */ + public Builder(String url) { + this.url = url; + } + + /** + * Builds a MessageInputAttachment. + * + * @return the new MessageInputAttachment instance + */ + public MessageInputAttachment build() { + return new MessageInputAttachment(this); + } + + /** + * Set the url. + * + * @param url the url + * @return the MessageInputAttachment builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the mediaType. + * + * @param mediaType the mediaType + * @return the MessageInputAttachment builder + */ + public Builder mediaType(String mediaType) { + this.mediaType = mediaType; + return this; + } + } + + protected MessageInputAttachment() {} + + protected MessageInputAttachment(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, "url cannot be null"); + url = builder.url; + mediaType = builder.mediaType; + } + + /** + * New builder. + * + * @return a MessageInputAttachment builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The URL of the media file. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the mediaType. + * + *

The media content type (such as a MIME type) of the attachment. + * + * @return the mediaType + */ + public String mediaType() { + return mediaType; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java index ada7f04900e..99c897864e4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,65 +10,68 @@ * 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.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Optional properties that control how the assistant responds. - */ +/** Optional properties that control how the assistant responds. */ public class MessageInputOptions extends GenericModel { - protected Boolean debug; protected Boolean restart; + @SerializedName("alternate_intents") protected Boolean alternateIntents; + + @SerializedName("async_callout") + protected Boolean asyncCallout; + + protected MessageInputOptionsSpelling spelling; + protected Boolean debug; + @SerializedName("return_context") protected Boolean returnContext; - /** - * Builder. - */ + protected Boolean export; + + /** Builder. */ public static class Builder { - private Boolean debug; private Boolean restart; private Boolean alternateIntents; + private Boolean asyncCallout; + private MessageInputOptionsSpelling spelling; + private Boolean debug; private Boolean returnContext; + private Boolean export; + /** + * Instantiates a new Builder from an existing MessageInputOptions instance. + * + * @param messageInputOptions the instance to initialize the Builder with + */ private Builder(MessageInputOptions messageInputOptions) { - this.debug = messageInputOptions.debug; this.restart = messageInputOptions.restart; this.alternateIntents = messageInputOptions.alternateIntents; + this.asyncCallout = messageInputOptions.asyncCallout; + this.spelling = messageInputOptions.spelling; + this.debug = messageInputOptions.debug; this.returnContext = messageInputOptions.returnContext; + this.export = messageInputOptions.export; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a MessageInputOptions. * - * @return the messageInputOptions + * @return the new MessageInputOptions instance */ public MessageInputOptions build() { return new MessageInputOptions(this); } - /** - * Set the debug. - * - * @param debug the debug - * @return the MessageInputOptions builder - */ - public Builder debug(Boolean debug) { - this.debug = debug; - return this; - } - /** * Set the restart. * @@ -91,6 +94,39 @@ public Builder alternateIntents(Boolean alternateIntents) { return this; } + /** + * Set the asyncCallout. + * + * @param asyncCallout the asyncCallout + * @return the MessageInputOptions builder + */ + public Builder asyncCallout(Boolean asyncCallout) { + this.asyncCallout = asyncCallout; + return this; + } + + /** + * Set the spelling. + * + * @param spelling the spelling + * @return the MessageInputOptions builder + */ + public Builder spelling(MessageInputOptionsSpelling spelling) { + this.spelling = spelling; + return this; + } + + /** + * Set the debug. + * + * @param debug the debug + * @return the MessageInputOptions builder + */ + public Builder debug(Boolean debug) { + this.debug = debug; + return this; + } + /** * Set the returnContext. * @@ -101,13 +137,29 @@ public Builder returnContext(Boolean returnContext) { this.returnContext = returnContext; return this; } + + /** + * Set the export. + * + * @param export the export + * @return the MessageInputOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } } + protected MessageInputOptions() {} + protected MessageInputOptions(Builder builder) { - debug = builder.debug; restart = builder.restart; alternateIntents = builder.alternateIntents; + asyncCallout = builder.asyncCallout; + spelling = builder.spelling; + debug = builder.debug; returnContext = builder.returnContext; + export = builder.export; } /** @@ -119,23 +171,11 @@ public Builder newBuilder() { return new Builder(this); } - /** - * Gets the debug. - * - * Whether to return additional diagnostic information. Set to `true` to return additional information under the - * `output.debug` key. - * - * @return the debug - */ - public Boolean debug() { - return debug; - } - /** * Gets the restart. * - * Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. - * **Note:** This does not affect `turn_count` or any other context variables. + *

Whether to restart dialog processing at the root of the dialog, regardless of any previously + * visited nodes. **Note:** This does not affect `turn_count` or any other context variables. * * @return the restart */ @@ -146,7 +186,7 @@ public Boolean restart() { /** * Gets the alternateIntents. * - * Whether to return more than one intent. Set to `true` to return all matching intents. + *

Whether to return more than one intent. Set to `true` to return all matching intents. * * @return the alternateIntents */ @@ -154,15 +194,73 @@ public Boolean alternateIntents() { return alternateIntents; } + /** + * Gets the asyncCallout. + * + *

Whether custom extension callouts are executed asynchronously. Asynchronous execution means + * the response to the extension callout will be processed on the subsequent message call, the + * initial message response signals to the client that the operation may be long running. With + * synchronous execution the custom extension is executed and returns the response in a single + * message turn. **Note:** **async_callout** defaults to true for API versions earlier than + * 2023-06-15. + * + * @return the asyncCallout + */ + public Boolean asyncCallout() { + return asyncCallout; + } + + /** + * Gets the spelling. + * + *

Spelling correction options for the message. Any options specified on an individual message + * override the settings configured for the skill. + * + * @return the spelling + */ + public MessageInputOptionsSpelling spelling() { + return spelling; + } + + /** + * Gets the debug. + * + *

Whether to return additional diagnostic information. Set to `true` to return additional + * information in the `output.debug` property. If you also specify **return_context**=`true`, the + * returned skill context includes the `system.state` property. + * + * @return the debug + */ + public Boolean debug() { + return debug; + } + /** * Gets the returnContext. * - * Whether to return session context with the response. If you specify `true`, the response will include the `context` - * property. + *

Whether to return session context with the response. If you specify `true`, the response + * includes the `context` property. If you also specify **debug**=`true`, the returned skill + * context includes the `system.state` property. * * @return the returnContext */ public Boolean returnContext() { return returnContext; } + + /** + * Gets the export. + * + *

Whether to return session context, including full conversation state. If you specify `true`, + * the response includes the `context` property, and the skill context includes the `system.state` + * property. + * + *

**Note:** If **export**=`true`, the context is returned regardless of the value of + * **return_context**. + * + * @return the export + */ + public Boolean export() { + return export; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java new file mode 100644 index 00000000000..a8c8206ed61 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Spelling correction options for the message. Any options specified on an individual message + * override the settings configured for the skill. + */ +public class MessageInputOptionsSpelling extends GenericModel { + + protected Boolean suggestions; + + @SerializedName("auto_correct") + protected Boolean autoCorrect; + + /** Builder. */ + public static class Builder { + private Boolean suggestions; + private Boolean autoCorrect; + + /** + * Instantiates a new Builder from an existing MessageInputOptionsSpelling instance. + * + * @param messageInputOptionsSpelling the instance to initialize the Builder with + */ + private Builder(MessageInputOptionsSpelling messageInputOptionsSpelling) { + this.suggestions = messageInputOptionsSpelling.suggestions; + this.autoCorrect = messageInputOptionsSpelling.autoCorrect; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageInputOptionsSpelling. + * + * @return the new MessageInputOptionsSpelling instance + */ + public MessageInputOptionsSpelling build() { + return new MessageInputOptionsSpelling(this); + } + + /** + * Set the suggestions. + * + * @param suggestions the suggestions + * @return the MessageInputOptionsSpelling builder + */ + public Builder suggestions(Boolean suggestions) { + this.suggestions = suggestions; + return this; + } + + /** + * Set the autoCorrect. + * + * @param autoCorrect the autoCorrect + * @return the MessageInputOptionsSpelling builder + */ + public Builder autoCorrect(Boolean autoCorrect) { + this.autoCorrect = autoCorrect; + return this; + } + } + + protected MessageInputOptionsSpelling() {} + + protected MessageInputOptionsSpelling(Builder builder) { + suggestions = builder.suggestions; + autoCorrect = builder.autoCorrect; + } + + /** + * New builder. + * + * @return a MessageInputOptionsSpelling builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the suggestions. + * + *

Whether to use spelling correction when processing the input. If spelling correction is used + * and **auto_correct** is `true`, any spelling corrections are automatically applied to the user + * input. If **auto_correct** is `false`, any suggested corrections are returned in the + * **output.spelling** property. + * + *

This property overrides the value of the **spelling_suggestions** property in the workspace + * settings for the skill. + * + * @return the suggestions + */ + public Boolean suggestions() { + return suggestions; + } + + /** + * Gets the autoCorrect. + * + *

Whether to use autocorrection when processing the input. If this property is `true`, any + * corrections are automatically applied to the user input, and the original text is returned in + * the **output.spelling** property of the message response. This property overrides the value of + * the **spelling_auto_correct** property in the workspace settings for the skill. + * + * @return the autoCorrect + */ + public Boolean autoCorrect() { + return autoCorrect; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java index be45b724733..c0c11684698 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,57 +10,64 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The message options. - */ +/** The message options. */ public class MessageOptions extends GenericModel { protected String assistantId; + protected String environmentId; protected String sessionId; protected MessageInput input; protected MessageContext context; + protected String userId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String assistantId; + private String environmentId; private String sessionId; private MessageInput input; private MessageContext context; + private String userId; + /** + * Instantiates a new Builder from an existing MessageOptions instance. + * + * @param messageOptions the instance to initialize the Builder with + */ private Builder(MessageOptions messageOptions) { this.assistantId = messageOptions.assistantId; + this.environmentId = messageOptions.environmentId; this.sessionId = messageOptions.sessionId; this.input = messageOptions.input; this.context = messageOptions.context; + this.userId = messageOptions.userId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param assistantId the assistantId + * @param environmentId the environmentId * @param sessionId the sessionId */ - public Builder(String assistantId, String sessionId) { + public Builder(String assistantId, String environmentId, String sessionId) { this.assistantId = assistantId; + this.environmentId = environmentId; this.sessionId = sessionId; } /** * Builds a MessageOptions. * - * @return the messageOptions + * @return the new MessageOptions instance */ public MessageOptions build() { return new MessageOptions(this); @@ -77,6 +84,17 @@ public Builder assistantId(String assistantId) { return this; } + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the MessageOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + /** * Set the sessionId. * @@ -109,17 +127,33 @@ public Builder context(MessageContext context) { this.context = context; return this; } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageOptions builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } } + protected MessageOptions() {} + protected MessageOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assistantId, - "assistantId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.sessionId, - "sessionId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.sessionId, "sessionId cannot be empty"); assistantId = builder.assistantId; + environmentId = builder.environmentId; sessionId = builder.sessionId; input = builder.input; context = builder.context; + userId = builder.userId; } /** @@ -134,11 +168,9 @@ public Builder newBuilder() { /** * Gets the assistantId. * - * Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the - * assistant settings and click **API Details**. For information about creating assistants, see the - * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). - * - * **Note:** Currently, the v2 API does not support creating assistants. + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. * * @return the assistantId */ @@ -146,10 +178,23 @@ public String assistantId() { return assistantId; } + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + /** * Gets the sessionId. * - * Unique identifier of the session. + *

Unique identifier of the session. * * @return the sessionId */ @@ -160,7 +205,7 @@ public String sessionId() { /** * Gets the input. * - * An input object that includes the input text. + *

An input object that includes the input text. * * @return the input */ @@ -171,12 +216,35 @@ public MessageInput input() { /** * Gets the context. * - * State information for the conversation. The context is stored by the assistant on a per-session basis. You can use - * this property to set or modify context variables, which can also be accessed by dialog nodes. + *

Context data for the conversation. You can use this property to set or modify context + * variables, which can also be accessed by dialog nodes. The context is stored by the assistant + * on a per-session basis. + * + *

**Note:** The total size of the context data stored for a stateful session cannot exceed + * 100KB. * * @return the context */ public MessageContext context() { return context; } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. If **user_id** is specified in both locations, the value specified at the root is + * used. + * + * @return the userId + */ + public String userId() { + return userId; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java index d53224d87c1..f59b20b826b 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,17 +10,15 @@ * 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.assistant.v2.model; -import java.util.List; -import java.util.Map; +package com.ibm.watson.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; -/** - * Assistant output to be rendered or processed by the client. - */ +/** Assistant output to be rendered or processed by the client. */ public class MessageOutput extends GenericModel { protected List generic; @@ -28,14 +26,22 @@ public class MessageOutput extends GenericModel { protected List entities; protected List actions; protected MessageOutputDebug debug; + @SerializedName("user_defined") protected Map userDefined; + protected MessageOutputSpelling spelling; + + @SerializedName("llm_metadata") + protected List llmMetadata; + + protected MessageOutput() {} + /** * Gets the generic. * - * Output intended for any channel. It is the responsibility of the client application to implement the supported - * response types. + *

Output intended for any channel. It is the responsibility of the client application to + * implement the supported response types. * * @return the generic */ @@ -46,7 +52,7 @@ public List getGeneric() { /** * Gets the intents. * - * An array of intents recognized in the user input, sorted in descending order of confidence. + *

An array of intents recognized in the user input, sorted in descending order of confidence. * * @return the intents */ @@ -57,7 +63,7 @@ public List getIntents() { /** * Gets the entities. * - * An array of entities identified in the user input. + *

An array of entities identified in the user input. * * @return the entities */ @@ -68,7 +74,7 @@ public List getEntities() { /** * Gets the actions. * - * An array of objects describing any actions requested by the dialog node. + *

An array of objects describing any actions requested by the dialog node. * * @return the actions */ @@ -79,7 +85,7 @@ public List getActions() { /** * Gets the debug. * - * Additional detailed information about a message response and how it was generated. + *

Additional detailed information about a message response and how it was generated. * * @return the debug */ @@ -90,12 +96,35 @@ public MessageOutputDebug getDebug() { /** * Gets the userDefined. * - * An object containing any custom properties included in the response. This object includes any arbitrary properties - * defined in the dialog JSON editor as part of the dialog node output. + *

An object containing any custom properties included in the response. This object includes + * any arbitrary properties defined in the dialog JSON editor as part of the dialog node output. * * @return the userDefined */ public Map getUserDefined() { return userDefined; } + + /** + * Gets the spelling. + * + *

Properties describing any spelling corrections in the user input that was received. + * + * @return the spelling + */ + public MessageOutputSpelling getSpelling() { + return spelling; + } + + /** + * Gets the llmMetadata. + * + *

An array of objects that provide information about calls to large language models that + * occured as part of handling this message. + * + * @return the llmMetadata + */ + public List getLlmMetadata() { + return llmMetadata; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java index fb3cc54e3ff..b32857b7da6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,21 +10,19 @@ * 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.assistant.v2.model; -import java.util.List; +package com.ibm.watson.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Additional detailed information about a message response and how it was generated. - */ +/** Additional detailed information about a message response and how it was generated. */ public class MessageOutputDebug extends GenericModel { /** - * When `branch_exited` is set to `true` by the Assistant, the `branch_exited_reason` specifies whether the dialog - * completed by itself or got interrupted. + * When `branch_exited` is set to `true` by the assistant, the `branch_exited_reason` specifies + * whether the dialog completed by itself or got interrupted. */ public interface BranchExitedReason { /** completed. */ @@ -34,30 +32,38 @@ public interface BranchExitedReason { } @SerializedName("nodes_visited") - protected List nodesVisited; + protected List nodesVisited; + @SerializedName("log_messages") protected List logMessages; + @SerializedName("branch_exited") protected Boolean branchExited; + @SerializedName("branch_exited_reason") protected String branchExitedReason; + @SerializedName("turn_events") + protected List turnEvents; + + protected MessageOutputDebug() {} + /** * Gets the nodesVisited. * - * An array of objects containing detailed diagnostic information about the nodes that were triggered during - * processing of the input message. + *

An array of objects containing detailed diagnostic information about dialog nodes that were + * visited during processing of the input message. * * @return the nodesVisited */ - public List getNodesVisited() { + public List getNodesVisited() { return nodesVisited; } /** * Gets the logMessages. * - * An array of up to 50 messages logged with the request. + *

An array of up to 50 messages logged with the request. * * @return the logMessages */ @@ -68,7 +74,7 @@ public List getLogMessages() { /** * Gets the branchExited. * - * Assistant sets this to true when this message response concludes or interrupts a dialog. + *

Assistant sets this to true when this message response concludes or interrupts a dialog. * * @return the branchExited */ @@ -79,12 +85,26 @@ public Boolean isBranchExited() { /** * Gets the branchExitedReason. * - * When `branch_exited` is set to `true` by the Assistant, the `branch_exited_reason` specifies whether the dialog - * completed by itself or got interrupted. + *

When `branch_exited` is set to `true` by the assistant, the `branch_exited_reason` specifies + * whether the dialog completed by itself or got interrupted. * * @return the branchExitedReason */ public String getBranchExitedReason() { return branchExitedReason; } + + /** + * Gets the turnEvents. + * + *

An array of objects containing detailed diagnostic information about dialog nodes and + * actions that were visited during processing of the input message. + * + *

This property is present only if the assistant has an action skill. + * + * @return the turnEvents + */ + public List getTurnEvents() { + return turnEvents; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEvent.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEvent.java new file mode 100644 index 00000000000..0230d99c7b9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEvent.java @@ -0,0 +1,296 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** + * MessageOutputDebugTurnEvent. + * + *

Classes which extend this class: - MessageOutputDebugTurnEventTurnEventActionVisited - + * MessageOutputDebugTurnEventTurnEventActionFinished - + * MessageOutputDebugTurnEventTurnEventStepVisited - + * MessageOutputDebugTurnEventTurnEventStepAnswered - + * MessageOutputDebugTurnEventTurnEventHandlerVisited - MessageOutputDebugTurnEventTurnEventCallout + * - MessageOutputDebugTurnEventTurnEventSearch - MessageOutputDebugTurnEventTurnEventNodeVisited - + * MessageOutputDebugTurnEventTurnEventConversationalSearchEnd - + * MessageOutputDebugTurnEventTurnEventManualRoute - + * MessageOutputDebugTurnEventTurnEventTopicSwitchDenied - + * MessageOutputDebugTurnEventTurnEventActionRoutingDenied - + * MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied - + * MessageOutputDebugTurnEventTurnEventGenerativeAICalled - + * MessageOutputDebugTurnEventTurnEventClientActions + */ +public class MessageOutputDebugTurnEvent extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "event"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "action_visited", MessageOutputDebugTurnEventTurnEventActionVisited.class); + discriminatorMapping.put( + "action_finished", MessageOutputDebugTurnEventTurnEventActionFinished.class); + discriminatorMapping.put("step_visited", MessageOutputDebugTurnEventTurnEventStepVisited.class); + discriminatorMapping.put( + "step_answered", MessageOutputDebugTurnEventTurnEventStepAnswered.class); + discriminatorMapping.put( + "handler_visited", MessageOutputDebugTurnEventTurnEventHandlerVisited.class); + discriminatorMapping.put("callout", MessageOutputDebugTurnEventTurnEventCallout.class); + discriminatorMapping.put("search", MessageOutputDebugTurnEventTurnEventSearch.class); + discriminatorMapping.put("node_visited", MessageOutputDebugTurnEventTurnEventNodeVisited.class); + discriminatorMapping.put( + "conversational_search_end", + MessageOutputDebugTurnEventTurnEventConversationalSearchEnd.class); + discriminatorMapping.put("manual_route", MessageOutputDebugTurnEventTurnEventManualRoute.class); + discriminatorMapping.put( + "topic_switch_denied", MessageOutputDebugTurnEventTurnEventTopicSwitchDenied.class); + discriminatorMapping.put( + "action_routing_denied", MessageOutputDebugTurnEventTurnEventActionRoutingDenied.class); + discriminatorMapping.put( + "suggestion_intents_denied", + MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied.class); + discriminatorMapping.put( + "generative_ai_called", MessageOutputDebugTurnEventTurnEventGenerativeAICalled.class); + discriminatorMapping.put( + "client_actions", MessageOutputDebugTurnEventTurnEventClientActions.class); + } + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + /** The reason the action was visited. */ + public interface Reason { + /** intent. */ + String INTENT = "intent"; + /** invoke_subaction. */ + String INVOKE_SUBACTION = "invoke_subaction"; + /** subaction_return. */ + String SUBACTION_RETURN = "subaction_return"; + /** invoke_external. */ + String INVOKE_EXTERNAL = "invoke_external"; + /** topic_switch. */ + String TOPIC_SWITCH = "topic_switch"; + /** topic_return. */ + String TOPIC_RETURN = "topic_return"; + /** agent_requested. */ + String AGENT_REQUESTED = "agent_requested"; + /** step_validation_failed. */ + String STEP_VALIDATION_FAILED = "step_validation_failed"; + /** no_action_matches. */ + String NO_ACTION_MATCHES = "no_action_matches"; + } + + protected String event; + + @SerializedName("action_start_time") + protected String actionStartTime; + + @SerializedName("condition_type") + protected String conditionType; + + protected String reason; + + @SerializedName("result_variable") + protected String resultVariable; + + @SerializedName("action_variables") + protected Map actionVariables; + + @SerializedName("has_question") + protected Boolean hasQuestion; + + protected Boolean prompted; + @SerializedName("route_name") + protected String routeName; + + @SerializedName("intents_denied") + protected List intentsDenied; + + @SerializedName("generative_ai_start_time") + protected String generativeAiStartTime; + + @SerializedName("generative_ai") + protected GenerativeAITask generativeAi; + + protected TurnEventGenerativeAICalledMetrics metrics; + + @SerializedName("client_actions") + protected List clientActions; + + protected MessageOutputDebugTurnEvent() {} + + /** + * Gets the event. + * + *

The type of turn event. + * + * @return the event + */ + public String getEvent() { + return event; + } + + /** + * Gets the actionStartTime. + * + *

The time when the action started processing the message. + * + * @return the actionStartTime + */ + public String getActionStartTime() { + return actionStartTime; + } + + /** + * Gets the conditionType. + * + *

The type of condition (if any) that is defined for the action. + * + * @return the conditionType + */ + public String getConditionType() { + return conditionType; + } + + /** + * Gets the reason. + * + *

The reason the action was visited. + * + * @return the reason + */ + public String getReason() { + return reason; + } + + /** + * Gets the resultVariable. + * + *

The variable where the result of the call to the action is stored. Included only if + * **reason**=`subaction_return`. + * + * @return the resultVariable + */ + public String getResultVariable() { + return resultVariable; + } + + /** + * Gets the actionVariables. + * + *

The state of all action variables at the time the action finished. + * + * @return the actionVariables + */ + public Map getActionVariables() { + return actionVariables; + } + + /** + * Gets the hasQuestion. + * + *

Whether the step collects a customer response. + * + * @return the hasQuestion + */ + public Boolean isHasQuestion() { + return hasQuestion; + } + + /** + * Gets the prompted. + * + *

Whether the step was answered in response to a prompt from the assistant. If this property + * is `false`, the user provided the answer without visiting the step. + * + * @return the prompted + */ + public Boolean isPrompted() { + return prompted; + } + + /** + * Gets the routeName. + * + *

The name of the route. + * + * @return the routeName + */ + public String getRouteName() { + return routeName; + } + + /** + * Gets the intentsDenied. + * + *

An array of denied intents. + * + * @return the intentsDenied + */ + public List getIntentsDenied() { + return intentsDenied; + } + + /** + * Gets the generativeAiStartTime. + * + *

The time when generative ai started processing the message. + * + * @return the generativeAiStartTime + */ + public String getGenerativeAiStartTime() { + return generativeAiStartTime; + } + + /** + * Gets the generativeAi. + * + * @return the generativeAi + */ + public GenerativeAITask getGenerativeAi() { + return generativeAi; + } + + /** + * Gets the metrics. + * + * @return the metrics + */ + public TurnEventGenerativeAICalledMetrics getMetrics() { + return metrics; + } + + /** + * Gets the clientActions. + * + *

An array of client actions. + * + * @return the clientActions + */ + public List getClientActions() { + return clientActions; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionFinished.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionFinished.java new file mode 100644 index 00000000000..57efba8589e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionFinished.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventActionFinished. */ +public class MessageOutputDebugTurnEventTurnEventActionFinished + extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + /** The reason the action finished processing. */ + public interface Reason { + /** all_steps_done. */ + String ALL_STEPS_DONE = "all_steps_done"; + /** no_steps_visited. */ + String NO_STEPS_VISITED = "no_steps_visited"; + /** ended_by_step. */ + String ENDED_BY_STEP = "ended_by_step"; + /** connect_to_agent. */ + String CONNECT_TO_AGENT = "connect_to_agent"; + /** max_retries_reached. */ + String MAX_RETRIES_REACHED = "max_retries_reached"; + /** fallback. */ + String FALLBACK = "fallback"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventActionFinished() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionRoutingDenied.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionRoutingDenied.java new file mode 100644 index 00000000000..df58e6350b8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionRoutingDenied.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventActionRoutingDenied. */ +public class MessageOutputDebugTurnEventTurnEventActionRoutingDenied + extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + /** The reason the action was visited. */ + public interface Reason { + /** action_conditions_failed. */ + String ACTION_CONDITIONS_FAILED = "action_conditions_failed"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventActionRoutingDenied() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionVisited.java new file mode 100644 index 00000000000..1ed5d4579eb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionVisited.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventActionVisited. */ +public class MessageOutputDebugTurnEventTurnEventActionVisited extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + /** The reason the action was visited. */ + public interface Reason { + /** intent. */ + String INTENT = "intent"; + /** invoke_subaction. */ + String INVOKE_SUBACTION = "invoke_subaction"; + /** subaction_return. */ + String SUBACTION_RETURN = "subaction_return"; + /** invoke_external. */ + String INVOKE_EXTERNAL = "invoke_external"; + /** topic_switch. */ + String TOPIC_SWITCH = "topic_switch"; + /** topic_return. */ + String TOPIC_RETURN = "topic_return"; + /** agent_requested. */ + String AGENT_REQUESTED = "agent_requested"; + /** step_validation_failed. */ + String STEP_VALIDATION_FAILED = "step_validation_failed"; + /** no_action_matches. */ + String NO_ACTION_MATCHES = "no_action_matches"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventActionVisited() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventCallout.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventCallout.java new file mode 100644 index 00000000000..b2ea8598734 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventCallout.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2022, 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventCallout. */ +public class MessageOutputDebugTurnEventTurnEventCallout extends MessageOutputDebugTurnEvent { + + protected TurnEventActionSource source; + protected TurnEventCalloutCallout callout; + protected TurnEventCalloutError error; + + protected MessageOutputDebugTurnEventTurnEventCallout() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } + + /** + * Gets the callout. + * + * @return the callout + */ + public TurnEventCalloutCallout getCallout() { + return callout; + } + + /** + * Gets the error. + * + * @return the error + */ + public TurnEventCalloutError getError() { + return error; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventClientActions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventClientActions.java new file mode 100644 index 00000000000..7432c84b9a2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventClientActions.java @@ -0,0 +1,31 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventClientActions. */ +public class MessageOutputDebugTurnEventTurnEventClientActions extends MessageOutputDebugTurnEvent { + + protected TurnEventStepSource source; + + protected MessageOutputDebugTurnEventTurnEventClientActions() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventStepSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventConversationalSearchEnd.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventConversationalSearchEnd.java new file mode 100644 index 00000000000..3841b581a19 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventConversationalSearchEnd.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventConversationalSearchEnd. */ +public class MessageOutputDebugTurnEventTurnEventConversationalSearchEnd + extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventConversationalSearchEnd() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventGenerativeAICalled.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventGenerativeAICalled.java new file mode 100644 index 00000000000..5133312f36d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventGenerativeAICalled.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import java.util.Map; + +/** MessageOutputDebugTurnEventTurnEventGenerativeAICalled. */ +public class MessageOutputDebugTurnEventTurnEventGenerativeAICalled + extends MessageOutputDebugTurnEvent { + + protected Map source; + protected TurnEventGenerativeAICalledCallout callout; + + protected MessageOutputDebugTurnEventTurnEventGenerativeAICalled() {} + + /** + * Gets the source. + * + * @return the source + */ + public Map getSource() { + return source; + } + + /** + * Gets the callout. + * + * @return the callout + */ + public TurnEventGenerativeAICalledCallout getCallout() { + return callout; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventHandlerVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventHandlerVisited.java new file mode 100644 index 00000000000..5831188a20b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventHandlerVisited.java @@ -0,0 +1,32 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventHandlerVisited. */ +public class MessageOutputDebugTurnEventTurnEventHandlerVisited + extends MessageOutputDebugTurnEvent { + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventHandlerVisited() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventManualRoute.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventManualRoute.java new file mode 100644 index 00000000000..ec139078b2e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventManualRoute.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventManualRoute. */ +public class MessageOutputDebugTurnEventTurnEventManualRoute extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + protected TurnEventStepSource source; + + protected MessageOutputDebugTurnEventTurnEventManualRoute() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventStepSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventNodeVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventNodeVisited.java new file mode 100644 index 00000000000..bc2ddd7945b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventNodeVisited.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventNodeVisited. */ +public class MessageOutputDebugTurnEventTurnEventNodeVisited extends MessageOutputDebugTurnEvent { + + /** The reason the dialog node was visited. */ + public interface Reason { + /** welcome. */ + String WELCOME = "welcome"; + /** branch_start. */ + String BRANCH_START = "branch_start"; + /** topic_switch. */ + String TOPIC_SWITCH = "topic_switch"; + /** topic_return. */ + String TOPIC_RETURN = "topic_return"; + /** topic_switch_without_return. */ + String TOPIC_SWITCH_WITHOUT_RETURN = "topic_switch_without_return"; + /** jump. */ + String JUMP = "jump"; + } + + protected TurnEventNodeSource source; + + protected MessageOutputDebugTurnEventTurnEventNodeVisited() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventNodeSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSearch.java new file mode 100644 index 00000000000..fd22e5dc743 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSearch.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventSearch. */ +public class MessageOutputDebugTurnEventTurnEventSearch extends MessageOutputDebugTurnEvent { + + protected TurnEventActionSource source; + protected TurnEventSearchError error; + + protected MessageOutputDebugTurnEventTurnEventSearch() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } + + /** + * Gets the error. + * + * @return the error + */ + public TurnEventSearchError getError() { + return error; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepAnswered.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepAnswered.java new file mode 100644 index 00000000000..a06536a0017 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepAnswered.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventStepAnswered. */ +public class MessageOutputDebugTurnEventTurnEventStepAnswered extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventStepAnswered() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepVisited.java new file mode 100644 index 00000000000..0fd3eb34fc5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepVisited.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventStepVisited. */ +public class MessageOutputDebugTurnEventTurnEventStepVisited extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventStepVisited() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied.java new file mode 100644 index 00000000000..3f6b9753dab --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied.java @@ -0,0 +1,21 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied. */ +public class MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied + extends MessageOutputDebugTurnEvent { + + protected MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventTopicSwitchDenied.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventTopicSwitchDenied.java new file mode 100644 index 00000000000..813d028a09a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventTopicSwitchDenied.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** MessageOutputDebugTurnEventTurnEventTopicSwitchDenied. */ +public class MessageOutputDebugTurnEventTurnEventTopicSwitchDenied + extends MessageOutputDebugTurnEvent { + + /** The type of condition (if any) that is defined for the action. */ + public interface ConditionType { + /** user_defined. */ + String USER_DEFINED = "user_defined"; + /** welcome. */ + String WELCOME = "welcome"; + /** anything_else. */ + String ANYTHING_ELSE = "anything_else"; + } + + /** The reason the action was visited. */ + public interface Reason { + /** action_conditions_failed. */ + String ACTION_CONDITIONS_FAILED = "action_conditions_failed"; + } + + protected TurnEventActionSource source; + + protected MessageOutputDebugTurnEventTurnEventTopicSwitchDenied() {} + + /** + * Gets the source. + * + * @return the source + */ + public TurnEventActionSource getSource() { + return source; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputLLMMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputLLMMetadata.java new file mode 100644 index 00000000000..419160398fe --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputLLMMetadata.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** MessageOutputLLMMetadata. */ +public class MessageOutputLLMMetadata extends GenericModel { + + protected String task; + + @SerializedName("model_id") + protected String modelId; + + protected MessageOutputLLMMetadata() {} + + /** + * Gets the task. + * + *

The task that used a large language model. + * + * @return the task + */ + public String getTask() { + return task; + } + + /** + * Gets the modelId. + * + *

The id for the large language model used for the task. + * + * @return the modelId + */ + public String getModelId() { + return modelId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputSpelling.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputSpelling.java new file mode 100644 index 00000000000..170d501947a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputSpelling.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Properties describing any spelling corrections in the user input that was received. */ +public class MessageOutputSpelling extends GenericModel { + + protected String text; + + @SerializedName("original_text") + protected String originalText; + + @SerializedName("suggested_text") + protected String suggestedText; + + protected MessageOutputSpelling() {} + + /** + * Gets the text. + * + *

The user input text that was used to generate the response. If spelling autocorrection is + * enabled, this text reflects any spelling corrections that were applied. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the originalText. + * + *

The original user input text. This property is returned only if autocorrection is enabled + * and the user input was corrected. + * + * @return the originalText + */ + public String getOriginalText() { + return originalText; + } + + /** + * Gets the suggestedText. + * + *

Any suggested corrections of the input text. This property is returned only if spelling + * correction is enabled and autocorrection is disabled. + * + * @return the suggestedText + */ + public String getSuggestedText() { + return suggestedText; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java deleted file mode 100644 index d5a5307491e..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.assistant.v2.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A response from the Watson Assistant service. - */ -public class MessageResponse extends GenericModel { - - protected MessageOutput output; - protected MessageContext context; - - /** - * Gets the output. - * - * Assistant output to be rendered or processed by the client. - * - * @return the output - */ - public MessageOutput getOutput() { - return output; - } - - /** - * Gets the context. - * - * State information for the conversation. The context is stored by the assistant on a per-session basis. You can use - * this property to access context variables. - * - * **Note:** The context is included in message responses only if **return_context**=`true` in the message request. - * - * @return the context - */ - public MessageContext getContext() { - return context; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java new file mode 100644 index 00000000000..e293def7c91 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java @@ -0,0 +1,220 @@ +/* + * (C) Copyright IBM Corp. 2020, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The messageStateless options. */ +public class MessageStatelessOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected StatelessMessageInput input; + protected StatelessMessageContext context; + protected String userId; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String environmentId; + private StatelessMessageInput input; + private StatelessMessageContext context; + private String userId; + + /** + * Instantiates a new Builder from an existing MessageStatelessOptions instance. + * + * @param messageStatelessOptions the instance to initialize the Builder with + */ + private Builder(MessageStatelessOptions messageStatelessOptions) { + this.assistantId = messageStatelessOptions.assistantId; + this.environmentId = messageStatelessOptions.environmentId; + this.input = messageStatelessOptions.input; + this.context = messageStatelessOptions.context; + this.userId = messageStatelessOptions.userId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param environmentId the environmentId + */ + public Builder(String assistantId, String environmentId) { + this.assistantId = assistantId; + this.environmentId = environmentId; + } + + /** + * Builds a MessageStatelessOptions. + * + * @return the new MessageStatelessOptions instance + */ + public MessageStatelessOptions build() { + return new MessageStatelessOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the MessageStatelessOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the MessageStatelessOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the MessageStatelessOptions builder + */ + public Builder input(StatelessMessageInput input) { + this.input = input; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the MessageStatelessOptions builder + */ + public Builder context(StatelessMessageContext context) { + this.context = context; + return this; + } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageStatelessOptions builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + } + + protected MessageStatelessOptions() {} + + protected MessageStatelessOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + assistantId = builder.assistantId; + environmentId = builder.environmentId; + input = builder.input; + context = builder.context; + userId = builder.userId; + } + + /** + * New builder. + * + * @return a MessageStatelessOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public StatelessMessageInput input() { + return input; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to set or modify context + * variables, which can also be accessed by dialog nodes. The context is not stored by the + * assistant. To maintain session state, include the context from the previous response. + * + *

**Note:** The total size of the context data for a stateless session cannot exceed 250KB. + * + * @return the context + */ + public StatelessMessageContext context() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. If **user_id** is specified in both locations in a message request, the value + * specified at the root is used. + * + * @return the userId + */ + public String userId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamMetadata.java new file mode 100644 index 00000000000..1d5999a5cef --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamMetadata.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Contains meta-information about the item(s) being streamed. */ +public class MessageStreamMetadata extends GenericModel { + + @SerializedName("streaming_metadata") + protected Metadata streamingMetadata; + + protected MessageStreamMetadata() {} + + /** + * Gets the streamingMetadata. + * + *

Contains meta-information about the item(s) being streamed. + * + * @return the streamingMetadata + */ + public Metadata getStreamingMetadata() { + return streamingMetadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamOptions.java new file mode 100644 index 00000000000..edee0ae6dac --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamOptions.java @@ -0,0 +1,250 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The messageStream options. */ +public class MessageStreamOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected String sessionId; + protected MessageInput input; + protected MessageContext context; + protected String userId; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String environmentId; + private String sessionId; + private MessageInput input; + private MessageContext context; + private String userId; + + /** + * Instantiates a new Builder from an existing MessageStreamOptions instance. + * + * @param messageStreamOptions the instance to initialize the Builder with + */ + private Builder(MessageStreamOptions messageStreamOptions) { + this.assistantId = messageStreamOptions.assistantId; + this.environmentId = messageStreamOptions.environmentId; + this.sessionId = messageStreamOptions.sessionId; + this.input = messageStreamOptions.input; + this.context = messageStreamOptions.context; + this.userId = messageStreamOptions.userId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param environmentId the environmentId + * @param sessionId the sessionId + */ + public Builder(String assistantId, String environmentId, String sessionId) { + this.assistantId = assistantId; + this.environmentId = environmentId; + this.sessionId = sessionId; + } + + /** + * Builds a MessageStreamOptions. + * + * @return the new MessageStreamOptions instance + */ + public MessageStreamOptions build() { + return new MessageStreamOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the MessageStreamOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the MessageStreamOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the sessionId. + * + * @param sessionId the sessionId + * @return the MessageStreamOptions builder + */ + public Builder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the MessageStreamOptions builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the MessageStreamOptions builder + */ + public Builder context(MessageContext context) { + this.context = context; + return this; + } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageStreamOptions builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + } + + protected MessageStreamOptions() {} + + protected MessageStreamOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.sessionId, "sessionId cannot be empty"); + assistantId = builder.assistantId; + environmentId = builder.environmentId; + sessionId = builder.sessionId; + input = builder.input; + context = builder.context; + userId = builder.userId; + } + + /** + * New builder. + * + * @return a MessageStreamOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the sessionId. + * + *

Unique identifier of the session. + * + * @return the sessionId + */ + public String sessionId() { + return sessionId; + } + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public MessageInput input() { + return input; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to set or modify context + * variables, which can also be accessed by dialog nodes. The context is stored by the assistant + * on a per-session basis. + * + *

**Note:** The total size of the context data stored for a stateful session cannot exceed + * 100KB. + * + * @return the context + */ + public MessageContext context() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. If **user_id** is specified in both locations, the value specified at the root is + * used. + * + * @return the userId + */ + public String userId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamResponse.java new file mode 100644 index 00000000000..ec46e1f4351 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamResponse.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A streamed response from the watsonx Assistant service. + * + *

Classes which extend this class: - MessageStreamResponseMessageStreamPartialItem - + * MessageStreamResponseMessageStreamCompleteItem - + * MessageStreamResponseStatefulMessageStreamFinalResponse + */ +public class MessageStreamResponse extends GenericModel { + + @SerializedName("partial_item") + protected PartialItem partialItem; + + @SerializedName("complete_item") + protected CompleteItem completeItem; + + @SerializedName("final_response") + protected FinalResponse finalResponse; + + protected MessageStreamResponse() {} + + /** + * Gets the partialItem. + * + *

Message response partial item content. + * + * @return the partialItem + */ + public PartialItem getPartialItem() { + return partialItem; + } + + /** + * Gets the completeItem. + * + * @return the completeItem + */ + public CompleteItem getCompleteItem() { + return completeItem; + } + + /** + * Gets the finalResponse. + * + *

Message final response content. + * + * @return the finalResponse + */ + public FinalResponse getFinalResponse() { + return finalResponse; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamStatelessOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamStatelessOptions.java new file mode 100644 index 00000000000..999f2e1ac09 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStreamStatelessOptions.java @@ -0,0 +1,221 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The messageStreamStateless options. */ +public class MessageStreamStatelessOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected MessageInput input; + protected MessageContext context; + protected String userId; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String environmentId; + private MessageInput input; + private MessageContext context; + private String userId; + + /** + * Instantiates a new Builder from an existing MessageStreamStatelessOptions instance. + * + * @param messageStreamStatelessOptions the instance to initialize the Builder with + */ + private Builder(MessageStreamStatelessOptions messageStreamStatelessOptions) { + this.assistantId = messageStreamStatelessOptions.assistantId; + this.environmentId = messageStreamStatelessOptions.environmentId; + this.input = messageStreamStatelessOptions.input; + this.context = messageStreamStatelessOptions.context; + this.userId = messageStreamStatelessOptions.userId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param environmentId the environmentId + */ + public Builder(String assistantId, String environmentId) { + this.assistantId = assistantId; + this.environmentId = environmentId; + } + + /** + * Builds a MessageStreamStatelessOptions. + * + * @return the new MessageStreamStatelessOptions instance + */ + public MessageStreamStatelessOptions build() { + return new MessageStreamStatelessOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the MessageStreamStatelessOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the MessageStreamStatelessOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the MessageStreamStatelessOptions builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the MessageStreamStatelessOptions builder + */ + public Builder context(MessageContext context) { + this.context = context; + return this; + } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageStreamStatelessOptions builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + } + + protected MessageStreamStatelessOptions() {} + + protected MessageStreamStatelessOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + assistantId = builder.assistantId; + environmentId = builder.environmentId; + input = builder.input; + context = builder.context; + userId = builder.userId; + } + + /** + * New builder. + * + * @return a MessageStreamStatelessOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public MessageInput input() { + return input; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to set or modify context + * variables, which can also be accessed by dialog nodes. The context is stored by the assistant + * on a per-session basis. + * + *

**Note:** The total size of the context data stored for a stateful session cannot exceed + * 100KB. + * + * @return the context + */ + public MessageContext context() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. If **user_id** is specified in both locations, the value specified at the root is + * used. + * + * @return the userId + */ + public String userId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Metadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Metadata.java new file mode 100644 index 00000000000..47c4ec13089 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Metadata.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Contains meta-information about the item(s) being streamed. */ +public class Metadata extends GenericModel { + + protected Long id; + + protected Metadata() {} + + /** + * Gets the id. + * + *

Identifies the index and sequence of the current streamed response item. + * + * @return the id + */ + public Long getId() { + return id; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MonitorAssistantReleaseImportArtifactResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MonitorAssistantReleaseImportArtifactResponse.java new file mode 100644 index 00000000000..349643b9b48 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MonitorAssistantReleaseImportArtifactResponse.java @@ -0,0 +1,160 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; + +/** MonitorAssistantReleaseImportArtifactResponse. */ +public class MonitorAssistantReleaseImportArtifactResponse extends GenericModel { + + /** + * The current status of the release import process: - **Completed**: The artifact import has + * completed. - **Failed**: The asynchronous artifact import process has failed. - **Processing**: + * An asynchronous operation to import the artifact is underway and not yet completed. + */ + public interface Status { + /** Completed. */ + String COMPLETED = "Completed"; + /** Failed. */ + String FAILED = "Failed"; + /** Processing. */ + String PROCESSING = "Processing"; + } + + /** The type of the skill in the draft environment. */ + public interface SkillImpactInDraft { + /** action. */ + String ACTION = "action"; + /** dialog. */ + String DIALOG = "dialog"; + } + + protected String status; + + @SerializedName("task_id") + protected String taskId; + + @SerializedName("assistant_id") + protected String assistantId; + + @SerializedName("status_errors") + protected List statusErrors; + + @SerializedName("status_description") + protected String statusDescription; + + @SerializedName("skill_impact_in_draft") + protected List skillImpactInDraft; + + protected Date created; + protected Date updated; + + protected MonitorAssistantReleaseImportArtifactResponse() {} + + /** + * Gets the status. + * + *

The current status of the release import process: - **Completed**: The artifact import has + * completed. - **Failed**: The asynchronous artifact import process has failed. - **Processing**: + * An asynchronous operation to import the artifact is underway and not yet completed. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the taskId. + * + *

A unique identifier for a background asynchronous task that is executing or has executed the + * operation. + * + * @return the taskId + */ + public String getTaskId() { + return taskId; + } + + /** + * Gets the assistantId. + * + *

The ID of the assistant to which the release belongs. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the statusErrors. + * + *

An array of messages about errors that caused an asynchronous operation to fail. Included + * only if **status**=`Failed`. + * + * @return the statusErrors + */ + public List getStatusErrors() { + return statusErrors; + } + + /** + * Gets the statusDescription. + * + *

The description of the failed asynchronous operation. Included only if **status**=`Failed`. + * + * @return the statusDescription + */ + public String getStatusDescription() { + return statusDescription; + } + + /** + * Gets the skillImpactInDraft. + * + *

An array of skill types in the draft environment which will be overridden with skills from + * the artifact being imported. + * + * @return the skillImpactInDraft + */ + public List getSkillImpactInDraft() { + return skillImpactInDraft; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Pagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Pagination.java new file mode 100644 index 00000000000..e2d5eb31534 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Pagination.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2018, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The pagination data for the returned objects. For more information about using pagination, see + * [Pagination](#pagination). + */ +public class Pagination extends GenericModel { + + @SerializedName("refresh_url") + protected String refreshUrl; + + @SerializedName("next_url") + protected String nextUrl; + + protected Long total; + protected Long matched; + + @SerializedName("refresh_cursor") + protected String refreshCursor; + + @SerializedName("next_cursor") + protected String nextCursor; + + protected Pagination() {} + + /** + * Gets the refreshUrl. + * + *

The URL that will return the same page of results. + * + * @return the refreshUrl + */ + public String getRefreshUrl() { + return refreshUrl; + } + + /** + * Gets the nextUrl. + * + *

The URL that will return the next page of results. + * + * @return the nextUrl + */ + public String getNextUrl() { + return nextUrl; + } + + /** + * Gets the total. + * + *

The total number of objects that satisfy the request. This total includes all results, not + * just those included in the current page. + * + * @return the total + */ + public Long getTotal() { + return total; + } + + /** + * Gets the matched. + * + *

Reserved for future use. + * + * @return the matched + */ + public Long getMatched() { + return matched; + } + + /** + * Gets the refreshCursor. + * + *

A token identifying the current page of results. + * + * @return the refreshCursor + */ + public String getRefreshCursor() { + return refreshCursor; + } + + /** + * Gets the nextCursor. + * + *

A token identifying the next page of results. + * + * @return the nextCursor + */ + public String getNextCursor() { + return nextCursor; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/PartialItem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/PartialItem.java new file mode 100644 index 00000000000..f1ff5d426cd --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/PartialItem.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Message response partial item content. */ +public class PartialItem extends GenericModel { + + @SerializedName("response_type") + protected String responseType; + + protected String text; + + @SerializedName("streaming_metadata") + protected Metadata streamingMetadata; + + protected PartialItem() {} + + /** + * Gets the responseType. + * + *

The type of response returned by the dialog node. The specified response type must be + * supported by the client application or channel. + * + * @return the responseType + */ + public String getResponseType() { + return responseType; + } + + /** + * Gets the text. + * + *

The text within the partial chunk of the message stream response. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the streamingMetadata. + * + *

Contains meta-information about the item(s) being streamed. + * + * @return the streamingMetadata + */ + public Metadata getStreamingMetadata() { + return streamingMetadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2.java new file mode 100644 index 00000000000..88eb0c23ff9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Non-private settings for oauth2 authentication. */ +public class ProviderAuthenticationOAuth2 extends GenericModel { + + /** + * The preferred "flow" or "grant type" for the API client to fetch an access token from the + * authorization server. + */ + public interface PreferredFlow { + /** password. */ + String PASSWORD = "password"; + /** client_credentials. */ + String CLIENT_CREDENTIALS = "client_credentials"; + /** authorization_code. */ + String AUTHORIZATION_CODE = "authorization_code"; + /** <$custom_flow_name>. */ + String CUSTOM_FLOW_NAME = "<$custom_flow_name>"; + } + + @SerializedName("preferred_flow") + protected String preferredFlow; + + protected ProviderAuthenticationOAuth2Flows flows; + + /** Builder. */ + public static class Builder { + private String preferredFlow; + private ProviderAuthenticationOAuth2Flows flows; + + /** + * Instantiates a new Builder from an existing ProviderAuthenticationOAuth2 instance. + * + * @param providerAuthenticationOAuth2 the instance to initialize the Builder with + */ + private Builder(ProviderAuthenticationOAuth2 providerAuthenticationOAuth2) { + this.preferredFlow = providerAuthenticationOAuth2.preferredFlow; + this.flows = providerAuthenticationOAuth2.flows; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderAuthenticationOAuth2. + * + * @return the new ProviderAuthenticationOAuth2 instance + */ + public ProviderAuthenticationOAuth2 build() { + return new ProviderAuthenticationOAuth2(this); + } + + /** + * Set the preferredFlow. + * + * @param preferredFlow the preferredFlow + * @return the ProviderAuthenticationOAuth2 builder + */ + public Builder preferredFlow(String preferredFlow) { + this.preferredFlow = preferredFlow; + return this; + } + + /** + * Set the flows. + * + * @param flows the flows + * @return the ProviderAuthenticationOAuth2 builder + */ + public Builder flows(ProviderAuthenticationOAuth2Flows flows) { + this.flows = flows; + return this; + } + } + + protected ProviderAuthenticationOAuth2() {} + + protected ProviderAuthenticationOAuth2(Builder builder) { + preferredFlow = builder.preferredFlow; + flows = builder.flows; + } + + /** + * New builder. + * + * @return a ProviderAuthenticationOAuth2 builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the preferredFlow. + * + *

The preferred "flow" or "grant type" for the API client to fetch an access token from the + * authorization server. + * + * @return the preferredFlow + */ + public String preferredFlow() { + return preferredFlow; + } + + /** + * Gets the flows. + * + *

Scenarios performed by the API client to fetch an access token from the authorization + * server. + * + * @return the flows + */ + public ProviderAuthenticationOAuth2Flows flows() { + return flows; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2Flows.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2Flows.java new file mode 100644 index 00000000000..c1f213937d7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2Flows.java @@ -0,0 +1,149 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Scenarios performed by the API client to fetch an access token from the authorization server. + * + *

Classes which extend this class: - + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password - + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials - + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + */ +public class ProviderAuthenticationOAuth2Flows extends GenericModel { + + /** The client authorization type. */ + public interface ClientAuthType { + /** Body. */ + String BODY = "Body"; + /** BasicAuthHeader. */ + String BASICAUTHHEADER = "BasicAuthHeader"; + } + + @SerializedName("token_url") + protected String tokenUrl; + + @SerializedName("refresh_url") + protected String refreshUrl; + + @SerializedName("client_auth_type") + protected String clientAuthType; + + @SerializedName("content_type") + protected String contentType; + + @SerializedName("header_prefix") + protected String headerPrefix; + + protected ProviderAuthenticationOAuth2PasswordUsername username; + + @SerializedName("authorization_url") + protected String authorizationUrl; + + @SerializedName("redirect_uri") + protected String redirectUri; + + protected ProviderAuthenticationOAuth2Flows() {} + + /** + * Gets the tokenUrl. + * + *

The token URL. + * + * @return the tokenUrl + */ + public String tokenUrl() { + return tokenUrl; + } + + /** + * Gets the refreshUrl. + * + *

The refresh token URL. + * + * @return the refreshUrl + */ + public String refreshUrl() { + return refreshUrl; + } + + /** + * Gets the clientAuthType. + * + *

The client authorization type. + * + * @return the clientAuthType + */ + public String clientAuthType() { + return clientAuthType; + } + + /** + * Gets the contentType. + * + *

The content type. + * + * @return the contentType + */ + public String contentType() { + return contentType; + } + + /** + * Gets the headerPrefix. + * + *

The prefix fo the header. + * + * @return the headerPrefix + */ + public String headerPrefix() { + return headerPrefix; + } + + /** + * Gets the username. + * + *

The username for oauth2 authentication when the preferred flow is "password". + * + * @return the username + */ + public ProviderAuthenticationOAuth2PasswordUsername username() { + return username; + } + + /** + * Gets the authorizationUrl. + * + *

The authorization URL. + * + * @return the authorizationUrl + */ + public String authorizationUrl() { + return authorizationUrl; + } + + /** + * Gets the redirectUri. + * + *

The redirect URI. + * + * @return the redirectUri + */ + public String redirectUri() { + return redirectUri; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode.java new file mode 100644 index 00000000000..f4729f54b9a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode.java @@ -0,0 +1,190 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** Non-private authentication settings for authorization-code flow. */ +public class ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + extends ProviderAuthenticationOAuth2Flows { + + /** The client authorization type. */ + public interface ClientAuthType { + /** Body. */ + String BODY = "Body"; + /** BasicAuthHeader. */ + String BASICAUTHHEADER = "BasicAuthHeader"; + } + + /** Builder. */ + public static class Builder { + private String tokenUrl; + private String refreshUrl; + private String clientAuthType; + private String contentType; + private String headerPrefix; + private String authorizationUrl; + private String redirectUri; + + /** + * Instantiates a new Builder from an existing + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode instance. + * + * @param providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode the + * instance to initialize the Builder with + */ + public Builder( + ProviderAuthenticationOAuth2Flows + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode) { + this.tokenUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode.tokenUrl; + this.refreshUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode.refreshUrl; + this.clientAuthType = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .clientAuthType; + this.contentType = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .contentType; + this.headerPrefix = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .headerPrefix; + this.authorizationUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .authorizationUrl; + this.redirectUri = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .redirectUri; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode. + * + * @return the new + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode instance + */ + public ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode build() { + return new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode( + this); + } + + /** + * Set the tokenUrl. + * + * @param tokenUrl the tokenUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder tokenUrl(String tokenUrl) { + this.tokenUrl = tokenUrl; + return this; + } + + /** + * Set the refreshUrl. + * + * @param refreshUrl the refreshUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder refreshUrl(String refreshUrl) { + this.refreshUrl = refreshUrl; + return this; + } + + /** + * Set the clientAuthType. + * + * @param clientAuthType the clientAuthType + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder clientAuthType(String clientAuthType) { + this.clientAuthType = clientAuthType; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the headerPrefix. + * + * @param headerPrefix the headerPrefix + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder headerPrefix(String headerPrefix) { + this.headerPrefix = headerPrefix; + return this; + } + + /** + * Set the authorizationUrl. + * + * @param authorizationUrl the authorizationUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder authorizationUrl(String authorizationUrl) { + this.authorizationUrl = authorizationUrl; + return this; + } + + /** + * Set the redirectUri. + * + * @param redirectUri the redirectUri + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder redirectUri(String redirectUri) { + this.redirectUri = redirectUri; + return this; + } + } + + protected ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode() {} + + protected ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode( + Builder builder) { + tokenUrl = builder.tokenUrl; + refreshUrl = builder.refreshUrl; + clientAuthType = builder.clientAuthType; + contentType = builder.contentType; + headerPrefix = builder.headerPrefix; + authorizationUrl = builder.authorizationUrl; + redirectUri = builder.redirectUri; + } + + /** + * New builder. + * + * @return a ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials.java new file mode 100644 index 00000000000..f4f9b82debe --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials.java @@ -0,0 +1,156 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials. */ +public class ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + extends ProviderAuthenticationOAuth2Flows { + + /** The client authorization type. */ + public interface ClientAuthType { + /** Body. */ + String BODY = "Body"; + /** BasicAuthHeader. */ + String BASICAUTHHEADER = "BasicAuthHeader"; + } + + /** Builder. */ + public static class Builder { + private String tokenUrl; + private String refreshUrl; + private String clientAuthType; + private String contentType; + private String headerPrefix; + + /** + * Instantiates a new Builder from an existing + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials instance. + * + * @param providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials the + * instance to initialize the Builder with + */ + public Builder( + ProviderAuthenticationOAuth2Flows + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials) { + this.tokenUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials.tokenUrl; + this.refreshUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials.refreshUrl; + this.clientAuthType = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + .clientAuthType; + this.contentType = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + .contentType; + this.headerPrefix = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + .headerPrefix; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials. + * + * @return the new + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials instance + */ + public ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials build() { + return new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials( + this); + } + + /** + * Set the tokenUrl. + * + * @param tokenUrl the tokenUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder tokenUrl(String tokenUrl) { + this.tokenUrl = tokenUrl; + return this; + } + + /** + * Set the refreshUrl. + * + * @param refreshUrl the refreshUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder refreshUrl(String refreshUrl) { + this.refreshUrl = refreshUrl; + return this; + } + + /** + * Set the clientAuthType. + * + * @param clientAuthType the clientAuthType + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder clientAuthType(String clientAuthType) { + this.clientAuthType = clientAuthType; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the headerPrefix. + * + * @param headerPrefix the headerPrefix + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder headerPrefix(String headerPrefix) { + this.headerPrefix = headerPrefix; + return this; + } + } + + protected ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials() {} + + protected ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials( + Builder builder) { + tokenUrl = builder.tokenUrl; + refreshUrl = builder.refreshUrl; + clientAuthType = builder.clientAuthType; + contentType = builder.contentType; + headerPrefix = builder.headerPrefix; + } + + /** + * New builder. + * + * @return a ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.java new file mode 100644 index 00000000000..ea2133b60f4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.java @@ -0,0 +1,160 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** Non-private authentication settings for resource owner password flow. */ +public class ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + extends ProviderAuthenticationOAuth2Flows { + + /** The client authorization type. */ + public interface ClientAuthType { + /** Body. */ + String BODY = "Body"; + /** BasicAuthHeader. */ + String BASICAUTHHEADER = "BasicAuthHeader"; + } + + /** Builder. */ + public static class Builder { + private String tokenUrl; + private String refreshUrl; + private String clientAuthType; + private String contentType; + private String headerPrefix; + private ProviderAuthenticationOAuth2PasswordUsername username; + + /** + * Instantiates a new Builder from an existing + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password instance. + * + * @param providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password the instance to + * initialize the Builder with + */ + public Builder( + ProviderAuthenticationOAuth2Flows + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password) { + this.tokenUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.tokenUrl; + this.refreshUrl = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.refreshUrl; + this.clientAuthType = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.clientAuthType; + this.contentType = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.contentType; + this.headerPrefix = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.headerPrefix; + this.username = + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.username; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password. + * + * @return the new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + * instance + */ + public ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password build() { + return new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password(this); + } + + /** + * Set the tokenUrl. + * + * @param tokenUrl the tokenUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder tokenUrl(String tokenUrl) { + this.tokenUrl = tokenUrl; + return this; + } + + /** + * Set the refreshUrl. + * + * @param refreshUrl the refreshUrl + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder refreshUrl(String refreshUrl) { + this.refreshUrl = refreshUrl; + return this; + } + + /** + * Set the clientAuthType. + * + * @param clientAuthType the clientAuthType + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder clientAuthType(String clientAuthType) { + this.clientAuthType = clientAuthType; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the headerPrefix. + * + * @param headerPrefix the headerPrefix + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder headerPrefix(String headerPrefix) { + this.headerPrefix = headerPrefix; + return this; + } + + /** + * Set the username. + * + * @param username the username + * @return the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder username(ProviderAuthenticationOAuth2PasswordUsername username) { + this.username = username; + return this; + } + } + + protected ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password() {} + + protected ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password(Builder builder) { + tokenUrl = builder.tokenUrl; + refreshUrl = builder.refreshUrl; + clientAuthType = builder.clientAuthType; + contentType = builder.contentType; + headerPrefix = builder.headerPrefix; + username = builder.username; + } + + /** + * New builder. + * + * @return a ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2PasswordUsername.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2PasswordUsername.java new file mode 100644 index 00000000000..787ff4f82e1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2PasswordUsername.java @@ -0,0 +1,120 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The username for oauth2 authentication when the preferred flow is "password". */ +public class ProviderAuthenticationOAuth2PasswordUsername extends GenericModel { + + /** The type of property observed in "value". */ + public interface Type { + /** value. */ + String VALUE = "value"; + } + + protected String type; + protected String value; + + /** Builder. */ + public static class Builder { + private String type; + private String value; + + /** + * Instantiates a new Builder from an existing ProviderAuthenticationOAuth2PasswordUsername + * instance. + * + * @param providerAuthenticationOAuth2PasswordUsername the instance to initialize the Builder + * with + */ + private Builder( + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsername) { + this.type = providerAuthenticationOAuth2PasswordUsername.type; + this.value = providerAuthenticationOAuth2PasswordUsername.value; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderAuthenticationOAuth2PasswordUsername. + * + * @return the new ProviderAuthenticationOAuth2PasswordUsername instance + */ + public ProviderAuthenticationOAuth2PasswordUsername build() { + return new ProviderAuthenticationOAuth2PasswordUsername(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the ProviderAuthenticationOAuth2PasswordUsername builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the ProviderAuthenticationOAuth2PasswordUsername builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + } + + protected ProviderAuthenticationOAuth2PasswordUsername() {} + + protected ProviderAuthenticationOAuth2PasswordUsername(Builder builder) { + type = builder.type; + value = builder.value; + } + + /** + * New builder. + * + * @return a ProviderAuthenticationOAuth2PasswordUsername builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + *

The type of property observed in "value". + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the value. + * + *

The stored information of the value. + * + * @return the value + */ + public String value() { + return value; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationTypeAndValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationTypeAndValue.java new file mode 100644 index 00000000000..ab74a9f0fbb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationTypeAndValue.java @@ -0,0 +1,117 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ProviderAuthenticationTypeAndValue. */ +public class ProviderAuthenticationTypeAndValue extends GenericModel { + + /** The type of property observed in "value". */ + public interface Type { + /** value. */ + String VALUE = "value"; + } + + protected String type; + protected String value; + + /** Builder. */ + public static class Builder { + private String type; + private String value; + + /** + * Instantiates a new Builder from an existing ProviderAuthenticationTypeAndValue instance. + * + * @param providerAuthenticationTypeAndValue the instance to initialize the Builder with + */ + private Builder(ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValue) { + this.type = providerAuthenticationTypeAndValue.type; + this.value = providerAuthenticationTypeAndValue.value; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderAuthenticationTypeAndValue. + * + * @return the new ProviderAuthenticationTypeAndValue instance + */ + public ProviderAuthenticationTypeAndValue build() { + return new ProviderAuthenticationTypeAndValue(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the ProviderAuthenticationTypeAndValue builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the ProviderAuthenticationTypeAndValue builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + } + + protected ProviderAuthenticationTypeAndValue() {} + + protected ProviderAuthenticationTypeAndValue(Builder builder) { + type = builder.type; + value = builder.value; + } + + /** + * New builder. + * + * @return a ProviderAuthenticationTypeAndValue builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + *

The type of property observed in "value". + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the value. + * + *

The stored information of the value. + * + * @return the value + */ + public String value() { + return value; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderCollection.java new file mode 100644 index 00000000000..f7b90e6e949 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderCollection.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** ProviderCollection. */ +public class ProviderCollection extends GenericModel { + + @SerializedName("conversational_skill_providers") + protected List conversationalSkillProviders; + + protected Pagination pagination; + + protected ProviderCollection() {} + + /** + * Gets the conversationalSkillProviders. + * + *

An array of objects describing the conversational skill providers associated with the + * instance. + * + * @return the conversationalSkillProviders + */ + public List getConversationalSkillProviders() { + return conversationalSkillProviders; + } + + /** + * Gets the pagination. + * + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). + * + * @return the pagination + */ + public Pagination getPagination() { + return pagination; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivate.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivate.java new file mode 100644 index 00000000000..ef650939786 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivate.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Private information of the provider. */ +public class ProviderPrivate extends GenericModel { + + protected ProviderPrivateAuthentication authentication; + + /** Builder. */ + public static class Builder { + private ProviderPrivateAuthentication authentication; + + /** + * Instantiates a new Builder from an existing ProviderPrivate instance. + * + * @param providerPrivate the instance to initialize the Builder with + */ + private Builder(ProviderPrivate providerPrivate) { + this.authentication = providerPrivate.authentication; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param authentication the authentication + */ + public Builder(ProviderPrivateAuthentication authentication) { + this.authentication = authentication; + } + + /** + * Builds a ProviderPrivate. + * + * @return the new ProviderPrivate instance + */ + public ProviderPrivate build() { + return new ProviderPrivate(this); + } + + /** + * Set the authentication. + * + * @param authentication the authentication + * @return the ProviderPrivate builder + */ + public Builder authentication(ProviderPrivateAuthentication authentication) { + this.authentication = authentication; + return this; + } + } + + protected ProviderPrivate() {} + + protected ProviderPrivate(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.authentication, "authentication cannot be null"); + authentication = builder.authentication; + } + + /** + * New builder. + * + * @return a ProviderPrivate builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the authentication. + * + *

Private authentication information of the provider. + * + * @return the authentication + */ + public ProviderPrivateAuthentication authentication() { + return authentication; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthentication.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthentication.java new file mode 100644 index 00000000000..ccc23d2f4c5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthentication.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Private authentication information of the provider. + * + *

Classes which extend this class: - ProviderPrivateAuthenticationBearerFlow - + * ProviderPrivateAuthenticationBasicFlow - ProviderPrivateAuthenticationOAuth2Flow + */ +public class ProviderPrivateAuthentication extends GenericModel { + + protected ProviderAuthenticationTypeAndValue token; + protected ProviderAuthenticationTypeAndValue password; + protected ProviderPrivateAuthenticationOAuth2FlowFlows flows; + + protected ProviderPrivateAuthentication() {} + + /** + * Gets the token. + * + *

The token for bearer authentication. + * + * @return the token + */ + public ProviderAuthenticationTypeAndValue token() { + return token; + } + + /** + * Gets the password. + * + *

The password for bearer authentication. + * + * @return the password + */ + public ProviderAuthenticationTypeAndValue password() { + return password; + } + + /** + * Gets the flows. + * + *

Scenarios performed by the API client to fetch an access token from the authorization + * server. + * + * @return the flows + */ + public ProviderPrivateAuthenticationOAuth2FlowFlows flows() { + return flows; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBasicFlow.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBasicFlow.java new file mode 100644 index 00000000000..1dd3fdc0272 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBasicFlow.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** The private data for basic authentication. */ +public class ProviderPrivateAuthenticationBasicFlow extends ProviderPrivateAuthentication { + + /** Builder. */ + public static class Builder { + private ProviderAuthenticationTypeAndValue password; + + /** + * Instantiates a new Builder from an existing ProviderPrivateAuthenticationBasicFlow instance. + * + * @param providerPrivateAuthenticationBasicFlow the instance to initialize the Builder with + */ + public Builder(ProviderPrivateAuthentication providerPrivateAuthenticationBasicFlow) { + this.password = providerPrivateAuthenticationBasicFlow.password; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderPrivateAuthenticationBasicFlow. + * + * @return the new ProviderPrivateAuthenticationBasicFlow instance + */ + public ProviderPrivateAuthenticationBasicFlow build() { + return new ProviderPrivateAuthenticationBasicFlow(this); + } + + /** + * Set the password. + * + * @param password the password + * @return the ProviderPrivateAuthenticationBasicFlow builder + */ + public Builder password(ProviderAuthenticationTypeAndValue password) { + this.password = password; + return this; + } + } + + protected ProviderPrivateAuthenticationBasicFlow() {} + + protected ProviderPrivateAuthenticationBasicFlow(Builder builder) { + password = builder.password; + } + + /** + * New builder. + * + * @return a ProviderPrivateAuthenticationBasicFlow builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBearerFlow.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBearerFlow.java new file mode 100644 index 00000000000..5933c815f5a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBearerFlow.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** The private data for bearer authentication. */ +public class ProviderPrivateAuthenticationBearerFlow extends ProviderPrivateAuthentication { + + /** Builder. */ + public static class Builder { + private ProviderAuthenticationTypeAndValue token; + + /** + * Instantiates a new Builder from an existing ProviderPrivateAuthenticationBearerFlow instance. + * + * @param providerPrivateAuthenticationBearerFlow the instance to initialize the Builder with + */ + public Builder(ProviderPrivateAuthentication providerPrivateAuthenticationBearerFlow) { + this.token = providerPrivateAuthenticationBearerFlow.token; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderPrivateAuthenticationBearerFlow. + * + * @return the new ProviderPrivateAuthenticationBearerFlow instance + */ + public ProviderPrivateAuthenticationBearerFlow build() { + return new ProviderPrivateAuthenticationBearerFlow(this); + } + + /** + * Set the token. + * + * @param token the token + * @return the ProviderPrivateAuthenticationBearerFlow builder + */ + public Builder token(ProviderAuthenticationTypeAndValue token) { + this.token = token; + return this; + } + } + + protected ProviderPrivateAuthenticationBearerFlow() {} + + protected ProviderPrivateAuthenticationBearerFlow(Builder builder) { + token = builder.token; + } + + /** + * New builder. + * + * @return a ProviderPrivateAuthenticationBearerFlow builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2Flow.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2Flow.java new file mode 100644 index 00000000000..2d45b3cb906 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2Flow.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** The private data for oauth2 authentication. */ +public class ProviderPrivateAuthenticationOAuth2Flow extends ProviderPrivateAuthentication { + + /** Builder. */ + public static class Builder { + private ProviderPrivateAuthenticationOAuth2FlowFlows flows; + + /** + * Instantiates a new Builder from an existing ProviderPrivateAuthenticationOAuth2Flow instance. + * + * @param providerPrivateAuthenticationOAuth2Flow the instance to initialize the Builder with + */ + public Builder(ProviderPrivateAuthentication providerPrivateAuthenticationOAuth2Flow) { + this.flows = providerPrivateAuthenticationOAuth2Flow.flows; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderPrivateAuthenticationOAuth2Flow. + * + * @return the new ProviderPrivateAuthenticationOAuth2Flow instance + */ + public ProviderPrivateAuthenticationOAuth2Flow build() { + return new ProviderPrivateAuthenticationOAuth2Flow(this); + } + + /** + * Set the flows. + * + * @param flows the flows + * @return the ProviderPrivateAuthenticationOAuth2Flow builder + */ + public Builder flows(ProviderPrivateAuthenticationOAuth2FlowFlows flows) { + this.flows = flows; + return this; + } + } + + protected ProviderPrivateAuthenticationOAuth2Flow() {} + + protected ProviderPrivateAuthenticationOAuth2Flow(Builder builder) { + flows = builder.flows; + } + + /** + * New builder. + * + * @return a ProviderPrivateAuthenticationOAuth2Flow builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlows.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlows.java new file mode 100644 index 00000000000..540d0eeef0d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlows.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Scenarios performed by the API client to fetch an access token from the authorization server. + * + *

Classes which extend this class: - + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password - + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * - + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + */ +public class ProviderPrivateAuthenticationOAuth2FlowFlows extends GenericModel { + + @SerializedName("client_id") + protected String clientId; + + @SerializedName("client_secret") + protected String clientSecret; + + @SerializedName("access_token") + protected String accessToken; + + @SerializedName("refresh_token") + protected String refreshToken; + + protected ProviderPrivateAuthenticationOAuth2PasswordPassword password; + + @SerializedName("authorization_code") + protected String authorizationCode; + + protected ProviderPrivateAuthenticationOAuth2FlowFlows() {} + + /** + * Gets the clientId. + * + *

The client ID. + * + * @return the clientId + */ + public String clientId() { + return clientId; + } + + /** + * Gets the clientSecret. + * + *

The client secret. + * + * @return the clientSecret + */ + public String clientSecret() { + return clientSecret; + } + + /** + * Gets the accessToken. + * + *

The access token. + * + * @return the accessToken + */ + public String accessToken() { + return accessToken; + } + + /** + * Gets the refreshToken. + * + *

The refresh token. + * + * @return the refreshToken + */ + public String refreshToken() { + return refreshToken; + } + + /** + * Gets the password. + * + *

The password for oauth2 authentication when the preferred flow is "password". + * + * @return the password + */ + public ProviderPrivateAuthenticationOAuth2PasswordPassword password() { + return password; + } + + /** + * Gets the authorizationCode. + * + *

The authorization code. + * + * @return the authorizationCode + */ + public String authorizationCode() { + return authorizationCode; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode.java new file mode 100644 index 00000000000..876c3138452 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** Private authentication settings for client credentials flow. */ +public +class ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + extends ProviderPrivateAuthenticationOAuth2FlowFlows { + + /** Builder. */ + public static class Builder { + private String clientId; + private String clientSecret; + private String accessToken; + private String refreshToken; + private String authorizationCode; + + /** + * Instantiates a new Builder from an existing + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * instance. + * + * @param + * providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * the instance to initialize the Builder with + */ + public Builder( + ProviderPrivateAuthenticationOAuth2FlowFlows + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode) { + this.clientId = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .clientId; + this.clientSecret = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .clientSecret; + this.accessToken = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .accessToken; + this.refreshToken = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .refreshToken; + this.authorizationCode = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .authorizationCode; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode. + * + * @return the new + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * instance + */ + public + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + build() { + return new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode( + this); + } + + /** + * Set the clientId. + * + * @param clientId the clientId + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder clientId(String clientId) { + this.clientId = clientId; + return this; + } + + /** + * Set the clientSecret. + * + * @param clientSecret the clientSecret + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder clientSecret(String clientSecret) { + this.clientSecret = clientSecret; + return this; + } + + /** + * Set the accessToken. + * + * @param accessToken the accessToken + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder accessToken(String accessToken) { + this.accessToken = accessToken; + return this; + } + + /** + * Set the refreshToken. + * + * @param refreshToken the refreshToken + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder refreshToken(String refreshToken) { + this.refreshToken = refreshToken; + return this; + } + + /** + * Set the authorizationCode. + * + * @param authorizationCode the authorizationCode + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder authorizationCode(String authorizationCode) { + this.authorizationCode = authorizationCode; + return this; + } + } + + protected + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode() {} + + protected + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode( + Builder builder) { + clientId = builder.clientId; + clientSecret = builder.clientSecret; + accessToken = builder.accessToken; + refreshToken = builder.refreshToken; + authorizationCode = builder.authorizationCode; + } + + /** + * New builder. + * + * @return a + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials.java new file mode 100644 index 00000000000..ad273689af1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials.java @@ -0,0 +1,149 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials. + */ +public +class ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + extends ProviderPrivateAuthenticationOAuth2FlowFlows { + + /** Builder. */ + public static class Builder { + private String clientId; + private String clientSecret; + private String accessToken; + private String refreshToken; + + /** + * Instantiates a new Builder from an existing + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * instance. + * + * @param + * providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * the instance to initialize the Builder with + */ + public Builder( + ProviderPrivateAuthenticationOAuth2FlowFlows + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials) { + this.clientId = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + .clientId; + this.clientSecret = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + .clientSecret; + this.accessToken = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + .accessToken; + this.refreshToken = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + .refreshToken; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials. + * + * @return the new + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * instance + */ + public + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + build() { + return new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials( + this); + } + + /** + * Set the clientId. + * + * @param clientId the clientId + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder clientId(String clientId) { + this.clientId = clientId; + return this; + } + + /** + * Set the clientSecret. + * + * @param clientSecret the clientSecret + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder clientSecret(String clientSecret) { + this.clientSecret = clientSecret; + return this; + } + + /** + * Set the accessToken. + * + * @param accessToken the accessToken + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder accessToken(String accessToken) { + this.accessToken = accessToken; + return this; + } + + /** + * Set the refreshToken. + * + * @param refreshToken the refreshToken + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder refreshToken(String refreshToken) { + this.refreshToken = refreshToken; + return this; + } + } + + protected + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials() {} + + protected + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials( + Builder builder) { + clientId = builder.clientId; + clientSecret = builder.clientSecret; + accessToken = builder.accessToken; + refreshToken = builder.refreshToken; + } + + /** + * New builder. + * + * @return a + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password.java new file mode 100644 index 00000000000..70c5031d22d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password.java @@ -0,0 +1,162 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +/** Private authentication settings for resource owner password flow. */ +public class ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + extends ProviderPrivateAuthenticationOAuth2FlowFlows { + + /** Builder. */ + public static class Builder { + private String clientId; + private String clientSecret; + private String accessToken; + private String refreshToken; + private ProviderPrivateAuthenticationOAuth2PasswordPassword password; + + /** + * Instantiates a new Builder from an existing + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * instance. + * + * @param + * providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * the instance to initialize the Builder with + */ + public Builder( + ProviderPrivateAuthenticationOAuth2FlowFlows + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password) { + this.clientId = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .clientId; + this.clientSecret = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .clientSecret; + this.accessToken = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .accessToken; + this.refreshToken = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .refreshToken; + this.password = + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .password; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password. + * + * @return the new + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * instance + */ + public ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + build() { + return new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password( + this); + } + + /** + * Set the clientId. + * + * @param clientId the clientId + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * builder + */ + public Builder clientId(String clientId) { + this.clientId = clientId; + return this; + } + + /** + * Set the clientSecret. + * + * @param clientSecret the clientSecret + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * builder + */ + public Builder clientSecret(String clientSecret) { + this.clientSecret = clientSecret; + return this; + } + + /** + * Set the accessToken. + * + * @param accessToken the accessToken + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * builder + */ + public Builder accessToken(String accessToken) { + this.accessToken = accessToken; + return this; + } + + /** + * Set the refreshToken. + * + * @param refreshToken the refreshToken + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * builder + */ + public Builder refreshToken(String refreshToken) { + this.refreshToken = refreshToken; + return this; + } + + /** + * Set the password. + * + * @param password the password + * @return the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * builder + */ + public Builder password(ProviderPrivateAuthenticationOAuth2PasswordPassword password) { + this.password = password; + return this; + } + } + + protected + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password() {} + + protected ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password( + Builder builder) { + clientId = builder.clientId; + clientSecret = builder.clientSecret; + accessToken = builder.accessToken; + refreshToken = builder.refreshToken; + password = builder.password; + } + + /** + * New builder. + * + * @return a + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + * builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2PasswordPassword.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2PasswordPassword.java new file mode 100644 index 00000000000..d2ced7cb911 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2PasswordPassword.java @@ -0,0 +1,121 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The password for oauth2 authentication when the preferred flow is "password". */ +public class ProviderPrivateAuthenticationOAuth2PasswordPassword extends GenericModel { + + /** The type of property observed in "value". */ + public interface Type { + /** value. */ + String VALUE = "value"; + } + + protected String type; + protected String value; + + /** Builder. */ + public static class Builder { + private String type; + private String value; + + /** + * Instantiates a new Builder from an existing + * ProviderPrivateAuthenticationOAuth2PasswordPassword instance. + * + * @param providerPrivateAuthenticationOAuth2PasswordPassword the instance to initialize the + * Builder with + */ + private Builder( + ProviderPrivateAuthenticationOAuth2PasswordPassword + providerPrivateAuthenticationOAuth2PasswordPassword) { + this.type = providerPrivateAuthenticationOAuth2PasswordPassword.type; + this.value = providerPrivateAuthenticationOAuth2PasswordPassword.value; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderPrivateAuthenticationOAuth2PasswordPassword. + * + * @return the new ProviderPrivateAuthenticationOAuth2PasswordPassword instance + */ + public ProviderPrivateAuthenticationOAuth2PasswordPassword build() { + return new ProviderPrivateAuthenticationOAuth2PasswordPassword(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the ProviderPrivateAuthenticationOAuth2PasswordPassword builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the ProviderPrivateAuthenticationOAuth2PasswordPassword builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + } + + protected ProviderPrivateAuthenticationOAuth2PasswordPassword() {} + + protected ProviderPrivateAuthenticationOAuth2PasswordPassword(Builder builder) { + type = builder.type; + value = builder.value; + } + + /** + * New builder. + * + * @return a ProviderPrivateAuthenticationOAuth2PasswordPassword builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + *

The type of property observed in "value". + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the value. + * + *

The stored information of the value. + * + * @return the value + */ + public String value() { + return value; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponse.java new file mode 100644 index 00000000000..3ae192e88fe --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponse.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ProviderResponse. */ +public class ProviderResponse extends GenericModel { + + @SerializedName("provider_id") + protected String providerId; + + protected ProviderResponseSpecification specification; + + protected ProviderResponse() {} + + /** + * Gets the providerId. + * + *

The unique identifier of the provider. + * + * @return the providerId + */ + public String getProviderId() { + return providerId; + } + + /** + * Gets the specification. + * + *

The specification of the provider. + * + * @return the specification + */ + public ProviderResponseSpecification getSpecification() { + return specification; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecification.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecification.java new file mode 100644 index 00000000000..45e497da7f3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecification.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** The specification of the provider. */ +public class ProviderResponseSpecification extends GenericModel { + + protected List servers; + protected ProviderResponseSpecificationComponents components; + + protected ProviderResponseSpecification() {} + + /** + * Gets the servers. + * + *

An array of objects defining all endpoints of the provider. + * + *

**Note:** Multiple array items are reserved for future use. + * + * @return the servers + */ + public List getServers() { + return servers; + } + + /** + * Gets the components. + * + *

An object defining various reusable definitions of the provider. + * + * @return the components + */ + public ProviderResponseSpecificationComponents getComponents() { + return components; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponents.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponents.java new file mode 100644 index 00000000000..75c886cd237 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponents.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object defining various reusable definitions of the provider. */ +public class ProviderResponseSpecificationComponents extends GenericModel { + + protected ProviderResponseSpecificationComponentsSecuritySchemes securitySchemes; + + protected ProviderResponseSpecificationComponents() {} + + /** + * Gets the securitySchemes. + * + *

The definition of the security scheme for the provider. + * + * @return the securitySchemes + */ + public ProviderResponseSpecificationComponentsSecuritySchemes getSecuritySchemes() { + return securitySchemes; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemes.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemes.java new file mode 100644 index 00000000000..f7d5c1133b4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemes.java @@ -0,0 +1,80 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The definition of the security scheme for the provider. */ +public class ProviderResponseSpecificationComponentsSecuritySchemes extends GenericModel { + + /** + * The authentication method required for requests made from watsonx Assistant to the + * conversational skill provider. + */ + public interface AuthenticationMethod { + /** basic. */ + String BASIC = "basic"; + /** bearer. */ + String BEARER = "bearer"; + /** api_key. */ + String API_KEY = "api_key"; + /** oauth2. */ + String OAUTH2 = "oauth2"; + /** none. */ + String NONE = "none"; + } + + @SerializedName("authentication_method") + protected String authenticationMethod; + + protected ProviderResponseSpecificationComponentsSecuritySchemesBasic basic; + protected ProviderAuthenticationOAuth2 oauth2; + + protected ProviderResponseSpecificationComponentsSecuritySchemes() {} + + /** + * Gets the authenticationMethod. + * + *

The authentication method required for requests made from watsonx Assistant to the + * conversational skill provider. + * + * @return the authenticationMethod + */ + public String getAuthenticationMethod() { + return authenticationMethod; + } + + /** + * Gets the basic. + * + *

Non-private settings for basic access authentication. + * + * @return the basic + */ + public ProviderResponseSpecificationComponentsSecuritySchemesBasic getBasic() { + return basic; + } + + /** + * Gets the oauth2. + * + *

Non-private settings for oauth2 authentication. + * + * @return the oauth2 + */ + public ProviderAuthenticationOAuth2 getOauth2() { + return oauth2; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesBasic.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesBasic.java new file mode 100644 index 00000000000..1e9f36be757 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesBasic.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Non-private settings for basic access authentication. */ +public class ProviderResponseSpecificationComponentsSecuritySchemesBasic extends GenericModel { + + protected ProviderAuthenticationTypeAndValue username; + + protected ProviderResponseSpecificationComponentsSecuritySchemesBasic() {} + + /** + * Gets the username. + * + *

The username for basic access authentication. + * + * @return the username + */ + public ProviderAuthenticationTypeAndValue getUsername() { + return username; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationServersItem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationServersItem.java new file mode 100644 index 00000000000..71b5ac1151b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationServersItem.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ProviderResponseSpecificationServersItem. */ +public class ProviderResponseSpecificationServersItem extends GenericModel { + + protected String url; + + protected ProviderResponseSpecificationServersItem() {} + + /** + * Gets the url. + * + *

The URL of the conversational skill provider. + * + * @return the url + */ + public String getUrl() { + return url; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecification.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecification.java new file mode 100644 index 00000000000..21afa8cfb28 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecification.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The specification of the provider. */ +public class ProviderSpecification extends GenericModel { + + protected List servers; + protected ProviderSpecificationComponents components; + + /** Builder. */ + public static class Builder { + private List servers; + private ProviderSpecificationComponents components; + + /** + * Instantiates a new Builder from an existing ProviderSpecification instance. + * + * @param providerSpecification the instance to initialize the Builder with + */ + private Builder(ProviderSpecification providerSpecification) { + this.servers = providerSpecification.servers; + this.components = providerSpecification.components; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param servers the servers + */ + public Builder(List servers) { + this.servers = servers; + } + + /** + * Builds a ProviderSpecification. + * + * @return the new ProviderSpecification instance + */ + public ProviderSpecification build() { + return new ProviderSpecification(this); + } + + /** + * Adds a new element to servers. + * + * @param servers the new element to be added + * @return the ProviderSpecification builder + */ + public Builder addServers(ProviderSpecificationServersItem servers) { + com.ibm.cloud.sdk.core.util.Validator.notNull(servers, "servers cannot be null"); + if (this.servers == null) { + this.servers = new ArrayList(); + } + this.servers.add(servers); + return this; + } + + /** + * Set the servers. Existing servers will be replaced. + * + * @param servers the servers + * @return the ProviderSpecification builder + */ + public Builder servers(List servers) { + this.servers = servers; + return this; + } + + /** + * Set the components. + * + * @param components the components + * @return the ProviderSpecification builder + */ + public Builder components(ProviderSpecificationComponents components) { + this.components = components; + return this; + } + } + + protected ProviderSpecification() {} + + protected ProviderSpecification(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.servers, "servers cannot be null"); + servers = builder.servers; + components = builder.components; + } + + /** + * New builder. + * + * @return a ProviderSpecification builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the servers. + * + *

An array of objects defining all endpoints of the provider. + * + *

**Note:** Multiple array items are reserved for future use. + * + * @return the servers + */ + public List servers() { + return servers; + } + + /** + * Gets the components. + * + *

An object defining various reusable definitions of the provider. + * + * @return the components + */ + public ProviderSpecificationComponents components() { + return components; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponents.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponents.java new file mode 100644 index 00000000000..b82d934c83b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponents.java @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object defining various reusable definitions of the provider. */ +public class ProviderSpecificationComponents extends GenericModel { + + protected ProviderSpecificationComponentsSecuritySchemes securitySchemes; + + /** Builder. */ + public static class Builder { + private ProviderSpecificationComponentsSecuritySchemes securitySchemes; + + /** + * Instantiates a new Builder from an existing ProviderSpecificationComponents instance. + * + * @param providerSpecificationComponents the instance to initialize the Builder with + */ + private Builder(ProviderSpecificationComponents providerSpecificationComponents) { + this.securitySchemes = providerSpecificationComponents.securitySchemes; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderSpecificationComponents. + * + * @return the new ProviderSpecificationComponents instance + */ + public ProviderSpecificationComponents build() { + return new ProviderSpecificationComponents(this); + } + + /** + * Set the securitySchemes. + * + * @param securitySchemes the securitySchemes + * @return the ProviderSpecificationComponents builder + */ + public Builder securitySchemes(ProviderSpecificationComponentsSecuritySchemes securitySchemes) { + this.securitySchemes = securitySchemes; + return this; + } + } + + protected ProviderSpecificationComponents() {} + + protected ProviderSpecificationComponents(Builder builder) { + securitySchemes = builder.securitySchemes; + } + + /** + * New builder. + * + * @return a ProviderSpecificationComponents builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the securitySchemes. + * + *

The definition of the security scheme for the provider. + * + * @return the securitySchemes + */ + public ProviderSpecificationComponentsSecuritySchemes securitySchemes() { + return securitySchemes; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemes.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemes.java new file mode 100644 index 00000000000..e9e09460808 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemes.java @@ -0,0 +1,163 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The definition of the security scheme for the provider. */ +public class ProviderSpecificationComponentsSecuritySchemes extends GenericModel { + + /** + * The authentication method required for requests made from watsonx Assistant to the + * conversational skill provider. + */ + public interface AuthenticationMethod { + /** basic. */ + String BASIC = "basic"; + /** bearer. */ + String BEARER = "bearer"; + /** api_key. */ + String API_KEY = "api_key"; + /** oauth2. */ + String OAUTH2 = "oauth2"; + /** none. */ + String NONE = "none"; + } + + @SerializedName("authentication_method") + protected String authenticationMethod; + + protected ProviderSpecificationComponentsSecuritySchemesBasic basic; + protected ProviderAuthenticationOAuth2 oauth2; + + /** Builder. */ + public static class Builder { + private String authenticationMethod; + private ProviderSpecificationComponentsSecuritySchemesBasic basic; + private ProviderAuthenticationOAuth2 oauth2; + + /** + * Instantiates a new Builder from an existing ProviderSpecificationComponentsSecuritySchemes + * instance. + * + * @param providerSpecificationComponentsSecuritySchemes the instance to initialize the Builder + * with + */ + private Builder( + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemes) { + this.authenticationMethod = + providerSpecificationComponentsSecuritySchemes.authenticationMethod; + this.basic = providerSpecificationComponentsSecuritySchemes.basic; + this.oauth2 = providerSpecificationComponentsSecuritySchemes.oauth2; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderSpecificationComponentsSecuritySchemes. + * + * @return the new ProviderSpecificationComponentsSecuritySchemes instance + */ + public ProviderSpecificationComponentsSecuritySchemes build() { + return new ProviderSpecificationComponentsSecuritySchemes(this); + } + + /** + * Set the authenticationMethod. + * + * @param authenticationMethod the authenticationMethod + * @return the ProviderSpecificationComponentsSecuritySchemes builder + */ + public Builder authenticationMethod(String authenticationMethod) { + this.authenticationMethod = authenticationMethod; + return this; + } + + /** + * Set the basic. + * + * @param basic the basic + * @return the ProviderSpecificationComponentsSecuritySchemes builder + */ + public Builder basic(ProviderSpecificationComponentsSecuritySchemesBasic basic) { + this.basic = basic; + return this; + } + + /** + * Set the oauth2. + * + * @param oauth2 the oauth2 + * @return the ProviderSpecificationComponentsSecuritySchemes builder + */ + public Builder oauth2(ProviderAuthenticationOAuth2 oauth2) { + this.oauth2 = oauth2; + return this; + } + } + + protected ProviderSpecificationComponentsSecuritySchemes() {} + + protected ProviderSpecificationComponentsSecuritySchemes(Builder builder) { + authenticationMethod = builder.authenticationMethod; + basic = builder.basic; + oauth2 = builder.oauth2; + } + + /** + * New builder. + * + * @return a ProviderSpecificationComponentsSecuritySchemes builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the authenticationMethod. + * + *

The authentication method required for requests made from watsonx Assistant to the + * conversational skill provider. + * + * @return the authenticationMethod + */ + public String authenticationMethod() { + return authenticationMethod; + } + + /** + * Gets the basic. + * + *

Non-private settings for basic access authentication. + * + * @return the basic + */ + public ProviderSpecificationComponentsSecuritySchemesBasic basic() { + return basic; + } + + /** + * Gets the oauth2. + * + *

Non-private settings for oauth2 authentication. + * + * @return the oauth2 + */ + public ProviderAuthenticationOAuth2 oauth2() { + return oauth2; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesBasic.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesBasic.java new file mode 100644 index 00000000000..91ae68942d8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesBasic.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Non-private settings for basic access authentication. */ +public class ProviderSpecificationComponentsSecuritySchemesBasic extends GenericModel { + + protected ProviderAuthenticationTypeAndValue username; + + /** Builder. */ + public static class Builder { + private ProviderAuthenticationTypeAndValue username; + + /** + * Instantiates a new Builder from an existing + * ProviderSpecificationComponentsSecuritySchemesBasic instance. + * + * @param providerSpecificationComponentsSecuritySchemesBasic the instance to initialize the + * Builder with + */ + private Builder( + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasic) { + this.username = providerSpecificationComponentsSecuritySchemesBasic.username; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderSpecificationComponentsSecuritySchemesBasic. + * + * @return the new ProviderSpecificationComponentsSecuritySchemesBasic instance + */ + public ProviderSpecificationComponentsSecuritySchemesBasic build() { + return new ProviderSpecificationComponentsSecuritySchemesBasic(this); + } + + /** + * Set the username. + * + * @param username the username + * @return the ProviderSpecificationComponentsSecuritySchemesBasic builder + */ + public Builder username(ProviderAuthenticationTypeAndValue username) { + this.username = username; + return this; + } + } + + protected ProviderSpecificationComponentsSecuritySchemesBasic() {} + + protected ProviderSpecificationComponentsSecuritySchemesBasic(Builder builder) { + username = builder.username; + } + + /** + * New builder. + * + * @return a ProviderSpecificationComponentsSecuritySchemesBasic builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the username. + * + *

The username for basic access authentication. + * + * @return the username + */ + public ProviderAuthenticationTypeAndValue username() { + return username; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationServersItem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationServersItem.java new file mode 100644 index 00000000000..e8e98126681 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationServersItem.java @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ProviderSpecificationServersItem. */ +public class ProviderSpecificationServersItem extends GenericModel { + + protected String url; + + /** Builder. */ + public static class Builder { + private String url; + + /** + * Instantiates a new Builder from an existing ProviderSpecificationServersItem instance. + * + * @param providerSpecificationServersItem the instance to initialize the Builder with + */ + private Builder(ProviderSpecificationServersItem providerSpecificationServersItem) { + this.url = providerSpecificationServersItem.url; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ProviderSpecificationServersItem. + * + * @return the new ProviderSpecificationServersItem instance + */ + public ProviderSpecificationServersItem build() { + return new ProviderSpecificationServersItem(this); + } + + /** + * Set the url. + * + * @param url the url + * @return the ProviderSpecificationServersItem builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + } + + protected ProviderSpecificationServersItem() {} + + protected ProviderSpecificationServersItem(Builder builder) { + url = builder.url; + } + + /** + * New builder. + * + * @return a ProviderSpecificationServersItem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The URL of the conversational skill provider. + * + * @return the url + */ + public String url() { + return url; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Release.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Release.java new file mode 100644 index 00000000000..38c3a47b648 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Release.java @@ -0,0 +1,180 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; + +/** Release. */ +public class Release extends GenericModel { + + /** + * The current status of the release: - **Available**: The release is available for deployment. - + * **Failed**: An asynchronous publish operation has failed. - **Processing**: An asynchronous + * publish operation has not yet completed. + */ + public interface Status { + /** Available. */ + String AVAILABLE = "Available"; + /** Failed. */ + String FAILED = "Failed"; + /** Processing. */ + String PROCESSING = "Processing"; + } + + protected String release; + protected String description; + + @SerializedName("environment_references") + protected List environmentReferences; + + protected ReleaseContent content; + protected String status; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String description; + + /** + * Instantiates a new Builder from an existing Release instance. + * + * @param release the instance to initialize the Builder with + */ + private Builder(Release release) { + this.description = release.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a Release. + * + * @return the new Release instance + */ + public Release build() { + return new Release(this); + } + + /** + * Set the description. + * + * @param description the description + * @return the Release builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected Release() {} + + protected Release(Builder builder) { + description = builder.description; + } + + /** + * New builder. + * + * @return a Release builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the release. + * + *

The name of the release. The name is the version number (an integer), returned as a string. + * + * @return the release + */ + public String release() { + return release; + } + + /** + * Gets the description. + * + *

The description of the release. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the environmentReferences. + * + *

An array of objects describing the environments where this release has been deployed. + * + * @return the environmentReferences + */ + public List environmentReferences() { + return environmentReferences; + } + + /** + * Gets the content. + * + *

An object identifying the versionable content objects (such as skill snapshots) that are + * included in the release. + * + * @return the content + */ + public ReleaseContent content() { + return content; + } + + /** + * Gets the status. + * + *

The current status of the release: - **Available**: The release is available for deployment. + * - **Failed**: An asynchronous publish operation has failed. - **Processing**: An asynchronous + * publish operation has not yet completed. + * + * @return the status + */ + public String status() { + return status; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date created() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date updated() { + return updated; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseCollection.java new file mode 100644 index 00000000000..e9b6d0c371e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseCollection.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** ReleaseCollection. */ +public class ReleaseCollection extends GenericModel { + + protected List releases; + protected Pagination pagination; + + protected ReleaseCollection() {} + + /** + * Gets the releases. + * + *

An array of objects describing the releases associated with an assistant. + * + * @return the releases + */ + public List getReleases() { + return releases; + } + + /** + * Gets the pagination. + * + *

The pagination data for the returned objects. For more information about using pagination, + * see [Pagination](#pagination). + * + * @return the pagination + */ + public Pagination getPagination() { + return pagination; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseContent.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseContent.java new file mode 100644 index 00000000000..fd661543705 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseContent.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** + * An object identifying the versionable content objects (such as skill snapshots) that are included + * in the release. + */ +public class ReleaseContent extends GenericModel { + + protected List skills; + + /** Builder. */ + public static class Builder { + + /** + * Instantiates a new Builder from an existing ReleaseContent instance. + * + * @param releaseContent the instance to initialize the Builder with + */ + private Builder(ReleaseContent releaseContent) {} + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ReleaseContent. + * + * @return the new ReleaseContent instance + */ + public ReleaseContent build() { + return new ReleaseContent(this); + } + } + + protected ReleaseContent() {} + + protected ReleaseContent(Builder builder) {} + + /** + * New builder. + * + * @return a ReleaseContent builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the skills. + * + *

The skill snapshots that are included in the release. + * + * @return the skills + */ + public List skills() { + return skills; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseSkill.java new file mode 100644 index 00000000000..7901a0fb2ad --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseSkill.java @@ -0,0 +1,161 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ReleaseSkill. */ +public class ReleaseSkill extends GenericModel { + + /** The type of the skill. */ + public interface Type { + /** dialog. */ + String DIALOG = "dialog"; + /** action. */ + String ACTION = "action"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("skill_id") + protected String skillId; + + protected String type; + protected String snapshot; + + /** Builder. */ + public static class Builder { + private String skillId; + private String type; + private String snapshot; + + /** + * Instantiates a new Builder from an existing ReleaseSkill instance. + * + * @param releaseSkill the instance to initialize the Builder with + */ + private Builder(ReleaseSkill releaseSkill) { + this.skillId = releaseSkill.skillId; + this.type = releaseSkill.type; + this.snapshot = releaseSkill.snapshot; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param skillId the skillId + */ + public Builder(String skillId) { + this.skillId = skillId; + } + + /** + * Builds a ReleaseSkill. + * + * @return the new ReleaseSkill instance + */ + public ReleaseSkill build() { + return new ReleaseSkill(this); + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the ReleaseSkill builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the ReleaseSkill builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the snapshot. + * + * @param snapshot the snapshot + * @return the ReleaseSkill builder + */ + public Builder snapshot(String snapshot) { + this.snapshot = snapshot; + return this; + } + } + + protected ReleaseSkill() {} + + protected ReleaseSkill(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.skillId, "skillId cannot be null"); + skillId = builder.skillId; + type = builder.type; + snapshot = builder.snapshot; + } + + /** + * New builder. + * + * @return a ReleaseSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the type. + * + *

The type of the skill. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the snapshot. + * + *

The name of the skill snapshot that is saved as part of the release (for example, `draft` or + * `1`). + * + * @return the snapshot + */ + public String snapshot() { + return snapshot; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseSkillReference.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseSkillReference.java new file mode 100644 index 00000000000..2a956701c74 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ReleaseSkillReference.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ReleaseSkillReference. */ +public class ReleaseSkillReference extends GenericModel { + + /** The type of the skill. */ + public interface Type { + /** dialog. */ + String DIALOG = "dialog"; + /** action. */ + String ACTION = "action"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("skill_id") + protected String skillId; + + protected String type; + protected String snapshot; + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String getSkillId() { + return skillId; + } + + /** + * Gets the type. + * + *

The type of the skill. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the snapshot. + * + *

The name of the snapshot (skill version) that is saved as part of the release (for example, + * `draft` or `1`). + * + * @return the snapshot + */ + public String getSnapshot() { + return snapshot; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RequestAnalytics.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RequestAnalytics.java new file mode 100644 index 00000000000..0cc31f7a05f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RequestAnalytics.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An optional object containing analytics data. Currently, this data is used only for events sent + * to the Segment extension. + */ +public class RequestAnalytics extends GenericModel { + + protected String browser; + protected String device; + protected String pageUrl; + + /** Builder. */ + public static class Builder { + private String browser; + private String device; + private String pageUrl; + + /** + * Instantiates a new Builder from an existing RequestAnalytics instance. + * + * @param requestAnalytics the instance to initialize the Builder with + */ + private Builder(RequestAnalytics requestAnalytics) { + this.browser = requestAnalytics.browser; + this.device = requestAnalytics.device; + this.pageUrl = requestAnalytics.pageUrl; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a RequestAnalytics. + * + * @return the new RequestAnalytics instance + */ + public RequestAnalytics build() { + return new RequestAnalytics(this); + } + + /** + * Set the browser. + * + * @param browser the browser + * @return the RequestAnalytics builder + */ + public Builder browser(String browser) { + this.browser = browser; + return this; + } + + /** + * Set the device. + * + * @param device the device + * @return the RequestAnalytics builder + */ + public Builder device(String device) { + this.device = device; + return this; + } + + /** + * Set the pageUrl. + * + * @param pageUrl the pageUrl + * @return the RequestAnalytics builder + */ + public Builder pageUrl(String pageUrl) { + this.pageUrl = pageUrl; + return this; + } + } + + protected RequestAnalytics() {} + + protected RequestAnalytics(Builder builder) { + browser = builder.browser; + device = builder.device; + pageUrl = builder.pageUrl; + } + + /** + * New builder. + * + * @return a RequestAnalytics builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the browser. + * + *

The browser that was used to send the message that triggered the event. + * + * @return the browser + */ + public String browser() { + return browser; + } + + /** + * Gets the device. + * + *

The type of device that was used to send the message that triggered the event. + * + * @return the device + */ + public String device() { + return device; + } + + /** + * Gets the pageUrl. + * + *

The URL of the web page that was used to send the message that triggered the event. + * + * @return the pageUrl + */ + public String pageUrl() { + return pageUrl; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericChannel.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericChannel.java new file mode 100644 index 00000000000..8200a08ab32 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericChannel.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ResponseGenericChannel. */ +public class ResponseGenericChannel extends GenericModel { + + protected String channel; + + protected ResponseGenericChannel() {} + + /** + * Gets the channel. + * + *

A channel for which the response is intended. + * + * @return the channel + */ + public String getChannel() { + return channel; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitation.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitation.java new file mode 100644 index 00000000000..766852067a1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitation.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** ResponseGenericCitation. */ +public class ResponseGenericCitation extends GenericModel { + + protected String title; + protected String text; + protected String body; + + @SerializedName("search_result_index") + protected Long searchResultIndex; + + protected List ranges; + + protected ResponseGenericCitation() {} + + /** + * Gets the title. + * + *

The title of the citation text. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the text. + * + *

The text of the citation. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the body. + * + *

The body content of the citation. + * + * @return the body + */ + public String getBody() { + return body; + } + + /** + * Gets the searchResultIndex. + * + *

The index of the search_result where the citation is generated. + * + * @return the searchResultIndex + */ + public Long getSearchResultIndex() { + return searchResultIndex; + } + + /** + * Gets the ranges. + * + *

The offsets of the start and end of the citation in the generated response. For example, + * `ranges:[ { start:0, end:5 }, ...]`. + * + * @return the ranges + */ + public List getRanges() { + return ranges; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationRangesItem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationRangesItem.java new file mode 100644 index 00000000000..1e0cd874afe --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationRangesItem.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** ResponseGenericCitationRangesItem. */ +public class ResponseGenericCitationRangesItem extends GenericModel { + + protected Long start; + protected Long end; + + protected ResponseGenericCitationRangesItem() {} + + /** + * Gets the start. + * + *

The offset of the start of the citation in the generated response. + * + * @return the start + */ + public Long getStart() { + return start; + } + + /** + * Gets the end. + * + *

The offset of the end of the citation in the generated response. + * + * @return the end + */ + public Long getEnd() { + return end; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericConfidenceScores.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericConfidenceScores.java new file mode 100644 index 00000000000..fbc36a19f22 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ResponseGenericConfidenceScores.java @@ -0,0 +1,84 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The confidence scores for determining whether to show the generated response or an “I don't know” + * response. + */ +public class ResponseGenericConfidenceScores extends GenericModel { + + protected Double threshold; + + @SerializedName("pre_gen") + protected Double preGen; + + @SerializedName("post_gen") + protected Double postGen; + + protected Double extractiveness; + + protected ResponseGenericConfidenceScores() {} + + /** + * Gets the threshold. + * + *

The confidence score threshold. If either the pre_gen or post_gen score is below this + * threshold, it shows an “I don't know” response to replace the generated text. You can configure + * the threshold in either the user interface or through the Update skill API. For more + * information, see the [watsonx Assistant documentation]( + * https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-conversational-search#behavioral-tuning-conversational-search). + * + * @return the threshold + */ + public Double getThreshold() { + return threshold; + } + + /** + * Gets the preGen. + * + *

The confidence score based on user query and search results. + * + * @return the preGen + */ + public Double getPreGen() { + return preGen; + } + + /** + * Gets the postGen. + * + *

The confidence score based on user query, search results, and the generated response. + * + * @return the postGen + */ + public Double getPostGen() { + return postGen; + } + + /** + * Gets the extractiveness. + * + *

It indicates how extractive the generated response is from the search results. + * + * @return the extractiveness + */ + public Double getExtractiveness() { + return extractiveness; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java index 352eb5357a7..cd67fed6fea 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,92 +10,86 @@ * 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.assistant.v2.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import java.util.Map; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The entity value that was recognized in the user input. - */ +/** The entity value that was recognized in the user input. */ public class RuntimeEntity extends GenericModel { protected String entity; protected List location; protected String value; protected Double confidence; - protected Map metadata; protected List groups; protected RuntimeEntityInterpretation interpretation; protected List alternatives; protected RuntimeEntityRole role; + protected String skill; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String entity; private List location; private String value; private Double confidence; - private Map metadata; private List groups; private RuntimeEntityInterpretation interpretation; private List alternatives; private RuntimeEntityRole role; + private String skill; + /** + * Instantiates a new Builder from an existing RuntimeEntity instance. + * + * @param runtimeEntity the instance to initialize the Builder with + */ private Builder(RuntimeEntity runtimeEntity) { this.entity = runtimeEntity.entity; this.location = runtimeEntity.location; this.value = runtimeEntity.value; this.confidence = runtimeEntity.confidence; - this.metadata = runtimeEntity.metadata; this.groups = runtimeEntity.groups; this.interpretation = runtimeEntity.interpretation; this.alternatives = runtimeEntity.alternatives; this.role = runtimeEntity.role; + this.skill = runtimeEntity.skill; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param entity the entity - * @param location the location * @param value the value */ - public Builder(String entity, List location, String value) { + public Builder(String entity, String value) { this.entity = entity; - this.location = location; this.value = value; } /** * Builds a RuntimeEntity. * - * @return the runtimeEntity + * @return the new RuntimeEntity instance */ public RuntimeEntity build() { return new RuntimeEntity(this); } /** - * Adds an location to location. + * Adds a new element to location. * - * @param location the new location + * @param location the new element to be added * @return the RuntimeEntity builder */ public Builder addLocation(Long location) { - com.ibm.cloud.sdk.core.util.Validator.notNull(location, - "location cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(location, "location cannot be null"); if (this.location == null) { this.location = new ArrayList(); } @@ -104,14 +98,13 @@ public Builder addLocation(Long location) { } /** - * Adds an groups to groups. + * Adds a new element to groups. * - * @param groups the new groups + * @param groups the new element to be added * @return the RuntimeEntity builder */ public Builder addGroups(CaptureGroup groups) { - com.ibm.cloud.sdk.core.util.Validator.notNull(groups, - "groups cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(groups, "groups cannot be null"); if (this.groups == null) { this.groups = new ArrayList(); } @@ -120,14 +113,13 @@ public Builder addGroups(CaptureGroup groups) { } /** - * Adds an alternatives to alternatives. + * Adds a new element to alternatives. * - * @param alternatives the new alternatives + * @param alternatives the new element to be added * @return the RuntimeEntity builder */ public Builder addAlternatives(RuntimeEntityAlternative alternatives) { - com.ibm.cloud.sdk.core.util.Validator.notNull(alternatives, - "alternatives cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(alternatives, "alternatives cannot be null"); if (this.alternatives == null) { this.alternatives = new ArrayList(); } @@ -147,8 +139,7 @@ public Builder entity(String entity) { } /** - * Set the location. - * Existing location will be replaced. + * Set the location. Existing location will be replaced. * * @param location the location * @return the RuntimeEntity builder @@ -181,19 +172,7 @@ public Builder confidence(Double confidence) { } /** - * Set the metadata. - * - * @param metadata the metadata - * @return the RuntimeEntity builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the groups. - * Existing groups will be replaced. + * Set the groups. Existing groups will be replaced. * * @param groups the groups * @return the RuntimeEntity builder @@ -215,8 +194,7 @@ public Builder interpretation(RuntimeEntityInterpretation interpretation) { } /** - * Set the alternatives. - * Existing alternatives will be replaced. + * Set the alternatives. Existing alternatives will be replaced. * * @param alternatives the alternatives * @return the RuntimeEntity builder @@ -236,24 +214,33 @@ public Builder role(RuntimeEntityRole role) { this.role = role; return this; } + + /** + * Set the skill. + * + * @param skill the skill + * @return the RuntimeEntity builder + */ + public Builder skill(String skill) { + this.skill = skill; + return this; + } } + protected RuntimeEntity() {} + protected RuntimeEntity(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, - "entity cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.location, - "location cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, - "value cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.entity, "entity cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); entity = builder.entity; location = builder.location; value = builder.value; confidence = builder.confidence; - metadata = builder.metadata; groups = builder.groups; interpretation = builder.interpretation; alternatives = builder.alternatives; role = builder.role; + skill = builder.skill; } /** @@ -268,7 +255,7 @@ public Builder newBuilder() { /** * Gets the entity. * - * An entity detected in the input. + *

An entity detected in the input. * * @return the entity */ @@ -279,8 +266,8 @@ public String entity() { /** * Gets the location. * - * An array of zero-based character offsets that indicate where the detected entity values begin and end in the input - * text. + *

An array of zero-based character offsets that indicate where the detected entity values + * begin and end in the input text. * * @return the location */ @@ -291,7 +278,7 @@ public List location() { /** * Gets the value. * - * The term in the input text that was recognized as an entity value. + *

The term in the input text that was recognized as an entity value. * * @return the value */ @@ -302,7 +289,7 @@ public String value() { /** * Gets the confidence. * - * A decimal percentage that represents Watson's confidence in the recognized entity. + *

A decimal percentage that represents confidence in the recognized entity. * * @return the confidence */ @@ -310,21 +297,10 @@ public Double confidence() { return confidence; } - /** - * Gets the metadata. - * - * Any metadata for the entity. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - /** * Gets the groups. * - * The recognized capture groups for the entity, as defined by the entity pattern. + *

The recognized capture groups for the entity, as defined by the entity pattern. * * @return the groups */ @@ -335,10 +311,10 @@ public List groups() { /** * Gets the interpretation. * - * An object containing detailed information about the entity recognized in the user input. This property is included - * only if the new system entities are enabled for the skill. + *

An object containing detailed information about the entity recognized in the user input. + * This property is included only if the new system entities are enabled for the skill. * - * For more information about how the new system entities are interpreted, see the + *

For more information about how the new system entities are interpreted, see the * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities). * * @return the interpretation @@ -350,11 +326,11 @@ public RuntimeEntityInterpretation interpretation() { /** * Gets the alternatives. * - * An array of possible alternative values that the user might have intended instead of the value returned in the - * **value** property. This property is returned only for `@sys-time` and `@sys-date` entities when the user's input - * is ambiguous. + *

An array of possible alternative values that the user might have intended instead of the + * value returned in the **value** property. This property is returned only for `@sys-time` and + * `@sys-date` entities when the user's input is ambiguous. * - * This property is included only if the new system entities are enabled for the skill. + *

This property is included only if the new system entities are enabled for the skill. * * @return the alternatives */ @@ -365,12 +341,27 @@ public List alternatives() { /** * Gets the role. * - * An object describing the role played by a system entity that is specifies the beginning or end of a range - * recognized in the user input. This property is included only if the new system entities are enabled for the skill. + *

An object describing the role played by a system entity that is specifies the beginning or + * end of a range recognized in the user input. This property is included only if the new system + * entities are enabled for the skill. * * @return the role */ public RuntimeEntityRole role() { return role; } + + /** + * Gets the skill. + * + *

The skill that recognized the entity value. Currently, the only possible values are `main + * skill` for the dialog skill (if enabled) and `actions skill` for the action skill. + * + *

This property is present only if the assistant has both a dialog skill and an action skill. + * + * @return the skill + */ + public String skill() { + return skill; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java index 9e9589b9634..ea779fbe194 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2024. * * 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 @@ -10,40 +10,39 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An alternative value for the recognized entity. - */ +/** An alternative value for the recognized entity. */ public class RuntimeEntityAlternative extends GenericModel { protected String value; protected Double confidence; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String value; private Double confidence; + /** + * Instantiates a new Builder from an existing RuntimeEntityAlternative instance. + * + * @param runtimeEntityAlternative the instance to initialize the Builder with + */ private Builder(RuntimeEntityAlternative runtimeEntityAlternative) { this.value = runtimeEntityAlternative.value; this.confidence = runtimeEntityAlternative.confidence; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a RuntimeEntityAlternative. * - * @return the runtimeEntityAlternative + * @return the new RuntimeEntityAlternative instance */ public RuntimeEntityAlternative build() { return new RuntimeEntityAlternative(this); @@ -72,6 +71,8 @@ public Builder confidence(Double confidence) { } } + protected RuntimeEntityAlternative() {} + protected RuntimeEntityAlternative(Builder builder) { value = builder.value; confidence = builder.confidence; @@ -89,7 +90,7 @@ public Builder newBuilder() { /** * Gets the value. * - * The entity value that was recognized in the user input. + *

The entity value that was recognized in the user input. * * @return the value */ @@ -100,7 +101,7 @@ public String value() { /** * Gets the confidence. * - * A decimal percentage that represents Watson's confidence in the recognized entity. + *

A decimal percentage that represents confidence in the recognized entity. * * @return the confidence */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java index 37c1665b331..7b3c2ad64ea 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2024. * * 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 @@ -10,18 +10,18 @@ * 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.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * RuntimeEntityInterpretation. - */ +/** RuntimeEntityInterpretation. */ public class RuntimeEntityInterpretation extends GenericModel { /** - * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. + * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` + * entity. */ public interface Granularity { /** day. */ @@ -50,56 +50,78 @@ public interface Granularity { @SerializedName("calendar_type") protected String calendarType; + @SerializedName("datetime_link") protected String datetimeLink; + protected String festival; protected String granularity; + @SerializedName("range_link") protected String rangeLink; + @SerializedName("range_modifier") protected String rangeModifier; + @SerializedName("relative_day") protected Double relativeDay; + @SerializedName("relative_month") protected Double relativeMonth; + @SerializedName("relative_week") protected Double relativeWeek; + @SerializedName("relative_weekend") protected Double relativeWeekend; + @SerializedName("relative_year") protected Double relativeYear; + @SerializedName("specific_day") protected Double specificDay; + @SerializedName("specific_day_of_week") protected String specificDayOfWeek; + @SerializedName("specific_month") protected Double specificMonth; + @SerializedName("specific_quarter") protected Double specificQuarter; + @SerializedName("specific_year") protected Double specificYear; + @SerializedName("numeric_value") protected Double numericValue; + protected String subtype; + @SerializedName("part_of_day") protected String partOfDay; + @SerializedName("relative_hour") protected Double relativeHour; + @SerializedName("relative_minute") protected Double relativeMinute; + @SerializedName("relative_second") protected Double relativeSecond; + @SerializedName("specific_hour") protected Double specificHour; + @SerializedName("specific_minute") protected Double specificMinute; + @SerializedName("specific_second") protected Double specificSecond; + protected String timezone; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String calendarType; private String datetimeLink; @@ -128,6 +150,11 @@ public static class Builder { private Double specificSecond; private String timezone; + /** + * Instantiates a new Builder from an existing RuntimeEntityInterpretation instance. + * + * @param runtimeEntityInterpretation the instance to initialize the Builder with + */ private Builder(RuntimeEntityInterpretation runtimeEntityInterpretation) { this.calendarType = runtimeEntityInterpretation.calendarType; this.datetimeLink = runtimeEntityInterpretation.datetimeLink; @@ -157,16 +184,13 @@ private Builder(RuntimeEntityInterpretation runtimeEntityInterpretation) { this.timezone = runtimeEntityInterpretation.timezone; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a RuntimeEntityInterpretation. * - * @return the runtimeEntityInterpretation + * @return the new RuntimeEntityInterpretation instance */ public RuntimeEntityInterpretation build() { return new RuntimeEntityInterpretation(this); @@ -459,6 +483,8 @@ public Builder timezone(String timezone) { } } + protected RuntimeEntityInterpretation() {} + protected RuntimeEntityInterpretation(Builder builder) { calendarType = builder.calendarType; datetimeLink = builder.datetimeLink; @@ -500,7 +526,7 @@ public Builder newBuilder() { /** * Gets the calendarType. * - * The calendar used to represent a recognized date (for example, `Gregorian`). + *

The calendar used to represent a recognized date (for example, `Gregorian`). * * @return the calendarType */ @@ -511,9 +537,9 @@ public String calendarType() { /** * Gets the datetimeLink. * - * A unique identifier used to associate a recognized time and date. If the user input contains a date and time that - * are mentioned together (for example, `Today at 5`, the same **datetime_link** value is returned for both the - * `@sys-date` and `@sys-time` entities). + *

A unique identifier used to associate a recognized time and date. If the user input contains + * a date and time that are mentioned together (for example, `Today at 5`, the same + * **datetime_link** value is returned for both the `@sys-date` and `@sys-time` entities). * * @return the datetimeLink */ @@ -524,8 +550,8 @@ public String datetimeLink() { /** * Gets the festival. * - * A locale-specific holiday name (such as `thanksgiving` or `christmas`). This property is included when a - * `@sys-date` entity is recognized based on a holiday name in the user input. + *

A locale-specific holiday name (such as `thanksgiving` or `christmas`). This property is + * included when a `@sys-date` entity is recognized based on a holiday name in the user input. * * @return the festival */ @@ -536,7 +562,8 @@ public String festival() { /** * Gets the granularity. * - * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. + *

The precision or duration of a time range specified by a recognized `@sys-time` or + * `@sys-date` entity. * * @return the granularity */ @@ -547,9 +574,9 @@ public String granularity() { /** * Gets the rangeLink. * - * A unique identifier used to associate multiple recognized `@sys-date`, `@sys-time`, or `@sys-number` entities that - * are recognized as a range of values in the user's input (for example, `from July 4 until July 14` or `from 20 to - * 25`). + *

A unique identifier used to associate multiple recognized `@sys-date`, `@sys-time`, or + * `@sys-number` entities that are recognized as a range of values in the user's input (for + * example, `from July 4 until July 14` or `from 20 to 25`). * * @return the rangeLink */ @@ -560,8 +587,8 @@ public String rangeLink() { /** * Gets the rangeModifier. * - * The word in the user input that indicates that a `sys-date` or `sys-time` entity is part of an implied range where - * only one date or time is specified (for example, `since` or `until`). + *

The word in the user input that indicates that a `sys-date` or `sys-time` entity is part of + * an implied range where only one date or time is specified (for example, `since` or `until`). * * @return the rangeModifier */ @@ -572,8 +599,8 @@ public String rangeModifier() { /** * Gets the relativeDay. * - * A recognized mention of a relative day, represented numerically as an offset from the current date (for example, - * `-1` for `yesterday` or `10` for `in ten days`). + *

A recognized mention of a relative day, represented numerically as an offset from the + * current date (for example, `-1` for `yesterday` or `10` for `in ten days`). * * @return the relativeDay */ @@ -584,8 +611,8 @@ public Double relativeDay() { /** * Gets the relativeMonth. * - * A recognized mention of a relative month, represented numerically as an offset from the current month (for example, - * `1` for `next month` or `-3` for `three months ago`). + *

A recognized mention of a relative month, represented numerically as an offset from the + * current month (for example, `1` for `next month` or `-3` for `three months ago`). * * @return the relativeMonth */ @@ -596,8 +623,8 @@ public Double relativeMonth() { /** * Gets the relativeWeek. * - * A recognized mention of a relative week, represented numerically as an offset from the current week (for example, - * `2` for `in two weeks` or `-1` for `last week). + *

A recognized mention of a relative week, represented numerically as an offset from the + * current week (for example, `2` for `in two weeks` or `-1` for `last week). * * @return the relativeWeek */ @@ -608,8 +635,9 @@ public Double relativeWeek() { /** * Gets the relativeWeekend. * - * A recognized mention of a relative date range for a weekend, represented numerically as an offset from the current - * weekend (for example, `0` for `this weekend` or `-1` for `last weekend`). + *

A recognized mention of a relative date range for a weekend, represented numerically as an + * offset from the current weekend (for example, `0` for `this weekend` or `-1` for `last + * weekend`). * * @return the relativeWeekend */ @@ -620,8 +648,8 @@ public Double relativeWeekend() { /** * Gets the relativeYear. * - * A recognized mention of a relative year, represented numerically as an offset from the current year (for example, - * `1` for `next year` or `-5` for `five years ago`). + *

A recognized mention of a relative year, represented numerically as an offset from the + * current year (for example, `1` for `next year` or `-5` for `five years ago`). * * @return the relativeYear */ @@ -632,8 +660,8 @@ public Double relativeYear() { /** * Gets the specificDay. * - * A recognized mention of a specific date, represented numerically as the date within the month (for example, `30` - * for `June 30`.). + *

A recognized mention of a specific date, represented numerically as the date within the + * month (for example, `30` for `June 30`.). * * @return the specificDay */ @@ -644,7 +672,8 @@ public Double specificDay() { /** * Gets the specificDayOfWeek. * - * A recognized mention of a specific day of the week as a lowercase string (for example, `monday`). + *

A recognized mention of a specific day of the week as a lowercase string (for example, + * `monday`). * * @return the specificDayOfWeek */ @@ -655,7 +684,8 @@ public String specificDayOfWeek() { /** * Gets the specificMonth. * - * A recognized mention of a specific month, represented numerically (for example, `7` for `July`). + *

A recognized mention of a specific month, represented numerically (for example, `7` for + * `July`). * * @return the specificMonth */ @@ -666,7 +696,8 @@ public Double specificMonth() { /** * Gets the specificQuarter. * - * A recognized mention of a specific quarter, represented numerically (for example, `3` for `the third quarter`). + *

A recognized mention of a specific quarter, represented numerically (for example, `3` for + * `the third quarter`). * * @return the specificQuarter */ @@ -677,7 +708,7 @@ public Double specificQuarter() { /** * Gets the specificYear. * - * A recognized mention of a specific year (for example, `2016`). + *

A recognized mention of a specific year (for example, `2016`). * * @return the specificYear */ @@ -688,7 +719,7 @@ public Double specificYear() { /** * Gets the numericValue. * - * A recognized numeric value, represented as an integer or double. + *

A recognized numeric value, represented as an integer or double. * * @return the numericValue */ @@ -699,7 +730,7 @@ public Double numericValue() { /** * Gets the subtype. * - * The type of numeric value recognized in the user input (`integer` or `rational`). + *

The type of numeric value recognized in the user input (`integer` or `rational`). * * @return the subtype */ @@ -710,8 +741,8 @@ public String subtype() { /** * Gets the partOfDay. * - * A recognized term for a time that was mentioned as a part of the day in the user's input (for example, `morning` or - * `afternoon`). + *

A recognized term for a time that was mentioned as a part of the day in the user's input + * (for example, `morning` or `afternoon`). * * @return the partOfDay */ @@ -722,8 +753,8 @@ public String partOfDay() { /** * Gets the relativeHour. * - * A recognized mention of a relative hour, represented numerically as an offset from the current hour (for example, - * `3` for `in three hours` or `-1` for `an hour ago`). + *

A recognized mention of a relative hour, represented numerically as an offset from the + * current hour (for example, `3` for `in three hours` or `-1` for `an hour ago`). * * @return the relativeHour */ @@ -734,8 +765,9 @@ public Double relativeHour() { /** * Gets the relativeMinute. * - * A recognized mention of a relative time, represented numerically as an offset in minutes from the current time (for - * example, `5` for `in five minutes` or `-15` for `fifteen minutes ago`). + *

A recognized mention of a relative time, represented numerically as an offset in minutes + * from the current time (for example, `5` for `in five minutes` or `-15` for `fifteen minutes + * ago`). * * @return the relativeMinute */ @@ -746,8 +778,9 @@ public Double relativeMinute() { /** * Gets the relativeSecond. * - * A recognized mention of a relative time, represented numerically as an offset in seconds from the current time (for - * example, `10` for `in ten seconds` or `-30` for `thirty seconds ago`). + *

A recognized mention of a relative time, represented numerically as an offset in seconds + * from the current time (for example, `10` for `in ten seconds` or `-30` for `thirty seconds + * ago`). * * @return the relativeSecond */ @@ -758,7 +791,8 @@ public Double relativeSecond() { /** * Gets the specificHour. * - * A recognized specific hour mentioned as part of a time value (for example, `10` for `10:15 AM`.). + *

A recognized specific hour mentioned as part of a time value (for example, `10` for `10:15 + * AM`.). * * @return the specificHour */ @@ -769,7 +803,8 @@ public Double specificHour() { /** * Gets the specificMinute. * - * A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 AM`.). + *

A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 + * AM`.). * * @return the specificMinute */ @@ -780,7 +815,8 @@ public Double specificMinute() { /** * Gets the specificSecond. * - * A recognized specific second mentioned as part of a time value (for example, `30` for `10:15:30 AM`.). + *

A recognized specific second mentioned as part of a time value (for example, `30` for + * `10:15:30 AM`.). * * @return the specificSecond */ @@ -791,7 +827,7 @@ public Double specificSecond() { /** * Gets the timezone. * - * A recognized time zone mentioned as part of a time value (for example, `EST`). + *

A recognized time zone mentioned as part of a time value (for example, `EST`). * * @return the timezone */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java index ad86e0898d6..315978c8fd0 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2024. * * 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 @@ -10,19 +10,19 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An object describing the role played by a system entity that is specifies the beginning or end of a range recognized - * in the user input. This property is included only if the new system entities are enabled for the skill. + * An object describing the role played by a system entity that is specifies the beginning or end of + * a range recognized in the user input. This property is included only if the new system entities + * are enabled for the skill. */ public class RuntimeEntityRole extends GenericModel { - /** - * The relationship of the entity to the range. - */ + /** The relationship of the entity to the range. */ public interface Type { /** date_from. */ String DATE_FROM = "date_from"; @@ -40,26 +40,26 @@ public interface Type { protected String type; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String type; + /** + * Instantiates a new Builder from an existing RuntimeEntityRole instance. + * + * @param runtimeEntityRole the instance to initialize the Builder with + */ private Builder(RuntimeEntityRole runtimeEntityRole) { this.type = runtimeEntityRole.type; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a RuntimeEntityRole. * - * @return the runtimeEntityRole + * @return the new RuntimeEntityRole instance */ public RuntimeEntityRole build() { return new RuntimeEntityRole(this); @@ -77,6 +77,8 @@ public Builder type(String type) { } } + protected RuntimeEntityRole() {} + protected RuntimeEntityRole(Builder builder) { type = builder.type; } @@ -93,7 +95,7 @@ public Builder newBuilder() { /** * Gets the type. * - * The relationship of the entity to the range. + *

The relationship of the entity to the range. * * @return the type */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java index 63f7547d03d..70a9bf87a91 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,51 +10,51 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An intent identified in the user input. - */ +/** An intent identified in the user input. */ public class RuntimeIntent extends GenericModel { protected String intent; protected Double confidence; + protected String skill; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String intent; private Double confidence; + private String skill; + /** + * Instantiates a new Builder from an existing RuntimeIntent instance. + * + * @param runtimeIntent the instance to initialize the Builder with + */ private Builder(RuntimeIntent runtimeIntent) { this.intent = runtimeIntent.intent; this.confidence = runtimeIntent.confidence; + this.skill = runtimeIntent.skill; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. * * @param intent the intent - * @param confidence the confidence */ - public Builder(String intent, Double confidence) { + public Builder(String intent) { this.intent = intent; - this.confidence = confidence; } /** * Builds a RuntimeIntent. * - * @return the runtimeIntent + * @return the new RuntimeIntent instance */ public RuntimeIntent build() { return new RuntimeIntent(this); @@ -81,15 +81,26 @@ public Builder confidence(Double confidence) { this.confidence = confidence; return this; } + + /** + * Set the skill. + * + * @param skill the skill + * @return the RuntimeIntent builder + */ + public Builder skill(String skill) { + this.skill = skill; + return this; + } } + protected RuntimeIntent() {} + protected RuntimeIntent(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, - "intent cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.confidence, - "confidence cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); intent = builder.intent; confidence = builder.confidence; + skill = builder.skill; } /** @@ -104,7 +115,7 @@ public Builder newBuilder() { /** * Gets the intent. * - * The name of the recognized intent. + *

The name of the recognized intent. * * @return the intent */ @@ -115,11 +126,26 @@ public String intent() { /** * Gets the confidence. * - * A decimal percentage that represents Watson's confidence in the intent. + *

A decimal percentage that represents confidence in the intent. If you are specifying an + * intent as part of a request, but you do not have a calculated confidence value, specify `1`. * * @return the confidence */ public Double confidence() { return confidence; } + + /** + * Gets the skill. + * + *

The skill that identified the intent. Currently, the only possible values are `main skill` + * for the dialog skill (if enabled) and `actions skill` for the action skill. + * + *

This property is present only if the assistant has both a dialog skill and an action skill. + * + * @return the skill + */ + public String skill() { + return skill; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java index 848f49b93c4..31ab92e73f9 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2026. * * 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 @@ -10,46 +10,63 @@ * 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.assistant.v2.model; -import java.util.ArrayList; -import java.util.List; +package com.ibm.watson.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; /** * RuntimeResponseGeneric. + * + *

Classes which extend this class: - + * RuntimeResponseGenericRuntimeResponseTypeConversationalSearch - + * RuntimeResponseGenericRuntimeResponseTypeText - RuntimeResponseGenericRuntimeResponseTypePause - + * RuntimeResponseGenericRuntimeResponseTypeImage - RuntimeResponseGenericRuntimeResponseTypeOption + * - RuntimeResponseGenericRuntimeResponseTypeConnectToAgent - + * RuntimeResponseGenericRuntimeResponseTypeSuggestion - + * RuntimeResponseGenericRuntimeResponseTypeChannelTransfer - + * RuntimeResponseGenericRuntimeResponseTypeSearch - + * RuntimeResponseGenericRuntimeResponseTypeUserDefined - + * RuntimeResponseGenericRuntimeResponseTypeVideo - RuntimeResponseGenericRuntimeResponseTypeAudio - + * RuntimeResponseGenericRuntimeResponseTypeIframe - RuntimeResponseGenericRuntimeResponseTypeDate - + * RuntimeResponseGenericRuntimeResponseTypeDtmf - + * RuntimeResponseGenericRuntimeResponseTypeEndSession */ public class RuntimeResponseGeneric extends GenericModel { - - /** - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for - * Premium users. - */ - public interface ResponseType { - /** text. */ - String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** suggestion. */ - String SUGGESTION = "suggestion"; - /** search. */ - String SEARCH = "search"; + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "response_type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "conversation_search", RuntimeResponseGenericRuntimeResponseTypeConversationalSearch.class); + discriminatorMapping.put("audio", RuntimeResponseGenericRuntimeResponseTypeAudio.class); + discriminatorMapping.put( + "channel_transfer", RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.class); + discriminatorMapping.put( + "connect_to_agent", RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.class); + discriminatorMapping.put("date", RuntimeResponseGenericRuntimeResponseTypeDate.class); + discriminatorMapping.put("iframe", RuntimeResponseGenericRuntimeResponseTypeIframe.class); + discriminatorMapping.put("image", RuntimeResponseGenericRuntimeResponseTypeImage.class); + discriminatorMapping.put("option", RuntimeResponseGenericRuntimeResponseTypeOption.class); + discriminatorMapping.put( + "suggestion", RuntimeResponseGenericRuntimeResponseTypeSuggestion.class); + discriminatorMapping.put("pause", RuntimeResponseGenericRuntimeResponseTypePause.class); + discriminatorMapping.put("search", RuntimeResponseGenericRuntimeResponseTypeSearch.class); + discriminatorMapping.put("text", RuntimeResponseGenericRuntimeResponseTypeText.class); + discriminatorMapping.put( + "user_defined", RuntimeResponseGenericRuntimeResponseTypeUserDefined.class); + discriminatorMapping.put("video", RuntimeResponseGenericRuntimeResponseTypeVideo.class); + discriminatorMapping.put("dtmf", RuntimeResponseGenericRuntimeResponseTypeDtmf.class); + discriminatorMapping.put( + "end_session", RuntimeResponseGenericRuntimeResponseTypeEndSession.class); } - - /** - * The preferred type of control to display. - */ + /** The preferred type of control to display. */ public interface Preference { /** dropdown. */ String DROPDOWN = "dropdown"; @@ -59,323 +76,79 @@ public interface Preference { @SerializedName("response_type") protected String responseType; + protected String text; + + @SerializedName("citations_title") + protected String citationsTitle; + + protected List citations; + + @SerializedName("confidence_scores") + protected ResponseGenericConfidenceScores confidenceScores; + + @SerializedName("response_length_option") + protected String responseLengthOption; + + @SerializedName("search_results") + protected List searchResults; + + protected String disclaimer; + protected List channels; protected Long time; protected Boolean typing; protected String source; protected String title; protected String description; + + @SerializedName("alt_text") + protected String altText; + protected String preference; protected List options; + @SerializedName("message_to_human_agent") protected String messageToHumanAgent; + + @SerializedName("agent_available") + protected AgentAvailabilityMessage agentAvailable; + + @SerializedName("agent_unavailable") + protected AgentAvailabilityMessage agentUnavailable; + protected String topic; protected List suggestions; + + @SerializedName("message_to_user") + protected String messageToUser; + protected String header; - protected List results; - /** - * Builder. - */ - public static class Builder { - private String responseType; - private String text; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String topic; - private List suggestions; - private String header; - private List results; - - private Builder(RuntimeResponseGeneric runtimeResponseGeneric) { - this.responseType = runtimeResponseGeneric.responseType; - this.text = runtimeResponseGeneric.text; - this.time = runtimeResponseGeneric.time; - this.typing = runtimeResponseGeneric.typing; - this.source = runtimeResponseGeneric.source; - this.title = runtimeResponseGeneric.title; - this.description = runtimeResponseGeneric.description; - this.preference = runtimeResponseGeneric.preference; - this.options = runtimeResponseGeneric.options; - this.messageToHumanAgent = runtimeResponseGeneric.messageToHumanAgent; - this.topic = runtimeResponseGeneric.topic; - this.suggestions = runtimeResponseGeneric.suggestions; - this.header = runtimeResponseGeneric.header; - this.results = runtimeResponseGeneric.results; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a RuntimeResponseGeneric. - * - * @return the runtimeResponseGeneric - */ - public RuntimeResponseGeneric build() { - return new RuntimeResponseGeneric(this); - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the RuntimeResponseGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, - "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Adds an suggestions to suggestions. - * - * @param suggestions the new suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder addSuggestions(DialogSuggestion suggestions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(suggestions, - "suggestions cannot be null"); - if (this.suggestions == null) { - this.suggestions = new ArrayList(); - } - this.suggestions.add(suggestions); - return this; - } - - /** - * Adds an results to results. - * - * @param results the new results - * @return the RuntimeResponseGeneric builder - */ - public Builder addResults(SearchResult results) { - com.ibm.cloud.sdk.core.util.Validator.notNull(results, - "results cannot be null"); - if (this.results == null) { - this.results = new ArrayList(); - } - this.results.add(results); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the RuntimeResponseGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the RuntimeResponseGeneric builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the RuntimeResponseGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the RuntimeResponseGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the RuntimeResponseGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the RuntimeResponseGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the RuntimeResponseGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the RuntimeResponseGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. - * Existing options will be replaced. - * - * @param options the options - * @return the RuntimeResponseGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the RuntimeResponseGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the topic. - * - * @param topic the topic - * @return the RuntimeResponseGeneric builder - */ - public Builder topic(String topic) { - this.topic = topic; - return this; - } - - /** - * Set the suggestions. - * Existing suggestions will be replaced. - * - * @param suggestions the suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder suggestions(List suggestions) { - this.suggestions = suggestions; - return this; - } - - /** - * Set the header. - * - * @param header the header - * @return the RuntimeResponseGeneric builder - */ - public Builder header(String header) { - this.header = header; - return this; - } - - /** - * Set the results. - * Existing results will be replaced. - * - * @param results the results - * @return the RuntimeResponseGeneric builder - */ - public Builder results(List results) { - this.results = results; - return this; - } - } - - protected RuntimeResponseGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.responseType, - "responseType cannot be null"); - responseType = builder.responseType; - text = builder.text; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - topic = builder.topic; - suggestions = builder.suggestions; - header = builder.header; - results = builder.results; - } + @SerializedName("primary_results") + protected List primaryResults; - /** - * New builder. - * - * @return a RuntimeResponseGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } + @SerializedName("additional_results") + protected List additionalResults; + + @SerializedName("user_defined") + protected Map userDefined; + + @SerializedName("channel_options") + protected Map channelOptions; + + @SerializedName("image_url") + protected String imageUrl; + + @SerializedName("command_info") + protected DtmfCommandInfo commandInfo; + + protected RuntimeResponseGeneric() {} /** * Gets the responseType. * - * The type of response returned by the dialog node. The specified response type must be supported by the client - * application or channel. - * - * **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for - * Premium users. + *

The type of response returned by the dialog node. The specified response type must be + * supported by the client application or channel. * * @return the responseType */ @@ -386,7 +159,7 @@ public String responseType() { /** * Gets the text. * - * The text of the response. + *

The text of the conversational search response. * * @return the text */ @@ -394,10 +167,94 @@ public String text() { return text; } + /** + * Gets the citationsTitle. + * + *

The title of the citations. The default is “How do we know?”. It can be updated in the + * conversational search user interface. + * + * @return the citationsTitle + */ + public String citationsTitle() { + return citationsTitle; + } + + /** + * Gets the citations. + * + *

The citations for the generated response. + * + * @return the citations + */ + public List citations() { + return citations; + } + + /** + * Gets the confidenceScores. + * + *

The confidence scores for determining whether to show the generated response or an “I don't + * know” response. + * + * @return the confidenceScores + */ + public ResponseGenericConfidenceScores confidenceScores() { + return confidenceScores; + } + + /** + * Gets the responseLengthOption. + * + *

The response length option. It is used to control the length of the generated response. It + * is configured either in the user interface or through the Update skill API. For more + * information, see [watsonx Assistant documentation]( + * https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-conversational-search#tuning-the-generated-response-length-in-conversational-search). + * + * @return the responseLengthOption + */ + public String responseLengthOption() { + return responseLengthOption; + } + + /** + * Gets the searchResults. + * + *

An array of objects containing the search results. + * + * @return the searchResults + */ + public List searchResults() { + return searchResults; + } + + /** + * Gets the disclaimer. + * + *

A disclaimer for the conversational search response. + * + * @return the disclaimer + */ + public String disclaimer() { + return disclaimer; + } + + /** + * Gets the channels. + * + *

An array of objects specifying channels for which the response is intended. If **channels** + * is present, the response is intended for a built-in integration and should not be handled by an + * API client. + * + * @return the channels + */ + public List channels() { + return channels; + } + /** * Gets the time. * - * How long to pause, in milliseconds. + *

How long to pause, in milliseconds. * * @return the time */ @@ -408,7 +265,7 @@ public Long time() { /** * Gets the typing. * - * Whether to send a "user is typing" event during the pause. + *

Whether to send a "user is typing" event during the pause. * * @return the typing */ @@ -419,7 +276,7 @@ public Boolean typing() { /** * Gets the source. * - * The URL of the image. + *

The `https:` URL of the image. * * @return the source */ @@ -430,7 +287,7 @@ public String source() { /** * Gets the title. * - * The title or introductory text to show before the response. + *

The title to show before the response. * * @return the title */ @@ -441,7 +298,7 @@ public String title() { /** * Gets the description. * - * The description to show with the the response. + *

The description to show with the the response. * * @return the description */ @@ -449,10 +306,22 @@ public String description() { return description; } + /** + * Gets the altText. + * + *

Descriptive text that can be used for screen readers or other situations where the image + * cannot be seen. + * + * @return the altText + */ + public String altText() { + return altText; + } + /** * Gets the preference. * - * The preferred type of control to display. + *

The preferred type of control to display. * * @return the preference */ @@ -463,7 +332,7 @@ public String preference() { /** * Gets the options. * - * An array of objects describing the options from which the user can choose. + *

An array of objects describing the options from which the user can choose. * * @return the options */ @@ -474,7 +343,7 @@ public List options() { /** * Gets the messageToHumanAgent. * - * A message to be sent to the human agent who will be taking over the conversation. + *

A message to be sent to the human agent who will be taking over the conversation. * * @return the messageToHumanAgent */ @@ -482,10 +351,35 @@ public String messageToHumanAgent() { return messageToHumanAgent; } + /** + * Gets the agentAvailable. + * + *

An optional message to be displayed to the user to indicate that the conversation will be + * transferred to the next available agent. + * + * @return the agentAvailable + */ + public AgentAvailabilityMessage agentAvailable() { + return agentAvailable; + } + + /** + * Gets the agentUnavailable. + * + *

An optional message to be displayed to the user to indicate that no online agent is + * available to take over the conversation. + * + * @return the agentUnavailable + */ + public AgentAvailabilityMessage agentUnavailable() { + return agentUnavailable; + } + /** * Gets the topic. * - * A label identifying the topic of the conversation, derived from the **user_label** property of the relevant node. + *

A label identifying the topic of the conversation, derived from the **title** property of + * the relevant node or the **topic** property of the dialog node response. * * @return the topic */ @@ -496,10 +390,8 @@ public String topic() { /** * Gets the suggestions. * - * An array of objects describing the possible matching dialog nodes from which the user can choose. - * - * **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for Premium - * users. + *

An array of objects describing the possible matching dialog nodes from which the user can + * choose. * * @return the suggestions */ @@ -507,10 +399,22 @@ public List suggestions() { return suggestions; } + /** + * Gets the messageToUser. + * + *

The message to display to the user when initiating a channel transfer. + * + * @return the messageToUser + */ + public String messageToUser() { + return messageToUser; + } + /** * Gets the header. * - * The title or introductory text to show before the response. This text is defined in the search skill configuration. + *

The title or introductory text to show before the response. This text is defined in the + * search skill configuration. * * @return the header */ @@ -519,13 +423,68 @@ public String header() { } /** - * Gets the results. + * Gets the primaryResults. + * + *

An array of objects that contains the search results to be displayed in the initial response + * to the user. + * + * @return the primaryResults + */ + public List primaryResults() { + return primaryResults; + } + + /** + * Gets the additionalResults. + * + *

An array of objects that contains additional search results that can be displayed to the + * user upon request. + * + * @return the additionalResults + */ + public List additionalResults() { + return additionalResults; + } + + /** + * Gets the userDefined. * - * An array of objects containing search results. + *

An object containing any properties for the user-defined response type. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the channelOptions. + * + *

For internal use only. + * + * @return the channelOptions + */ + public Map channelOptions() { + return channelOptions; + } + + /** + * Gets the imageUrl. + * + *

The URL of an image that shows a preview of the embedded content. + * + * @return the imageUrl + */ + public String imageUrl() { + return imageUrl; + } + + /** + * Gets the commandInfo. * - * @return the results + * @return the commandInfo */ - public List results() { - return results; + public DtmfCommandInfo commandInfo() { + return commandInfo; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeAudio.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeAudio.java new file mode 100644 index 00000000000..56bfaee8873 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeAudio.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeAudio. */ +public class RuntimeResponseGenericRuntimeResponseTypeAudio extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeAudio() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.java new file mode 100644 index 00000000000..148895299f4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; + +/** RuntimeResponseGenericRuntimeResponseTypeChannelTransfer. */ +public class RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + extends RuntimeResponseGeneric { + + @SerializedName("transfer_info") + protected ChannelTransferInfo transferInfo; + + protected RuntimeResponseGenericRuntimeResponseTypeChannelTransfer() {} + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public ChannelTransferInfo transferInfo() { + return transferInfo; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java new file mode 100644 index 00000000000..51af855df04 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; + +/** RuntimeResponseGenericRuntimeResponseTypeConnectToAgent. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + extends RuntimeResponseGeneric { + + @SerializedName("transfer_info") + protected DialogNodeOutputConnectToAgentTransferInfo transferInfo; + + protected RuntimeResponseGenericRuntimeResponseTypeConnectToAgent() {} + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public DialogNodeOutputConnectToAgentTransferInfo transferInfo() { + return transferInfo; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConversationalSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConversationalSearch.java new file mode 100644 index 00000000000..8de4a9e5e23 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConversationalSearch.java @@ -0,0 +1,21 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeConversationalSearch. */ +public class RuntimeResponseGenericRuntimeResponseTypeConversationalSearch + extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeConversationalSearch() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDate.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDate.java new file mode 100644 index 00000000000..74c2386502f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDate.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeDate. */ +public class RuntimeResponseGenericRuntimeResponseTypeDate extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeDate() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmf.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmf.java new file mode 100644 index 00000000000..832398bd95f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmf.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeDtmf. */ +public class RuntimeResponseGenericRuntimeResponseTypeDtmf extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeDtmf() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSession.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSession.java new file mode 100644 index 00000000000..50774bb0204 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSession.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeEndSession. */ +public class RuntimeResponseGenericRuntimeResponseTypeEndSession extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeEndSession() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeIframe.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeIframe.java new file mode 100644 index 00000000000..f2833c6a2e1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeIframe.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeIframe. */ +public class RuntimeResponseGenericRuntimeResponseTypeIframe extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeIframe() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImage.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImage.java new file mode 100644 index 00000000000..0afb76fe2e7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImage.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeImage. */ +public class RuntimeResponseGenericRuntimeResponseTypeImage extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeImage() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOption.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOption.java new file mode 100644 index 00000000000..5602a52ed51 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOption.java @@ -0,0 +1,28 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeOption. */ +public class RuntimeResponseGenericRuntimeResponseTypeOption extends RuntimeResponseGeneric { + + /** The preferred type of control to display. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + protected RuntimeResponseGenericRuntimeResponseTypeOption() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePause.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePause.java new file mode 100644 index 00000000000..979e3f8825e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePause.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypePause. */ +public class RuntimeResponseGenericRuntimeResponseTypePause extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypePause() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearch.java new file mode 100644 index 00000000000..a60d12fedf1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearch.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeSearch. */ +public class RuntimeResponseGenericRuntimeResponseTypeSearch extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeSearch() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java new file mode 100644 index 00000000000..c00057637e8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeSuggestion. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestion extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeSuggestion() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeText.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeText.java new file mode 100644 index 00000000000..7785b5a164c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeText.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeText. */ +public class RuntimeResponseGenericRuntimeResponseTypeText extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeText() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeUserDefined.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeUserDefined.java new file mode 100644 index 00000000000..ad4276e0acf --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeUserDefined.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeUserDefined. */ +public class RuntimeResponseGenericRuntimeResponseTypeUserDefined extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeUserDefined() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeVideo.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeVideo.java new file mode 100644 index 00000000000..55b448e00f9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeVideo.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeVideo. */ +public class RuntimeResponseGenericRuntimeResponseTypeVideo extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeVideo() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java index 699b4d899d5..1009c164335 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,31 +10,36 @@ * 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.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * SearchResult. - */ +/** SearchResult. */ public class SearchResult extends GenericModel { protected String id; + @SerializedName("result_metadata") protected SearchResultMetadata resultMetadata; + protected String body; protected String title; protected String url; protected SearchResultHighlight highlight; + protected List answers; + + protected SearchResult() {} /** * Gets the id. * - * The unique identifier of the document in the Discovery service collection. + *

The unique identifier of the document in the Discovery service collection. * - * This property is included in responses from search skills, which are a beta feature available only to Plus or - * Premium plan users. + *

This property is included in responses from search skills, which are available only to Plus + * or Enterprise plan users. * * @return the id */ @@ -45,7 +50,7 @@ public String getId() { /** * Gets the resultMetadata. * - * An object containing search result metadata from the Discovery service. + *

An object containing search result metadata from the Discovery service. * * @return the resultMetadata */ @@ -56,8 +61,8 @@ public SearchResultMetadata getResultMetadata() { /** * Gets the body. * - * A description of the search result. This is taken from an abstract, summary, or highlight field in the Discovery - * service response, as specified in the search skill configuration. + *

A description of the search result. This is taken from an abstract, summary, or highlight + * field in the Discovery service response, as specified in the search skill configuration. * * @return the body */ @@ -68,8 +73,8 @@ public String getBody() { /** * Gets the title. * - * The title of the search result. This is taken from a title or name field in the Discovery service response, as - * specified in the search skill configuration. + *

The title of the search result. This is taken from a title or name field in the Discovery + * service response, as specified in the search skill configuration. * * @return the title */ @@ -80,7 +85,7 @@ public String getTitle() { /** * Gets the url. * - * The URL of the original data object in its native data source. + *

The URL of the original data object in its native data source. * * @return the url */ @@ -91,12 +96,28 @@ public String getUrl() { /** * Gets the highlight. * - * An object containing segments of text from search results with query-matching text highlighted using HTML - * tags. + *

An object containing segments of text from search results with query-matching text + * highlighted using HTML `<em>` tags. * * @return the highlight */ public SearchResultHighlight getHighlight() { return highlight; } + + /** + * Gets the answers. + * + *

An array specifying segments of text within the result that were identified as direct + * answers to the search query. Currently, only the single answer with the highest confidence (if + * any) is returned. + * + *

**Notes:** - Answer finding is available only if the search skill is connected to a + * Discovery v2 service instance. - Answer finding is not supported on IBM Cloud Pak for Data. + * + * @return the answers + */ + public List getAnswers() { + return answers; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultAnswer.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultAnswer.java new file mode 100644 index 00000000000..434299302d5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultAnswer.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object specifing a segment of text that was identified as a direct answer to the search query. + */ +public class SearchResultAnswer extends GenericModel { + + protected String text; + protected Double confidence; + + protected SearchResultAnswer() {} + + /** + * Gets the text. + * + *

The text of the answer. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the confidence. + * + *

The confidence score for the answer, as returned by the Discovery service. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java index ae59fa9489e..5159b13fb6f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,36 +10,43 @@ * 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.assistant.v2.model; -import java.util.List; +package com.ibm.watson.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.List; /** - * An object containing segments of text from search results with query-matching text highlighted using HTML tags. + * An object containing segments of text from search results with query-matching text highlighted + * using HTML `<em>` tags. + * + *

This type supports additional properties of type List<String>. An array of strings + * containing segments taken from a field in the search results that is not mapped to the `body`, + * `title`, or `url` property, with query-matching substrings highlighted. The property name is the + * name of the field in the Discovery collection. */ public class SearchResultHighlight extends DynamicModel> { @SerializedName("body") protected List body; + @SerializedName("title") protected List title; + @SerializedName("url") protected List url; public SearchResultHighlight() { - super(new TypeToken>() { - }); + super(new TypeToken>() {}); } /** * Gets the body. * - * An array of strings containing segments taken from body text in the search results, with query-matching substrings - * highlighted. + *

An array of strings containing segments taken from body text in the search results, with + * query-matching substrings highlighted. * * @return the body */ @@ -50,8 +57,8 @@ public List getBody() { /** * Gets the title. * - * An array of strings containing segments taken from title text in the search results, with query-matching substrings - * highlighted. + *

An array of strings containing segments taken from title text in the search results, with + * query-matching substrings highlighted. * * @return the title */ @@ -62,8 +69,8 @@ public List getTitle() { /** * Gets the url. * - * An array of strings containing segments taken from URLs in the search results, with query-matching substrings - * highlighted. + *

An array of strings containing segments taken from URLs in the search results, with + * query-matching substrings highlighted. * * @return the url */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java index b93d13a33c0..065bc768b96 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,23 @@ * 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.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An object containing search result metadata from the Discovery service. - */ +/** An object containing search result metadata from the Discovery service. */ public class SearchResultMetadata extends GenericModel { protected Double confidence; protected Double score; + protected SearchResultMetadata() {} + /** * Gets the confidence. * - * The confidence score for the given result. For more information about how the confidence is calculated, see the - * Discovery service [documentation](../discovery#query-your-collection). + *

The confidence score for the given result, as returned by the Discovery service. * * @return the confidence */ @@ -37,8 +37,8 @@ public Double getConfidence() { /** * Gets the score. * - * An unbounded measure of the relevance of a particular result, dependent on the query and matching document. A - * higher score indicates a greater match to the query parameters. + *

An unbounded measure of the relevance of a particular result, dependent on the query and + * matching document. A higher score indicates a greater match to the query parameters. * * @return the score */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResults.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResults.java new file mode 100644 index 00000000000..063d995c9ea --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResults.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SearchResults. */ +public class SearchResults extends GenericModel { + + @SerializedName("result_metadata") + protected SearchResultsResultMetadata resultMetadata; + + protected String id; + protected String title; + protected String body; + + protected SearchResults() {} + + /** + * Gets the resultMetadata. + * + *

The metadata of the search result. + * + * @return the resultMetadata + */ + public SearchResultsResultMetadata getResultMetadata() { + return resultMetadata; + } + + /** + * Gets the id. + * + *

The ID of the search result. It may not be unique. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the title. + * + *

The title of the search result. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the body. + * + *

The body content of the search result. + * + * @return the body + */ + public String getBody() { + return body; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultsResultMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultsResultMetadata.java new file mode 100644 index 00000000000..2a5873b51c0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultsResultMetadata.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The metadata of the search result. */ +public class SearchResultsResultMetadata extends GenericModel { + + @SerializedName("document_retrieval_source") + protected String documentRetrievalSource; + + protected Long score; + + protected SearchResultsResultMetadata() {} + + /** + * Gets the documentRetrievalSource. + * + *

The source of the search result. + * + * @return the documentRetrievalSource + */ + public String getDocumentRetrievalSource() { + return documentRetrievalSource; + } + + /** + * Gets the score. + * + *

The relevance score of the search result to the user query. + * + * @return the score + */ + public Long getScore() { + return score; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettings.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettings.java new file mode 100644 index 00000000000..d7ebc4e46ae --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettings.java @@ -0,0 +1,283 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object describing the search skill configuration. + * + *

**Note:** Search settings are not supported in **Import skills** requests, and are not + * included in **Export skills** responses. + */ +public class SearchSettings extends GenericModel { + + protected SearchSettingsDiscovery discovery; + protected SearchSettingsMessages messages; + + @SerializedName("schema_mapping") + protected SearchSettingsSchemaMapping schemaMapping; + + @SerializedName("elastic_search") + protected SearchSettingsElasticSearch elasticSearch; + + @SerializedName("conversational_search") + protected SearchSettingsConversationalSearch conversationalSearch; + + @SerializedName("server_side_search") + protected SearchSettingsServerSideSearch serverSideSearch; + + @SerializedName("client_side_search") + protected SearchSettingsClientSideSearch clientSideSearch; + + /** Builder. */ + public static class Builder { + private SearchSettingsDiscovery discovery; + private SearchSettingsMessages messages; + private SearchSettingsSchemaMapping schemaMapping; + private SearchSettingsElasticSearch elasticSearch; + private SearchSettingsConversationalSearch conversationalSearch; + private SearchSettingsServerSideSearch serverSideSearch; + private SearchSettingsClientSideSearch clientSideSearch; + + /** + * Instantiates a new Builder from an existing SearchSettings instance. + * + * @param searchSettings the instance to initialize the Builder with + */ + private Builder(SearchSettings searchSettings) { + this.discovery = searchSettings.discovery; + this.messages = searchSettings.messages; + this.schemaMapping = searchSettings.schemaMapping; + this.elasticSearch = searchSettings.elasticSearch; + this.conversationalSearch = searchSettings.conversationalSearch; + this.serverSideSearch = searchSettings.serverSideSearch; + this.clientSideSearch = searchSettings.clientSideSearch; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param messages the messages + * @param schemaMapping the schemaMapping + * @param conversationalSearch the conversationalSearch + */ + public Builder( + SearchSettingsMessages messages, + SearchSettingsSchemaMapping schemaMapping, + SearchSettingsConversationalSearch conversationalSearch) { + this.messages = messages; + this.schemaMapping = schemaMapping; + this.conversationalSearch = conversationalSearch; + } + + /** + * Builds a SearchSettings. + * + * @return the new SearchSettings instance + */ + public SearchSettings build() { + return new SearchSettings(this); + } + + /** + * Set the discovery. + * + * @param discovery the discovery + * @return the SearchSettings builder + */ + public Builder discovery(SearchSettingsDiscovery discovery) { + this.discovery = discovery; + return this; + } + + /** + * Set the messages. + * + * @param messages the messages + * @return the SearchSettings builder + */ + public Builder messages(SearchSettingsMessages messages) { + this.messages = messages; + return this; + } + + /** + * Set the schemaMapping. + * + * @param schemaMapping the schemaMapping + * @return the SearchSettings builder + */ + public Builder schemaMapping(SearchSettingsSchemaMapping schemaMapping) { + this.schemaMapping = schemaMapping; + return this; + } + + /** + * Set the elasticSearch. + * + * @param elasticSearch the elasticSearch + * @return the SearchSettings builder + */ + public Builder elasticSearch(SearchSettingsElasticSearch elasticSearch) { + this.elasticSearch = elasticSearch; + return this; + } + + /** + * Set the conversationalSearch. + * + * @param conversationalSearch the conversationalSearch + * @return the SearchSettings builder + */ + public Builder conversationalSearch(SearchSettingsConversationalSearch conversationalSearch) { + this.conversationalSearch = conversationalSearch; + return this; + } + + /** + * Set the serverSideSearch. + * + * @param serverSideSearch the serverSideSearch + * @return the SearchSettings builder + */ + public Builder serverSideSearch(SearchSettingsServerSideSearch serverSideSearch) { + this.serverSideSearch = serverSideSearch; + return this; + } + + /** + * Set the clientSideSearch. + * + * @param clientSideSearch the clientSideSearch + * @return the SearchSettings builder + */ + public Builder clientSideSearch(SearchSettingsClientSideSearch clientSideSearch) { + this.clientSideSearch = clientSideSearch; + return this; + } + } + + protected SearchSettings() {} + + protected SearchSettings(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.messages, "messages cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.schemaMapping, "schemaMapping cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.conversationalSearch, "conversationalSearch cannot be null"); + discovery = builder.discovery; + messages = builder.messages; + schemaMapping = builder.schemaMapping; + elasticSearch = builder.elasticSearch; + conversationalSearch = builder.conversationalSearch; + serverSideSearch = builder.serverSideSearch; + clientSideSearch = builder.clientSideSearch; + } + + /** + * New builder. + * + * @return a SearchSettings builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the discovery. + * + *

Configuration settings for the Watson Discovery service instance used by the search + * integration. + * + * @return the discovery + */ + public SearchSettingsDiscovery discovery() { + return discovery; + } + + /** + * Gets the messages. + * + *

The messages included with responses from the search integration. + * + * @return the messages + */ + public SearchSettingsMessages messages() { + return messages; + } + + /** + * Gets the schemaMapping. + * + *

The mapping between fields in the Watson Discovery collection and properties in the search + * response. + * + * @return the schemaMapping + */ + public SearchSettingsSchemaMapping schemaMapping() { + return schemaMapping; + } + + /** + * Gets the elasticSearch. + * + *

Configuration settings for the Elasticsearch service used by the search integration. You can + * provide either basic auth or apiKey auth. + * + * @return the elasticSearch + */ + public SearchSettingsElasticSearch elasticSearch() { + return elasticSearch; + } + + /** + * Gets the conversationalSearch. + * + *

Configuration settings for conversational search. + * + * @return the conversationalSearch + */ + public SearchSettingsConversationalSearch conversationalSearch() { + return conversationalSearch; + } + + /** + * Gets the serverSideSearch. + * + *

Configuration settings for the server-side search service used by the search integration. + * You can provide either basic auth, apiKey auth or none. + * + * @return the serverSideSearch + */ + public SearchSettingsServerSideSearch serverSideSearch() { + return serverSideSearch; + } + + /** + * Gets the clientSideSearch. + * + *

Configuration settings for the client-side search service or server-side search service used + * by the search integration. + * + * @return the clientSideSearch + */ + public SearchSettingsClientSideSearch clientSideSearch() { + return clientSideSearch; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsClientSideSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsClientSideSearch.java new file mode 100644 index 00000000000..04cf2a565b8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsClientSideSearch.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** + * Configuration settings for the client-side search service or server-side search service used by + * the search integration. + */ +public class SearchSettingsClientSideSearch extends GenericModel { + + protected String filter; + protected Map metadata; + + /** Builder. */ + public static class Builder { + private String filter; + private Map metadata; + + /** + * Instantiates a new Builder from an existing SearchSettingsClientSideSearch instance. + * + * @param searchSettingsClientSideSearch the instance to initialize the Builder with + */ + private Builder(SearchSettingsClientSideSearch searchSettingsClientSideSearch) { + this.filter = searchSettingsClientSideSearch.filter; + this.metadata = searchSettingsClientSideSearch.metadata; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a SearchSettingsClientSideSearch. + * + * @return the new SearchSettingsClientSideSearch instance + */ + public SearchSettingsClientSideSearch build() { + return new SearchSettingsClientSideSearch(this); + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the SearchSettingsClientSideSearch builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the SearchSettingsClientSideSearch builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + } + + protected SearchSettingsClientSideSearch() {} + + protected SearchSettingsClientSideSearch(Builder builder) { + filter = builder.filter; + metadata = builder.metadata; + } + + /** + * New builder. + * + * @return a SearchSettingsClientSideSearch builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the filter. + * + *

The filter string that is applied to the search results. + * + * @return the filter + */ + public String filter() { + return filter; + } + + /** + * Gets the metadata. + * + *

The metadata object. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearch.java new file mode 100644 index 00000000000..77cc98e8a67 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearch.java @@ -0,0 +1,149 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Configuration settings for conversational search. */ +public class SearchSettingsConversationalSearch extends GenericModel { + + protected Boolean enabled; + + @SerializedName("response_length") + protected SearchSettingsConversationalSearchResponseLength responseLength; + + @SerializedName("search_confidence") + protected SearchSettingsConversationalSearchSearchConfidence searchConfidence; + + /** Builder. */ + public static class Builder { + private Boolean enabled; + private SearchSettingsConversationalSearchResponseLength responseLength; + private SearchSettingsConversationalSearchSearchConfidence searchConfidence; + + /** + * Instantiates a new Builder from an existing SearchSettingsConversationalSearch instance. + * + * @param searchSettingsConversationalSearch the instance to initialize the Builder with + */ + private Builder(SearchSettingsConversationalSearch searchSettingsConversationalSearch) { + this.enabled = searchSettingsConversationalSearch.enabled; + this.responseLength = searchSettingsConversationalSearch.responseLength; + this.searchConfidence = searchSettingsConversationalSearch.searchConfidence; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param enabled the enabled + */ + public Builder(Boolean enabled) { + this.enabled = enabled; + } + + /** + * Builds a SearchSettingsConversationalSearch. + * + * @return the new SearchSettingsConversationalSearch instance + */ + public SearchSettingsConversationalSearch build() { + return new SearchSettingsConversationalSearch(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the SearchSettingsConversationalSearch builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the responseLength. + * + * @param responseLength the responseLength + * @return the SearchSettingsConversationalSearch builder + */ + public Builder responseLength(SearchSettingsConversationalSearchResponseLength responseLength) { + this.responseLength = responseLength; + return this; + } + + /** + * Set the searchConfidence. + * + * @param searchConfidence the searchConfidence + * @return the SearchSettingsConversationalSearch builder + */ + public Builder searchConfidence( + SearchSettingsConversationalSearchSearchConfidence searchConfidence) { + this.searchConfidence = searchConfidence; + return this; + } + } + + protected SearchSettingsConversationalSearch() {} + + protected SearchSettingsConversationalSearch(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.enabled, "enabled cannot be null"); + enabled = builder.enabled; + responseLength = builder.responseLength; + searchConfidence = builder.searchConfidence; + } + + /** + * New builder. + * + * @return a SearchSettingsConversationalSearch builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

Whether to enable conversational search. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the responseLength. + * + * @return the responseLength + */ + public SearchSettingsConversationalSearchResponseLength responseLength() { + return responseLength; + } + + /** + * Gets the searchConfidence. + * + * @return the searchConfidence + */ + public SearchSettingsConversationalSearchSearchConfidence searchConfidence() { + return searchConfidence; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchResponseLength.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchResponseLength.java new file mode 100644 index 00000000000..e28aba049d3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchResponseLength.java @@ -0,0 +1,99 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SearchSettingsConversationalSearchResponseLength. */ +public class SearchSettingsConversationalSearchResponseLength extends GenericModel { + + /** The response length option. It controls the length of the generated response. */ + public interface Option { + /** concise. */ + String CONCISE = "concise"; + /** moderate. */ + String MODERATE = "moderate"; + /** verbose. */ + String VERBOSE = "verbose"; + } + + protected String option; + + /** Builder. */ + public static class Builder { + private String option; + + /** + * Instantiates a new Builder from an existing SearchSettingsConversationalSearchResponseLength + * instance. + * + * @param searchSettingsConversationalSearchResponseLength the instance to initialize the + * Builder with + */ + private Builder( + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLength) { + this.option = searchSettingsConversationalSearchResponseLength.option; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a SearchSettingsConversationalSearchResponseLength. + * + * @return the new SearchSettingsConversationalSearchResponseLength instance + */ + public SearchSettingsConversationalSearchResponseLength build() { + return new SearchSettingsConversationalSearchResponseLength(this); + } + + /** + * Set the option. + * + * @param option the option + * @return the SearchSettingsConversationalSearchResponseLength builder + */ + public Builder option(String option) { + this.option = option; + return this; + } + } + + protected SearchSettingsConversationalSearchResponseLength() {} + + protected SearchSettingsConversationalSearchResponseLength(Builder builder) { + option = builder.option; + } + + /** + * New builder. + * + * @return a SearchSettingsConversationalSearchResponseLength builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the option. + * + *

The response length option. It controls the length of the generated response. + * + * @return the option + */ + public String option() { + return option; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchSearchConfidence.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchSearchConfidence.java new file mode 100644 index 00000000000..09c5f6139ee --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchSearchConfidence.java @@ -0,0 +1,105 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SearchSettingsConversationalSearchSearchConfidence. */ +public class SearchSettingsConversationalSearchSearchConfidence extends GenericModel { + + /** + * The search confidence threshold. It controls the tendency for conversational search to produce + * “I don't know” answers. + */ + public interface Threshold { + /** rarely. */ + String RARELY = "rarely"; + /** less_often. */ + String LESS_OFTEN = "less_often"; + /** more_often. */ + String MORE_OFTEN = "more_often"; + /** most_often. */ + String MOST_OFTEN = "most_often"; + } + + protected String threshold; + + /** Builder. */ + public static class Builder { + private String threshold; + + /** + * Instantiates a new Builder from an existing + * SearchSettingsConversationalSearchSearchConfidence instance. + * + * @param searchSettingsConversationalSearchSearchConfidence the instance to initialize the + * Builder with + */ + private Builder( + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidence) { + this.threshold = searchSettingsConversationalSearchSearchConfidence.threshold; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a SearchSettingsConversationalSearchSearchConfidence. + * + * @return the new SearchSettingsConversationalSearchSearchConfidence instance + */ + public SearchSettingsConversationalSearchSearchConfidence build() { + return new SearchSettingsConversationalSearchSearchConfidence(this); + } + + /** + * Set the threshold. + * + * @param threshold the threshold + * @return the SearchSettingsConversationalSearchSearchConfidence builder + */ + public Builder threshold(String threshold) { + this.threshold = threshold; + return this; + } + } + + protected SearchSettingsConversationalSearchSearchConfidence() {} + + protected SearchSettingsConversationalSearchSearchConfidence(Builder builder) { + threshold = builder.threshold; + } + + /** + * New builder. + * + * @return a SearchSettingsConversationalSearchSearchConfidence builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the threshold. + * + *

The search confidence threshold. It controls the tendency for conversational search to + * produce “I don't know” answers. + * + * @return the threshold + */ + public String threshold() { + return threshold; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscovery.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscovery.java new file mode 100644 index 00000000000..0aa11cdbde0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscovery.java @@ -0,0 +1,343 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Configuration settings for the Watson Discovery service instance used by the search integration. + */ +public class SearchSettingsDiscovery extends GenericModel { + + @SerializedName("instance_id") + protected String instanceId; + + @SerializedName("project_id") + protected String projectId; + + protected String url; + + @SerializedName("max_primary_results") + protected Long maxPrimaryResults; + + @SerializedName("max_total_results") + protected Long maxTotalResults; + + @SerializedName("confidence_threshold") + protected Double confidenceThreshold; + + protected Boolean highlight; + + @SerializedName("find_answers") + protected Boolean findAnswers; + + protected SearchSettingsDiscoveryAuthentication authentication; + + /** Builder. */ + public static class Builder { + private String instanceId; + private String projectId; + private String url; + private Long maxPrimaryResults; + private Long maxTotalResults; + private Double confidenceThreshold; + private Boolean highlight; + private Boolean findAnswers; + private SearchSettingsDiscoveryAuthentication authentication; + + /** + * Instantiates a new Builder from an existing SearchSettingsDiscovery instance. + * + * @param searchSettingsDiscovery the instance to initialize the Builder with + */ + private Builder(SearchSettingsDiscovery searchSettingsDiscovery) { + this.instanceId = searchSettingsDiscovery.instanceId; + this.projectId = searchSettingsDiscovery.projectId; + this.url = searchSettingsDiscovery.url; + this.maxPrimaryResults = searchSettingsDiscovery.maxPrimaryResults; + this.maxTotalResults = searchSettingsDiscovery.maxTotalResults; + this.confidenceThreshold = searchSettingsDiscovery.confidenceThreshold; + this.highlight = searchSettingsDiscovery.highlight; + this.findAnswers = searchSettingsDiscovery.findAnswers; + this.authentication = searchSettingsDiscovery.authentication; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param instanceId the instanceId + * @param projectId the projectId + * @param url the url + * @param authentication the authentication + */ + public Builder( + String instanceId, + String projectId, + String url, + SearchSettingsDiscoveryAuthentication authentication) { + this.instanceId = instanceId; + this.projectId = projectId; + this.url = url; + this.authentication = authentication; + } + + /** + * Builds a SearchSettingsDiscovery. + * + * @return the new SearchSettingsDiscovery instance + */ + public SearchSettingsDiscovery build() { + return new SearchSettingsDiscovery(this); + } + + /** + * Set the instanceId. + * + * @param instanceId the instanceId + * @return the SearchSettingsDiscovery builder + */ + public Builder instanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the SearchSettingsDiscovery builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the url. + * + * @param url the url + * @return the SearchSettingsDiscovery builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the maxPrimaryResults. + * + * @param maxPrimaryResults the maxPrimaryResults + * @return the SearchSettingsDiscovery builder + */ + public Builder maxPrimaryResults(long maxPrimaryResults) { + this.maxPrimaryResults = maxPrimaryResults; + return this; + } + + /** + * Set the maxTotalResults. + * + * @param maxTotalResults the maxTotalResults + * @return the SearchSettingsDiscovery builder + */ + public Builder maxTotalResults(long maxTotalResults) { + this.maxTotalResults = maxTotalResults; + return this; + } + + /** + * Set the confidenceThreshold. + * + * @param confidenceThreshold the confidenceThreshold + * @return the SearchSettingsDiscovery builder + */ + public Builder confidenceThreshold(Double confidenceThreshold) { + this.confidenceThreshold = confidenceThreshold; + return this; + } + + /** + * Set the highlight. + * + * @param highlight the highlight + * @return the SearchSettingsDiscovery builder + */ + public Builder highlight(Boolean highlight) { + this.highlight = highlight; + return this; + } + + /** + * Set the findAnswers. + * + * @param findAnswers the findAnswers + * @return the SearchSettingsDiscovery builder + */ + public Builder findAnswers(Boolean findAnswers) { + this.findAnswers = findAnswers; + return this; + } + + /** + * Set the authentication. + * + * @param authentication the authentication + * @return the SearchSettingsDiscovery builder + */ + public Builder authentication(SearchSettingsDiscoveryAuthentication authentication) { + this.authentication = authentication; + return this; + } + } + + protected SearchSettingsDiscovery() {} + + protected SearchSettingsDiscovery(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.instanceId, "instanceId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.projectId, "projectId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, "url cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.authentication, "authentication cannot be null"); + instanceId = builder.instanceId; + projectId = builder.projectId; + url = builder.url; + maxPrimaryResults = builder.maxPrimaryResults; + maxTotalResults = builder.maxTotalResults; + confidenceThreshold = builder.confidenceThreshold; + highlight = builder.highlight; + findAnswers = builder.findAnswers; + authentication = builder.authentication; + } + + /** + * New builder. + * + * @return a SearchSettingsDiscovery builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the instanceId. + * + *

The ID for the Watson Discovery service instance. + * + * @return the instanceId + */ + public String instanceId() { + return instanceId; + } + + /** + * Gets the projectId. + * + *

The ID for the Watson Discovery project. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the url. + * + *

The URL for the Watson Discovery service instance. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the maxPrimaryResults. + * + *

The maximum number of primary results to include in the response. + * + * @return the maxPrimaryResults + */ + public Long maxPrimaryResults() { + return maxPrimaryResults; + } + + /** + * Gets the maxTotalResults. + * + *

The maximum total number of primary and additional results to include in the response. + * + * @return the maxTotalResults + */ + public Long maxTotalResults() { + return maxTotalResults; + } + + /** + * Gets the confidenceThreshold. + * + *

The minimum confidence threshold for included results. Any results with a confidence below + * this threshold will be discarded. + * + * @return the confidenceThreshold + */ + public Double confidenceThreshold() { + return confidenceThreshold; + } + + /** + * Gets the highlight. + * + *

Whether to include the most relevant passages of text in the **highlight** property of each + * result. + * + * @return the highlight + */ + public Boolean highlight() { + return highlight; + } + + /** + * Gets the findAnswers. + * + *

Whether to use the answer finding feature to emphasize answers within highlighted passages. + * This property is ignored if **highlight**=`false`. + * + *

**Notes:** - Answer finding is available only if the search skill is connected to a + * Discovery v2 service instance. - Answer finding is not supported on IBM Cloud Pak for Data. + * + * @return the findAnswers + */ + public Boolean findAnswers() { + return findAnswers; + } + + /** + * Gets the authentication. + * + *

Authentication information for the Watson Discovery service. For more information, see the + * [Watson Discovery documentation](https://cloud.ibm.com/apidocs/discovery-data#authentication). + * + *

**Note:** You must specify either **basic** or **bearer**, but not both. + * + * @return the authentication + */ + public SearchSettingsDiscoveryAuthentication authentication() { + return authentication; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryAuthentication.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryAuthentication.java new file mode 100644 index 00000000000..0c7b498b395 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryAuthentication.java @@ -0,0 +1,117 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Authentication information for the Watson Discovery service. For more information, see the + * [Watson Discovery documentation](https://cloud.ibm.com/apidocs/discovery-data#authentication). + * + *

**Note:** You must specify either **basic** or **bearer**, but not both. + */ +public class SearchSettingsDiscoveryAuthentication extends GenericModel { + + protected String basic; + protected String bearer; + + /** Builder. */ + public static class Builder { + private String basic; + private String bearer; + + /** + * Instantiates a new Builder from an existing SearchSettingsDiscoveryAuthentication instance. + * + * @param searchSettingsDiscoveryAuthentication the instance to initialize the Builder with + */ + private Builder(SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthentication) { + this.basic = searchSettingsDiscoveryAuthentication.basic; + this.bearer = searchSettingsDiscoveryAuthentication.bearer; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a SearchSettingsDiscoveryAuthentication. + * + * @return the new SearchSettingsDiscoveryAuthentication instance + */ + public SearchSettingsDiscoveryAuthentication build() { + return new SearchSettingsDiscoveryAuthentication(this); + } + + /** + * Set the basic. + * + * @param basic the basic + * @return the SearchSettingsDiscoveryAuthentication builder + */ + public Builder basic(String basic) { + this.basic = basic; + return this; + } + + /** + * Set the bearer. + * + * @param bearer the bearer + * @return the SearchSettingsDiscoveryAuthentication builder + */ + public Builder bearer(String bearer) { + this.bearer = bearer; + return this; + } + } + + protected SearchSettingsDiscoveryAuthentication() {} + + protected SearchSettingsDiscoveryAuthentication(Builder builder) { + basic = builder.basic; + bearer = builder.bearer; + } + + /** + * New builder. + * + * @return a SearchSettingsDiscoveryAuthentication builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the basic. + * + *

The HTTP basic authentication credentials for Watson Discovery. Specify your Watson + * Discovery API key in the format `apikey:{apikey}`. + * + * @return the basic + */ + public String basic() { + return basic; + } + + /** + * Gets the bearer. + * + *

The authentication bearer token for Watson Discovery. + * + * @return the bearer + */ + public String bearer() { + return bearer; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsElasticSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsElasticSearch.java new file mode 100644 index 00000000000..162f662aee8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsElasticSearch.java @@ -0,0 +1,344 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Configuration settings for the Elasticsearch service used by the search integration. You can + * provide either basic auth or apiKey auth. + */ +public class SearchSettingsElasticSearch extends GenericModel { + + protected String url; + protected String port; + protected String username; + protected String password; + protected String index; + protected List filter; + + @SerializedName("query_body") + protected Map queryBody; + + @SerializedName("managed_index") + protected String managedIndex; + + protected String apikey; + + /** Builder. */ + public static class Builder { + private String url; + private String port; + private String username; + private String password; + private String index; + private List filter; + private Map queryBody; + private String managedIndex; + private String apikey; + + /** + * Instantiates a new Builder from an existing SearchSettingsElasticSearch instance. + * + * @param searchSettingsElasticSearch the instance to initialize the Builder with + */ + private Builder(SearchSettingsElasticSearch searchSettingsElasticSearch) { + this.url = searchSettingsElasticSearch.url; + this.port = searchSettingsElasticSearch.port; + this.username = searchSettingsElasticSearch.username; + this.password = searchSettingsElasticSearch.password; + this.index = searchSettingsElasticSearch.index; + this.filter = searchSettingsElasticSearch.filter; + this.queryBody = searchSettingsElasticSearch.queryBody; + this.managedIndex = searchSettingsElasticSearch.managedIndex; + this.apikey = searchSettingsElasticSearch.apikey; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param url the url + * @param port the port + * @param index the index + */ + public Builder(String url, String port, String index) { + this.url = url; + this.port = port; + this.index = index; + } + + /** + * Builds a SearchSettingsElasticSearch. + * + * @return the new SearchSettingsElasticSearch instance + */ + public SearchSettingsElasticSearch build() { + return new SearchSettingsElasticSearch(this); + } + + /** + * Adds a new element to filter. + * + * @param filter the new element to be added + * @return the SearchSettingsElasticSearch builder + */ + public Builder addFilter(Object filter) { + com.ibm.cloud.sdk.core.util.Validator.notNull(filter, "filter cannot be null"); + if (this.filter == null) { + this.filter = new ArrayList(); + } + this.filter.add(filter); + return this; + } + + /** + * Set the url. + * + * @param url the url + * @return the SearchSettingsElasticSearch builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the port. + * + * @param port the port + * @return the SearchSettingsElasticSearch builder + */ + public Builder port(String port) { + this.port = port; + return this; + } + + /** + * Set the username. + * + * @param username the username + * @return the SearchSettingsElasticSearch builder + */ + public Builder username(String username) { + this.username = username; + return this; + } + + /** + * Set the password. + * + * @param password the password + * @return the SearchSettingsElasticSearch builder + */ + public Builder password(String password) { + this.password = password; + return this; + } + + /** + * Set the index. + * + * @param index the index + * @return the SearchSettingsElasticSearch builder + */ + public Builder index(String index) { + this.index = index; + return this; + } + + /** + * Set the filter. Existing filter will be replaced. + * + * @param filter the filter + * @return the SearchSettingsElasticSearch builder + */ + public Builder filter(List filter) { + this.filter = filter; + return this; + } + + /** + * Set the queryBody. + * + * @param queryBody the queryBody + * @return the SearchSettingsElasticSearch builder + */ + public Builder queryBody(Map queryBody) { + this.queryBody = queryBody; + return this; + } + + /** + * Set the managedIndex. + * + * @param managedIndex the managedIndex + * @return the SearchSettingsElasticSearch builder + */ + public Builder managedIndex(String managedIndex) { + this.managedIndex = managedIndex; + return this; + } + + /** + * Set the apikey. + * + * @param apikey the apikey + * @return the SearchSettingsElasticSearch builder + */ + public Builder apikey(String apikey) { + this.apikey = apikey; + return this; + } + } + + protected SearchSettingsElasticSearch() {} + + protected SearchSettingsElasticSearch(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, "url cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.port, "port cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.index, "index cannot be null"); + url = builder.url; + port = builder.port; + username = builder.username; + password = builder.password; + index = builder.index; + filter = builder.filter; + queryBody = builder.queryBody; + managedIndex = builder.managedIndex; + apikey = builder.apikey; + } + + /** + * New builder. + * + * @return a SearchSettingsElasticSearch builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The URL for the Elasticsearch service. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the port. + * + *

The port number for the Elasticsearch service URL. + * + *

**Note:** It can be omitted if a port number is appended to the URL. + * + * @return the port + */ + public String port() { + return port; + } + + /** + * Gets the username. + * + *

The username of the basic authentication method. + * + * @return the username + */ + public String username() { + return username; + } + + /** + * Gets the password. + * + *

The password of the basic authentication method. The credentials are not returned due to + * security reasons. + * + * @return the password + */ + public String password() { + return password; + } + + /** + * Gets the index. + * + *

The Elasticsearch index to use for the search integration. + * + * @return the index + */ + public String index() { + return index; + } + + /** + * Gets the filter. + * + *

An array of filters that can be applied to the search results via the `$FILTER` variable in + * the `query_body`.For more information, see [Elasticsearch filter + * documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/filter-search-results.html). + * + * @return the filter + */ + public List filter() { + return filter; + } + + /** + * Gets the queryBody. + * + *

The Elasticsearch query object. For more information, see [Elasticsearch search API + * documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html). + * + * @return the queryBody + */ + public Map queryBody() { + return queryBody; + } + + /** + * Gets the managedIndex. + * + *

The Elasticsearch index for uploading documents. It is created automatically when the upload + * document option is selected from the user interface. + * + * @return the managedIndex + */ + public String managedIndex() { + return managedIndex; + } + + /** + * Gets the apikey. + * + *

The API key of the apiKey authentication method. Use either basic auth or apiKey auth. The + * credentials are not returned due to security reasons. + * + * @return the apikey + */ + public String apikey() { + return apikey; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsMessages.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsMessages.java new file mode 100644 index 00000000000..6b85b69aa9b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsMessages.java @@ -0,0 +1,156 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The messages included with responses from the search integration. */ +public class SearchSettingsMessages extends GenericModel { + + protected String success; + protected String error; + + @SerializedName("no_result") + protected String noResult; + + /** Builder. */ + public static class Builder { + private String success; + private String error; + private String noResult; + + /** + * Instantiates a new Builder from an existing SearchSettingsMessages instance. + * + * @param searchSettingsMessages the instance to initialize the Builder with + */ + private Builder(SearchSettingsMessages searchSettingsMessages) { + this.success = searchSettingsMessages.success; + this.error = searchSettingsMessages.error; + this.noResult = searchSettingsMessages.noResult; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param success the success + * @param error the error + * @param noResult the noResult + */ + public Builder(String success, String error, String noResult) { + this.success = success; + this.error = error; + this.noResult = noResult; + } + + /** + * Builds a SearchSettingsMessages. + * + * @return the new SearchSettingsMessages instance + */ + public SearchSettingsMessages build() { + return new SearchSettingsMessages(this); + } + + /** + * Set the success. + * + * @param success the success + * @return the SearchSettingsMessages builder + */ + public Builder success(String success) { + this.success = success; + return this; + } + + /** + * Set the error. + * + * @param error the error + * @return the SearchSettingsMessages builder + */ + public Builder error(String error) { + this.error = error; + return this; + } + + /** + * Set the noResult. + * + * @param noResult the noResult + * @return the SearchSettingsMessages builder + */ + public Builder noResult(String noResult) { + this.noResult = noResult; + return this; + } + } + + protected SearchSettingsMessages() {} + + protected SearchSettingsMessages(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.success, "success cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.error, "error cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.noResult, "noResult cannot be null"); + success = builder.success; + error = builder.error; + noResult = builder.noResult; + } + + /** + * New builder. + * + * @return a SearchSettingsMessages builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the success. + * + *

The message to include in the response to a successful query. + * + * @return the success + */ + public String success() { + return success; + } + + /** + * Gets the error. + * + *

The message to include in the response when the query encounters an error. + * + * @return the error + */ + public String error() { + return error; + } + + /** + * Gets the noResult. + * + *

The message to include in the response when there is no result from the query. + * + * @return the noResult + */ + public String noResult() { + return noResult; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsSchemaMapping.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsSchemaMapping.java new file mode 100644 index 00000000000..27b1d47814f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsSchemaMapping.java @@ -0,0 +1,156 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The mapping between fields in the Watson Discovery collection and properties in the search + * response. + */ +public class SearchSettingsSchemaMapping extends GenericModel { + + protected String url; + protected String body; + protected String title; + + /** Builder. */ + public static class Builder { + private String url; + private String body; + private String title; + + /** + * Instantiates a new Builder from an existing SearchSettingsSchemaMapping instance. + * + * @param searchSettingsSchemaMapping the instance to initialize the Builder with + */ + private Builder(SearchSettingsSchemaMapping searchSettingsSchemaMapping) { + this.url = searchSettingsSchemaMapping.url; + this.body = searchSettingsSchemaMapping.body; + this.title = searchSettingsSchemaMapping.title; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param url the url + * @param body the body + * @param title the title + */ + public Builder(String url, String body, String title) { + this.url = url; + this.body = body; + this.title = title; + } + + /** + * Builds a SearchSettingsSchemaMapping. + * + * @return the new SearchSettingsSchemaMapping instance + */ + public SearchSettingsSchemaMapping build() { + return new SearchSettingsSchemaMapping(this); + } + + /** + * Set the url. + * + * @param url the url + * @return the SearchSettingsSchemaMapping builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the body. + * + * @param body the body + * @return the SearchSettingsSchemaMapping builder + */ + public Builder body(String body) { + this.body = body; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the SearchSettingsSchemaMapping builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + } + + protected SearchSettingsSchemaMapping() {} + + protected SearchSettingsSchemaMapping(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, "url cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.body, "body cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + url = builder.url; + body = builder.body; + title = builder.title; + } + + /** + * New builder. + * + * @return a SearchSettingsSchemaMapping builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The field in the collection to map to the **url** property of the response. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the body. + * + *

The field in the collection to map to the **body** property in the response. + * + * @return the body + */ + public String body() { + return body; + } + + /** + * Gets the title. + * + *

The field in the collection to map to the **title** property for the schema. + * + * @return the title + */ + public String title() { + return title; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsServerSideSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsServerSideSearch.java new file mode 100644 index 00000000000..4f91a3dd09a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSettingsServerSideSearch.java @@ -0,0 +1,324 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** + * Configuration settings for the server-side search service used by the search integration. You can + * provide either basic auth, apiKey auth or none. + */ +public class SearchSettingsServerSideSearch extends GenericModel { + + /** The authorization type that is used. */ + public interface AuthType { + /** basic. */ + String BASIC = "basic"; + /** apikey. */ + String APIKEY = "apikey"; + /** none. */ + String NONE = "none"; + } + + protected String url; + protected String port; + protected String username; + protected String password; + protected String filter; + protected Map metadata; + protected String apikey; + + @SerializedName("no_auth") + protected Boolean noAuth; + + @SerializedName("auth_type") + protected String authType; + + /** Builder. */ + public static class Builder { + private String url; + private String port; + private String username; + private String password; + private String filter; + private Map metadata; + private String apikey; + private Boolean noAuth; + private String authType; + + /** + * Instantiates a new Builder from an existing SearchSettingsServerSideSearch instance. + * + * @param searchSettingsServerSideSearch the instance to initialize the Builder with + */ + private Builder(SearchSettingsServerSideSearch searchSettingsServerSideSearch) { + this.url = searchSettingsServerSideSearch.url; + this.port = searchSettingsServerSideSearch.port; + this.username = searchSettingsServerSideSearch.username; + this.password = searchSettingsServerSideSearch.password; + this.filter = searchSettingsServerSideSearch.filter; + this.metadata = searchSettingsServerSideSearch.metadata; + this.apikey = searchSettingsServerSideSearch.apikey; + this.noAuth = searchSettingsServerSideSearch.noAuth; + this.authType = searchSettingsServerSideSearch.authType; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param url the url + */ + public Builder(String url) { + this.url = url; + } + + /** + * Builds a SearchSettingsServerSideSearch. + * + * @return the new SearchSettingsServerSideSearch instance + */ + public SearchSettingsServerSideSearch build() { + return new SearchSettingsServerSideSearch(this); + } + + /** + * Set the url. + * + * @param url the url + * @return the SearchSettingsServerSideSearch builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the port. + * + * @param port the port + * @return the SearchSettingsServerSideSearch builder + */ + public Builder port(String port) { + this.port = port; + return this; + } + + /** + * Set the username. + * + * @param username the username + * @return the SearchSettingsServerSideSearch builder + */ + public Builder username(String username) { + this.username = username; + return this; + } + + /** + * Set the password. + * + * @param password the password + * @return the SearchSettingsServerSideSearch builder + */ + public Builder password(String password) { + this.password = password; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the SearchSettingsServerSideSearch builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the SearchSettingsServerSideSearch builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the apikey. + * + * @param apikey the apikey + * @return the SearchSettingsServerSideSearch builder + */ + public Builder apikey(String apikey) { + this.apikey = apikey; + return this; + } + + /** + * Set the noAuth. + * + * @param noAuth the noAuth + * @return the SearchSettingsServerSideSearch builder + */ + public Builder noAuth(Boolean noAuth) { + this.noAuth = noAuth; + return this; + } + + /** + * Set the authType. + * + * @param authType the authType + * @return the SearchSettingsServerSideSearch builder + */ + public Builder authType(String authType) { + this.authType = authType; + return this; + } + } + + protected SearchSettingsServerSideSearch() {} + + protected SearchSettingsServerSideSearch(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, "url cannot be null"); + url = builder.url; + port = builder.port; + username = builder.username; + password = builder.password; + filter = builder.filter; + metadata = builder.metadata; + apikey = builder.apikey; + noAuth = builder.noAuth; + authType = builder.authType; + } + + /** + * New builder. + * + * @return a SearchSettingsServerSideSearch builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The URL of the server-side search service. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the port. + * + *

The port number of the server-side search service. + * + * @return the port + */ + public String port() { + return port; + } + + /** + * Gets the username. + * + *

The username of the basic authentication method. + * + * @return the username + */ + public String username() { + return username; + } + + /** + * Gets the password. + * + *

The password of the basic authentication method. The credentials are not returned due to + * security reasons. + * + * @return the password + */ + public String password() { + return password; + } + + /** + * Gets the filter. + * + *

The filter string that is applied to the search results. + * + * @return the filter + */ + public String filter() { + return filter; + } + + /** + * Gets the metadata. + * + *

The metadata object. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the apikey. + * + *

The API key of the apiKey authentication method. The credentails are not returned due to + * security reasons. + * + * @return the apikey + */ + public String apikey() { + return apikey; + } + + /** + * Gets the noAuth. + * + *

To clear previous auth, specify `no_auth = true`. + * + * @return the noAuth + */ + public Boolean noAuth() { + return noAuth; + } + + /** + * Gets the authType. + * + *

The authorization type that is used. + * + * @return the authType + */ + public String authType() { + return authType; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSkillWarning.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSkillWarning.java new file mode 100644 index 00000000000..b569c9bdce3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchSkillWarning.java @@ -0,0 +1,137 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A warning describing an error in the search skill configuration. */ +public class SearchSkillWarning extends GenericModel { + + protected String code; + protected String path; + protected String message; + + /** Builder. */ + public static class Builder { + private String code; + private String path; + private String message; + + /** + * Instantiates a new Builder from an existing SearchSkillWarning instance. + * + * @param searchSkillWarning the instance to initialize the Builder with + */ + private Builder(SearchSkillWarning searchSkillWarning) { + this.code = searchSkillWarning.code; + this.path = searchSkillWarning.path; + this.message = searchSkillWarning.message; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a SearchSkillWarning. + * + * @return the new SearchSkillWarning instance + */ + public SearchSkillWarning build() { + return new SearchSkillWarning(this); + } + + /** + * Set the code. + * + * @param code the code + * @return the SearchSkillWarning builder + */ + public Builder code(String code) { + this.code = code; + return this; + } + + /** + * Set the path. + * + * @param path the path + * @return the SearchSkillWarning builder + */ + public Builder path(String path) { + this.path = path; + return this; + } + + /** + * Set the message. + * + * @param message the message + * @return the SearchSkillWarning builder + */ + public Builder message(String message) { + this.message = message; + return this; + } + } + + protected SearchSkillWarning() {} + + protected SearchSkillWarning(Builder builder) { + code = builder.code; + path = builder.path; + message = builder.message; + } + + /** + * New builder. + * + * @return a SearchSkillWarning builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the code. + * + *

The error code. + * + * @return the code + */ + public String code() { + return code; + } + + /** + * Gets the path. + * + *

The location of the error in the search skill configuration object. + * + * @return the path + */ + public String path() { + return path; + } + + /** + * Gets the message. + * + *

The error message. + * + * @return the message + */ + public String message() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java index e8d23dc87f2..63817af86f5 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,24 @@ * 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.assistant.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * SessionResponse. - */ +/** SessionResponse. */ public class SessionResponse extends GenericModel { @SerializedName("session_id") protected String sessionId; + protected SessionResponse() {} + /** * Gets the sessionId. * - * The session ID. + *

The session ID. * * @return the sessionId */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Skill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Skill.java new file mode 100644 index 00000000000..b3c5ae2daef --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Skill.java @@ -0,0 +1,297 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** Skill. */ +public class Skill extends GenericModel { + + /** + * The current status of the skill: - **Available**: The skill is available and ready to process + * messages. - **Failed**: An asynchronous operation has failed. See the **status_errors** + * property for more information about the cause of the failure. - **Non Existent**: The skill + * does not exist. - **Processing**: An asynchronous operation has not yet completed. - + * **Training**: The skill is training based on new data. + */ + public interface Status { + /** Available. */ + String AVAILABLE = "Available"; + /** Failed. */ + String FAILED = "Failed"; + /** Non Existent. */ + String NON_EXISTENT = "Non Existent"; + /** Processing. */ + String PROCESSING = "Processing"; + /** Training. */ + String TRAINING = "Training"; + /** Unavailable. */ + String UNAVAILABLE = "Unavailable"; + } + + /** The type of skill. */ + public interface Type { + /** action. */ + String ACTION = "action"; + /** dialog. */ + String DIALOG = "dialog"; + /** search. */ + String SEARCH = "search"; + } + + protected String name; + protected String description; + protected Map workspace; + + @SerializedName("skill_id") + protected String skillId; + + protected String status; + + @SerializedName("status_errors") + protected List statusErrors; + + @SerializedName("status_description") + protected String statusDescription; + + @SerializedName("dialog_settings") + protected Map dialogSettings; + + @SerializedName("assistant_id") + protected String assistantId; + + @SerializedName("workspace_id") + protected String workspaceId; + + @SerializedName("environment_id") + protected String environmentId; + + protected Boolean valid; + + @SerializedName("next_snapshot_version") + protected String nextSnapshotVersion; + + @SerializedName("search_settings") + protected SearchSettings searchSettings; + + protected List warnings; + protected String language; + protected String type; + + protected Skill() {} + + /** + * Gets the name. + * + *

The name of the skill. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

The description of the skill. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the workspace. + * + *

An object containing the conversational content of an action or dialog skill. + * + * @return the workspace + */ + public Map getWorkspace() { + return workspace; + } + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String getSkillId() { + return skillId; + } + + /** + * Gets the status. + * + *

The current status of the skill: - **Available**: The skill is available and ready to + * process messages. - **Failed**: An asynchronous operation has failed. See the **status_errors** + * property for more information about the cause of the failure. - **Non Existent**: The skill + * does not exist. - **Processing**: An asynchronous operation has not yet completed. - + * **Training**: The skill is training based on new data. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the statusErrors. + * + *

An array of messages about errors that caused an asynchronous operation to fail. Included + * only if **status**=`Failed`. + * + * @return the statusErrors + */ + public List getStatusErrors() { + return statusErrors; + } + + /** + * Gets the statusDescription. + * + *

The description of the failed asynchronous operation. Included only if **status**=`Failed`. + * + * @return the statusDescription + */ + public String getStatusDescription() { + return statusDescription; + } + + /** + * Gets the dialogSettings. + * + *

For internal use only. + * + * @return the dialogSettings + */ + public Map getDialogSettings() { + return dialogSettings; + } + + /** + * Gets the assistantId. + * + *

The unique identifier of the assistant the skill is associated with. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the workspaceId. + * + *

The unique identifier of the workspace that contains the skill content. Included only for + * action and dialog skills. + * + * @return the workspaceId + */ + public String getWorkspaceId() { + return workspaceId; + } + + /** + * Gets the environmentId. + * + *

The unique identifier of the environment where the skill is defined. For action and dialog + * skills, this is always the draft environment. + * + * @return the environmentId + */ + public String getEnvironmentId() { + return environmentId; + } + + /** + * Gets the valid. + * + *

Whether the skill is structurally valid. + * + * @return the valid + */ + public Boolean isValid() { + return valid; + } + + /** + * Gets the nextSnapshotVersion. + * + *

The name that will be given to the next snapshot that is created for the skill. A snapshot + * of each versionable skill is saved for each new release of an assistant. + * + * @return the nextSnapshotVersion + */ + public String getNextSnapshotVersion() { + return nextSnapshotVersion; + } + + /** + * Gets the searchSettings. + * + *

An object describing the search skill configuration. + * + *

**Note:** Search settings are not supported in **Import skills** requests, and are not + * included in **Export skills** responses. + * + * @return the searchSettings + */ + public SearchSettings getSearchSettings() { + return searchSettings; + } + + /** + * Gets the warnings. + * + *

An array of warnings describing errors with the search skill configuration. Included only + * for search skills. + * + * @return the warnings + */ + public List getWarnings() { + return warnings; + } + + /** + * Gets the language. + * + *

The language of the skill. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the type. + * + *

The type of skill. + * + * @return the type + */ + public String getType() { + return type; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillImport.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillImport.java new file mode 100644 index 00000000000..67f4332635a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillImport.java @@ -0,0 +1,442 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** SkillImport. */ +public class SkillImport extends GenericModel { + + /** + * The current status of the skill: - **Available**: The skill is available and ready to process + * messages. - **Failed**: An asynchronous operation has failed. See the **status_errors** + * property for more information about the cause of the failure. - **Non Existent**: The skill + * does not exist. - **Processing**: An asynchronous operation has not yet completed. - + * **Training**: The skill is training based on new data. + */ + public interface Status { + /** Available. */ + String AVAILABLE = "Available"; + /** Failed. */ + String FAILED = "Failed"; + /** Non Existent. */ + String NON_EXISTENT = "Non Existent"; + /** Processing. */ + String PROCESSING = "Processing"; + /** Training. */ + String TRAINING = "Training"; + /** Unavailable. */ + String UNAVAILABLE = "Unavailable"; + } + + /** The type of skill. */ + public interface Type { + /** action. */ + String ACTION = "action"; + /** dialog. */ + String DIALOG = "dialog"; + } + + protected String name; + protected String description; + protected Map workspace; + + @SerializedName("skill_id") + protected String skillId; + + protected String status; + + @SerializedName("status_errors") + protected List statusErrors; + + @SerializedName("status_description") + protected String statusDescription; + + @SerializedName("dialog_settings") + protected Map dialogSettings; + + @SerializedName("assistant_id") + protected String assistantId; + + @SerializedName("workspace_id") + protected String workspaceId; + + @SerializedName("environment_id") + protected String environmentId; + + protected Boolean valid; + + @SerializedName("next_snapshot_version") + protected String nextSnapshotVersion; + + @SerializedName("search_settings") + protected SearchSettings searchSettings; + + protected List warnings; + protected String language; + protected String type; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private Map workspace; + private Map dialogSettings; + private SearchSettings searchSettings; + private String language; + private String type; + + /** + * Instantiates a new Builder from an existing SkillImport instance. + * + * @param skillImport the instance to initialize the Builder with + */ + private Builder(SkillImport skillImport) { + this.name = skillImport.name; + this.description = skillImport.description; + this.workspace = skillImport.workspace; + this.dialogSettings = skillImport.dialogSettings; + this.searchSettings = skillImport.searchSettings; + this.language = skillImport.language; + this.type = skillImport.type; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param language the language + * @param type the type + */ + public Builder(String language, String type) { + this.language = language; + this.type = type; + } + + /** + * Builds a SkillImport. + * + * @return the new SkillImport instance + */ + public SkillImport build() { + return new SkillImport(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the SkillImport builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the SkillImport builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the workspace. + * + * @param workspace the workspace + * @return the SkillImport builder + */ + public Builder workspace(Map workspace) { + this.workspace = workspace; + return this; + } + + /** + * Set the dialogSettings. + * + * @param dialogSettings the dialogSettings + * @return the SkillImport builder + */ + public Builder dialogSettings(Map dialogSettings) { + this.dialogSettings = dialogSettings; + return this; + } + + /** + * Set the searchSettings. + * + * @param searchSettings the searchSettings + * @return the SkillImport builder + */ + public Builder searchSettings(SearchSettings searchSettings) { + this.searchSettings = searchSettings; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the SkillImport builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the SkillImport builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + } + + protected SkillImport() {} + + protected SkillImport(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, "type cannot be null"); + name = builder.name; + description = builder.description; + workspace = builder.workspace; + dialogSettings = builder.dialogSettings; + searchSettings = builder.searchSettings; + language = builder.language; + type = builder.type; + } + + /** + * New builder. + * + * @return a SkillImport builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of the skill. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the skill. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the workspace. + * + *

An object containing the conversational content of an action or dialog skill. + * + * @return the workspace + */ + public Map workspace() { + return workspace; + } + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the status. + * + *

The current status of the skill: - **Available**: The skill is available and ready to + * process messages. - **Failed**: An asynchronous operation has failed. See the **status_errors** + * property for more information about the cause of the failure. - **Non Existent**: The skill + * does not exist. - **Processing**: An asynchronous operation has not yet completed. - + * **Training**: The skill is training based on new data. + * + * @return the status + */ + public String status() { + return status; + } + + /** + * Gets the statusErrors. + * + *

An array of messages about errors that caused an asynchronous operation to fail. Included + * only if **status**=`Failed`. + * + * @return the statusErrors + */ + public List statusErrors() { + return statusErrors; + } + + /** + * Gets the statusDescription. + * + *

The description of the failed asynchronous operation. Included only if **status**=`Failed`. + * + * @return the statusDescription + */ + public String statusDescription() { + return statusDescription; + } + + /** + * Gets the dialogSettings. + * + *

For internal use only. + * + * @return the dialogSettings + */ + public Map dialogSettings() { + return dialogSettings; + } + + /** + * Gets the assistantId. + * + *

The unique identifier of the assistant the skill is associated with. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the workspaceId. + * + *

The unique identifier of the workspace that contains the skill content. Included only for + * action and dialog skills. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the environmentId. + * + *

The unique identifier of the environment where the skill is defined. For action and dialog + * skills, this is always the draft environment. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the valid. + * + *

Whether the skill is structurally valid. + * + * @return the valid + */ + public Boolean valid() { + return valid; + } + + /** + * Gets the nextSnapshotVersion. + * + *

The name that will be given to the next snapshot that is created for the skill. A snapshot + * of each versionable skill is saved for each new release of an assistant. + * + * @return the nextSnapshotVersion + */ + public String nextSnapshotVersion() { + return nextSnapshotVersion; + } + + /** + * Gets the searchSettings. + * + *

An object describing the search skill configuration. + * + *

**Note:** Search settings are not supported in **Import skills** requests, and are not + * included in **Export skills** responses. + * + * @return the searchSettings + */ + public SearchSettings searchSettings() { + return searchSettings; + } + + /** + * Gets the warnings. + * + *

An array of warnings describing errors with the search skill configuration. Included only + * for search skills. + * + * @return the warnings + */ + public List warnings() { + return warnings; + } + + /** + * Gets the language. + * + *

The language of the skill. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the type. + * + *

The type of skill. + * + * @return the type + */ + public String type() { + return type; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillReference.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillReference.java new file mode 100644 index 00000000000..8615356e2b3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillReference.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SkillReference. */ +public class SkillReference extends GenericModel { + + /** The type of the skill. */ + public interface Type { + /** dialog. */ + String DIALOG = "dialog"; + /** action. */ + String ACTION = "action"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("skill_id") + protected String skillId; + + protected String type; + protected Boolean disabled; + protected String snapshot; + + @SerializedName("skill_reference") + protected String skillReference; + + /** + * Gets the skillId. + * + *

The skill ID of the skill. + * + * @return the skillId + */ + public String getSkillId() { + return skillId; + } + + /** + * Gets the type. + * + *

The type of the skill. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the disabled. + * + *

Whether the skill is disabled. A disabled skill in the draft environment does not handle any + * messages at run time, and it is not included in saved releases. + * + * @return the disabled + */ + public Boolean isDisabled() { + return disabled; + } + + /** + * Gets the snapshot. + * + *

The name of the snapshot (skill version) that is saved as part of the release (for example, + * `draft` or `1`). + * + * @return the snapshot + */ + public String getSnapshot() { + return snapshot; + } + + /** + * Gets the skillReference. + * + *

The type of skill identified by the skill reference. The possible values are `main skill` + * (for a dialog skill), `actions skill`, and `search skill`. + * + * @return the skillReference + */ + public String getSkillReference() { + return skillReference; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillsAsyncRequestStatus.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillsAsyncRequestStatus.java new file mode 100644 index 00000000000..a1c8e515340 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillsAsyncRequestStatus.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** SkillsAsyncRequestStatus. */ +public class SkillsAsyncRequestStatus extends GenericModel { + + /** + * The current status of the asynchronous operation: - `Available`: An asynchronous export is + * available. - `Completed`: An asynchronous import operation has completed successfully. - + * `Failed`: An asynchronous operation has failed. See the **status_errors** property for more + * information about the cause of the failure. - `Processing`: An asynchronous operation has not + * yet completed. + */ + public interface Status { + /** Available. */ + String AVAILABLE = "Available"; + /** Completed. */ + String COMPLETED = "Completed"; + /** Failed. */ + String FAILED = "Failed"; + /** Processing. */ + String PROCESSING = "Processing"; + } + + @SerializedName("assistant_id") + protected String assistantId; + + protected String status; + + @SerializedName("status_description") + protected String statusDescription; + + @SerializedName("status_errors") + protected List statusErrors; + + protected SkillsAsyncRequestStatus() {} + + /** + * Gets the assistantId. + * + *

The assistant ID of the assistant. + * + * @return the assistantId + */ + public String getAssistantId() { + return assistantId; + } + + /** + * Gets the status. + * + *

The current status of the asynchronous operation: - `Available`: An asynchronous export is + * available. - `Completed`: An asynchronous import operation has completed successfully. - + * `Failed`: An asynchronous operation has failed. See the **status_errors** property for more + * information about the cause of the failure. - `Processing`: An asynchronous operation has not + * yet completed. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the statusDescription. + * + *

The description of the failed asynchronous operation. Included only if **status**=`Failed`. + * + * @return the statusDescription + */ + public String getStatusDescription() { + return statusDescription; + } + + /** + * Gets the statusErrors. + * + *

An array of messages about errors that caused an asynchronous operation to fail. Included + * only if **status**=`Failed`. + * + * @return the statusErrors + */ + public List getStatusErrors() { + return statusErrors; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillsExport.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillsExport.java new file mode 100644 index 00000000000..45c0b1c310e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SkillsExport.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** SkillsExport. */ +public class SkillsExport extends GenericModel { + + @SerializedName("assistant_skills") + protected List assistantSkills; + + @SerializedName("assistant_state") + protected AssistantState assistantState; + + protected SkillsExport() {} + + /** + * Gets the assistantSkills. + * + *

An array of objects describing the skills for the assistant. Included in responses only if + * **status**=`Available`. + * + * @return the assistantSkills + */ + public List getAssistantSkills() { + return assistantSkills; + } + + /** + * Gets the assistantState. + * + *

Status information about the skills for the assistant. Included in responses only if + * **status**=`Available`. + * + * @return the assistantState + */ + public AssistantState getAssistantState() { + return assistantState; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponse.java new file mode 100644 index 00000000000..0511730897a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponse.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A response from the watsonx Assistant service. */ +public class StatefulMessageResponse extends GenericModel { + + protected MessageOutput output; + protected MessageContext context; + + @SerializedName("user_id") + protected String userId; + + @SerializedName("masked_output") + protected MessageOutput maskedOutput; + + @SerializedName("masked_input") + protected MessageInput maskedInput; + + protected StatefulMessageResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. + * + * @return the output + */ + public MessageOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is stored by the assistant on a per-session basis. + * + *

**Note:** The context is included in message responses only if **return_context**=`true` in + * the message request. Full context is always included in logs. + * + * @return the context + */ + public MessageContext getContext() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } + + /** + * Gets the maskedOutput. + * + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + * + * @return the maskedOutput + */ + public MessageOutput getMaskedOutput() { + return maskedOutput; + } + + /** + * Gets the maskedInput. + * + *

An input object that includes the input text. All private data is masked or removed. + * + * @return the maskedInput + */ + public MessageInput getMaskedInput() { + return maskedInput; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponse.java new file mode 100644 index 00000000000..9ff9afeef07 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponse.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Message final response content. */ +public class StatelessFinalResponse extends GenericModel { + + protected StatelessFinalResponseOutput output; + protected StatelessMessageContext context; + + @SerializedName("user_id") + protected String userId; + + protected StatelessFinalResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. + * + * @return the output + */ + public StatelessFinalResponseOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is stored by the assistant on a per-session basis. + * + *

**Note:** The context is included in message responses only if **return_context**=`true` in + * the message request. Full context is always included in logs. + * + * @return the context + */ + public StatelessMessageContext getContext() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseOutput.java new file mode 100644 index 00000000000..0d86df8d9fc --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseOutput.java @@ -0,0 +1,142 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** Assistant output to be rendered or processed by the client. */ +public class StatelessFinalResponseOutput extends GenericModel { + + protected List generic; + protected List intents; + protected List entities; + protected List actions; + protected MessageOutputDebug debug; + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageOutputSpelling spelling; + + @SerializedName("llm_metadata") + protected List llmMetadata; + + @SerializedName("streaming_metadata") + protected StatelessMessageContext streamingMetadata; + + protected StatelessFinalResponseOutput() {} + + /** + * Gets the generic. + * + *

Output intended for any channel. It is the responsibility of the client application to + * implement the supported response types. + * + * @return the generic + */ + public List getGeneric() { + return generic; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the user input, sorted in descending order of confidence. + * + * @return the intents + */ + public List getIntents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the user input. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the actions. + * + *

An array of objects describing any actions requested by the dialog node. + * + * @return the actions + */ + public List getActions() { + return actions; + } + + /** + * Gets the debug. + * + *

Additional detailed information about a message response and how it was generated. + * + * @return the debug + */ + public MessageOutputDebug getDebug() { + return debug; + } + + /** + * Gets the userDefined. + * + *

An object containing any custom properties included in the response. This object includes + * any arbitrary properties defined in the dialog JSON editor as part of the dialog node output. + * + * @return the userDefined + */ + public Map getUserDefined() { + return userDefined; + } + + /** + * Gets the spelling. + * + *

Properties describing any spelling corrections in the user input that was received. + * + * @return the spelling + */ + public MessageOutputSpelling getSpelling() { + return spelling; + } + + /** + * Gets the llmMetadata. + * + *

An array of objects that provide information about calls to large language models that + * occured as part of handling this message. + * + * @return the llmMetadata + */ + public List getLlmMetadata() { + return llmMetadata; + } + + /** + * Gets the streamingMetadata. + * + * @return the streamingMetadata + */ + public StatelessMessageContext getStreamingMetadata() { + return streamingMetadata; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContext.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContext.java new file mode 100644 index 00000000000..b0970694307 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContext.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** StatelessMessageContext. */ +public class StatelessMessageContext extends GenericModel { + + protected StatelessMessageContextGlobal global; + protected StatelessMessageContextSkills skills; + protected Map integrations; + + /** Builder. */ + public static class Builder { + private StatelessMessageContextGlobal global; + private StatelessMessageContextSkills skills; + private Map integrations; + + /** + * Instantiates a new Builder from an existing StatelessMessageContext instance. + * + * @param statelessMessageContext the instance to initialize the Builder with + */ + private Builder(StatelessMessageContext statelessMessageContext) { + this.global = statelessMessageContext.global; + this.skills = statelessMessageContext.skills; + this.integrations = statelessMessageContext.integrations; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContext. + * + * @return the new StatelessMessageContext instance + */ + public StatelessMessageContext build() { + return new StatelessMessageContext(this); + } + + /** + * Set the global. + * + * @param global the global + * @return the StatelessMessageContext builder + */ + public Builder global(StatelessMessageContextGlobal global) { + this.global = global; + return this; + } + + /** + * Set the skills. + * + * @param skills the skills + * @return the StatelessMessageContext builder + */ + public Builder skills(StatelessMessageContextSkills skills) { + this.skills = skills; + return this; + } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the StatelessMessageContext builder + */ + public Builder integrations(Map integrations) { + this.integrations = integrations; + return this; + } + } + + protected StatelessMessageContext() {} + + protected StatelessMessageContext(Builder builder) { + global = builder.global; + skills = builder.skills; + integrations = builder.integrations; + } + + /** + * New builder. + * + * @return a StatelessMessageContext builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the global. + * + *

Session context data that is shared by all skills used by the assistant. + * + * @return the global + */ + public StatelessMessageContextGlobal global() { + return global; + } + + /** + * Gets the skills. + * + *

Context data specific to particular skills used by the assistant. + * + * @return the skills + */ + public StatelessMessageContextSkills skills() { + return skills; + } + + /** + * Gets the integrations. + * + *

An object containing context data that is specific to particular integrations. For more + * information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations). + * + * @return the integrations + */ + public Map integrations() { + return integrations; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobal.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobal.java new file mode 100644 index 00000000000..00631826f13 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobal.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Session context data that is shared by all skills used by the assistant. */ +public class StatelessMessageContextGlobal extends GenericModel { + + protected MessageContextGlobalSystem system; + + @SerializedName("session_id") + protected String sessionId; + + /** Builder. */ + public static class Builder { + private MessageContextGlobalSystem system; + private String sessionId; + + /** + * Instantiates a new Builder from an existing StatelessMessageContextGlobal instance. + * + * @param statelessMessageContextGlobal the instance to initialize the Builder with + */ + private Builder(StatelessMessageContextGlobal statelessMessageContextGlobal) { + this.system = statelessMessageContextGlobal.system; + this.sessionId = statelessMessageContextGlobal.sessionId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContextGlobal. + * + * @return the new StatelessMessageContextGlobal instance + */ + public StatelessMessageContextGlobal build() { + return new StatelessMessageContextGlobal(this); + } + + /** + * Set the system. + * + * @param system the system + * @return the StatelessMessageContextGlobal builder + */ + public Builder system(MessageContextGlobalSystem system) { + this.system = system; + return this; + } + + /** + * Set the sessionId. + * + * @param sessionId the sessionId + * @return the StatelessMessageContextGlobal builder + */ + public Builder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + } + + protected StatelessMessageContextGlobal() {} + + protected StatelessMessageContextGlobal(Builder builder) { + system = builder.system; + sessionId = builder.sessionId; + } + + /** + * New builder. + * + * @return a StatelessMessageContextGlobal builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the system. + * + *

Built-in system properties that apply to all skills used by the assistant. + * + * @return the system + */ + public MessageContextGlobalSystem system() { + return system; + } + + /** + * Gets the sessionId. + * + *

The unique identifier of the session. + * + * @return the sessionId + */ + public String sessionId() { + return sessionId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkills.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkills.java new file mode 100644 index 00000000000..6f2495d6977 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkills.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Context data specific to particular skills used by the assistant. */ +public class StatelessMessageContextSkills extends GenericModel { + + @SerializedName("main skill") + protected MessageContextDialogSkill mainSkill; + + @SerializedName("actions skill") + protected StatelessMessageContextSkillsActionsSkill actionsSkill; + + /** Builder. */ + public static class Builder { + private MessageContextDialogSkill mainSkill; + private StatelessMessageContextSkillsActionsSkill actionsSkill; + + /** + * Instantiates a new Builder from an existing StatelessMessageContextSkills instance. + * + * @param statelessMessageContextSkills the instance to initialize the Builder with + */ + private Builder(StatelessMessageContextSkills statelessMessageContextSkills) { + this.mainSkill = statelessMessageContextSkills.mainSkill; + this.actionsSkill = statelessMessageContextSkills.actionsSkill; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContextSkills. + * + * @return the new StatelessMessageContextSkills instance + */ + public StatelessMessageContextSkills build() { + return new StatelessMessageContextSkills(this); + } + + /** + * Set the mainSkill. + * + * @param mainSkill the mainSkill + * @return the StatelessMessageContextSkills builder + */ + public Builder mainSkill(MessageContextDialogSkill mainSkill) { + this.mainSkill = mainSkill; + return this; + } + + /** + * Set the actionsSkill. + * + * @param actionsSkill the actionsSkill + * @return the StatelessMessageContextSkills builder + */ + public Builder actionsSkill(StatelessMessageContextSkillsActionsSkill actionsSkill) { + this.actionsSkill = actionsSkill; + return this; + } + } + + protected StatelessMessageContextSkills() {} + + protected StatelessMessageContextSkills(Builder builder) { + mainSkill = builder.mainSkill; + actionsSkill = builder.actionsSkill; + } + + /** + * New builder. + * + * @return a StatelessMessageContextSkills builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the mainSkill. + * + *

Context variables that are used by the dialog skill. + * + * @return the mainSkill + */ + public MessageContextDialogSkill mainSkill() { + return mainSkill; + } + + /** + * Gets the actionsSkill. + * + *

Context variables that are used by the action skill. + * + * @return the actionsSkill + */ + public StatelessMessageContextSkillsActionsSkill actionsSkill() { + return actionsSkill; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkill.java new file mode 100644 index 00000000000..c551297d575 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkill.java @@ -0,0 +1,238 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Context variables that are used by the action skill. */ +public class StatelessMessageContextSkillsActionsSkill extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + @SerializedName("action_variables") + protected Map actionVariables; + + @SerializedName("skill_variables") + protected Map skillVariables; + + @SerializedName("private_action_variables") + protected Map privateActionVariables; + + @SerializedName("private_skill_variables") + protected Map privateSkillVariables; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + private Map actionVariables; + private Map skillVariables; + private Map privateActionVariables; + private Map privateSkillVariables; + + /** + * Instantiates a new Builder from an existing StatelessMessageContextSkillsActionsSkill + * instance. + * + * @param statelessMessageContextSkillsActionsSkill the instance to initialize the Builder with + */ + private Builder( + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkill) { + this.userDefined = statelessMessageContextSkillsActionsSkill.userDefined; + this.system = statelessMessageContextSkillsActionsSkill.system; + this.actionVariables = statelessMessageContextSkillsActionsSkill.actionVariables; + this.skillVariables = statelessMessageContextSkillsActionsSkill.skillVariables; + this.privateActionVariables = + statelessMessageContextSkillsActionsSkill.privateActionVariables; + this.privateSkillVariables = statelessMessageContextSkillsActionsSkill.privateSkillVariables; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContextSkillsActionsSkill. + * + * @return the new StatelessMessageContextSkillsActionsSkill instance + */ + public StatelessMessageContextSkillsActionsSkill build() { + return new StatelessMessageContextSkillsActionsSkill(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + + /** + * Set the actionVariables. + * + * @param actionVariables the actionVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder actionVariables(Map actionVariables) { + this.actionVariables = actionVariables; + return this; + } + + /** + * Set the skillVariables. + * + * @param skillVariables the skillVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder skillVariables(Map skillVariables) { + this.skillVariables = skillVariables; + return this; + } + + /** + * Set the privateActionVariables. + * + * @param privateActionVariables the privateActionVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder privateActionVariables(Map privateActionVariables) { + this.privateActionVariables = privateActionVariables; + return this; + } + + /** + * Set the privateSkillVariables. + * + * @param privateSkillVariables the privateSkillVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder privateSkillVariables(Map privateSkillVariables) { + this.privateSkillVariables = privateSkillVariables; + return this; + } + } + + protected StatelessMessageContextSkillsActionsSkill() {} + + protected StatelessMessageContextSkillsActionsSkill(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + actionVariables = builder.actionVariables; + skillVariables = builder.skillVariables; + privateActionVariables = builder.privateActionVariables; + privateSkillVariables = builder.privateSkillVariables; + } + + /** + * New builder. + * + * @return a StatelessMessageContextSkillsActionsSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } + + /** + * Gets the actionVariables. + * + *

An object containing action variables. Action variables can be accessed only by steps in the + * same action, and do not persist after the action ends. + * + * @return the actionVariables + */ + public Map actionVariables() { + return actionVariables; + } + + /** + * Gets the skillVariables. + * + *

An object containing skill variables. (In the watsonx Assistant user interface, skill + * variables are called _session variables_.) Skill variables can be accessed by any action and + * persist for the duration of the session. + * + * @return the skillVariables + */ + public Map skillVariables() { + return skillVariables; + } + + /** + * Gets the privateActionVariables. + * + *

An object containing private action variables. Action variables can be accessed only by + * steps in the same action, and do not persist after the action ends. Private variables are + * encrypted. + * + * @return the privateActionVariables + */ + public Map privateActionVariables() { + return privateActionVariables; + } + + /** + * Gets the privateSkillVariables. + * + *

An object containing private skill variables. (In the watsonx Assistant user interface, + * skill variables are called _session variables_.) Skill variables can be accessed by any action + * and persist for the duration of the session. Private variables are encrypted. + * + * @return the privateSkillVariables + */ + public Map privateSkillVariables() { + return privateSkillVariables; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInput.java new file mode 100644 index 00000000000..ea2995aeb33 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInput.java @@ -0,0 +1,349 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** An input object that includes the input text. */ +public class StatelessMessageInput extends GenericModel { + + /** + * The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + */ + public interface MessageType { + /** text. */ + String TEXT = "text"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("message_type") + protected String messageType; + + protected String text; + protected List intents; + protected List entities; + + @SerializedName("suggestion_id") + protected String suggestionId; + + protected List attachments; + protected RequestAnalytics analytics; + protected StatelessMessageInputOptions options; + + /** Builder. */ + public static class Builder { + private String messageType; + private String text; + private List intents; + private List entities; + private String suggestionId; + private List attachments; + private RequestAnalytics analytics; + private StatelessMessageInputOptions options; + + /** + * Instantiates a new Builder from an existing StatelessMessageInput instance. + * + * @param statelessMessageInput the instance to initialize the Builder with + */ + private Builder(StatelessMessageInput statelessMessageInput) { + this.messageType = statelessMessageInput.messageType; + this.text = statelessMessageInput.text; + this.intents = statelessMessageInput.intents; + this.entities = statelessMessageInput.entities; + this.suggestionId = statelessMessageInput.suggestionId; + this.attachments = statelessMessageInput.attachments; + this.analytics = statelessMessageInput.analytics; + this.options = statelessMessageInput.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageInput. + * + * @return the new StatelessMessageInput instance + */ + public StatelessMessageInput build() { + return new StatelessMessageInput(this); + } + + /** + * Adds a new element to intents. + * + * @param intent the new element to be added + * @return the StatelessMessageInput builder + */ + public Builder addIntent(RuntimeIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity the new element to be added + * @return the StatelessMessageInput builder + */ + public Builder addEntity(RuntimeEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + + /** + * Adds a new element to attachments. + * + * @param attachments the new element to be added + * @return the StatelessMessageInput builder + */ + public Builder addAttachments(MessageInputAttachment attachments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attachments, "attachments cannot be null"); + if (this.attachments == null) { + this.attachments = new ArrayList(); + } + this.attachments.add(attachments); + return this; + } + + /** + * Set the messageType. + * + * @param messageType the messageType + * @return the StatelessMessageInput builder + */ + public Builder messageType(String messageType) { + this.messageType = messageType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the StatelessMessageInput builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the StatelessMessageInput builder + */ + public Builder intents(List intents) { + this.intents = intents; + return this; + } + + /** + * Set the entities. Existing entities will be replaced. + * + * @param entities the entities + * @return the StatelessMessageInput builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the suggestionId. + * + * @param suggestionId the suggestionId + * @return the StatelessMessageInput builder + */ + public Builder suggestionId(String suggestionId) { + this.suggestionId = suggestionId; + return this; + } + + /** + * Set the attachments. Existing attachments will be replaced. + * + * @param attachments the attachments + * @return the StatelessMessageInput builder + */ + public Builder attachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Set the analytics. + * + * @param analytics the analytics + * @return the StatelessMessageInput builder + */ + public Builder analytics(RequestAnalytics analytics) { + this.analytics = analytics; + return this; + } + + /** + * Set the options. + * + * @param options the options + * @return the StatelessMessageInput builder + */ + public Builder options(StatelessMessageInputOptions options) { + this.options = options; + return this; + } + } + + protected StatelessMessageInput() {} + + protected StatelessMessageInput(Builder builder) { + messageType = builder.messageType; + text = builder.text; + intents = builder.intents; + entities = builder.entities; + suggestionId = builder.suggestionId; + attachments = builder.attachments; + analytics = builder.analytics; + options = builder.options; + } + + /** + * New builder. + * + * @return a StatelessMessageInput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the messageType. + * + *

The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + * + * @return the messageType + */ + public String messageType() { + return messageType; + } + + /** + * Gets the text. + * + *

The text of the user input. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the intents. + * + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. + * + * @return the entities + */ + public List entities() { + return entities; + } + + /** + * Gets the suggestionId. + * + *

For internal use only. + * + * @return the suggestionId + */ + public String suggestionId() { + return suggestionId; + } + + /** + * Gets the attachments. + * + *

An array of multimedia attachments to be sent with the message. Attachments are not + * processed by the assistant itself, but can be sent to external services by webhooks. + * + *

**Note:** Attachments are not supported on IBM Cloud Pak for Data. + * + * @return the attachments + */ + public List attachments() { + return attachments; + } + + /** + * Gets the analytics. + * + *

An optional object containing analytics data. Currently, this data is used only for events + * sent to the Segment extension. + * + * @return the analytics + */ + public RequestAnalytics analytics() { + return analytics; + } + + /** + * Gets the options. + * + *

Optional properties that control how the assistant responds. + * + * @return the options + */ + public StatelessMessageInputOptions options() { + return options; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptions.java new file mode 100644 index 00000000000..f04c014cccb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptions.java @@ -0,0 +1,203 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Optional properties that control how the assistant responds. */ +public class StatelessMessageInputOptions extends GenericModel { + + protected Boolean restart; + + @SerializedName("alternate_intents") + protected Boolean alternateIntents; + + @SerializedName("async_callout") + protected Boolean asyncCallout; + + protected MessageInputOptionsSpelling spelling; + protected Boolean debug; + + /** Builder. */ + public static class Builder { + private Boolean restart; + private Boolean alternateIntents; + private Boolean asyncCallout; + private MessageInputOptionsSpelling spelling; + private Boolean debug; + + /** + * Instantiates a new Builder from an existing StatelessMessageInputOptions instance. + * + * @param statelessMessageInputOptions the instance to initialize the Builder with + */ + private Builder(StatelessMessageInputOptions statelessMessageInputOptions) { + this.restart = statelessMessageInputOptions.restart; + this.alternateIntents = statelessMessageInputOptions.alternateIntents; + this.asyncCallout = statelessMessageInputOptions.asyncCallout; + this.spelling = statelessMessageInputOptions.spelling; + this.debug = statelessMessageInputOptions.debug; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageInputOptions. + * + * @return the new StatelessMessageInputOptions instance + */ + public StatelessMessageInputOptions build() { + return new StatelessMessageInputOptions(this); + } + + /** + * Set the restart. + * + * @param restart the restart + * @return the StatelessMessageInputOptions builder + */ + public Builder restart(Boolean restart) { + this.restart = restart; + return this; + } + + /** + * Set the alternateIntents. + * + * @param alternateIntents the alternateIntents + * @return the StatelessMessageInputOptions builder + */ + public Builder alternateIntents(Boolean alternateIntents) { + this.alternateIntents = alternateIntents; + return this; + } + + /** + * Set the asyncCallout. + * + * @param asyncCallout the asyncCallout + * @return the StatelessMessageInputOptions builder + */ + public Builder asyncCallout(Boolean asyncCallout) { + this.asyncCallout = asyncCallout; + return this; + } + + /** + * Set the spelling. + * + * @param spelling the spelling + * @return the StatelessMessageInputOptions builder + */ + public Builder spelling(MessageInputOptionsSpelling spelling) { + this.spelling = spelling; + return this; + } + + /** + * Set the debug. + * + * @param debug the debug + * @return the StatelessMessageInputOptions builder + */ + public Builder debug(Boolean debug) { + this.debug = debug; + return this; + } + } + + protected StatelessMessageInputOptions() {} + + protected StatelessMessageInputOptions(Builder builder) { + restart = builder.restart; + alternateIntents = builder.alternateIntents; + asyncCallout = builder.asyncCallout; + spelling = builder.spelling; + debug = builder.debug; + } + + /** + * New builder. + * + * @return a StatelessMessageInputOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the restart. + * + *

Whether to restart dialog processing at the root of the dialog, regardless of any previously + * visited nodes. **Note:** This does not affect `turn_count` or any other context variables. + * + * @return the restart + */ + public Boolean restart() { + return restart; + } + + /** + * Gets the alternateIntents. + * + *

Whether to return more than one intent. Set to `true` to return all matching intents. + * + * @return the alternateIntents + */ + public Boolean alternateIntents() { + return alternateIntents; + } + + /** + * Gets the asyncCallout. + * + *

Whether custom extension callouts are executed asynchronously. Asynchronous execution means + * the response to the extension callout will be processed on the subsequent message call, the + * initial message response signals to the client that the operation may be long running. With + * synchronous execution the custom extension is executed and returns the response in a single + * message turn. **Note:** **async_callout** defaults to true for API versions earlier than + * 2023-06-15. + * + * @return the asyncCallout + */ + public Boolean asyncCallout() { + return asyncCallout; + } + + /** + * Gets the spelling. + * + *

Spelling correction options for the message. Any options specified on an individual message + * override the settings configured for the skill. + * + * @return the spelling + */ + public MessageInputOptionsSpelling spelling() { + return spelling; + } + + /** + * Gets the debug. + * + *

Whether to return additional diagnostic information. Set to `true` to return additional + * information in the `output.debug` property. + * + * @return the debug + */ + public Boolean debug() { + return debug; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponse.java new file mode 100644 index 00000000000..c4a45493ac0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponse.java @@ -0,0 +1,100 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A stateless response from the watsonx Assistant service. */ +public class StatelessMessageResponse extends GenericModel { + + protected MessageOutput output; + protected StatelessMessageContext context; + + @SerializedName("masked_output") + protected MessageOutput maskedOutput; + + @SerializedName("masked_input") + protected MessageInput maskedInput; + + @SerializedName("user_id") + protected String userId; + + protected StatelessMessageResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. + * + * @return the output + */ + public MessageOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is not stored by the assistant; to maintain session state, include the context from + * the response in the next message. + * + * @return the context + */ + public StatelessMessageContext getContext() { + return context; + } + + /** + * Gets the maskedOutput. + * + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + * + * @return the maskedOutput + */ + public MessageOutput getMaskedOutput() { + return maskedOutput; + } + + /** + * Gets the maskedInput. + * + *

An input object that includes the input text. All private data is masked or removed. + * + * @return the maskedInput + */ + public MessageInput getMaskedInput() { + return maskedInput; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageStreamResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageStreamResponse.java new file mode 100644 index 00000000000..67b52cd8601 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageStreamResponse.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A stateless streamed response form the watsonx Assistant service. + * + *

Classes which extend this class: - StatelessMessageStreamResponseMessageStreamPartialItem - + * StatelessMessageStreamResponseMessageStreamCompleteItem - + * StatelessMessageStreamResponseStatelessMessageStreamFinalResponse + */ +public class StatelessMessageStreamResponse extends GenericModel { + + @SerializedName("partial_item") + protected PartialItem partialItem; + + @SerializedName("complete_item") + protected CompleteItem completeItem; + + @SerializedName("final_response") + protected StatelessFinalResponse finalResponse; + + protected StatelessMessageStreamResponse() {} + + /** + * Gets the partialItem. + * + *

Message response partial item content. + * + * @return the partialItem + */ + public PartialItem getPartialItem() { + return partialItem; + } + + /** + * Gets the completeItem. + * + * @return the completeItem + */ + public CompleteItem getCompleteItem() { + return completeItem; + } + + /** + * Gets the finalResponse. + * + *

Message final response content. + * + * @return the finalResponse + */ + public StatelessFinalResponse getFinalResponse() { + return finalResponse; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatusError.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatusError.java new file mode 100644 index 00000000000..a203cc6c46e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatusError.java @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object describing an error that occurred during processing of an asynchronous operation. */ +public class StatusError extends GenericModel { + + protected String message; + + /** Builder. */ + public static class Builder { + private String message; + + /** + * Instantiates a new Builder from an existing StatusError instance. + * + * @param statusError the instance to initialize the Builder with + */ + private Builder(StatusError statusError) { + this.message = statusError.message; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatusError. + * + * @return the new StatusError instance + */ + public StatusError build() { + return new StatusError(this); + } + + /** + * Set the message. + * + * @param message the message + * @return the StatusError builder + */ + public Builder message(String message) { + this.message = message; + return this; + } + } + + protected StatusError() {} + + protected StatusError(Builder builder) { + message = builder.message; + } + + /** + * New builder. + * + * @return a StatusError builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the message. + * + *

The text of the error message. + * + * @return the message + */ + public String message() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventActionSource.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventActionSource.java new file mode 100644 index 00000000000..166b72776e9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventActionSource.java @@ -0,0 +1,81 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventActionSource. */ +public class TurnEventActionSource extends GenericModel { + + /** The type of turn event. */ + public interface Type { + /** action. */ + String ACTION = "action"; + } + + protected String type; + protected String action; + + @SerializedName("action_title") + protected String actionTitle; + + protected String condition; + + protected TurnEventActionSource() {} + + /** + * Gets the type. + * + *

The type of turn event. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the action. + * + *

An action that was visited during processing of the message. + * + * @return the action + */ + public String getAction() { + return action; + } + + /** + * Gets the actionTitle. + * + *

The title of the action. + * + * @return the actionTitle + */ + public String getActionTitle() { + return actionTitle; + } + + /** + * Gets the condition. + * + *

The condition that triggered the dialog node. + * + * @return the condition + */ + public String getCondition() { + return condition; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCallout.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCallout.java new file mode 100644 index 00000000000..287ab6d477a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCallout.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** TurnEventCalloutCallout. */ +public class TurnEventCalloutCallout extends GenericModel { + + /** + * The type of callout. Currently, the only supported value is `integration_interaction` (for + * calls to extensions). + */ + public interface Type { + /** integration_interaction. */ + String INTEGRATION_INTERACTION = "integration_interaction"; + } + + protected String type; + protected Map internal; + + @SerializedName("result_variable") + protected String resultVariable; + + protected TurnEventCalloutCalloutRequest request; + protected TurnEventCalloutCalloutResponse response; + + protected TurnEventCalloutCallout() {} + + /** + * Gets the type. + * + *

The type of callout. Currently, the only supported value is `integration_interaction` (for + * calls to extensions). + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the internal. + * + *

For internal use only. + * + * @return the internal + */ + public Map getInternal() { + return internal; + } + + /** + * Gets the resultVariable. + * + *

The name of the variable where the callout result is stored. + * + * @return the resultVariable + */ + public String getResultVariable() { + return resultVariable; + } + + /** + * Gets the request. + * + *

The request object executed to the external server specified by the extension. + * + * @return the request + */ + public TurnEventCalloutCalloutRequest getRequest() { + return request; + } + + /** + * Gets the response. + * + *

The response object received by the external server made by the extension. + * + * @return the response + */ + public TurnEventCalloutCalloutResponse getResponse() { + return response; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutRequest.java new file mode 100644 index 00000000000..cdc9d43d5df --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutRequest.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** TurnEventCalloutCalloutRequest. */ +public class TurnEventCalloutCalloutRequest extends GenericModel { + + /** The REST method of the request. */ + public interface Method { + /** get. */ + String GET = "get"; + /** post. */ + String POST = "post"; + /** put. */ + String PUT = "put"; + /** delete. */ + String DELETE = "delete"; + /** patch. */ + String PATCH = "patch"; + } + + protected String method; + protected String url; + protected String path; + + @SerializedName("query_parameters") + protected String queryParameters; + + protected Map headers; + protected Map body; + + protected TurnEventCalloutCalloutRequest() {} + + /** + * Gets the method. + * + *

The REST method of the request. + * + * @return the method + */ + public String getMethod() { + return method; + } + + /** + * Gets the url. + * + *

The host URL of the request call. + * + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * Gets the path. + * + *

The URL path of the request call. + * + * @return the path + */ + public String getPath() { + return path; + } + + /** + * Gets the queryParameters. + * + *

Any query parameters appended to the URL of the request call. + * + * @return the queryParameters + */ + public String getQueryParameters() { + return queryParameters; + } + + /** + * Gets the headers. + * + *

Any headers included in the request call. + * + * @return the headers + */ + public Map getHeaders() { + return headers; + } + + /** + * Gets the body. + * + *

Contains the response of the external server or an object. In cases like timeouts or + * connections errors, it will contain details of why the callout to the external server failed. + * + * @return the body + */ + public Map getBody() { + return body; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutResponse.java new file mode 100644 index 00000000000..ae2a2ebecb9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutResponse.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** TurnEventCalloutCalloutResponse. */ +public class TurnEventCalloutCalloutResponse extends GenericModel { + + protected String body; + + @SerializedName("status_code") + protected Long statusCode; + + @SerializedName("last_event") + protected Map lastEvent; + + protected TurnEventCalloutCalloutResponse() {} + + /** + * Gets the body. + * + *

The final response string. This response is a composition of every partial chunk received + * from the stream. + * + * @return the body + */ + public String getBody() { + return body; + } + + /** + * Gets the statusCode. + * + *

The final status code of the response. + * + * @return the statusCode + */ + public Long getStatusCode() { + return statusCode; + } + + /** + * Gets the lastEvent. + * + *

The response from the last chunk received from the response stream. + * + * @return the lastEvent + */ + public Map getLastEvent() { + return lastEvent; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutError.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutError.java new file mode 100644 index 00000000000..675d9a3be08 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutError.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventCalloutError. */ +public class TurnEventCalloutError extends GenericModel { + + protected String message; + + protected TurnEventCalloutError() {} + + /** + * Gets the message. + * + *

Any error message returned by a failed call to an external service. + * + * @return the message + */ + public String getMessage() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCallout.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCallout.java new file mode 100644 index 00000000000..b233722cbbb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCallout.java @@ -0,0 +1,87 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventGenerativeAICalledCallout. */ +public class TurnEventGenerativeAICalledCallout extends GenericModel { + + @SerializedName("search_called") + protected Boolean searchCalled; + + @SerializedName("llm_called") + protected Boolean llmCalled; + + protected TurnEventGenerativeAICalledCalloutSearch search; + protected TurnEventGenerativeAICalledCalloutLlm llm; + + @SerializedName("idk_reason_code") + protected String idkReasonCode; + + protected TurnEventGenerativeAICalledCallout() {} + + /** + * Gets the searchCalled. + * + *

Whether the document search engine was called. + * + * @return the searchCalled + */ + public Boolean isSearchCalled() { + return searchCalled; + } + + /** + * Gets the llmCalled. + * + *

Whether watsonx.ai was called during answer generation. + * + * @return the llmCalled + */ + public Boolean isLlmCalled() { + return llmCalled; + } + + /** + * Gets the search. + * + * @return the search + */ + public TurnEventGenerativeAICalledCalloutSearch getSearch() { + return search; + } + + /** + * Gets the llm. + * + * @return the llm + */ + public TurnEventGenerativeAICalledCalloutLlm getLlm() { + return llm; + } + + /** + * Gets the idkReasonCode. + * + *

Indicates why a conversational search response resolved to an idk response. This field will + * only be available when the conversational search response is an idk response. + * + * @return the idkReasonCode + */ + public String getIdkReasonCode() { + return idkReasonCode; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlm.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlm.java new file mode 100644 index 00000000000..80d3f7f9190 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlm.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** TurnEventGenerativeAICalledCalloutLlm. */ +public class TurnEventGenerativeAICalledCalloutLlm extends GenericModel { + + protected String type; + + @SerializedName("model_id") + protected String modelId; + + @SerializedName("model_class_id") + protected String modelClassId; + + @SerializedName("generated_token_count") + protected Long generatedTokenCount; + + @SerializedName("input_token_count") + protected Long inputTokenCount; + + protected Boolean success; + protected TurnEventGenerativeAICalledCalloutLlmResponse response; + protected List request; + + protected TurnEventGenerativeAICalledCalloutLlm() {} + + /** + * Gets the type. + * + *

The name of the LLM engine called by the system. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the modelId. + * + *

The LLM model used to generate the response. + * + * @return the modelId + */ + public String getModelId() { + return modelId; + } + + /** + * Gets the modelClassId. + * + *

The watsonx.ai class ID that was used during the answer generation request to the LLM. This + * is only included when a request to the LLM has been made by the system. + * + * @return the modelClassId + */ + public String getModelClassId() { + return modelClassId; + } + + /** + * Gets the generatedTokenCount. + * + *

The number of tokens that were generated in the response by the LLM. This is only included + * when a request to the LLM was successful and a response was generated. + * + * @return the generatedTokenCount + */ + public Long getGeneratedTokenCount() { + return generatedTokenCount; + } + + /** + * Gets the inputTokenCount. + * + *

The number of tokens that were sent to the LLM during answer generation. This is only + * included when a request to the LLM has been made by the system. + * + * @return the inputTokenCount + */ + public Long getInputTokenCount() { + return inputTokenCount; + } + + /** + * Gets the success. + * + *

Whether the answer generation request to the LLM was successful. + * + * @return the success + */ + public Boolean isSuccess() { + return success; + } + + /** + * Gets the response. + * + * @return the response + */ + public TurnEventGenerativeAICalledCalloutLlmResponse getResponse() { + return response; + } + + /** + * Gets the request. + * + *

n array of objects containing the search results. + * + * @return the request + */ + public List getRequest() { + return request; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmResponse.java new file mode 100644 index 00000000000..2e5013f567c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmResponse.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** */ +public class TurnEventGenerativeAICalledCalloutLlmResponse extends GenericModel { + + protected String text; + + @SerializedName("response_type") + protected String responseType; + + @SerializedName("is_idk_response") + protected Boolean isIdkResponse; + + protected TurnEventGenerativeAICalledCalloutLlmResponse() {} + + /** + * Gets the text. + * + *

The LLM response that is returned. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the responseType. + * + *

The type of response that is returned. + * + * @return the responseType + */ + public String getResponseType() { + return responseType; + } + + /** + * Gets the isIdkResponse. + * + *

Whether the response is an idk response. + * + * @return the isIdkResponse + */ + public Boolean isIsIdkResponse() { + return isIdkResponse; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutRequest.java new file mode 100644 index 00000000000..06d6a2fb81a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutRequest.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** TurnEventGenerativeAICalledCalloutRequest. */ +public class TurnEventGenerativeAICalledCalloutRequest extends GenericModel { + + /** The REST method of the request. */ + public interface Method { + /** GET. */ + String GET = "GET"; + /** POST. */ + String POST = "POST"; + /** PUT. */ + String PUT = "PUT"; + /** DELETE. */ + String DELETE = "DELETE"; + /** PATCH. */ + String PATCH = "PATCH"; + } + + protected String method; + protected String url; + protected String port; + protected String path; + + @SerializedName("query_parameters") + protected String queryParameters; + + protected Map headers; + protected Map body; + + protected TurnEventGenerativeAICalledCalloutRequest() {} + + /** + * Gets the method. + * + *

The REST method of the request. + * + * @return the method + */ + public String getMethod() { + return method; + } + + /** + * Gets the url. + * + *

The host URL of the request call. + * + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * Gets the port. + * + *

The host port of the request call. + * + * @return the port + */ + public String getPort() { + return port; + } + + /** + * Gets the path. + * + *

The URL path of the request call. + * + * @return the path + */ + public String getPath() { + return path; + } + + /** + * Gets the queryParameters. + * + *

Any query parameters appended to the URL of the request call. + * + * @return the queryParameters + */ + public String getQueryParameters() { + return queryParameters; + } + + /** + * Gets the headers. + * + *

Any headers included in the request call. + * + * @return the headers + */ + public Map getHeaders() { + return headers; + } + + /** + * Gets the body. + * + *

Contains the response of the external server or an object. In cases like timeouts or + * connections errors, it will contain details of why the callout to the external server failed. + * + * @return the body + */ + public Map getBody() { + return body; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutResponse.java new file mode 100644 index 00000000000..8202916b42b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutResponse.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventGenerativeAICalledCalloutResponse. */ +public class TurnEventGenerativeAICalledCalloutResponse extends GenericModel { + + protected String body; + + @SerializedName("status_code") + protected Long statusCode; + + protected TurnEventGenerativeAICalledCalloutResponse() {} + + /** + * Gets the body. + * + *

The final response string. This response is a composition of every partial chunk received + * from the stream. + * + * @return the body + */ + public String getBody() { + return body; + } + + /** + * Gets the statusCode. + * + *

The final status code of the response. + * + * @return the statusCode + */ + public Long getStatusCode() { + return statusCode; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutSearch.java new file mode 100644 index 00000000000..890fd8508e7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutSearch.java @@ -0,0 +1,80 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventGenerativeAICalledCalloutSearch. */ +public class TurnEventGenerativeAICalledCalloutSearch extends GenericModel { + + protected String engine; + protected String index; + protected String query; + protected TurnEventGenerativeAICalledCalloutRequest request; + protected TurnEventGenerativeAICalledCalloutResponse response; + + protected TurnEventGenerativeAICalledCalloutSearch() {} + + /** + * Gets the engine. + * + *

The search engine that was used to scan the documents. + * + * @return the engine + */ + public String getEngine() { + return engine; + } + + /** + * Gets the index. + * + *

The name of the Elasticsearch index being used. This field is only available if the engine + * being used is Elasticsearch. + * + * @return the index + */ + public String getIndex() { + return index; + } + + /** + * Gets the query. + * + *

The query that will be used by the system to initiate search on the document search engine. + * + * @return the query + */ + public String getQuery() { + return query; + } + + /** + * Gets the request. + * + * @return the request + */ + public TurnEventGenerativeAICalledCalloutRequest getRequest() { + return request; + } + + /** + * Gets the response. + * + * @return the response + */ + public TurnEventGenerativeAICalledCalloutResponse getResponse() { + return response; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledMetrics.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledMetrics.java new file mode 100644 index 00000000000..7c433d0fd64 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledMetrics.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventGenerativeAICalledMetrics. */ +public class TurnEventGenerativeAICalledMetrics extends GenericModel { + + @SerializedName("search_time_ms") + protected Double searchTimeMs; + + @SerializedName("answer_generation_time_ms") + protected Double answerGenerationTimeMs; + + @SerializedName("total_time_ms") + protected Double totalTimeMs; + + protected TurnEventGenerativeAICalledMetrics() {} + + /** + * Gets the searchTimeMs. + * + *

The amount of time (in milliseconds) it took for the system to complete the search using the + * document search engine. + * + * @return the searchTimeMs + */ + public Double getSearchTimeMs() { + return searchTimeMs; + } + + /** + * Gets the answerGenerationTimeMs. + * + *

The amount of time (in milliseconds) it took for the system to complete answer generation + * process by reaching out to watsonx.ai. + * + * @return the answerGenerationTimeMs + */ + public Double getAnswerGenerationTimeMs() { + return answerGenerationTimeMs; + } + + /** + * Gets the totalTimeMs. + * + *

The amount of time (in milliseconds) it took for the system to fully process the + * conversational search. + * + * @return the totalTimeMs + */ + public Double getTotalTimeMs() { + return totalTimeMs; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventNodeSource.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventNodeSource.java new file mode 100644 index 00000000000..1bbb39ea9c6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventNodeSource.java @@ -0,0 +1,81 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventNodeSource. */ +public class TurnEventNodeSource extends GenericModel { + + /** The type of turn event. */ + public interface Type { + /** dialog_node. */ + String DIALOG_NODE = "dialog_node"; + } + + protected String type; + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String title; + protected String condition; + + protected TurnEventNodeSource() {} + + /** + * Gets the type. + * + *

The type of turn event. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the dialogNode. + * + *

A dialog node that was visited during processing of the input message. + * + * @return the dialogNode + */ + public String getDialogNode() { + return dialogNode; + } + + /** + * Gets the title. + * + *

The title of the dialog node. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the condition. + * + *

The condition that triggered the dialog node. + * + * @return the condition + */ + public String getCondition() { + return condition; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventSearchError.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventSearchError.java new file mode 100644 index 00000000000..a32726575fb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventSearchError.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventSearchError. */ +public class TurnEventSearchError extends GenericModel { + + protected String message; + + protected TurnEventSearchError() {} + + /** + * Gets the message. + * + *

Any error message returned by a failed call to a search skill. + * + * @return the message + */ + public String getMessage() { + return message; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventStepSource.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventStepSource.java new file mode 100644 index 00000000000..204a2b22d94 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/TurnEventStepSource.java @@ -0,0 +1,109 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TurnEventStepSource. */ +public class TurnEventStepSource extends GenericModel { + + /** The type of turn event. */ + public interface Type { + /** step. */ + String STEP = "step"; + } + + protected String type; + protected String action; + + @SerializedName("action_title") + protected String actionTitle; + + protected String step; + + @SerializedName("is_ai_guided") + protected Boolean isAiGuided; + + @SerializedName("is_skill_based") + protected Boolean isSkillBased; + + protected TurnEventStepSource() {} + + /** + * Gets the type. + * + *

The type of turn event. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the action. + * + *

An action that was visited during processing of the message. + * + * @return the action + */ + public String getAction() { + return action; + } + + /** + * Gets the actionTitle. + * + *

The title of the action. + * + * @return the actionTitle + */ + public String getActionTitle() { + return actionTitle; + } + + /** + * Gets the step. + * + *

A step that was visited during processing of the message. + * + * @return the step + */ + public String getStep() { + return step; + } + + /** + * Gets the isAiGuided. + * + *

Whether the action that the turn event was generated from is an AI-guided action. + * + * @return the isAiGuided + */ + public Boolean isIsAiGuided() { + return isAiGuided; + } + + /** + * Gets the isSkillBased. + * + *

Whether the action that the turn event was generated from is a skill-guided action. + * + * @return the isSkillBased + */ + public Boolean isIsSkillBased() { + return isSkillBased; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOptions.java new file mode 100644 index 00000000000..18a8394b2d5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOptions.java @@ -0,0 +1,279 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The updateEnvironment options. */ +public class UpdateEnvironmentOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected String name; + protected String description; + protected UpdateEnvironmentOrchestration orchestration; + protected Long sessionTimeout; + protected List skillReferences; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String environmentId; + private String name; + private String description; + private UpdateEnvironmentOrchestration orchestration; + private Long sessionTimeout; + private List skillReferences; + + /** + * Instantiates a new Builder from an existing UpdateEnvironmentOptions instance. + * + * @param updateEnvironmentOptions the instance to initialize the Builder with + */ + private Builder(UpdateEnvironmentOptions updateEnvironmentOptions) { + this.assistantId = updateEnvironmentOptions.assistantId; + this.environmentId = updateEnvironmentOptions.environmentId; + this.name = updateEnvironmentOptions.name; + this.description = updateEnvironmentOptions.description; + this.orchestration = updateEnvironmentOptions.orchestration; + this.sessionTimeout = updateEnvironmentOptions.sessionTimeout; + this.skillReferences = updateEnvironmentOptions.skillReferences; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param environmentId the environmentId + */ + public Builder(String assistantId, String environmentId) { + this.assistantId = assistantId; + this.environmentId = environmentId; + } + + /** + * Builds a UpdateEnvironmentOptions. + * + * @return the new UpdateEnvironmentOptions instance + */ + public UpdateEnvironmentOptions build() { + return new UpdateEnvironmentOptions(this); + } + + /** + * Adds a new element to skillReferences. + * + * @param skillReference the new element to be added + * @return the UpdateEnvironmentOptions builder + */ + public Builder addSkillReference(EnvironmentSkill skillReference) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + skillReference, "skillReference cannot be null"); + if (this.skillReferences == null) { + this.skillReferences = new ArrayList(); + } + this.skillReferences.add(skillReference); + return this; + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the UpdateEnvironmentOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the environmentId. + * + * @param environmentId the environmentId + * @return the UpdateEnvironmentOptions builder + */ + public Builder environmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateEnvironmentOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateEnvironmentOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the orchestration. + * + * @param orchestration the orchestration + * @return the UpdateEnvironmentOptions builder + */ + public Builder orchestration(UpdateEnvironmentOrchestration orchestration) { + this.orchestration = orchestration; + return this; + } + + /** + * Set the sessionTimeout. + * + * @param sessionTimeout the sessionTimeout + * @return the UpdateEnvironmentOptions builder + */ + public Builder sessionTimeout(long sessionTimeout) { + this.sessionTimeout = sessionTimeout; + return this; + } + + /** + * Set the skillReferences. Existing skillReferences will be replaced. + * + * @param skillReferences the skillReferences + * @return the UpdateEnvironmentOptions builder + */ + public Builder skillReferences(List skillReferences) { + this.skillReferences = skillReferences; + return this; + } + } + + protected UpdateEnvironmentOptions() {} + + protected UpdateEnvironmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.environmentId, "environmentId cannot be empty"); + assistantId = builder.assistantId; + environmentId = builder.environmentId; + name = builder.name; + description = builder.description; + orchestration = builder.orchestration; + sessionTimeout = builder.sessionTimeout; + skillReferences = builder.skillReferences; + } + + /** + * New builder. + * + * @return a UpdateEnvironmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the environmentId. + * + *

Unique identifier of the environment. To find the environment ID in the watsonx Assistant + * user interface, open the environment settings and click **API Details**. **Note:** Currently, + * the API does not support creating environments. + * + * @return the environmentId + */ + public String environmentId() { + return environmentId; + } + + /** + * Gets the name. + * + *

The name of the environment. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the environment. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the orchestration. + * + *

The search skill orchestration settings for the environment. + * + * @return the orchestration + */ + public UpdateEnvironmentOrchestration orchestration() { + return orchestration; + } + + /** + * Gets the sessionTimeout. + * + *

The session inactivity timeout setting for the environment (in seconds). + * + * @return the sessionTimeout + */ + public Long sessionTimeout() { + return sessionTimeout; + } + + /** + * Gets the skillReferences. + * + *

An array of objects identifying the skills (such as action and dialog) that exist in the + * environment. + * + * @return the skillReferences + */ + public List skillReferences() { + return skillReferences; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOrchestration.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOrchestration.java new file mode 100644 index 00000000000..bee979e0a47 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOrchestration.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The search skill orchestration settings for the environment. */ +public class UpdateEnvironmentOrchestration extends GenericModel { + + @SerializedName("search_skill_fallback") + protected Boolean searchSkillFallback; + + /** Builder. */ + public static class Builder { + private Boolean searchSkillFallback; + + /** + * Instantiates a new Builder from an existing UpdateEnvironmentOrchestration instance. + * + * @param updateEnvironmentOrchestration the instance to initialize the Builder with + */ + private Builder(UpdateEnvironmentOrchestration updateEnvironmentOrchestration) { + this.searchSkillFallback = updateEnvironmentOrchestration.searchSkillFallback; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a UpdateEnvironmentOrchestration. + * + * @return the new UpdateEnvironmentOrchestration instance + */ + public UpdateEnvironmentOrchestration build() { + return new UpdateEnvironmentOrchestration(this); + } + + /** + * Set the searchSkillFallback. + * + * @param searchSkillFallback the searchSkillFallback + * @return the UpdateEnvironmentOrchestration builder + */ + public Builder searchSkillFallback(Boolean searchSkillFallback) { + this.searchSkillFallback = searchSkillFallback; + return this; + } + } + + protected UpdateEnvironmentOrchestration() {} + + protected UpdateEnvironmentOrchestration(Builder builder) { + searchSkillFallback = builder.searchSkillFallback; + } + + /** + * New builder. + * + * @return a UpdateEnvironmentOrchestration builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the searchSkillFallback. + * + *

Whether to fall back to a search skill when responding to messages that do not match any + * intent or action defined in dialog or action skills. (If no search skill is configured for the + * environment, this property is ignored.). + * + * @return the searchSkillFallback + */ + public Boolean searchSkillFallback() { + return searchSkillFallback; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateProviderOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateProviderOptions.java new file mode 100644 index 00000000000..23b9c42494f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateProviderOptions.java @@ -0,0 +1,156 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The updateProvider options. */ +public class UpdateProviderOptions extends GenericModel { + + protected String providerId; + protected ProviderSpecification specification; + protected ProviderPrivate xPrivate; + + /** Builder. */ + public static class Builder { + private String providerId; + private ProviderSpecification specification; + private ProviderPrivate xPrivate; + + /** + * Instantiates a new Builder from an existing UpdateProviderOptions instance. + * + * @param updateProviderOptions the instance to initialize the Builder with + */ + private Builder(UpdateProviderOptions updateProviderOptions) { + this.providerId = updateProviderOptions.providerId; + this.specification = updateProviderOptions.specification; + this.xPrivate = updateProviderOptions.xPrivate; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param providerId the providerId + * @param specification the specification + * @param xPrivate the xPrivate + */ + public Builder( + String providerId, ProviderSpecification specification, ProviderPrivate xPrivate) { + this.providerId = providerId; + this.specification = specification; + this.xPrivate = xPrivate; + } + + /** + * Builds a UpdateProviderOptions. + * + * @return the new UpdateProviderOptions instance + */ + public UpdateProviderOptions build() { + return new UpdateProviderOptions(this); + } + + /** + * Set the providerId. + * + * @param providerId the providerId + * @return the UpdateProviderOptions builder + */ + public Builder providerId(String providerId) { + this.providerId = providerId; + return this; + } + + /** + * Set the specification. + * + * @param specification the specification + * @return the UpdateProviderOptions builder + */ + public Builder specification(ProviderSpecification specification) { + this.specification = specification; + return this; + } + + /** + * Set the xPrivate. + * + * @param xPrivate the xPrivate + * @return the UpdateProviderOptions builder + */ + public Builder xPrivate(ProviderPrivate xPrivate) { + this.xPrivate = xPrivate; + return this; + } + } + + protected UpdateProviderOptions() {} + + protected UpdateProviderOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.providerId, "providerId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.specification, "specification cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.xPrivate, "xPrivate cannot be null"); + providerId = builder.providerId; + specification = builder.specification; + xPrivate = builder.xPrivate; + } + + /** + * New builder. + * + * @return a UpdateProviderOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the providerId. + * + *

Unique identifier of the conversational skill provider. + * + * @return the providerId + */ + public String providerId() { + return providerId; + } + + /** + * Gets the specification. + * + *

The specification of the provider. + * + * @return the specification + */ + public ProviderSpecification specification() { + return specification; + } + + /** + * Gets the xPrivate. + * + *

Private information of the provider. + * + * @return the xPrivate + */ + public ProviderPrivate xPrivate() { + return xPrivate; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateSkillOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateSkillOptions.java new file mode 100644 index 00000000000..b82bcd54c36 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/UpdateSkillOptions.java @@ -0,0 +1,266 @@ +/* + * (C) Copyright IBM Corp. 2023, 2025. + * + * 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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** The updateSkill options. */ +public class UpdateSkillOptions extends GenericModel { + + protected String assistantId; + protected String skillId; + protected String name; + protected String description; + protected Map workspace; + protected Map dialogSettings; + protected SearchSettings searchSettings; + + /** Builder. */ + public static class Builder { + private String assistantId; + private String skillId; + private String name; + private String description; + private Map workspace; + private Map dialogSettings; + private SearchSettings searchSettings; + + /** + * Instantiates a new Builder from an existing UpdateSkillOptions instance. + * + * @param updateSkillOptions the instance to initialize the Builder with + */ + private Builder(UpdateSkillOptions updateSkillOptions) { + this.assistantId = updateSkillOptions.assistantId; + this.skillId = updateSkillOptions.skillId; + this.name = updateSkillOptions.name; + this.description = updateSkillOptions.description; + this.workspace = updateSkillOptions.workspace; + this.dialogSettings = updateSkillOptions.dialogSettings; + this.searchSettings = updateSkillOptions.searchSettings; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param assistantId the assistantId + * @param skillId the skillId + */ + public Builder(String assistantId, String skillId) { + this.assistantId = assistantId; + this.skillId = skillId; + } + + /** + * Builds a UpdateSkillOptions. + * + * @return the new UpdateSkillOptions instance + */ + public UpdateSkillOptions build() { + return new UpdateSkillOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the UpdateSkillOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = assistantId; + return this; + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the UpdateSkillOptions builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateSkillOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateSkillOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the workspace. + * + * @param workspace the workspace + * @return the UpdateSkillOptions builder + */ + public Builder workspace(Map workspace) { + this.workspace = workspace; + return this; + } + + /** + * Set the dialogSettings. + * + * @param dialogSettings the dialogSettings + * @return the UpdateSkillOptions builder + */ + public Builder dialogSettings(Map dialogSettings) { + this.dialogSettings = dialogSettings; + return this; + } + + /** + * Set the searchSettings. + * + * @param searchSettings the searchSettings + * @return the UpdateSkillOptions builder + */ + public Builder searchSettings(SearchSettings searchSettings) { + this.searchSettings = searchSettings; + return this; + } + } + + protected UpdateSkillOptions() {} + + protected UpdateSkillOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.assistantId, "assistantId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.skillId, "skillId cannot be empty"); + assistantId = builder.assistantId; + skillId = builder.skillId; + name = builder.name; + description = builder.description; + workspace = builder.workspace; + dialogSettings = builder.dialogSettings; + searchSettings = builder.searchSettings; + } + + /** + * New builder. + * + * @return a UpdateSkillOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assistantId. + * + *

Unique identifier of the assistant. To get the **assistant ID** in the watsonx Assistant + * interface, open the **Assistant settings** page, and scroll to the **Assistant IDs and API + * details** section and click **View Details**. + * + * @return the assistantId + */ + public String assistantId() { + return assistantId; + } + + /** + * Gets the skillId. + * + *

Unique identifier of the skill. To find the action or dialog skill ID in the watsonx + * Assistant user interface, open the skill settings and click **API Details**. To find the search + * skill ID, use the Get environment API to retrieve the skill references for an environment and + * it will include the search skill info, if available. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the name. + * + *

The name of the skill. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of the skill. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the workspace. + * + *

An object containing the conversational content of an action or dialog skill. + * + * @return the workspace + */ + public Map workspace() { + return workspace; + } + + /** + * Gets the dialogSettings. + * + *

For internal use only. + * + * @return the dialogSettings + */ + public Map dialogSettings() { + return dialogSettings; + } + + /** + * Gets the searchSettings. + * + *

An object describing the search skill configuration. + * + *

**Note:** Search settings are not supported in **Import skills** requests, and are not + * included in **Export skills** responses. + * + * @return the searchSettings + */ + public SearchSettings searchSettings() { + return searchSettings; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java index 80ceb741a14..9e101146c21 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,7 +10,6 @@ * 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. */ -/** - * Watson Assistant v2 v2. - */ + +/** watsonx Assistant v2 v2. */ package com.ibm.watson.assistant.v2; diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java index 2fc047e1523..ff6026d6bcf 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2022. * * 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 @@ -12,92 +12,40 @@ */ package com.ibm.watson.assistant.v1; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.http.ServiceCallback; import com.ibm.cloud.sdk.core.security.BasicAuthenticator; import com.ibm.cloud.sdk.core.service.exception.NotFoundException; import com.ibm.cloud.sdk.core.service.exception.UnauthorizedException; -import com.ibm.watson.assistant.v1.model.Context; -import com.ibm.watson.assistant.v1.model.Counterexample; -import com.ibm.watson.assistant.v1.model.CounterexampleCollection; -import com.ibm.watson.assistant.v1.model.CreateCounterexampleOptions; -import com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.assistant.v1.model.CreateEntity; -import com.ibm.watson.assistant.v1.model.CreateExampleOptions; -import com.ibm.watson.assistant.v1.model.CreateIntent; -import com.ibm.watson.assistant.v1.model.CreateIntentOptions; -import com.ibm.watson.assistant.v1.model.CreateValue; -import com.ibm.watson.assistant.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.DeleteCounterexampleOptions; -import com.ibm.watson.assistant.v1.model.DeleteDialogNodeOptions; -import com.ibm.watson.assistant.v1.model.DeleteExampleOptions; -import com.ibm.watson.assistant.v1.model.DeleteIntentOptions; -import com.ibm.watson.assistant.v1.model.DeleteUserDataOptions; -import com.ibm.watson.assistant.v1.model.DeleteWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.DialogNode; -import com.ibm.watson.assistant.v1.model.DialogNodeCollection; -import com.ibm.watson.assistant.v1.model.EntityMentionCollection; -import com.ibm.watson.assistant.v1.model.Example; -import com.ibm.watson.assistant.v1.model.ExampleCollection; -import com.ibm.watson.assistant.v1.model.GetCounterexampleOptions; -import com.ibm.watson.assistant.v1.model.GetDialogNodeOptions; -import com.ibm.watson.assistant.v1.model.GetExampleOptions; -import com.ibm.watson.assistant.v1.model.GetIntentOptions; -import com.ibm.watson.assistant.v1.model.GetWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.Intent; -import com.ibm.watson.assistant.v1.model.IntentCollection; -import com.ibm.watson.assistant.v1.model.ListCounterexamplesOptions; -import com.ibm.watson.assistant.v1.model.ListDialogNodesOptions; -import com.ibm.watson.assistant.v1.model.ListExamplesOptions; -import com.ibm.watson.assistant.v1.model.ListIntentsOptions; -import com.ibm.watson.assistant.v1.model.ListLogsOptions; -import com.ibm.watson.assistant.v1.model.ListMentionsOptions; -import com.ibm.watson.assistant.v1.model.ListWorkspacesOptions; -import com.ibm.watson.assistant.v1.model.Log; -import com.ibm.watson.assistant.v1.model.LogCollection; -import com.ibm.watson.assistant.v1.model.MessageInput; -import com.ibm.watson.assistant.v1.model.MessageOptions; -import com.ibm.watson.assistant.v1.model.MessageResponse; -import com.ibm.watson.assistant.v1.model.RuntimeIntent; -import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions; -import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; -import com.ibm.watson.assistant.v1.model.UpdateIntentOptions; -import com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.Webhook; -import com.ibm.watson.assistant.v1.model.WebhookHeader; -import com.ibm.watson.assistant.v1.model.Workspace; -import com.ibm.watson.assistant.v1.model.WorkspaceCollection; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettings; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsDisambiguation; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsTooling; +import com.ibm.watson.assistant.v1.model.*; import com.ibm.watson.common.RetryRunner; import io.reactivex.Single; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - +import java.awt.*; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Integration test for the {@link Assistant}. - */ +/** Integration test for the {@link Assistant}. */ @RunWith(RetryRunner.class) public class AssistantServiceIT extends AssistantServiceTest { @@ -106,7 +54,13 @@ public class AssistantServiceIT extends AssistantServiceTest { private String workspaceId; private DateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); + private CountDownLatch lock = new CountDownLatch(1); + /** + * Sets up the tests. + * + * @throws Exception the exception + */ @Override @Before public void setUp() throws Exception { @@ -115,20 +69,55 @@ public void setUp() throws Exception { this.workspaceId = getWorkspaceId(); } - /** - * Test README. - */ + /** Test README. */ @Test public void testReadme() { MessageInput input = new MessageInput(); input.setText("Hi"); MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); MessageResponse response = service.message(options).execute().getResult(); - System.out.println(response); + + assertNotNull(response); + } + + /** Test RuntimeResponseGenericRuntimeResponseTypeText. */ + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeText() { + MessageInput input = new MessageInput(); + input.setText("Hi"); + MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); + MessageResponse response = service.message(options).execute().getResult(); + // System.out.println(response); + + RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeText = + response.getOutput().getGeneric().get(0); + + assertNotNull(runtimeResponseGenericRuntimeResponseTypeText); + } + + /** Test RuntimeResponseGenericRuntimeResponseTypeChannelTransfer. */ + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeChannelTransfer() { + MessageInput input = new MessageInput(); + input.setText("test sdk"); + MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); + MessageResponse response = service.message(options).execute().getResult(); + // System.out.println(response); + + RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + runtimeResponseGenericRuntimeResponseTypeChannelTransfer = + (RuntimeResponseGenericRuntimeResponseTypeChannelTransfer) + response.getOutput().getGeneric().get(0); + ChannelTransferInfo channelTransferInfo = + runtimeResponseGenericRuntimeResponseTypeChannelTransfer.transferInfo(); + + assertNotNull(channelTransferInfo); } /** * Test Example. + * + * @throws InterruptedException the interrupted exception */ @Test public void testExample() throws InterruptedException { @@ -138,34 +127,39 @@ public void testExample() throws InterruptedException { // sync MessageResponse response = service.message(options).execute().getResult(); - System.out.println(response); + // System.out.println(response); // async - service.message(options).enqueue(new ServiceCallback() { - @Override - public void onResponse(Response response) { - System.out.println(response.getResult()); - } - - @Override - public void onFailure(Exception e) { - } - }); + service + .message(options) + .enqueue( + new ServiceCallback() { + @Override + public void onResponse(Response response) { + /*System.out.println(response.getResult()); */ + } + + @Override + public void onFailure(Exception e) {} + }); // reactive - Single> observableRequest = service.message(options).reactiveRequest(); + Single> observableRequest = + service.message(options).reactiveRequest(); observableRequest .subscribeOn(Schedulers.single()) - .subscribe(new Consumer>() { - @Override - public void accept(Response response) throws Exception { - System.out.println(response.getResult()); - } - }); + .subscribe( + new Consumer>() { + @Override + public void accept(Response response) throws Exception { + // System.out.println(response.getResult()); + } + }); Thread.sleep(5000); } + /** Ping bad credentials throws exception. */ @Test(expected = UnauthorizedException.class) public void pingBadCredentialsThrowsException() { Assistant badService = new Assistant("2019-02-28", new BasicAuthenticator("foo", "bar")); @@ -173,9 +167,7 @@ public void pingBadCredentialsThrowsException() { badService.message(options).execute().getResult(); } - /** - * Test start a conversation without message. - */ + /** Test start a conversation without message. */ @Test() public void testStartAConversationWithoutMessage() { MessageOptions options = new MessageOptions.Builder(workspaceId).build(); @@ -189,23 +181,22 @@ public void testStartAConversationWithoutMessage() { */ @Test public void testSendMessages() throws InterruptedException { - final String[] messages = new String[] { "turn ac on", "turn right", "no", "yes" }; + final String[] messages = new String[] {"turn ac on", "turn right", "no", "yes"}; Context context = null; MessageInput input = new MessageInput(); for (final String message : messages) { input.setText(message); - MessageOptions request = new MessageOptions.Builder(workspaceId) - .input(input) - .alternateIntents(true) - .context(context) - .nodesVisitedDetails(true) - .build(); + MessageOptions request = + new MessageOptions.Builder(workspaceId) + .input(input) + .alternateIntents(true) + .context(context) + .nodesVisitedDetails(true) + .build(); if (message.equals("yes")) { - RuntimeIntent offTopic = new RuntimeIntent.Builder() - .intent("off_topic") - .confidence(1.0) - .build(); + RuntimeIntent offTopic = + new RuntimeIntent.Builder().intent("off_topic").confidence(1.0).build(); request = request.newBuilder().addIntent(offTopic).build(); } MessageResponse response = service.message(request).execute().getResult(); @@ -231,30 +222,25 @@ private void assertMessageFromService(MessageResponse message) { assertNotNull(message.getIntents()); } - /** - * Test message with null. - */ + /** Test message with null. */ @Test(expected = IllegalArgumentException.class) public void testMessageWithNull() { service.message(null).execute().getResult(); } - /** - * Test to string. - */ + /** Test to string. */ @Test public void testToString() { assertNotNull(service.toString()); } - /** - * Test createCounterexample. - */ + /** Test createCounterexample. */ @Test public void testCreateCounterexample() { - String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + String counterExampleText = + "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); Counterexample response = service.createCounterexample(createOptions).execute().getResult(); try { @@ -265,30 +251,29 @@ public void testCreateCounterexample() { fail(ex.getMessage()); } finally { // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.deleteCounterexample(deleteOptions).execute(); } } - /** - * Test deleteCounterexample. - */ + /** Test deleteCounterexample. */ @Test public void testDeleteCounterexample() { - String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + String counterExampleText = + "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.createCounterexample(createOptions).execute().getResult(); - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.deleteCounterexample(deleteOptions).execute(); try { - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + GetCounterexampleOptions getOptions = + new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.getCounterexample(getOptions).execute(); fail("deleteCounterexample failed"); } catch (Exception ex) { @@ -297,23 +282,23 @@ public void testDeleteCounterexample() { } } - /** - * Test getCounterexample. - */ + /** Test getCounterexample. */ @Test public void testGetCounterexample() { Date start = new Date(); - String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + String counterExampleText = + "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.createCounterexample(createOptions).execute().getResult(); try { - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .includeAudit(true) - .build(); + GetCounterexampleOptions getOptions = + new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) + .includeAudit(true) + .build(); Counterexample response = service.getCounterexample(getOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.text()); @@ -331,23 +316,24 @@ public void testGetCounterexample() { fail(ex.getMessage()); } finally { // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.deleteCounterexample(deleteOptions).execute(); } } - /** - * Test listCounterexamples. - */ + /** Test listCounterexamples. */ @Test public void testListCounterexamples() { - String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique + String counterExampleText = + "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique try { - ListCounterexamplesOptions listOptions = new ListCounterexamplesOptions.Builder(workspaceId).build(); - CounterexampleCollection ccResponse = service.listCounterexamples(listOptions).execute().getResult(); + ListCounterexamplesOptions listOptions = + new ListCounterexamplesOptions.Builder(workspaceId).build(); + CounterexampleCollection ccResponse = + service.listCounterexamples(listOptions).execute().getResult(); assertNotNull(ccResponse); assertNotNull(ccResponse.getCounterexamples()); assertNotNull(ccResponse.getPagination()); @@ -357,15 +343,17 @@ public void testListCounterexamples() { Date start = new Date(); // Now add a counterexample and make sure we get it back - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.createCounterexample(createOptions).execute().getResult(); long count = ccResponse.getCounterexamples().size(); - CounterexampleCollection ccResponse2 = service.listCounterexamples(listOptions.newBuilder() - .pageLimit(count + 1) - .includeAudit(true) - .build()).execute().getResult(); + CounterexampleCollection ccResponse2 = + service + .listCounterexamples( + listOptions.newBuilder().pageLimit(count + 1).includeAudit(true).build()) + .execute() + .getResult(); assertNotNull(ccResponse2); assertNotNull(ccResponse2.getCounterexamples()); @@ -392,8 +380,8 @@ public void testListCounterexamples() { } finally { // Clean up try { - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.deleteCounterexample(deleteOptions).execute(); } catch (NotFoundException ex) { // Okay @@ -401,9 +389,7 @@ public void testListCounterexamples() { } } - /** - * Test listCounterexamples with paging. - */ + /** Test listCounterexamples with paging. */ @Test public void testListCounterexamplesWithPaging() { @@ -411,15 +397,19 @@ public void testListCounterexamplesWithPaging() { String counterExampleText2 = "zeta" + UUID.randomUUID().toString(); // gotta be unique // Add two counterexamples - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, - counterExampleText1).build(); + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText1).build(); service.createCounterexample(createOptions).execute().getResult(); - service.createCounterexample(createOptions.newBuilder().text(counterExampleText2).build()).execute().getResult(); + service + .createCounterexample(createOptions.newBuilder().text(counterExampleText2).build()) + .execute() + .getResult(); try { - ListCounterexamplesOptions listOptions = new ListCounterexamplesOptions.Builder(workspaceId).pageLimit(1L).sort( - "text").build(); - CounterexampleCollection response = service.listCounterexamples(listOptions).execute().getResult(); + ListCounterexamplesOptions listOptions = + new ListCounterexamplesOptions.Builder(workspaceId).pageLimit(1L).sort("text").build(); + CounterexampleCollection response = + service.listCounterexamples(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getPagination()); assertNotNull(response.getPagination().getRefreshUrl()); @@ -438,7 +428,11 @@ public void testListCounterexamplesWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listCounterexamples(listOptions.newBuilder().cursor(cursor).build()).execute().getResult(); + response = + service + .listCounterexamples(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); } assertTrue(found1 && found2); @@ -446,27 +440,30 @@ public void testListCounterexamplesWithPaging() { fail(ex.getMessage()); } finally { // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText1).build(); + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText1).build(); service.deleteCounterexample(deleteOptions).execute(); - service.deleteCounterexample(deleteOptions.newBuilder().text(counterExampleText2).build()).execute(); + service + .deleteCounterexample(deleteOptions.newBuilder().text(counterExampleText2).build()) + .execute(); } } - /** - * Test updateCounterexample. - */ + /** Test updateCounterexample. */ @Test public void testUpdateCounterexample() { - String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique - String counterExampleText2 = "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + String counterExampleText = + "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique + String counterExampleText2 = + "Make me a " + UUID.randomUUID().toString() + " sandwich"; // gotta be unique + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); service.createCounterexample(createOptions).execute().getResult(); try { - UpdateCounterexampleOptions updateOptions = new UpdateCounterexampleOptions.Builder(workspaceId, - counterExampleText).newText(counterExampleText2) + UpdateCounterexampleOptions updateOptions = + new UpdateCounterexampleOptions.Builder(workspaceId, counterExampleText) + .newText(counterExampleText2) .build(); Counterexample response = service.updateCounterexample(updateOptions).execute().getResult(); assertNotNull(response); @@ -476,17 +473,20 @@ public void testUpdateCounterexample() { fail(ex.getMessage()); } finally { // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText2).build(); + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText2).build(); service.deleteCounterexample(deleteOptions).execute(); } } + /** Creates the example intent. */ public void createExampleIntent() { exampleIntent = "Hello"; try { - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, exampleIntent).description( - "Example Intent").build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, exampleIntent) + .description("Example Intent") + .build(); service.createIntent(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -494,16 +494,14 @@ public void createExampleIntent() { } } - /** - * Test createExample. - */ + /** Test createExample. */ @Test public void testCreateExample() { createExampleIntent(); String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + CreateExampleOptions createOptions = + new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); Example response = service.createExample(createOptions).execute().getResult(); try { @@ -514,31 +512,30 @@ public void testCreateExample() { fail(ex.getMessage()); } finally { // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.deleteExample(deleteOptions).execute(); } } - /** - * Test deleteExample. - */ + /** Test deleteExample. */ @Test public void testDeleteExample() { createExampleIntent(); String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + CreateExampleOptions createOptions = + new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.createExample(createOptions).execute().getResult(); - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.deleteExample(deleteOptions).execute(); try { - GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); + GetExampleOptions getOptions = + new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.getExample(getOptions).execute().getResult(); fail("deleteCounterexample failed"); } catch (Exception ex) { @@ -547,9 +544,7 @@ public void testDeleteExample() { } } - /** - * Test getExample. - */ + /** Test getExample. */ @Test public void testGetExample() { @@ -558,14 +553,15 @@ public void testGetExample() { Date start = new Date(); String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + CreateExampleOptions createOptions = + new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.createExample(createOptions).execute().getResult(); try { - GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .includeAudit(true) - .build(); + GetExampleOptions getOptions = + new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText) + .includeAudit(true) + .build(); Example response = service.getExample(getOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.text()); @@ -583,15 +579,13 @@ public void testGetExample() { fail(ex.getMessage()); } finally { // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.deleteExample(deleteOptions).execute(); } } - /** - * Test listExamples. - */ + /** Test listExamples. */ @Test public void testListExamples() { @@ -600,9 +594,8 @@ public void testListExamples() { String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique try { - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, exampleIntent) - .includeAudit(true) - .build(); + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, exampleIntent).includeAudit(true).build(); ExampleCollection ecResponse = service.listExamples(listOptions).execute().getResult(); assertNotNull(ecResponse); assertNotNull(ecResponse.getExamples()); @@ -613,16 +606,17 @@ public void testListExamples() { Date start = new Date(); // Now add an example and make sure we get it back - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + CreateExampleOptions createOptions = + new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.createExample(createOptions).execute().getResult(); long count = ecResponse.getExamples().size(); - ExampleCollection ecResponse2 = service.listExamples(listOptions.newBuilder() - .pageLimit(count + 1) - .includeAudit(true) - .build()) - .execute().getResult(); + ExampleCollection ecResponse2 = + service + .listExamples( + listOptions.newBuilder().pageLimit(count + 1).includeAudit(true).build()) + .execute() + .getResult(); assertNotNull(ecResponse2); assertNotNull(ecResponse2.getExamples()); @@ -648,16 +642,13 @@ public void testListExamples() { fail(ex.getMessage()); } finally { // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.deleteExample(deleteOptions).execute(); } - } - /** - * Test listExamples with paging. - */ + /** Test listExamples with paging. */ @Test public void testListExamplesWithPaging() { @@ -665,14 +656,20 @@ public void testListExamplesWithPaging() { String exampleText1 = "Alpha " + UUID.randomUUID().toString(); // gotta be unique String exampleText2 = "Zeta " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText1) - .build(); + CreateExampleOptions createOptions = + new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText1).build(); service.createExample(createOptions).execute().getResult(); - service.createExample(createOptions.newBuilder().text(exampleText2).build()).execute().getResult(); + service + .createExample(createOptions.newBuilder().text(exampleText2).build()) + .execute() + .getResult(); try { - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, exampleIntent).pageLimit(1L).sort( - "-text").build(); + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, exampleIntent) + .pageLimit(1L) + .sort("-text") + .build(); ExampleCollection response = service.listExamples(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getExamples()); @@ -693,7 +690,11 @@ public void testListExamplesWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listExamples(listOptions.newBuilder().cursor(cursor).build()).execute().getResult(); + response = + service + .listExamples(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); } assertTrue(found1 && found2); @@ -701,17 +702,14 @@ public void testListExamplesWithPaging() { fail(ex.getMessage()); } finally { // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText1) - .build(); + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText1).build(); service.deleteExample(deleteOptions).execute(); service.deleteExample(deleteOptions.newBuilder().text(exampleText2).build()).execute(); } - } - /** - * Test updateExample. - */ + /** Test updateExample. */ @Test public void testUpdateExample() { @@ -719,14 +717,15 @@ public void testUpdateExample() { String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique String exampleText2 = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); + CreateExampleOptions createOptions = + new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); service.createExample(createOptions).execute().getResult(); try { - UpdateExampleOptions updateOptions = new UpdateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .newText(exampleText2) - .build(); + UpdateExampleOptions updateOptions = + new UpdateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) + .newText(exampleText2) + .build(); Example response = service.updateExample(updateOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.text()); @@ -735,15 +734,13 @@ public void testUpdateExample() { fail(ex.getMessage()); } finally { // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText2) - .build(); + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText2).build(); service.deleteExample(deleteOptions).execute(); } } - /** - * Test createIntent. - */ + /** Test createIntent. */ @Test public void testCreateIntent() { @@ -755,8 +752,11 @@ public void testCreateIntent() { Date start = new Date(); - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName) + .description(intentDescription) + .examples(intentExamples) + .build(); Intent response = service.createIntent(createOptions).execute().getResult(); try { @@ -768,9 +768,8 @@ public void testCreateIntent() { Date now = new Date(); - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, intentName) - .includeAudit(true) - .build(); + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, intentName).includeAudit(true).build(); ExampleCollection ecResponse = service.listExamples(listOptions).execute().getResult(); assertNotNull(ecResponse); assertNotNull(ecResponse.getExamples()); @@ -787,23 +786,24 @@ public void testCreateIntent() { fail(ex.getMessage()); } finally { // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); service.deleteIntent(deleteOptions).execute(); } } - /** - * Test deleteIntent. - */ + /** Test deleteIntent. */ @Test public void testDeleteIntent() { String intentName = "Hello" + UUID.randomUUID().toString(); // gotta be unique - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName).build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName).build(); service.createIntent(createOptions).execute().getResult(); - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); service.deleteIntent(deleteOptions).execute(); try { @@ -816,9 +816,7 @@ public void testDeleteIntent() { } } - /** - * Test getIntent. - */ + /** Test getIntent. */ @Test public void testGetIntent() { @@ -830,17 +828,23 @@ public void testGetIntent() { Date start = new Date(); - CreateIntentOptions createOptions = new CreateIntentOptions.Builder().workspaceId(workspaceId).intent(intentName) - .description(intentDescription).examples(intentExamples).build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder() + .workspaceId(workspaceId) + .intent(intentName) + .description(intentDescription) + .examples(intentExamples) + .build(); service.createIntent(createOptions).execute().getResult(); try { - GetIntentOptions getOptions = new GetIntentOptions.Builder() - .workspaceId(workspaceId) - .intent(intentName) - .export(true) - .includeAudit(true) - .build(); + GetIntentOptions getOptions = + new GetIntentOptions.Builder() + .workspaceId(workspaceId) + .intent(intentName) + .export(true) + .includeAudit(true) + .build(); Intent response = service.getIntent(getOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getIntent()); @@ -869,23 +873,21 @@ public void testGetIntent() { fail(ex.getMessage()); } finally { // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); service.deleteIntent(deleteOptions).execute(); } } - /** - * Test listIntents. - */ + /** Test listIntents. */ @Test public void testListIntents() { String intentName = "Hello" + UUID.randomUUID().toString(); // gotta be unique try { - ListIntentsOptions listOptions = new ListIntentsOptions.Builder(workspaceId) - .includeAudit(true) - .build(); + ListIntentsOptions listOptions = + new ListIntentsOptions.Builder(workspaceId).includeAudit(true).build(); IntentCollection response = service.listIntents(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getIntents()); @@ -901,16 +903,20 @@ public void testListIntents() { Date start = new Date(); - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName) + .description(intentDescription) + .examples(intentExamples) + .build(); service.createIntent(createOptions).execute().getResult(); long count = response.getIntents().size(); - ListIntentsOptions listOptions2 = new ListIntentsOptions.Builder(workspaceId) - .export(true) - .pageLimit(count + 1) - .includeAudit(true) - .build(); + ListIntentsOptions listOptions2 = + new ListIntentsOptions.Builder(workspaceId) + .export(true) + .pageLimit(count + 1) + .includeAudit(true) + .build(); IntentCollection response2 = service.listIntents(listOptions2).execute().getResult(); assertNotNull(response2); assertNotNull(response2.getIntents()); @@ -943,32 +949,36 @@ public void testListIntents() { fail(ex.getMessage()); } finally { // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); service.deleteIntent(deleteOptions).execute(); } } - /** - * Test listIntents with paging. - */ + /** Test listIntents with paging. */ @Test public void testListIntentsWithPaging() { String intentName1 = "First" + UUID.randomUUID().toString(); // gotta be unique String intentName2 = "Second" + UUID.randomUUID().toString(); // gotta be unique - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName1).build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName1).build(); service.createIntent(createOptions).execute().getResult(); - service.createIntent(createOptions.newBuilder().intent(intentName2).build()).execute().getResult(); + service + .createIntent(createOptions.newBuilder().intent(intentName2).build()) + .execute() + .getResult(); try { - ListIntentsOptions listOptions = new ListIntentsOptions.Builder() - .workspaceId(workspaceId) - .export(true) - .pageLimit(1L) - .sort("modified") - .includeAudit(true) - .build(); + ListIntentsOptions listOptions = + new ListIntentsOptions.Builder() + .workspaceId(workspaceId) + .export(true) + .pageLimit(1L) + .sort("modified") + .includeAudit(true) + .build(); IntentCollection response = service.listIntents(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getIntents()); @@ -989,8 +999,11 @@ public void testListIntentsWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listIntents(listOptions.newBuilder().cursor(cursor).build()).execute().getResult(); - + response = + service + .listIntents(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); } assertTrue(found1 && found2); @@ -998,15 +1011,14 @@ public void testListIntentsWithPaging() { fail(ex.getMessage()); } finally { // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName1).build(); + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName1).build(); service.deleteIntent(deleteOptions).execute(); service.deleteIntent(deleteOptions.newBuilder().intent(intentName2).build()).execute(); } } - /** - * Test updateIntent. - */ + /** Test updateIntent. */ @Test public void testUpdateIntent() { @@ -1016,8 +1028,11 @@ public void testUpdateIntent() { List intentExamples = new ArrayList<>(); intentExamples.add(new Example.Builder().text(intentExample).build()); - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName) + .description(intentDescription) + .examples(intentExamples) + .build(); service.createIntent(createOptions).execute().getResult(); try { @@ -1026,8 +1041,11 @@ public void testUpdateIntent() { List intentExamples2 = new ArrayList<>(); intentExamples2.add(new Example.Builder().text(intentExample2).build()); Date start = new Date(); - UpdateIntentOptions updateOptions = new UpdateIntentOptions.Builder(workspaceId, intentName) - .newDescription(intentDescription2).newExamples(intentExamples2).build(); + UpdateIntentOptions updateOptions = + new UpdateIntentOptions.Builder(workspaceId, intentName) + .newDescription(intentDescription2) + .newExamples(intentExamples2) + .build(); Intent response = service.updateIntent(updateOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getIntent()); @@ -1037,9 +1055,8 @@ public void testUpdateIntent() { Date now = new Date(); - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, intentName) - .includeAudit(true) - .build(); + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, intentName).includeAudit(true).build(); ExampleCollection ecResponse = service.listExamples(listOptions).execute().getResult(); assertNotNull(ecResponse); assertNotNull(ecResponse.getExamples()); @@ -1056,14 +1073,13 @@ public void testUpdateIntent() { fail(ex.getMessage()); } finally { // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); service.deleteIntent(deleteOptions).execute(); } } - /** - * Test createWorkspace. - */ + /** Test createWorkspace. */ @Test public void testCreateWorkspace() { @@ -1084,7 +1100,10 @@ public void testCreateWorkspace() { List intentExamples = new ArrayList<>(); intentExamples.add(new Example.Builder().text(intentExample).build()); workspaceIntents.add( - new CreateIntent.Builder().intent(intentName).description(intentDescription).examples(intentExamples) + new CreateIntent.Builder() + .intent(intentName) + .description(intentDescription) + .examples(intentExamples) .build()); // entities @@ -1094,9 +1113,13 @@ public void testCreateWorkspace() { String entityValue = "Value of " + entityName; String entityValueSynonym = "Synonym for Value of " + entityName; List entityValues = new ArrayList(); - entityValues.add(new CreateValue.Builder().value(entityValue).addSynonym(entityValueSynonym).build()); - workspaceEntities - .add(new CreateEntity.Builder().entity(entityName).description(entityDescription).values(entityValues) + entityValues.add( + new CreateValue.Builder().value(entityValue).addSynonym(entityValueSynonym).build()); + workspaceEntities.add( + new CreateEntity.Builder() + .entity(entityName) + .description(entityDescription) + .values(entityValues) .build()); // counterexamples @@ -1105,46 +1128,43 @@ public void testCreateWorkspace() { workspaceCounterExamples.add(new Counterexample.Builder().text(counterExampleText).build()); // systemSettings - WorkspaceSystemSettingsDisambiguation disambiguation = new WorkspaceSystemSettingsDisambiguation.Builder() - .enabled(true) - .noneOfTheAbovePrompt("none of the above") - .prompt("prompt") - .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) - .build(); - WorkspaceSystemSettingsTooling tooling = new WorkspaceSystemSettingsTooling.Builder() - .storeGenericResponses(true) - .build(); - WorkspaceSystemSettings systemSettings = new WorkspaceSystemSettings.Builder() - .disambiguation(disambiguation) - .tooling(tooling) - .build(); + WorkspaceSystemSettingsDisambiguation disambiguation = + new WorkspaceSystemSettingsDisambiguation.Builder() + .enabled(true) + .noneOfTheAbovePrompt("none of the above") + .prompt("prompt") + .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) + .build(); + WorkspaceSystemSettingsTooling tooling = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + WorkspaceSystemSettings systemSettings = + new WorkspaceSystemSettings.Builder() + .disambiguation(disambiguation) + .tooling(tooling) + .build(); // webhooks String webhookHeaderName = "Webhook-Header"; String webhookHeaderValue = "webhook_header_value"; String webhookName = "java-sdk-test-webhook"; String webhookUrl = "https://github.com/watson-developer-cloud/java-sdk"; - WebhookHeader webhookHeader = new WebhookHeader.Builder() - .name(webhookHeaderName) - .value(webhookHeaderValue) - .build(); - Webhook webhook = new Webhook.Builder() - .name(webhookName) - .url(webhookUrl) - .addHeaders(webhookHeader) - .build(); - - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder() - .name(workspaceName) - .description(workspaceDescription) - .language(workspaceLanguage) - .metadata(workspaceMetadata) - .intents(workspaceIntents) - .entities(workspaceEntities) - .counterexamples(workspaceCounterExamples) - .systemSettings(systemSettings) - .addWebhooks(webhook) - .build(); + WebhookHeader webhookHeader = + new WebhookHeader.Builder().name(webhookHeaderName).value(webhookHeaderValue).build(); + Webhook webhook = + new Webhook.Builder().name(webhookName).url(webhookUrl).addHeaders(webhookHeader).build(); + + CreateWorkspaceOptions createOptions = + new CreateWorkspaceOptions.Builder() + .name(workspaceName) + .description(workspaceDescription) + .language(workspaceLanguage) + .metadata(workspaceMetadata) + .intents(workspaceIntents) + .entities(workspaceEntities) + .counterexamples(workspaceCounterExamples) + .systemSettings(systemSettings) + .addWebhooks(webhook) + .build(); String workspaceId = null; try { @@ -1165,7 +1185,8 @@ public void testCreateWorkspace() { assertNotNull(response.getMetadata().get("key")); assertEquals(response.getMetadata().get("key"), metadataValue); - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); + GetWorkspaceOptions getOptions = + new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); Workspace exResponse = service.getWorkspace(getOptions).execute().getResult(); assertNotNull(exResponse); @@ -1195,7 +1216,8 @@ public void testCreateWorkspace() { assertEquals(exResponse.getEntities().get(0).getValues().get(0).value(), entityValue); assertNotNull(exResponse.getEntities().get(0).getValues().get(0).synonyms()); assertTrue(exResponse.getEntities().get(0).getValues().get(0).synonyms().size() == 1); - assertEquals(exResponse.getEntities().get(0).getValues().get(0).synonyms().get(0), entityValueSynonym); + assertEquals( + exResponse.getEntities().get(0).getValues().get(0).synonyms().get(0), entityValueSynonym); // counterexamples assertNotNull(exResponse.getCounterexamples()); @@ -1205,13 +1227,18 @@ public void testCreateWorkspace() { // systemSettings assertNotNull(exResponse.getSystemSettings()); - assertEquals(exResponse.getSystemSettings().disambiguation().noneOfTheAbovePrompt(), + assertEquals( + exResponse.getSystemSettings().getDisambiguation().noneOfTheAbovePrompt(), disambiguation.noneOfTheAbovePrompt()); - assertEquals(exResponse.getSystemSettings().disambiguation().sensitivity(), + assertEquals( + exResponse.getSystemSettings().getDisambiguation().sensitivity(), disambiguation.sensitivity()); - assertEquals(exResponse.getSystemSettings().disambiguation().prompt(), disambiguation.prompt()); - assertEquals(exResponse.getSystemSettings().disambiguation().enabled(), disambiguation.enabled()); - assertEquals(exResponse.getSystemSettings().tooling().storeGenericResponses(), + assertEquals( + exResponse.getSystemSettings().getDisambiguation().prompt(), disambiguation.prompt()); + assertEquals( + exResponse.getSystemSettings().getDisambiguation().enabled(), disambiguation.enabled()); + assertEquals( + exResponse.getSystemSettings().getTooling().storeGenericResponses(), tooling.storeGenericResponses()); // webhooks @@ -1226,15 +1253,14 @@ public void testCreateWorkspace() { } finally { // Clean up if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); service.deleteWorkspace(deleteOptions).execute(); } } } - /** - * Test deleteWorkspace. - */ + /** Test deleteWorkspace. */ @Test public void testDeleteWorkspace() { @@ -1247,10 +1273,12 @@ public void testDeleteWorkspace() { assertNotNull(response.getWorkspaceId()); workspaceId = response.getWorkspaceId(); - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); service.deleteWorkspace(deleteOptions).execute(); - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); + GetWorkspaceOptions getOptions = + new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); service.getWorkspace(getOptions).execute().getResult(); } catch (Exception ex) { // Expected result @@ -1259,22 +1287,19 @@ public void testDeleteWorkspace() { } finally { // Clean up if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); service.deleteWorkspace(deleteOptions).execute(); } } } - /** - * Test getWorkspace. - */ + /** Test getWorkspace. */ @Test public void testGetWorkspace() { - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId) - .export(false) - .includeAudit(true) - .build(); + GetWorkspaceOptions getOptions = + new GetWorkspaceOptions.Builder(workspaceId).export(false).includeAudit(true).build(); Workspace response = service.getWorkspace(getOptions).execute().getResult(); try { @@ -1298,15 +1323,12 @@ public void testGetWorkspace() { } } - /** - * Test listWorkspaces. - */ + /** Test listWorkspaces. */ @Test public void testListWorkspaces() { ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().build(); WorkspaceCollection response = service.listWorkspaces(listOptions).execute().getResult(); - assertNotNull(response); assertNotNull(response.getWorkspaces()); assertTrue(response.getWorkspaces().size() > 0); @@ -1325,13 +1347,12 @@ public void testListWorkspaces() { assertNotNull(wResponse.getName()); } - /** - * Test listWorkspaces with paging. - */ + /** Test listWorkspaces with paging. */ @Test public void testListWorkspacesWithPaging() { - ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build(); + ListWorkspacesOptions listOptions = + new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build(); WorkspaceCollection response = service.listWorkspaces(listOptions).execute().getResult(); assertNotNull(response); @@ -1347,15 +1368,17 @@ public void testListWorkspacesWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listWorkspaces(listOptions.newBuilder().cursor(cursor).build()).execute().getResult(); + response = + service + .listWorkspaces(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); } assertTrue(found); } - /** - * Test updateWorkspace. - */ + /** Test updateWorkspace. */ @Test public void testUpdateWorkspace() { @@ -1374,16 +1397,17 @@ public void testUpdateWorkspace() { Counterexample counterexample0 = new Counterexample.Builder("What are you wearing?").build(); Counterexample counterexample1 = new Counterexample.Builder("What are you eating?").build(); - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder() - .name(workspaceName) - .description(workspaceDescription) - .addIntent(intent0) - .addIntent(intent1) - .addEntity(entity0) - .addEntity(entity1) - .addCounterexample(counterexample0) - .addCounterexample(counterexample1) - .build(); + CreateWorkspaceOptions createOptions = + new CreateWorkspaceOptions.Builder() + .name(workspaceName) + .description(workspaceDescription) + .addIntent(intent0) + .addIntent(intent1) + .addEntity(entity0) + .addEntity(entity1) + .addCounterexample(counterexample0) + .addCounterexample(counterexample1) + .build(); String workspaceId = null; try { @@ -1401,27 +1425,23 @@ public void testUpdateWorkspace() { String webhookHeaderValue = "webhook_header_value"; String webhookName = "java-sdk-test-webhook"; String webhookUrl = "https://github.com/watson-developer-cloud/java-sdk"; - WebhookHeader webhookHeader = new WebhookHeader.Builder() - .name(webhookHeaderName) - .value(webhookHeaderValue) - .build(); - Webhook webhook = new Webhook.Builder() - .name(webhookName) - .url(webhookUrl) - .addHeaders(webhookHeader) - .build(); - - UpdateWorkspaceOptions updateOptions = new UpdateWorkspaceOptions.Builder(workspaceId) - .addCounterexample(counterexample2) - .append(false) - .addWebhooks(webhook) - .build(); + WebhookHeader webhookHeader = + new WebhookHeader.Builder().name(webhookHeaderName).value(webhookHeaderValue).build(); + Webhook webhook = + new Webhook.Builder().name(webhookName).url(webhookUrl).addHeaders(webhookHeader).build(); + + UpdateWorkspaceOptions updateOptions = + new UpdateWorkspaceOptions.Builder(workspaceId) + .addCounterexample(counterexample2) + .append(false) + .addWebhooks(webhook) + .build(); Workspace updateResponse = service.updateWorkspace(updateOptions).execute().getResult(); assertNotNull(updateResponse); - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); + GetCounterexampleOptions getOptions = + new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); Counterexample eResponse = service.getCounterexample(getOptions).execute().getResult(); assertNotNull(eResponse); assertNotNull(eResponse.text()); @@ -1432,23 +1452,244 @@ public void testUpdateWorkspace() { assertEquals(webhookName, updateResponse.getWebhooks().get(0).name()); assertEquals(webhookUrl, updateResponse.getWebhooks().get(0).url()); assertEquals(webhookHeaderName, updateResponse.getWebhooks().get(0).headers().get(0).name()); - assertEquals(webhookHeaderValue, updateResponse.getWebhooks().get(0).headers().get(0).value()); + assertEquals( + webhookHeaderValue, updateResponse.getWebhooks().get(0).headers().get(0).value()); } catch (Exception ex) { fail(ex.getMessage()); } finally { // Clean up if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); service.deleteWorkspace(deleteOptions).execute(); } } } - /** - * Test listLogs. - */ + /** Test createWorkspaceAsync, exportWorkspaceAsync, and updateWorkspaceAsync */ + @Test + public void testWorkspaceAsyncSuite() { + + String workspaceName = "API Test " + UUID.randomUUID().toString(); // gotta be unique + String workspaceDescription = "Description of " + workspaceName; + String workspaceLanguage = "en"; + + // metadata + Map workspaceMetadata = new HashMap(); + String metadataValue = "value for " + workspaceName; + workspaceMetadata.put("key", metadataValue); + + // intents + List workspaceIntents = new ArrayList(); + String intentName = "Hello" + UUID.randomUUID().toString(); // gotta be unique + String intentDescription = "Description of " + intentName; + String intentExample = "Example of " + intentName; + List intentExamples = new ArrayList<>(); + intentExamples.add(new Example.Builder().text(intentExample).build()); + workspaceIntents.add( + new CreateIntent.Builder() + .intent(intentName) + .description(intentDescription) + .examples(intentExamples) + .build()); + + // entities + List workspaceEntities = new ArrayList(); + String entityName = "Hello" + UUID.randomUUID().toString(); // gotta be unique + String entityDescription = "Description of " + entityName; + String entityValue = "Value of " + entityName; + String entityValueSynonym = "Synonym for Value of " + entityName; + List entityValues = new ArrayList(); + entityValues.add( + new CreateValue.Builder().value(entityValue).addSynonym(entityValueSynonym).build()); + workspaceEntities.add( + new CreateEntity.Builder() + .entity(entityName) + .description(entityDescription) + .values(entityValues) + .build()); + + // counterexamples + List workspaceCounterExamples = new ArrayList<>(); + String counterExampleText = "Counterexample for " + workspaceName; + workspaceCounterExamples.add(new Counterexample.Builder().text(counterExampleText).build()); + + // systemSettings + WorkspaceSystemSettingsDisambiguation disambiguation = + new WorkspaceSystemSettingsDisambiguation.Builder() + .enabled(true) + .noneOfTheAbovePrompt("none of the above") + .prompt("prompt") + .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) + .build(); + WorkspaceSystemSettingsTooling tooling = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + WorkspaceSystemSettings systemSettings = + new WorkspaceSystemSettings.Builder() + .disambiguation(disambiguation) + .tooling(tooling) + .build(); + + // webhooks + String webhookHeaderName = "Webhook-Header"; + String webhookHeaderValue = "webhook_header_value"; + String webhookName = "java-sdk-test-webhook"; + String webhookUrl = "https://github.com/watson-developer-cloud/java-sdk"; + WebhookHeader webhookHeader = + new WebhookHeader.Builder().name(webhookHeaderName).value(webhookHeaderValue).build(); + Webhook webhook = + new Webhook.Builder().name(webhookName).url(webhookUrl).addHeaders(webhookHeader).build(); + + CreateWorkspaceAsyncOptions createAsyncOptions = + new CreateWorkspaceAsyncOptions.Builder() + .name(workspaceName) + .description(workspaceDescription) + .language(workspaceLanguage) + .metadata(workspaceMetadata) + .intents(workspaceIntents) + .entities(workspaceEntities) + .counterexamples(workspaceCounterExamples) + .systemSettings(systemSettings) + .addWebhooks(webhook) + .build(); + + String workspaceId = null; + try { + Workspace response = service.createWorkspaceAsync(createAsyncOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getWorkspaceId()); + ExportWorkspaceAsyncOptions exportWorkspaceAsyncOptions = + new ExportWorkspaceAsyncOptions.Builder().workspaceId(response.getWorkspaceId()).build(); + Workspace exportResponse = + service.exportWorkspaceAsync(exportWorkspaceAsyncOptions).execute().getResult(); + + for (int seconds = 0; + exportResponse.getStatus().equals("Processing") && seconds <= 60; + seconds += 5) { + lock.await(5, TimeUnit.SECONDS); + exportResponse = + service.exportWorkspaceAsync(exportWorkspaceAsyncOptions).execute().getResult(); + } + + workspaceId = exportResponse.getWorkspaceId(); + assertNotNull(exportResponse.getName()); + assertEquals(exportResponse.getName(), workspaceName); + assertNotNull(exportResponse.getDescription()); + assertEquals(exportResponse.getDescription(), workspaceDescription); + assertNotNull(exportResponse.getLanguage()); + assertEquals(exportResponse.getLanguage(), workspaceLanguage); + + // metadata + assertNotNull(exportResponse.getMetadata()); + assertNotNull(exportResponse.getMetadata().get("key")); + assertEquals(exportResponse.getMetadata().get("key"), metadataValue); + + GetWorkspaceOptions getOptions = + new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); + Workspace exResponse = service.getWorkspace(getOptions).execute().getResult(); + assertNotNull(exResponse); + + // intents + assertNotNull(exResponse.getIntents()); + assertTrue(exResponse.getIntents().size() == 1); + assertNotNull(exResponse.getIntents().get(0).getIntent()); + assertEquals(exResponse.getIntents().get(0).getIntent(), intentName); + assertNotNull(exResponse.getIntents().get(0).getDescription()); + assertEquals(exResponse.getIntents().get(0).getDescription(), intentDescription); + assertNotNull(exResponse.getIntents().get(0).getExamples()); + assertTrue(exResponse.getIntents().get(0).getExamples().size() == 1); + assertNotNull(exResponse.getIntents().get(0).getExamples().get(0)); + assertNotNull(exResponse.getIntents().get(0).getExamples().get(0).text()); + assertEquals(exResponse.getIntents().get(0).getExamples().get(0).text(), intentExample); + + // entities + assertNotNull(exResponse.getEntities()); + assertTrue(exResponse.getEntities().size() == 1); + assertNotNull(exResponse.getEntities().get(0).getEntity()); + assertEquals(exResponse.getEntities().get(0).getEntity(), entityName); + assertNotNull(exResponse.getEntities().get(0).getDescription()); + assertEquals(exResponse.getEntities().get(0).getDescription(), entityDescription); + assertNotNull(exResponse.getEntities().get(0).getValues()); + assertTrue(exResponse.getEntities().get(0).getValues().size() == 1); + assertNotNull(exResponse.getEntities().get(0).getValues().get(0).value()); + assertEquals(exResponse.getEntities().get(0).getValues().get(0).value(), entityValue); + assertNotNull(exResponse.getEntities().get(0).getValues().get(0).synonyms()); + assertTrue(exResponse.getEntities().get(0).getValues().get(0).synonyms().size() == 1); + assertEquals( + exResponse.getEntities().get(0).getValues().get(0).synonyms().get(0), entityValueSynonym); + + // counterexamples + assertNotNull(exResponse.getCounterexamples()); + assertTrue(exResponse.getCounterexamples().size() == 1); + assertNotNull(exResponse.getCounterexamples().get(0).text()); + assertEquals(exResponse.getCounterexamples().get(0).text(), counterExampleText); + + // systemSettings + assertNotNull(exResponse.getSystemSettings()); + assertEquals( + exResponse.getSystemSettings().getDisambiguation().noneOfTheAbovePrompt(), + disambiguation.noneOfTheAbovePrompt()); + assertEquals( + exResponse.getSystemSettings().getDisambiguation().sensitivity(), + disambiguation.sensitivity()); + assertEquals( + exResponse.getSystemSettings().getDisambiguation().prompt(), disambiguation.prompt()); + assertEquals( + exResponse.getSystemSettings().getDisambiguation().enabled(), disambiguation.enabled()); + assertEquals( + exResponse.getSystemSettings().getTooling().storeGenericResponses(), + tooling.storeGenericResponses()); + + // webhooks + assertNotNull(exResponse.getWebhooks()); + assertEquals(webhookName, exResponse.getWebhooks().get(0).name()); + assertEquals(webhookUrl, exResponse.getWebhooks().get(0).url()); + assertEquals(webhookHeaderName, exResponse.getWebhooks().get(0).headers().get(0).name()); + assertEquals(webhookHeaderValue, exResponse.getWebhooks().get(0).headers().get(0).value()); + + String updatedDescription = "Angelo's First Java SDK IT"; + UpdateWorkspaceAsyncOptions updateAsyncOptions = + new UpdateWorkspaceAsyncOptions.Builder() + .workspaceId(workspaceId) + .description(updatedDescription) + .build(); + + Workspace updateResponse = + service.updateWorkspaceAsync(updateAsyncOptions).execute().getResult(); + + assertNotNull(updateResponse); + assertNotNull(updateResponse.getWorkspaceId()); + ExportWorkspaceAsyncOptions newExportWorkspaceAsyncOptions = + new ExportWorkspaceAsyncOptions.Builder() + .workspaceId(updateResponse.getWorkspaceId()) + .build(); + + for (int seconds = 0; + updateResponse.getStatus().equals("Processing") && seconds <= 60; + seconds += 5) { + lock.await(5, TimeUnit.SECONDS); + updateResponse = + service.exportWorkspaceAsync(newExportWorkspaceAsyncOptions).execute().getResult(); + } + + assertEquals(updatedDescription, updateResponse.getDescription()); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + if (workspaceId != null) { + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); + service.deleteWorkspace(deleteOptions).execute(); + } + } + } + + /** Test listLogs. */ @Test + @Ignore public void testListLogs() { try { @@ -1470,9 +1711,7 @@ public void testListLogs() { } } - /** - * Test listLogs with pagination. - */ + /** Test listLogs with pagination. */ @Test @Ignore("To be run locally until we fix the Rate limitation issue") public void testListLogsWithPaging() { @@ -1513,16 +1752,16 @@ public void testListLogsWithPaging() { } } - /** - * Test createDialogNode. - */ + /** Test createDialogNode. */ @Test public void testCreateDialogNode() { String dialogNodeName = "Test" + UUID.randomUUID().toString(); String dialogNodeDescription = "Description of " + dialogNodeName; - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription).build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) + .description(dialogNodeDescription) + .build(); DialogNode response = service.createDialogNode(createOptions).execute().getResult(); try { @@ -1535,26 +1774,28 @@ public void testCreateDialogNode() { fail(ex.getMessage()); } finally { // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); service.deleteDialogNode(deleteOptions).execute(); } } - /** - * Test deleteDialogNode. - */ + /** Test deleteDialogNode. */ @Test public void testDeleteDialogNode() { String dialogNodeName = "Test" + UUID.randomUUID().toString(); // gotta be unique - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); service.createDialogNode(createOptions).execute().getResult(); - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); service.deleteDialogNode(deleteOptions).execute(); try { - GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + GetDialogNodeOptions getOptions = + new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); service.getDialogNode(getOptions).execute(); fail("deleteDialogNode failed"); } catch (Exception ex) { @@ -1563,9 +1804,7 @@ public void testDeleteDialogNode() { } } - /** - * Test getDialogNode. - */ + /** Test getDialogNode. */ @Test public void testGetDialogNode() { String dialogNodeName = "Test" + UUID.randomUUID().toString(); @@ -1573,16 +1812,19 @@ public void testGetDialogNode() { Date start = new Date(); - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription).build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) + .description(dialogNodeDescription) + .build(); service.createDialogNode(createOptions).execute().getResult(); try { - GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder() - .workspaceId(workspaceId) - .dialogNode(dialogNodeName) - .includeAudit(true) - .build(); + GetDialogNodeOptions getOptions = + new GetDialogNodeOptions.Builder() + .workspaceId(workspaceId) + .dialogNode(dialogNodeName) + .includeAudit(true) + .build(); DialogNode response = service.getDialogNode(getOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.dialogNode()); @@ -1601,14 +1843,13 @@ public void testGetDialogNode() { fail(ex.getMessage()); } finally { // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); service.deleteDialogNode(deleteOptions).execute(); } } - /** - * Test listDialogNodes. - */ + /** Test listDialogNodes. */ @Test public void testListDialogNodes() { String dialogNodeName = "Test" + UUID.randomUUID().toString(); @@ -1627,16 +1868,18 @@ public void testListDialogNodes() { Date start = new Date(); - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription) - .build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) + .description(dialogNodeDescription) + .build(); service.createDialogNode(createOptions).execute().getResult(); long count = response.getDialogNodes().size(); - ListDialogNodesOptions listOptions2 = new ListDialogNodesOptions.Builder(workspaceId) - .pageLimit(count + 1) - .includeAudit(true) - .build(); + ListDialogNodesOptions listOptions2 = + new ListDialogNodesOptions.Builder(workspaceId) + .pageLimit(count + 1) + .includeAudit(true) + .build(); DialogNodeCollection response2 = service.listDialogNodes(listOptions2).execute().getResult(); assertNotNull(response2); assertNotNull(response2.getDialogNodes()); @@ -1665,26 +1908,33 @@ public void testListDialogNodes() { fail(ex.getMessage()); } finally { // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); service.deleteDialogNode(deleteOptions).execute(); } } - /** - * Test listDialogNodes with pagination. - */ + /** Test listDialogNodes with pagination. */ @Test public void testListDialogNodesWithPaging() { String dialogNodeName1 = "First" + UUID.randomUUID().toString(); String dialogNodeName2 = "Second" + UUID.randomUUID().toString(); - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName1).build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName1).build(); service.createDialogNode(createOptions).execute().getResult(); - service.createDialogNode(createOptions.newBuilder().dialogNode(dialogNodeName2).build()).execute().getResult(); + service + .createDialogNode(createOptions.newBuilder().dialogNode(dialogNodeName2).build()) + .execute() + .getResult(); try { - ListDialogNodesOptions listOptions = new ListDialogNodesOptions.Builder().workspaceId(workspaceId).pageLimit(1L) - .sort("dialog_node").build(); + ListDialogNodesOptions listOptions = + new ListDialogNodesOptions.Builder() + .workspaceId(workspaceId) + .pageLimit(1L) + .sort("dialog_node") + .build(); DialogNodeCollection response = service.listDialogNodes(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getDialogNodes()); @@ -1704,42 +1954,49 @@ public void testListDialogNodesWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listDialogNodes(listOptions.newBuilder().cursor(cursor).build()).execute().getResult(); - + response = + service + .listDialogNodes(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); } assertTrue(found1 && found2); } catch (Exception ex) { fail(ex.getMessage()); } finally { // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName1).build(); + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName1).build(); service.deleteDialogNode(deleteOptions).execute(); - service.deleteDialogNode(deleteOptions.newBuilder().dialogNode(dialogNodeName2).build()).execute(); + service + .deleteDialogNode(deleteOptions.newBuilder().dialogNode(dialogNodeName2).build()) + .execute(); } } - /** - * Test updateDialogNode. - */ + /** Test updateDialogNode. */ @Test public void testUpdateDialogNode() { String dialogNodeName = "Test" + UUID.randomUUID().toString(); String dialogNodeDescription = "Description of " + dialogNodeName; - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription).build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) + .description(dialogNodeDescription) + .build(); service.createDialogNode(createOptions).execute().getResult(); String dialogNodeName2 = "Test2" + UUID.randomUUID().toString(); try { String dialogNodeDescription2 = "Updated description of " + dialogNodeName; - UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder() - .workspaceId(workspaceId) - .dialogNode(dialogNodeName) - .newDialogNode(dialogNodeName2) - .newDescription(dialogNodeDescription2) - .build(); + UpdateDialogNodeOptions updateOptions = + new UpdateDialogNodeOptions.Builder() + .workspaceId(workspaceId) + .dialogNode(dialogNodeName) + .newDialogNode(dialogNodeName2) + .newDescription(dialogNodeDescription2) + .build(); DialogNode response = service.updateDialogNode(updateOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.dialogNode()); @@ -1750,37 +2007,124 @@ public void testUpdateDialogNode() { fail(ex.getMessage()); } finally { // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build(); + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build(); service.deleteDialogNode(deleteOptions).execute(); } } - /** - * Test deleteUserData. - */ + /** Test updateDialogNodeNullable. */ + @Test + public void testUpdateDialogNodeNullable() { + String dialogNodeName = "Test" + UUID.randomUUID().toString(); + String dialogNodeDescription = "Description of " + dialogNodeName; + + DialogNodeNextStep dialogNodeNextStep = + new DialogNodeNextStep.Builder() + .behavior(DialogNodeNextStep.Behavior.SKIP_USER_INPUT) + .build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) + .description(dialogNodeDescription) + .nextStep(dialogNodeNextStep) + .build(); + service.createDialogNode(createOptions).execute().getResult(); + + String dialogNodeName2 = "Test2" + UUID.randomUUID().toString(); + + try { + String dialogNodeDescription2 = "Updated description of " + dialogNodeName; + + UpdateDialogNode updateDialogNode = + new UpdateDialogNode.Builder() + .description(dialogNodeDescription2) + .nextStep(null) + .dialogNode(dialogNodeName2) + .build(); + Map body = updateDialogNode.asPatch(); + + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptions = + new UpdateDialogNodeNullableOptions.Builder() + .workspaceId(workspaceId) + .dialogNode(dialogNodeName) + .body(body) + .build(); + DialogNode response = + service.updateDialogNodeNullable(updateDialogNodeNullableOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.dialogNode()); + assertEquals(response.dialogNode(), dialogNodeName2); + assertNotNull(response.description()); + assertEquals(response.description(), dialogNodeDescription2); + assertNull(response.nextStep()); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build(); + service.deleteDialogNode(deleteOptions).execute(); + } + } + + /** Test deleteUserData. */ @Test public void testDeleteUserData() { String customerId = "java_sdk_test_id"; try { - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); + DeleteUserDataOptions deleteOptions = + new DeleteUserDataOptions.Builder().customerId(customerId).build(); service.deleteUserData(deleteOptions).execute(); } catch (Exception ex) { fail(ex.getMessage()); } } + /** Test list mentions. */ @Test public void testListMentions() { - String entity = "amenity"; + String entity = "beverage"; - ListMentionsOptions listMentionsOptions = new ListMentionsOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .build(); - EntityMentionCollection collection = service.listMentions(listMentionsOptions).execute().getResult(); + ListMentionsOptions listMentionsOptions = + new ListMentionsOptions.Builder().workspaceId(workspaceId).entity(entity).build(); + EntityMentionCollection collection = + service.listMentions(listMentionsOptions).execute().getResult(); assertNotNull(collection); } + + @Test + public void testRuntimeResponseGeneric() { + try { + ArrayList inputStrings = new ArrayList<>(Arrays.asList("audio", "iframe", "video")); + for (String inputMessage : inputStrings) { + MessageInput input = new MessageInput(); + input.setText(inputMessage); + + MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); + MessageResponse response = service.message(options).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getOutput().getGeneric().get(0).responseType().contains(inputMessage)); + } + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + /** Test bulk classify */ + @Ignore + @Test + public void testBulkClassify() { + BulkClassifyUtterance bulkClassifyUtterance = + new BulkClassifyUtterance.Builder().text("help I need help").build(); + BulkClassifyOptions bulkClassifyOptions = + new BulkClassifyOptions.Builder() + .addInput(bulkClassifyUtterance) + .workspaceId("{workspaceId}") + .build(); + BulkClassifyResponse response = service.bulkClassify(bulkClassifyOptions).execute().getResult(); + + assertNotNull(response); + } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceTest.java index 34187865bc7..f9b281f612a 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2019. + * (C) Copyright IBM Corp. 2018, 2022. * * 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 @@ -15,40 +15,64 @@ import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.common.WatsonServiceTest; +import java.util.Date; import org.junit.Assume; import org.junit.Before; -import java.util.Date; - +/** The Class AssistantServiceTest. */ public class AssistantServiceTest extends WatsonServiceTest { private Assistant service; private String workspaceId; + /** + * Gets the service. + * + * @return the service + */ public Assistant getService() { return this.service; } + /** + * Gets the workspace id. + * + * @return the workspace id + */ public String getWorkspaceId() { return this.workspaceId; } + /** + * Sets up the tests. + * + * @throws Exception the exception + */ /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - String apiKey = getProperty("assistant.apikey"); - workspaceId = getProperty("assistant.workspace_id"); + String apiKey = System.getenv("ASSISTANT_APIKEY"); + workspaceId = System.getenv("ASSISTANT_WORKSPACE_ID"); + String serviceUrl = System.getenv("ASSISTANT_URL"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); + if (apiKey == null) { + apiKey = getProperty("assistant.apikey"); + workspaceId = getProperty("assistant.workspace_id"); + serviceUrl = getProperty("assistant.url"); + } + + Assume.assumeFalse( + "ASSISTANT_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey == null); Authenticator authenticator = new IamAuthenticator(apiKey); service = new Assistant("2019-02-28", authenticator); - service.setServiceUrl(getProperty("assistant.url")); + service.setServiceUrl(serviceUrl); service.setDefaultHeaders(getDefaultHeaders()); } @@ -56,6 +80,10 @@ public void setUp() throws Exception { /** * return `true` if ldate before rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful */ public boolean fuzzyBefore(Date ldate, Date rdate) { return (ldate.getTime() - rdate.getTime()) < tolerance; @@ -63,9 +91,12 @@ public boolean fuzzyBefore(Date ldate, Date rdate) { /** * return `true` if ldate after rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful */ public boolean fuzzyAfter(Date ldate, Date rdate) { return (rdate.getTime() - ldate.getTime()) < tolerance; } - } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java index 282c0d254a9..19dc8438dc4 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,1169 +10,4302 @@ * 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.assistant.v1; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.assistant.v1.model.Context; -import com.ibm.watson.assistant.v1.model.Counterexample; -import com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.assistant.v1.model.CreateEntity; -import com.ibm.watson.assistant.v1.model.CreateEntityOptions; -import com.ibm.watson.assistant.v1.model.CreateExampleOptions; -import com.ibm.watson.assistant.v1.model.CreateIntent; -import com.ibm.watson.assistant.v1.model.CreateIntentOptions; -import com.ibm.watson.assistant.v1.model.CreateValue; -import com.ibm.watson.assistant.v1.model.CreateValueOptions; -import com.ibm.watson.assistant.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.DeleteUserDataOptions; -import com.ibm.watson.assistant.v1.model.DialogNode; -import com.ibm.watson.assistant.v1.model.DialogNodeAction; -import com.ibm.watson.assistant.v1.model.Example; -import com.ibm.watson.assistant.v1.model.GetWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.ListAllLogsOptions; -import com.ibm.watson.assistant.v1.model.ListMentionsOptions; -import com.ibm.watson.assistant.v1.model.Mention; -import com.ibm.watson.assistant.v1.model.MessageContextMetadata; -import com.ibm.watson.assistant.v1.model.MessageInput; -import com.ibm.watson.assistant.v1.model.MessageOptions; -import com.ibm.watson.assistant.v1.model.MessageRequest; -import com.ibm.watson.assistant.v1.model.MessageResponse; -import com.ibm.watson.assistant.v1.model.OutputData; -import com.ibm.watson.assistant.v1.model.RuntimeEntity; -import com.ibm.watson.assistant.v1.model.RuntimeIntent; -import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; -import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; -import com.ibm.watson.assistant.v1.model.UpdateIntentOptions; -import com.ibm.watson.assistant.v1.model.UpdateValueOptions; -import com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.assistant.v1.model.Webhook; -import com.ibm.watson.assistant.v1.model.WebhookHeader; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettings; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsDisambiguation; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsOffTopic; -import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsTooling; -import com.ibm.watson.common.WatsonServiceUnitTest; -import okhttp3.mockwebserver.RecordedRequest; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; +import static org.testng.Assert.*; -import java.io.FileNotFoundException; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.model.*; +import com.ibm.watson.assistant.v1.utils.TestUtilities; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; +import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the Assistant service. */ +public class AssistantTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Assistant assistantService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // Set mock values for global params + String version = "testString"; + new Assistant(version, serviceName, null); + } + + // Test the getter for the version global parameter + @Test + public void testGetVersion() throws Throwable { + assertEquals(assistantService.getVersion(), "testString"); + } + + @Test + public void testUpdateDialogNodeNullableWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateDialogNodeNullablePath = "/v1/workspaces/testString/dialog_nodes/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + // model + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the UpdateDialogNode model + UpdateDialogNode updateDialogNodeModel = + new UpdateDialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + Map updateDialogNodeModelAsPatch = updateDialogNodeModel.asPatch(); + + // Construct an instance of the UpdateDialogNodeNullableOptions model + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptionsModel = + new UpdateDialogNodeNullableOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .body(updateDialogNodeModelAsPatch) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateDialogNodeNullable(updateDialogNodeNullableOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDialogNodeNullablePath); + } -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; + // Test the updateDialogNodeNullable operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNullableNoOptions() throws Throwable { + // construct the service + constructClientService(); -/** - * Unit tests for the {@link Assistant}. - */ -public class AssistantTest extends WatsonServiceUnitTest { - private static final String VERSION_DATE = "2019-02-28"; - private static final String INTENT = "turn_on"; - private static final Double CONFIDENCE = 0.0; - private static final String ENTITY = "genre"; - private static final String VALUE = "jazz"; - private static final String NONE_OF_THE_ABOVE_PROMPT = "none of the above"; - private static final String PROMPT = "prompt"; - private static final List LOCATION = Arrays.asList(1L, 2L); - private static final String TEXT = "text"; - private static final String NAME = "name"; - private static final String CREDENTIALS = "credentials"; - private static final String RESULT_VARIABLE = "result_variable"; - private static final String WEBHOOK_HEADER_NAME = "Webhook-Header"; - private static final String WEBHOOK_HEADER_VALUE = "webhook_value"; - private static final String WEBHOOK_NAME = "webhook_name"; - private static final String WEBHOOK_URL = "webhook_url"; - private static final Long MAX_SUGGESTIONS = 100L; - private static final String SUGGESTION_TEXT_POLICY = "suggestion_text_policy"; - - private Assistant service; - private static final String FIXTURE = "src/test/resources/assistant/assistant.json"; - private static final String WORKSPACE_ID = "123"; - private static final String PATH_MESSAGE = "/v1/workspaces/" + WORKSPACE_ID + "/message"; - private static final String VERSION = "version"; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new Assistant(VERSION_DATE, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new Assistant(null, new NoAuthAuthenticator()); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new Assistant("", new NoAuthAuthenticator()); - } - - /** - * Negative - Test assistant with null options. - */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithNullOptions() { - service.message(null).execute().getResult(); - } - - /** - * Negative - Test assistant with null workspaceId. - */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithNullWorkspaceId() { - MessageOptions options = new MessageOptions.Builder().build(); - service.message(options).execute().getResult(); - } - - /** - * Negative - Test assistant with empty workspaceId. - */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithEmptyWorkspaceId() { - MessageOptions options = new MessageOptions.Builder("").build(); - service.message(options).execute().getResult(); - } - - /** - * Test send message. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testSendMessage() throws IOException, InterruptedException { - String text = "I would love to hear some jazz music."; - - MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); - server.enqueue(jsonResponse(mockResponse)); - - MessageInput input = new MessageInput(); - input.setText(text); - RuntimeIntent intent = new RuntimeIntent.Builder() - .intent(INTENT) - .confidence(CONFIDENCE) - .build(); - RuntimeEntity entity = new RuntimeEntity.Builder() - .entity(ENTITY) - .value(VALUE) - .location(LOCATION) - .build(); - MessageOptions options = new MessageOptions.Builder(WORKSPACE_ID) - .input(input) - .addIntent(intent) - .addEntity(entity) - .alternateIntents(true) - .build(); - - // execute first request - MessageResponse serviceResponse = service.message(options).execute().getResult(); - - // first request + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateDialogNodeNullable(null).execute(); + } + + // Test the message operation with a valid options model parameter + @Test + public void testMessageWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": false, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"anyKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"chat\"}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"user_id\": \"userId\"}"; + String messagePath = "/v1/workspaces/testString/message"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the MessageInput model + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + + // Construct an instance of the MessageContextMetadata model + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + + // Construct an instance of the Context model + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system(java.util.Collections.singletonMap("anyKey", "anyValue")) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeVisitedDetails model + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + + // Construct an instance of the LogMessageSource model + LogMessageSource logMessageSourceModel = + new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build(); + + // Construct an instance of the LogMessage model + LogMessage logMessageModel = + new LogMessage.Builder() + .level("info") + .msg("testString") + .code("testString") + .source(logMessageSourceModel) + .build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the RuntimeResponseGenericRuntimeResponseTypeText model + RuntimeResponseGenericRuntimeResponseTypeText runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeText.Builder() + .responseType("text") + .text("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the OutputData model + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(java.util.Arrays.asList("testString")) + .nodesVisitedDetails(java.util.Arrays.asList(dialogNodeVisitedDetailsModel)) + .logMessages(java.util.Arrays.asList(logMessageModel)) + .generic(java.util.Arrays.asList(runtimeResponseGenericModel)) + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageOptions model + MessageOptions messageOptionsModel = + new MessageOptions.Builder() + .workspaceId("testString") + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .alternateIntents(false) + .context(contextModel) + .output(outputDataModel) + .userId("testString") + .nodesVisitedDetails(false) + .build(); + + // Invoke message() with a valid options model and verify the result + Response response = assistantService.message(messageOptionsModel).execute(); + assertNotNull(response); + MessageResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messagePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("nodes_visited_details")), Boolean.valueOf(false)); + } + + // Test the message operation with and without retries enabled + @Test + public void testMessageWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testMessageWOptions(); + + assistantService.disableRetries(); + testMessageWOptions(); + } + + // Test the message operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.message(null).execute(); + } + + // Test the bulkClassify operation with a valid options model parameter + @Test + public void testBulkClassifyWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"output\": [{\"input\": {\"text\": \"text\"}, \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}]}]}"; + String bulkClassifyPath = "/v1/workspaces/testString/bulk_classify"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the BulkClassifyUtterance model + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + + // Construct an instance of the BulkClassifyOptions model + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .workspaceId("testString") + .input(java.util.Arrays.asList(bulkClassifyUtteranceModel)) + .build(); + + // Invoke bulkClassify() with a valid options model and verify the result + Response response = + assistantService.bulkClassify(bulkClassifyOptionsModel).execute(); + assertNotNull(response); + BulkClassifyResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, bulkClassifyPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the bulkClassify operation with and without retries enabled + @Test + public void testBulkClassifyWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testBulkClassifyWOptions(); + + assistantService.disableRetries(); + testBulkClassifyWOptions(); + } + + // Test the bulkClassify operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.bulkClassify(null).execute(); + } + + // Test the listWorkspaces operation with a valid options model parameter + @Test + public void testListWorkspacesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"workspaces\": [{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listWorkspacesPath = "/v1/workspaces"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListWorkspacesOptions model + ListWorkspacesOptions listWorkspacesOptionsModel = + new ListWorkspacesOptions.Builder() + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listWorkspaces() with a valid options model and verify the result + Response response = + assistantService.listWorkspaces(listWorkspacesOptionsModel).execute(); + assertNotNull(response); + WorkspaceCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listWorkspacesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "name"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listWorkspaces operation with and without retries enabled + @Test + public void testListWorkspacesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListWorkspacesWOptions(); + + assistantService.disableRetries(); + testListWorkspacesWOptions(); + } + + // Test the createWorkspace operation with a valid options model parameter + @Test + public void testCreateWorkspaceWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}"; + String createWorkspacePath = "/v1/workspaces"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the DialogNodeOutputTextValuesElement model + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the DialogNode model + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + + // Construct an instance of the Counterexample model + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + + // Construct an instance of the WorkspaceSystemSettingsTooling model + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + + // Construct an instance of the WorkspaceSystemSettingsDisambiguation model + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + + // Construct an instance of the WorkspaceSystemSettingsSystemEntities model + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsOffTopic model + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsNlp model + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + + // Construct an instance of the WorkspaceSystemSettings model + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the Webhook model + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + + // Construct an instance of the CreateIntent model + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateEntity model + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + + // Construct an instance of the CreateWorkspaceOptions model + CreateWorkspaceOptions createWorkspaceOptionsModel = + new CreateWorkspaceOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .includeAudit(false) + .build(); + + // Invoke createWorkspace() with a valid options model and verify the result + Response response = + assistantService.createWorkspace(createWorkspaceOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createWorkspacePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createWorkspace operation with and without retries enabled + @Test + public void testCreateWorkspaceWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateWorkspaceWOptions(); + + assistantService.disableRetries(); + testCreateWorkspaceWOptions(); + } + + // Test the getWorkspace operation with a valid options model parameter + @Test + public void testGetWorkspaceWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}"; + String getWorkspacePath = "/v1/workspaces/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetWorkspaceOptions model + GetWorkspaceOptions getWorkspaceOptionsModel = + new GetWorkspaceOptions.Builder() + .workspaceId("testString") + .export(false) + .includeAudit(false) + .sort("stable") + .build(); + + // Invoke getWorkspace() with a valid options model and verify the result + Response response = + assistantService.getWorkspace(getWorkspaceOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getWorkspacePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "stable"); + } + + // Test the getWorkspace operation with and without retries enabled + @Test + public void testGetWorkspaceWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetWorkspaceWOptions(); + + assistantService.disableRetries(); + testGetWorkspaceWOptions(); + } + + // Test the getWorkspace operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWorkspaceNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getWorkspace(null).execute(); + } + + // Test the updateWorkspace operation with a valid options model parameter + @Test + public void testUpdateWorkspaceWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}"; + String updateWorkspacePath = "/v1/workspaces/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DialogNodeOutputTextValuesElement model + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the DialogNode model + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + + // Construct an instance of the Counterexample model + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + + // Construct an instance of the WorkspaceSystemSettingsTooling model + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + + // Construct an instance of the WorkspaceSystemSettingsDisambiguation model + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + + // Construct an instance of the WorkspaceSystemSettingsSystemEntities model + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsOffTopic model + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsNlp model + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + + // Construct an instance of the WorkspaceSystemSettings model + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the Webhook model + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + + // Construct an instance of the CreateIntent model + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateEntity model + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + + // Construct an instance of the UpdateWorkspaceOptions model + UpdateWorkspaceOptions updateWorkspaceOptionsModel = + new UpdateWorkspaceOptions.Builder() + .workspaceId("testString") + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .append(false) + .includeAudit(false) + .build(); + + // Invoke updateWorkspace() with a valid options model and verify the result + Response response = + assistantService.updateWorkspace(updateWorkspaceOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateWorkspacePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateWorkspace operation with and without retries enabled + @Test + public void testUpdateWorkspaceWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateWorkspaceWOptions(); + + assistantService.disableRetries(); + testUpdateWorkspaceWOptions(); + } + + // Test the updateWorkspace operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateWorkspaceNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateWorkspace(null).execute(); + } + + // Test the deleteWorkspace operation with a valid options model parameter + @Test + public void testDeleteWorkspaceWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteWorkspacePath = "/v1/workspaces/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteWorkspaceOptions model + DeleteWorkspaceOptions deleteWorkspaceOptionsModel = + new DeleteWorkspaceOptions.Builder().workspaceId("testString").build(); + + // Invoke deleteWorkspace() with a valid options model and verify the result + Response response = + assistantService.deleteWorkspace(deleteWorkspaceOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteWorkspacePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteWorkspace operation with and without retries enabled + @Test + public void testDeleteWorkspaceWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteWorkspaceWOptions(); + + assistantService.disableRetries(); + testDeleteWorkspaceWOptions(); + } + + // Test the deleteWorkspace operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWorkspaceNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteWorkspace(null).execute(); + } + + // Test the createWorkspaceAsync operation with a valid options model parameter + @Test + public void testCreateWorkspaceAsyncWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}"; + String createWorkspaceAsyncPath = "/v1/workspaces_async"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the DialogNodeOutputTextValuesElement model + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the DialogNode model + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + + // Construct an instance of the Counterexample model + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + + // Construct an instance of the WorkspaceSystemSettingsTooling model + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + + // Construct an instance of the WorkspaceSystemSettingsDisambiguation model + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + + // Construct an instance of the WorkspaceSystemSettingsSystemEntities model + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsOffTopic model + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsNlp model + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + + // Construct an instance of the WorkspaceSystemSettings model + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the Webhook model + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + + // Construct an instance of the CreateIntent model + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateEntity model + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + + // Construct an instance of the CreateWorkspaceAsyncOptions model + CreateWorkspaceAsyncOptions createWorkspaceAsyncOptionsModel = + new CreateWorkspaceAsyncOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .build(); + + // Invoke createWorkspaceAsync() with a valid options model and verify the result + Response response = + assistantService.createWorkspaceAsync(createWorkspaceAsyncOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createWorkspaceAsyncPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createWorkspaceAsync operation with and without retries enabled + @Test + public void testCreateWorkspaceAsyncWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateWorkspaceAsyncWOptions(); + + assistantService.disableRetries(); + testCreateWorkspaceAsyncWOptions(); + } + + // Test the updateWorkspaceAsync operation with a valid options model parameter + @Test + public void testUpdateWorkspaceAsyncWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}"; + String updateWorkspaceAsyncPath = "/v1/workspaces_async/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the DialogNodeOutputTextValuesElement model + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the DialogNode model + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + + // Construct an instance of the Counterexample model + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + + // Construct an instance of the WorkspaceSystemSettingsTooling model + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + + // Construct an instance of the WorkspaceSystemSettingsDisambiguation model + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + + // Construct an instance of the WorkspaceSystemSettingsSystemEntities model + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsOffTopic model + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + + // Construct an instance of the WorkspaceSystemSettingsNlp model + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + + // Construct an instance of the WorkspaceSystemSettings model + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the Webhook model + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + + // Construct an instance of the CreateIntent model + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateEntity model + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + + // Construct an instance of the UpdateWorkspaceAsyncOptions model + UpdateWorkspaceAsyncOptions updateWorkspaceAsyncOptionsModel = + new UpdateWorkspaceAsyncOptions.Builder() + .workspaceId("testString") + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .append(false) + .build(); + + // Invoke updateWorkspaceAsync() with a valid options model and verify the result + Response response = + assistantService.updateWorkspaceAsync(updateWorkspaceAsyncOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateWorkspaceAsyncPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false)); + } + + // Test the updateWorkspaceAsync operation with and without retries enabled + @Test + public void testUpdateWorkspaceAsyncWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateWorkspaceAsyncWOptions(); + + assistantService.disableRetries(); + testUpdateWorkspaceAsyncWOptions(); + } + + // Test the updateWorkspaceAsync operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateWorkspaceAsyncNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateWorkspaceAsync(null).execute(); + } + + // Test the exportWorkspaceAsync operation with a valid options model parameter + @Test + public void testExportWorkspaceAsyncWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"anyKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}, \"nlp\": {\"model\": \"model\"}}, \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"counts\": {\"intent\": 6, \"entity\": 6, \"node\": 4}}"; + String exportWorkspaceAsyncPath = "/v1/workspaces_async/testString/export"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ExportWorkspaceAsyncOptions model + ExportWorkspaceAsyncOptions exportWorkspaceAsyncOptionsModel = + new ExportWorkspaceAsyncOptions.Builder() + .workspaceId("testString") + .includeAudit(false) + .sort("stable") + .verbose(false) + .build(); + + // Invoke exportWorkspaceAsync() with a valid options model and verify the result + Response response = + assistantService.exportWorkspaceAsync(exportWorkspaceAsyncOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, exportWorkspaceAsyncPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "stable"); + assertEquals(Boolean.valueOf(query.get("verbose")), Boolean.valueOf(false)); + } + + // Test the exportWorkspaceAsync operation with and without retries enabled + @Test + public void testExportWorkspaceAsyncWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testExportWorkspaceAsyncWOptions(); + + assistantService.disableRetries(); + testExportWorkspaceAsyncWOptions(); + } + + // Test the exportWorkspaceAsync operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExportWorkspaceAsyncNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.exportWorkspaceAsync(null).execute(); + } + + // Test the listIntents operation with a valid options model parameter + @Test + public void testListIntentsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listIntentsPath = "/v1/workspaces/testString/intents"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListIntentsOptions model + ListIntentsOptions listIntentsOptionsModel = + new ListIntentsOptions.Builder() + .workspaceId("testString") + .export(false) + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("intent") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listIntents() with a valid options model and verify the result + Response response = + assistantService.listIntents(listIntentsOptionsModel).execute(); + assertNotNull(response); + IntentCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listIntentsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "intent"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listIntents operation with and without retries enabled + @Test + public void testListIntentsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListIntentsWOptions(); + + assistantService.disableRetries(); + testListIntentsWOptions(); + } + + // Test the listIntents operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListIntentsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listIntents(null).execute(); + } + + // Test the createIntent operation with a valid options model parameter + @Test + public void testCreateIntentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String createIntentPath = "/v1/workspaces/testString/intents"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + + // Construct an instance of the CreateIntentOptions model + CreateIntentOptions createIntentOptionsModel = + new CreateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .includeAudit(false) + .build(); + + // Invoke createIntent() with a valid options model and verify the result + Response response = assistantService.createIntent(createIntentOptionsModel).execute(); + assertNotNull(response); + Intent responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createIntentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createIntent operation with and without retries enabled + @Test + public void testCreateIntentWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateIntentWOptions(); + + assistantService.disableRetries(); + testCreateIntentWOptions(); + } + + // Test the createIntent operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateIntentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createIntent(null).execute(); + } + + // Test the getIntent operation with a valid options model parameter + @Test + public void testGetIntentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String getIntentPath = "/v1/workspaces/testString/intents/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetIntentOptions model + GetIntentOptions getIntentOptionsModel = + new GetIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .export(false) + .includeAudit(false) + .build(); + + // Invoke getIntent() with a valid options model and verify the result + Response response = assistantService.getIntent(getIntentOptionsModel).execute(); + assertNotNull(response); + Intent responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getIntentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getIntent operation with and without retries enabled + @Test + public void testGetIntentWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetIntentWOptions(); + + assistantService.disableRetries(); + testGetIntentWOptions(); + } + + // Test the getIntent operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetIntentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getIntent(null).execute(); + } + + // Test the updateIntent operation with a valid options model parameter + @Test + public void testUpdateIntentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String updateIntentPath = "/v1/workspaces/testString/intents/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + + // Construct an instance of the UpdateIntentOptions model + UpdateIntentOptions updateIntentOptionsModel = + new UpdateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .newIntent("testString") + .newDescription("testString") + .newExamples(java.util.Arrays.asList(exampleModel)) + .append(false) + .includeAudit(false) + .build(); + + // Invoke updateIntent() with a valid options model and verify the result + Response response = assistantService.updateIntent(updateIntentOptionsModel).execute(); + assertNotNull(response); + Intent responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateIntentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateIntent operation with and without retries enabled + @Test + public void testUpdateIntentWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateIntentWOptions(); + + assistantService.disableRetries(); + testUpdateIntentWOptions(); + } + + // Test the updateIntent operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateIntentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateIntent(null).execute(); + } + + // Test the deleteIntent operation with a valid options model parameter + @Test + public void testDeleteIntentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteIntentPath = "/v1/workspaces/testString/intents/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteIntentOptions model + DeleteIntentOptions deleteIntentOptionsModel = + new DeleteIntentOptions.Builder().workspaceId("testString").intent("testString").build(); + + // Invoke deleteIntent() with a valid options model and verify the result + Response response = assistantService.deleteIntent(deleteIntentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteIntentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteIntent operation with and without retries enabled + @Test + public void testDeleteIntentWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteIntentWOptions(); + + assistantService.disableRetries(); + testDeleteIntentWOptions(); + } + + // Test the deleteIntent operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteIntentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteIntent(null).execute(); + } + + // Test the listExamples operation with a valid options model parameter + @Test + public void testListExamplesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listExamplesPath = "/v1/workspaces/testString/intents/testString/examples"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListExamplesOptions model + ListExamplesOptions listExamplesOptionsModel = + new ListExamplesOptions.Builder() + .workspaceId("testString") + .intent("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("text") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listExamples() with a valid options model and verify the result + Response response = + assistantService.listExamples(listExamplesOptionsModel).execute(); + assertNotNull(response); + ExampleCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listExamplesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "text"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listExamples operation with and without retries enabled + @Test + public void testListExamplesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListExamplesWOptions(); + + assistantService.disableRetries(); + testListExamplesWOptions(); + } + + // Test the listExamples operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExamplesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listExamples(null).execute(); + } + + // Test the createExample operation with a valid options model parameter + @Test + public void testCreateExampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createExamplePath = "/v1/workspaces/testString/intents/testString/examples"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the CreateExampleOptions model + CreateExampleOptions createExampleOptionsModel = + new CreateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .includeAudit(false) + .build(); + + // Invoke createExample() with a valid options model and verify the result + Response response = + assistantService.createExample(createExampleOptionsModel).execute(); + assertNotNull(response); + Example responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createExamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createExample operation with and without retries enabled + @Test + public void testCreateExampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateExampleWOptions(); + + assistantService.disableRetries(); + testCreateExampleWOptions(); + } + + // Test the createExample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createExample(null).execute(); + } + + // Test the getExample operation with a valid options model parameter + @Test + public void testGetExampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetExampleOptions model + GetExampleOptions getExampleOptionsModel = + new GetExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .includeAudit(false) + .build(); + + // Invoke getExample() with a valid options model and verify the result + Response response = assistantService.getExample(getExampleOptionsModel).execute(); + assertNotNull(response); + Example responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getExamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getExample operation with and without retries enabled + @Test + public void testGetExampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetExampleWOptions(); + + assistantService.disableRetries(); + testGetExampleWOptions(); + } + + // Test the getExample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetExampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getExample(null).execute(); + } - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=", VERSION_DATE); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); + // Test the updateExample operation with a valid options model parameter + @Test + public void testUpdateExampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String updateExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the UpdateExampleOptions model + UpdateExampleOptions updateExampleOptionsModel = + new UpdateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .newText("testString") + .newMentions(java.util.Arrays.asList(mentionModel)) + .includeAudit(false) + .build(); + + // Invoke updateExample() with a valid options model and verify the result + Response response = + assistantService.updateExample(updateExampleOptionsModel).execute(); + assertNotNull(response); + Example responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); assertEquals(request.getMethod(), "POST"); - assertNotNull(serviceResponse.getActions()); - assertNotNull(serviceResponse.getActions().get(0).name()); - assertNotNull(serviceResponse.getActions().get(0).credentials()); - assertNotNull(serviceResponse.getActions().get(0).type()); - assertNotNull(serviceResponse.getActions().get(0).parameters()); - assertNotNull(serviceResponse.getActions().get(0).resultVariable()); - assertNotNull(serviceResponse.getOutput().getLogMessages()); - assertNotNull(serviceResponse.getOutput().getNodesVisited()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).dialogNode()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).title()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - } - - /** - * Test send message. use some different MessageOptions options like context and other public methods - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testSendMessageWithAlternateIntents() throws IOException, InterruptedException { - MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); - server.enqueue(jsonResponse(mockResponse)); - - MessageContextMetadata metadata = new MessageContextMetadata.Builder().build(); - Context contextTemp = new Context(); - contextTemp.put("name", "Myname"); - contextTemp.setMetadata(metadata); - MessageInput inputTemp = new MessageInput(); - inputTemp.setText("My text"); - - assertEquals("Myname", contextTemp.get("name")); - assertEquals(metadata, contextTemp.getMetadata()); - - MessageOptions options = new MessageOptions.Builder(WORKSPACE_ID) - .input(inputTemp) - .alternateIntents(false) - .context(contextTemp) - .entities(null).intents(null).build(); - - // execute first request - MessageResponse serviceResponse = service.message(options).execute().getResult(); - - // first request + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateExamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateExample operation with and without retries enabled + @Test + public void testUpdateExampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateExampleWOptions(); + + assistantService.disableRetries(); + testUpdateExampleWOptions(); + } + + // Test the updateExample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateExampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateExample(null).execute(); + } + + // Test the deleteExample operation with a valid options model parameter + @Test + public void testDeleteExampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteExampleOptions model + DeleteExampleOptions deleteExampleOptionsModel = + new DeleteExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .build(); + + // Invoke deleteExample() with a valid options model and verify the result + Response response = assistantService.deleteExample(deleteExampleOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteExamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteExample operation with and without retries enabled + @Test + public void testDeleteExampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteExampleWOptions(); + + assistantService.disableRetries(); + testDeleteExampleWOptions(); + } + + // Test the deleteExample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteExample(null).execute(); + } + + // Test the listCounterexamples operation with a valid options model parameter + @Test + public void testListCounterexamplesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listCounterexamplesPath = "/v1/workspaces/testString/counterexamples"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListCounterexamplesOptions model + ListCounterexamplesOptions listCounterexamplesOptionsModel = + new ListCounterexamplesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("text") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listCounterexamples() with a valid options model and verify the result + Response response = + assistantService.listCounterexamples(listCounterexamplesOptionsModel).execute(); + assertNotNull(response); + CounterexampleCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCounterexamplesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "text"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listCounterexamples operation with and without retries enabled + @Test + public void testListCounterexamplesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListCounterexamplesWOptions(); - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=", VERSION_DATE); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); + assistantService.disableRetries(); + testListCounterexamplesWOptions(); + } + + // Test the listCounterexamples operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCounterexamplesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listCounterexamples(null).execute(); + } + + // Test the createCounterexample operation with a valid options model parameter + @Test + public void testCreateCounterexampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createCounterexamplePath = "/v1/workspaces/testString/counterexamples"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateCounterexampleOptions model + CreateCounterexampleOptions createCounterexampleOptionsModel = + new CreateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(false) + .build(); + + // Invoke createCounterexample() with a valid options model and verify the result + Response response = + assistantService.createCounterexample(createCounterexampleOptionsModel).execute(); + assertNotNull(response); + Counterexample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCounterexamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createCounterexample operation with and without retries enabled + @Test + public void testCreateCounterexampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateCounterexampleWOptions(); + + assistantService.disableRetries(); + testCreateCounterexampleWOptions(); + } + + // Test the createCounterexample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCounterexampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createCounterexample(null).execute(); } + // Test the getCounterexample operation with a valid options model parameter @Test - public void testSendMessageWithMessageRequest() throws FileNotFoundException, InterruptedException { - String text = "I would love to hear some jazz music."; - - MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); - server.enqueue(jsonResponse(mockResponse)); - - MessageInput input = new MessageInput(); - input.setText(text); - RuntimeIntent intent = new RuntimeIntent.Builder() - .intent(INTENT) - .confidence(CONFIDENCE) - .build(); - RuntimeEntity entity = new RuntimeEntity.Builder() - .entity(ENTITY) - .value(VALUE) - .location(LOCATION) - .build(); - Context context = new Context(); - OutputData outputData = new OutputData(); - - MessageRequest messageRequest = new MessageRequest.Builder() - .input(input) - .intents(Collections.singletonList(intent)) - .entities(Collections.singletonList(entity)) - .alternateIntents(true) - .context(context) - .output(outputData) - .build(); - - assertEquals(input, messageRequest.input()); - assertEquals(intent, messageRequest.intents().get(0)); - assertEquals(entity, messageRequest.entities().get(0)); - assertEquals(context, messageRequest.context()); - assertEquals(outputData, messageRequest.output()); - - MessageOptions options = new MessageOptions.Builder() - .workspaceId(WORKSPACE_ID) - .messageRequest(messageRequest) - .build(); - - // execute first request - MessageResponse serviceResponse = service.message(options).execute().getResult(); - - // first request + public void testGetCounterexampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getCounterexamplePath = "/v1/workspaces/testString/counterexamples/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCounterexampleOptions model + GetCounterexampleOptions getCounterexampleOptionsModel = + new GetCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(false) + .build(); + + // Invoke getCounterexample() with a valid options model and verify the result + Response response = + assistantService.getCounterexample(getCounterexampleOptionsModel).execute(); + assertNotNull(response); + Counterexample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCounterexamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getCounterexample operation with and without retries enabled + @Test + public void testGetCounterexampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetCounterexampleWOptions(); + + assistantService.disableRetries(); + testGetCounterexampleWOptions(); + } + + // Test the getCounterexample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCounterexampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getCounterexample(null).execute(); + } - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=", VERSION_DATE); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); + // Test the updateCounterexample operation with a valid options model parameter + @Test + public void testUpdateCounterexampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String updateCounterexamplePath = "/v1/workspaces/testString/counterexamples/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateCounterexampleOptions model + UpdateCounterexampleOptions updateCounterexampleOptionsModel = + new UpdateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .newText("testString") + .includeAudit(false) + .build(); + + // Invoke updateCounterexample() with a valid options model and verify the result + Response response = + assistantService.updateCounterexample(updateCounterexampleOptionsModel).execute(); + assertNotNull(response); + Counterexample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); assertEquals(request.getMethod(), "POST"); - assertNotNull(serviceResponse.getActions()); - assertNotNull(serviceResponse.getActions().get(0).name()); - assertNotNull(serviceResponse.getActions().get(0).credentials()); - assertNotNull(serviceResponse.getActions().get(0).type()); - assertNotNull(serviceResponse.getActions().get(0).parameters()); - assertNotNull(serviceResponse.getActions().get(0).resultVariable()); - assertNotNull(serviceResponse.getOutput().getLogMessages()); - assertNotNull(serviceResponse.getOutput().getNodesVisited()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).dialogNode()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).title()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - } - - /** - * Negative - Test message with null workspace id. - * - * @throws InterruptedException the interrupted exception - */ - @Test(expected = IllegalArgumentException.class) - public void testSendMessageWithNullWorkspaceId() throws InterruptedException { - String text = "I'd like to get insurance to for my home"; - - MessageInput input = new MessageInput(); - input.setText(text); - MessageOptions options = new MessageOptions.Builder().input(input).alternateIntents(true).build(); - - service.message(options).execute().getResult(); - } - - /** - * Test CreateWorkspace builder. - */ - @Test - public void testCreateWorkspaceBuilder() { - - String workspaceName = "Builder Test"; - String workspaceDescription = "Description of " + workspaceName; - String workspaceLanguage = "en"; - String userLabel = "user_label"; - - // intents - CreateIntent testIntent0 = new CreateIntent.Builder("testIntent0").build(); - CreateIntent testIntent1 = new CreateIntent.Builder("testIntent1").build(); - - // entities - CreateEntity testEntity0 = new CreateEntity.Builder("testEntity0").build(); - CreateEntity testEntity1 = new CreateEntity.Builder("testEntity1").build(); - - // counterexamples - Counterexample testCounterexample0 = new Counterexample.Builder("testCounterexample0").build(); - Counterexample testCounterexample1 = new Counterexample.Builder("testCounterexample1").build(); - - // dialognodes - DialogNode testDialogNode0 = new DialogNode.Builder("dialogNode0") - .userLabel(userLabel) - .build(); - DialogNode testDialogNode1 = new DialogNode.Builder("dialogNode1").build(); - - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); - - // systemSettings - WorkspaceSystemSettingsDisambiguation disambiguation = new WorkspaceSystemSettingsDisambiguation.Builder() - .enabled(true) - .noneOfTheAbovePrompt(NONE_OF_THE_ABOVE_PROMPT) - .prompt(PROMPT) - .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) - .randomize(true) - .maxSuggestions(MAX_SUGGESTIONS) - .suggestionTextPolicy(SUGGESTION_TEXT_POLICY) - .build(); - WorkspaceSystemSettingsTooling tooling = new WorkspaceSystemSettingsTooling.Builder() - .storeGenericResponses(true) - .build(); - Map humanAgentAssist = new HashMap<>(); - humanAgentAssist.put("help", "ok"); - WorkspaceSystemSettingsOffTopic offTopic = new WorkspaceSystemSettingsOffTopic.Builder() - .enabled(true) - .build(); - WorkspaceSystemSettings systemSettings = new WorkspaceSystemSettings.Builder() - .disambiguation(disambiguation) - .tooling(tooling) - .humanAgentAssist(humanAgentAssist) - .offTopic(offTopic) - .build(); - - WebhookHeader webhookHeader = new WebhookHeader.Builder() - .name(WEBHOOK_HEADER_NAME) - .value(WEBHOOK_HEADER_VALUE) - .build(); - List webhookHeaderList = new ArrayList<>(); - webhookHeaderList.add(webhookHeader); - Webhook webhook = new Webhook.Builder() - .name(WEBHOOK_NAME) - .url(WEBHOOK_URL) - .headers(webhookHeaderList) - .addHeaders(webhookHeader) - .build(); - List webhookList = new ArrayList<>(); - webhookList.add(webhook); - - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder() - .name(workspaceName) - .description(workspaceDescription) - .language(workspaceLanguage) - .addIntent(testIntent0).addIntent(testIntent1) - .addEntity(testEntity0).addEntity(testEntity1) - .addCounterexample(testCounterexample0).addCounterexample(testCounterexample1) - .addDialogNode(testDialogNode0).addDialogNode(testDialogNode1) - .metadata(workspaceMetadata) - .systemSettings(systemSettings) - .webhooks(webhookList) - .addWebhooks(webhook) - .build(); - - assertEquals(createOptions.name(), workspaceName); - assertEquals(createOptions.description(), workspaceDescription); - assertEquals(createOptions.language(), workspaceLanguage); - assertNotNull(createOptions.intents()); - assertEquals(createOptions.intents().size(), 2); - assertEquals(createOptions.intents().get(0), testIntent0); - assertEquals(createOptions.intents().get(1), testIntent1); - assertNotNull(createOptions.entities()); - assertEquals(createOptions.entities().size(), 2); - assertEquals(createOptions.entities().get(0), testEntity0); - assertEquals(createOptions.entities().get(1), testEntity1); - assertNotNull(createOptions.counterexamples()); - assertEquals(createOptions.counterexamples().size(), 2); - assertEquals(createOptions.counterexamples().get(0), testCounterexample0); - assertEquals(createOptions.counterexamples().get(1), testCounterexample1); - assertNotNull(createOptions.dialogNodes()); - assertEquals(createOptions.dialogNodes().size(), 2); - assertEquals(createOptions.dialogNodes().get(0), testDialogNode0); - assertEquals(createOptions.dialogNodes().get(0).userLabel(), userLabel); - assertEquals(createOptions.dialogNodes().get(1), testDialogNode1); - assertNotNull(createOptions.systemSettings()); - assertEquals(createOptions.systemSettings().disambiguation().noneOfTheAbovePrompt(), - disambiguation.noneOfTheAbovePrompt()); - assertEquals(createOptions.systemSettings().disambiguation().prompt(), disambiguation.prompt()); - assertEquals(createOptions.systemSettings().disambiguation().sensitivity(), disambiguation.sensitivity()); - assertEquals(createOptions.systemSettings().disambiguation().enabled(), disambiguation.enabled()); - assertTrue(createOptions.systemSettings().disambiguation().randomize()); - assertEquals(MAX_SUGGESTIONS, createOptions.systemSettings().disambiguation().maxSuggestions()); - assertEquals(SUGGESTION_TEXT_POLICY, createOptions.systemSettings().disambiguation().suggestionTextPolicy()); - assertEquals(createOptions.systemSettings().tooling().storeGenericResponses(), - tooling.storeGenericResponses()); - assertEquals(createOptions.systemSettings().humanAgentAssist(), humanAgentAssist); - assertTrue(createOptions.systemSettings().offTopic().enabled()); - - assertEquals(2, createOptions.webhooks().size()); - assertEquals(webhook, createOptions.webhooks().get(0)); - assertEquals(WEBHOOK_NAME, createOptions.webhooks().get(0).name()); - assertEquals(WEBHOOK_URL, createOptions.webhooks().get(0).url()); - assertEquals(2, createOptions.webhooks().get(0).headers().size()); - assertEquals(webhookHeader, createOptions.webhooks().get(0).headers().get(0)); - assertEquals(WEBHOOK_HEADER_NAME, createOptions.webhooks().get(0).headers().get(0).name()); - assertEquals(WEBHOOK_HEADER_VALUE, createOptions.webhooks().get(0).headers().get(0).value()); - - CreateWorkspaceOptions.Builder builder = createOptions.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - Counterexample testCounterexample2 = new Counterexample.Builder("testCounterexample2").build(); - DialogNode testDialogNode2 = new DialogNode.Builder("dialogNode2").build(); - - builder.intents(Collections.singletonList(testIntent2)); - builder.entities(Collections.singletonList(testEntity2)); - builder.counterexamples(Collections.singletonList(testCounterexample2)); - builder.dialogNodes(Collections.singletonList(testDialogNode2)); - - CreateWorkspaceOptions options2 = builder.build(); - - assertNotNull(options2.intents()); - assertEquals(options2.intents().size(), 1); - assertEquals(options2.intents().get(0), testIntent2); - assertNotNull(options2.entities()); - assertEquals(options2.entities().size(), 1); - assertEquals(options2.entities().get(0), testEntity2); - assertNotNull(options2.counterexamples()); - assertEquals(options2.counterexamples().size(), 1); - assertEquals(options2.counterexamples().get(0), testCounterexample2); - assertNotNull(options2.dialogNodes()); - assertEquals(options2.dialogNodes().size(), 1); - assertEquals(options2.dialogNodes().get(0), testDialogNode2); - } - - /** - * Test UpdateWorkspaceOptions builder. - */ - @Test - public void testUpdateWorkspaceOptionsBuilder() { - - String workspaceName = "Builder Test"; - String workspaceDescription = "Description of " + workspaceName; - String workspaceLanguage = "en"; - - // intents - CreateIntent testIntent = new CreateIntent.Builder("testIntent").build(); - - // entities - CreateEntity testEntity = new CreateEntity.Builder("testEntity").build(); - - // counterexamples - Counterexample testCounterexample = new Counterexample.Builder("testCounterexample").build(); - - // dialognodes - DialogNode testDialogNode = new DialogNode.Builder("dialogNode").build(); - - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); - - // systemSettings - WorkspaceSystemSettingsDisambiguation disambiguation = new WorkspaceSystemSettingsDisambiguation.Builder() - .enabled(true) - .noneOfTheAbovePrompt(NONE_OF_THE_ABOVE_PROMPT) - .prompt(PROMPT) - .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) - .randomize(true) - .maxSuggestions(MAX_SUGGESTIONS) - .build(); - WorkspaceSystemSettingsTooling tooling = new WorkspaceSystemSettingsTooling.Builder() - .storeGenericResponses(true) - .build(); - Map humanAgentAssist = new HashMap<>(); - humanAgentAssist.put("help", "ok"); - WorkspaceSystemSettings systemSettings = new WorkspaceSystemSettings.Builder() - .disambiguation(disambiguation) - .tooling(tooling) - .humanAgentAssist(humanAgentAssist) - .build(); - - WebhookHeader webhookHeader = new WebhookHeader.Builder() - .name(WEBHOOK_HEADER_NAME) - .value(WEBHOOK_HEADER_VALUE) - .build(); - List webhookHeaderList = new ArrayList<>(); - webhookHeaderList.add(webhookHeader); - Webhook webhook = new Webhook.Builder() - .name(WEBHOOK_NAME) - .url(WEBHOOK_URL) - .headers(webhookHeaderList) - .addHeaders(webhookHeader) - .build(); - List webhookList = new ArrayList<>(); - webhookList.add(webhook); - - UpdateWorkspaceOptions.Builder builder = new UpdateWorkspaceOptions.Builder(WORKSPACE_ID); - builder.name(workspaceName); - builder.description(workspaceDescription); - builder.language(workspaceLanguage); - builder.addIntent(testIntent); - builder.addEntity(testEntity); - builder.addCounterexample(testCounterexample); - builder.addDialogNode(testDialogNode); - builder.metadata(workspaceMetadata); - builder.systemSettings(systemSettings); - builder.webhooks(webhookList); - builder.addWebhooks(webhook); - - UpdateWorkspaceOptions options = builder.build(); - - assertEquals(options.name(), workspaceName); - assertEquals(options.description(), workspaceDescription); - assertEquals(options.language(), workspaceLanguage); - assertNotNull(options.intents()); - assertEquals(options.intents().size(), 1); - assertEquals(options.intents().get(0), testIntent); - assertNotNull(options.entities()); - assertEquals(options.entities().size(), 1); - assertEquals(options.entities().get(0), testEntity); - assertNotNull(options.counterexamples()); - assertEquals(options.counterexamples().size(), 1); - assertEquals(options.counterexamples().get(0), testCounterexample); - assertNotNull(options.dialogNodes()); - assertEquals(options.dialogNodes().size(), 1); - assertEquals(options.dialogNodes().get(0), testDialogNode); - assertNotNull(options.metadata()); - assertEquals(options.metadata(), workspaceMetadata); - assertNotNull(options.systemSettings()); - assertEquals(options.systemSettings().disambiguation().noneOfTheAbovePrompt(), - disambiguation.noneOfTheAbovePrompt()); - assertEquals(options.systemSettings().disambiguation().sensitivity(), disambiguation.sensitivity()); - assertEquals(options.systemSettings().disambiguation().prompt(), disambiguation.prompt()); - assertEquals(options.systemSettings().disambiguation().enabled(), disambiguation.enabled()); - assertTrue(options.systemSettings().disambiguation().randomize()); - assertEquals(MAX_SUGGESTIONS, options.systemSettings().disambiguation().maxSuggestions()); - assertEquals(options.systemSettings().tooling().storeGenericResponses(), tooling.storeGenericResponses()); - assertEquals(options.systemSettings().humanAgentAssist(), humanAgentAssist); - assertEquals(2, options.webhooks().size()); - assertEquals(webhook, options.webhooks().get(0)); - assertEquals(WEBHOOK_NAME, options.webhooks().get(0).name()); - assertEquals(WEBHOOK_URL, options.webhooks().get(0).url()); - assertEquals(2, options.webhooks().get(0).headers().size()); - assertEquals(webhookHeader, options.webhooks().get(0).headers().get(0)); - assertEquals(WEBHOOK_HEADER_NAME, options.webhooks().get(0).headers().get(0).name()); - assertEquals(WEBHOOK_HEADER_VALUE, options.webhooks().get(0).headers().get(0).value()); - - UpdateWorkspaceOptions.Builder builder2 = options.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - Counterexample testCounterexample2 = new Counterexample.Builder("testCounterexample2").build(); - DialogNode testDialogNode2 = new DialogNode.Builder("dialogNode2").build(); - - builder2.intents(new ArrayList()); - builder2.addIntent(testIntent2); - builder2.entities(new ArrayList()); - builder2.addEntity(testEntity2); - builder2.counterexamples(new ArrayList()); - builder2.addCounterexample(testCounterexample2); - builder2.dialogNodes(new ArrayList()); - builder2.addDialogNode(testDialogNode2); - - UpdateWorkspaceOptions options2 = builder2.build(); - - assertNotNull(options2.intents()); - assertEquals(options2.intents().size(), 1); - assertEquals(options2.intents().get(0), testIntent2); - assertNotNull(options2.entities()); - assertEquals(options2.entities().size(), 1); - assertEquals(options2.entities().get(0), testEntity2); - assertNotNull(options2.counterexamples()); - assertEquals(options2.counterexamples().size(), 1); - assertEquals(options2.counterexamples().get(0), testCounterexample2); - assertNotNull(options2.dialogNodes()); - assertEquals(options2.dialogNodes().size(), 1); - assertEquals(options2.dialogNodes().get(0), testDialogNode2); - } - - @Test - public void testGetWorkspaceOptionsBuilder() { - String workspaceId = "workspace_id"; - String sort = GetWorkspaceOptions.Sort.STABLE; - - GetWorkspaceOptions getWorkspaceOptions = new GetWorkspaceOptions.Builder() - .workspaceId(workspaceId) - .export(true) - .includeAudit(true) - .sort(sort) - .build(); - getWorkspaceOptions = getWorkspaceOptions.newBuilder().build(); - - assertEquals(workspaceId, getWorkspaceOptions.workspaceId()); - assertTrue(getWorkspaceOptions.export()); - assertTrue(getWorkspaceOptions.includeAudit()); - assertEquals(sort, getWorkspaceOptions.sort()); - } - - @Test - public void testCreateExampleOptionsBuilder() { - Mention mentions1 = new Mention.Builder() - .entity(ENTITY) - .location(LOCATION) - .build(); - List mentionsList = new ArrayList<>(); - mentionsList.add(mentions1); - Mention mentions2 = new Mention.Builder() - .entity(ENTITY) - .location(LOCATION) - .build(); - - CreateExampleOptions createExampleOptions = new CreateExampleOptions.Builder() - .workspaceId(WORKSPACE_ID) - .mentions(mentionsList) - .addMentions(mentions2) - .text(TEXT) - .intent(INTENT) - .build(); - - mentionsList.add(mentions2); - - assertEquals(createExampleOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createExampleOptions.mentions(), mentionsList); - assertEquals(createExampleOptions.text(), TEXT); - assertEquals(createExampleOptions.intent(), INTENT); - } - - @Test - public void testUpdateExampleOptionsBuilder() { - Mention mentions1 = new Mention.Builder() - .entity(ENTITY) - .location(LOCATION) - .build(); - List mentionsList = new ArrayList<>(); - mentionsList.add(mentions1); - Mention mentions2 = new Mention.Builder() - .entity(ENTITY) - .location(LOCATION) - .build(); - - UpdateExampleOptions updateExampleOptions = new UpdateExampleOptions.Builder() - .workspaceId(WORKSPACE_ID) - .intent(INTENT) - .text(TEXT) - .newMentions(mentionsList) - .newText(TEXT) - .build(); - - mentionsList.add(mentions2); - - assertEquals(updateExampleOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateExampleOptions.newMentions(), mentionsList); - assertEquals(updateExampleOptions.newText(), TEXT); - assertEquals(updateExampleOptions.intent(), INTENT); - assertEquals(updateExampleOptions.text(), TEXT); - } - - /** - * Test CreateIntentOptions builder. - */ - @Test - public void testCreateIntentOptionsBuilder() { - String intent = "anIntent"; - Example intentExample0 = new Example.Builder().text("intentExample0").build(); - Example intentExample1 = new Example.Builder().text("intentExample1").build(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder() - .workspaceId(WORKSPACE_ID) - .intent(intent) - .addExample(intentExample0).addExample(intentExample1) - .build(); - - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.intent(), intent); - assertEquals(createOptions.examples().size(), 2); - assertEquals(createOptions.examples().get(0), intentExample0); - assertEquals(createOptions.examples().get(1), intentExample1); - - CreateIntentOptions.Builder builder = createOptions.newBuilder(); - - Example intentExample2 = new Example.Builder().text("intentExample2").build(); - builder.examples(Collections.singletonList(intentExample2)); - - CreateIntentOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.intent(), intent); - assertEquals(options2.examples().size(), 1); - assertEquals(options2.examples().get(0), intentExample2); - } - - /** - * Test UpdateIntentOptions builder. - */ - @Test - public void testUpdateIntentOptionsBuilder() { - String intent = "anIntent"; - String newIntent = "renamedIntent"; - Example intentExample0 = new Example.Builder().text("intentExample0").build(); - Example intentExample1 = new Example.Builder().text("intentExample1").build(); - - UpdateIntentOptions updateOptions = new UpdateIntentOptions.Builder() - .workspaceId(WORKSPACE_ID) - .intent(intent) - .newIntent(newIntent) - .addExample(intentExample0).addExample(intentExample1) - .build(); - - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.intent(), intent); - assertEquals(updateOptions.newIntent(), newIntent); - assertEquals(updateOptions.newExamples().size(), 2); - assertEquals(updateOptions.newExamples().get(0), intentExample0); - assertEquals(updateOptions.newExamples().get(1), intentExample1); - - UpdateIntentOptions.Builder builder = updateOptions.newBuilder(); - - Example intentExample2 = new Example.Builder().text("intentExample2").build(); - builder.newExamples(Collections.singletonList(intentExample2)); - - UpdateIntentOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.intent(), intent); - assertEquals(options2.newIntent(), newIntent); - assertEquals(options2.newExamples().size(), 1); - assertEquals(options2.newExamples().get(0), intentExample2); - } - - /** - * Test CreateEntityOptions builder. - */ - @Test - public void testCreateEntityOptionsBuilder() { - String entity = "anEntity"; - CreateValue entityValue0 = new CreateValue.Builder().value("entityValue0").addPattern("pattern0").build(); - CreateValue entityValue1 = new CreateValue.Builder().value("entityValue1").addPattern("pattern1").build(); - - CreateEntityOptions createOptions = new CreateEntityOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .addValues(entityValue0).addValues(entityValue1) - .build(); - - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.entity(), entity); - assertEquals(createOptions.values().size(), 2); - assertEquals(createOptions.values().get(0), entityValue0); - assertEquals(createOptions.values().get(1), entityValue1); - - CreateEntityOptions.Builder builder = createOptions.newBuilder(); - - CreateValue entityValue2 = new CreateValue.Builder().value("entityValue2").addPattern("pattern2").build(); - builder.values(Collections.singletonList(entityValue2)); - - CreateEntityOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.values().size(), 1); - assertEquals(options2.values().get(0), entityValue2); - } - - /** - * Test UpdateEntityOptions builder. - */ - @Test - public void testUpdateEntityOptionsBuilder() { - String entity = "anEntity"; - String newEntity = "renamedEntity"; - CreateValue entityValue0 = new CreateValue.Builder().value("entityValue0").addPattern("pattern0").build(); - CreateValue entityValue1 = new CreateValue.Builder().value("entityValue1").addPattern("pattern1").build(); - - UpdateEntityOptions updateOptions = new UpdateEntityOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .newEntity(newEntity) - .addValue(entityValue0).addValue(entityValue1) - .build(); - - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.entity(), entity); - assertEquals(updateOptions.newEntity(), newEntity); - assertEquals(updateOptions.newValues().size(), 2); - assertEquals(updateOptions.newValues().get(0), entityValue0); - assertEquals(updateOptions.newValues().get(1), entityValue1); - - UpdateEntityOptions.Builder builder = updateOptions.newBuilder(); - - CreateValue entityValue2 = new CreateValue.Builder().value("entityValue2").addPattern("pattern2").build(); - builder.newValues(Collections.singletonList(entityValue2)); - - UpdateEntityOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.newEntity(), newEntity); - assertEquals(options2.newValues().size(), 1); - assertEquals(options2.newValues().get(0), entityValue2); - } - - /** - * Test CreateValueOptions builder. - */ - @Test - public void testCreateValueOptionsBuilder() { - String entity = "anEntity"; - String value = "aValue"; - String valueSynonym0 = "valueSynonym0"; - String valueSynonym1 = "valueSynonym1"; - String valuePattern0 = "valuePattern0"; - String valuePattern1 = "valuePattern1"; - String valueType = "patterns"; - - CreateValueOptions createOptions = new CreateValueOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .value(value) - .addSynonym(valueSynonym0).addSynonym(valueSynonym1) - .addPattern(valuePattern0).addPattern(valuePattern1) - .type(valueType) - .build(); - - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.entity(), entity); - assertEquals(createOptions.value(), value); - assertEquals(createOptions.synonyms().size(), 2); - assertEquals(createOptions.synonyms().get(0), valueSynonym0); - assertEquals(createOptions.synonyms().get(1), valueSynonym1); - assertEquals(createOptions.patterns().size(), 2); - assertEquals(createOptions.patterns().get(0), valuePattern0); - assertEquals(createOptions.patterns().get(1), valuePattern1); - assertEquals(createOptions.type(), valueType); - - CreateValueOptions.Builder builder = createOptions.newBuilder(); - - String valueSynonym2 = "valueSynonym2"; - String valuePattern2 = "valuePattern2"; - builder.synonyms(Collections.singletonList(valueSynonym2)); - builder.patterns(Collections.singletonList(valuePattern2)); - - CreateValueOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.value(), value); - assertEquals(options2.synonyms().size(), 1); - assertEquals(options2.synonyms().get(0), valueSynonym2); - assertEquals(options2.patterns().size(), 1); - assertEquals(options2.patterns().get(0), valuePattern2); - } - - /** - * Test UpdateValueOptions builder. - */ - @Test - public void testUpdateValueOptionsBuilder() { - String entity = "anEntity"; - String value = "aValue"; - String newValue = "renamedValue"; - String valueSynonym0 = "valueSynonym0"; - String valueSynonym1 = "valueSynonym1"; - - UpdateValueOptions updateOptions = new UpdateValueOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .value(value) - .newValue(newValue) - .addSynonym(valueSynonym0).addSynonym(valueSynonym1) - .build(); - - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.entity(), entity); - assertEquals(updateOptions.newValue(), newValue); - assertEquals(updateOptions.newSynonyms().size(), 2); - assertEquals(updateOptions.newSynonyms().get(0), valueSynonym0); - assertEquals(updateOptions.newSynonyms().get(1), valueSynonym1); - - UpdateValueOptions.Builder builder = updateOptions.newBuilder(); - - String valueSynonym2 = "valueSynonym2"; - builder.newSynonyms(Collections.singletonList(valueSynonym2)); - - UpdateValueOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.newValue(), newValue); - assertEquals(options2.newSynonyms().size(), 1); - assertEquals(options2.newSynonyms().get(0), valueSynonym2); - } - - /** - * Test CreateDialogNodeOptions builder. - */ - @Test - public void testCreateDialogNodeOptionsBuilder() { - String dialogNodeName = "aDialogNode"; - DialogNodeAction action0 = new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) - .build(); - DialogNodeAction action1 = new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) - .build(); - String userLabel = "user_label"; - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder() - .workspaceId(WORKSPACE_ID) - .dialogNode(dialogNodeName) - .addActions(action0).addActions(action1) - .digressIn(CreateDialogNodeOptions.DigressIn.RETURNS) - .digressOut(CreateDialogNodeOptions.DigressOut.ALLOW_ALL) - .digressOutSlots(CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL) - .userLabel(userLabel) - .disambiguationOptOut(true) - .build(); - - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.dialogNode(), dialogNodeName); - assertEquals(createOptions.actions().size(), 2); - assertEquals(createOptions.actions().get(0), action0); - assertEquals(createOptions.actions().get(0).credentials(), CREDENTIALS); - assertEquals(createOptions.actions().get(1), action1); - assertEquals(createOptions.actions().get(1).credentials(), CREDENTIALS); - assertEquals(createOptions.digressIn(), CreateDialogNodeOptions.DigressIn.RETURNS); - assertEquals(createOptions.digressOut(), CreateDialogNodeOptions.DigressOut.ALLOW_ALL); - assertEquals(createOptions.digressOutSlots(), CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL); - assertEquals(createOptions.userLabel(), userLabel); - assertTrue(createOptions.disambiguationOptOut()); - } - - /** - * Test UpdateDialogNodeOptions builder. - */ - @Test - public void testUpdateDialogNodeOptionsBuilder() { - String dialogNodeName = "aDialogNode"; - String newDialogNodeName = "renamedDialogNode"; - DialogNodeAction action0 = new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) - .build(); - DialogNodeAction action1 = new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) - .build(); - String userLabel = "user_label"; - - UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder() - .workspaceId(WORKSPACE_ID) - .dialogNode(dialogNodeName) - .newDialogNode(newDialogNodeName) - .addNewActions(action0).addNewActions(action1) - .newDigressIn(UpdateDialogNodeOptions.NewDigressIn.RETURNS) - .newDigressOut(UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL) - .newDigressOutSlots(UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL) - .newUserLabel(userLabel) - .newDisambiguationOptOut(true) - .build(); - - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.dialogNode(), dialogNodeName); - assertEquals(updateOptions.newActions().size(), 2); - assertEquals(updateOptions.newActions().get(0), action0); - assertEquals(updateOptions.newActions().get(0).credentials(), CREDENTIALS); - assertEquals(updateOptions.newActions().get(1), action1); - assertEquals(updateOptions.newActions().get(1).credentials(), CREDENTIALS); - assertEquals(updateOptions.newDigressIn(), UpdateDialogNodeOptions.NewDigressIn.RETURNS); - assertEquals(updateOptions.newDigressOut(), UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL); - assertEquals(updateOptions.newDigressOutSlots(), UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL); - assertEquals(updateOptions.newUserLabel(), userLabel); - assertTrue(updateOptions.newDisambiguationOptOut()); - } - - /** - * Test ListAllLogsOptions builder. - */ - @Test - public void testListAllLogsOptionsBuilder() { - String sort = "sort"; - String filter = "filter"; - Long pageLimit = 5L; - String cursor = "cursor"; - - ListAllLogsOptions listOptions = new ListAllLogsOptions.Builder() - .sort(sort) - .filter(filter) - .pageLimit(pageLimit) - .cursor(cursor) - .build(); - - assertEquals(listOptions.sort(), sort); - assertEquals(listOptions.filter(), filter); - assertEquals(listOptions.pageLimit(), pageLimit); - assertEquals(listOptions.cursor(), cursor); - } - - /** - * Test DeleteUserDataOptions builder. - */ - @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "customer_id"; - - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); - - assertEquals(deleteOptions.customerId(), customerId); - } - - @Test - public void testListMentionsBuilder() { - String entity = "entity"; - - ListMentionsOptions listMentionsOptions = new ListMentionsOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .export(true) - .includeAudit(true) - .build(); - - assertEquals(listMentionsOptions.workspaceId(), WORKSPACE_ID); - assertEquals(listMentionsOptions.entity(), entity); - assertEquals(listMentionsOptions.export(), true); - assertEquals(listMentionsOptions.includeAudit(), true); - } - - @Test - public void testMessageContextMetadata() { - String deployment = "deployment"; - String userId = "user_id"; - - MessageContextMetadata messageContextMetadata = new MessageContextMetadata.Builder() - .deployment(deployment) - .userId(userId) - .build(); - - assertEquals(deployment, messageContextMetadata.deployment()); - assertEquals(userId, messageContextMetadata.userId()); - } - - @Test - public void testCreateEntityBuilder() { - String entity = "entity"; - String description = "Entity description"; - Map metadata = new HashMap<>(); - String metadataKey = "metadata_key"; - String metadataValue = "metadata_value"; - metadata.put(metadataKey, metadataValue); - Date testDate = new Date(); - String value = "value"; - CreateValue createValue = new CreateValue.Builder(value).build(); - CreateValue secondValue = new CreateValue.Builder().value(value).build(); - List values = new ArrayList<>(); - values.add(createValue); - - CreateEntity createEntity = new CreateEntity.Builder() - .entity(entity) - .description(description) - .metadata(metadata) - .values(values) - .addValues(secondValue) - .fuzzyMatch(true) - .created(testDate) - .updated(testDate) - .build(); - createEntity = createEntity.newBuilder().build(); - - assertEquals(entity, createEntity.entity()); - assertEquals(description, createEntity.description()); - assertTrue(createEntity.metadata().containsKey(metadataKey)); - assertEquals(metadataValue, createEntity.metadata().get(metadataKey)); - assertNotNull(createEntity.values()); - assertEquals(2, createEntity.values().size()); - assertTrue(createEntity.fuzzyMatch()); - assertEquals(testDate, createEntity.created()); - assertEquals(testDate, createEntity.updated()); - } - - @Test - public void testCreateIntentBuilder() { - String intent = "intent"; - String description = "Intent description"; - Date testDate = new Date(); - String text = "text"; - Example example = new Example.Builder(text).build(); - Example secondExample = new Example.Builder().text(text).build(); - List examples = new ArrayList<>(); - examples.add(example); - - CreateIntent createIntent = new CreateIntent.Builder() - .intent(intent) - .description(description) - .examples(examples) - .addExample(secondExample) - .created(testDate) - .updated(testDate) - .build(); - createIntent = createIntent.newBuilder().build(); - - assertEquals(intent, createIntent.intent()); - assertEquals(description, createIntent.description()); - assertNotNull(createIntent.examples()); - assertEquals(2, createIntent.examples().size()); - assertEquals(testDate, createIntent.created()); - assertEquals(testDate, createIntent.updated()); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCounterexamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateCounterexample operation with and without retries enabled + @Test + public void testUpdateCounterexampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateCounterexampleWOptions(); + + assistantService.disableRetries(); + testUpdateCounterexampleWOptions(); + } + + // Test the updateCounterexample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCounterexampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateCounterexample(null).execute(); + } + + // Test the deleteCounterexample operation with a valid options model parameter + @Test + public void testDeleteCounterexampleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteCounterexamplePath = "/v1/workspaces/testString/counterexamples/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteCounterexampleOptions model + DeleteCounterexampleOptions deleteCounterexampleOptionsModel = + new DeleteCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .build(); + + // Invoke deleteCounterexample() with a valid options model and verify the result + Response response = + assistantService.deleteCounterexample(deleteCounterexampleOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCounterexamplePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteCounterexample operation with and without retries enabled + @Test + public void testDeleteCounterexampleWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteCounterexampleWOptions(); + + assistantService.disableRetries(); + testDeleteCounterexampleWOptions(); + } + + // Test the deleteCounterexample operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCounterexampleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteCounterexample(null).execute(); + } + + // Test the listEntities operation with a valid options model parameter + @Test + public void testListEntitiesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listEntitiesPath = "/v1/workspaces/testString/entities"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListEntitiesOptions model + ListEntitiesOptions listEntitiesOptionsModel = + new ListEntitiesOptions.Builder() + .workspaceId("testString") + .export(false) + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("entity") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listEntities() with a valid options model and verify the result + Response response = + assistantService.listEntities(listEntitiesOptionsModel).execute(); + assertNotNull(response); + EntityCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listEntitiesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "entity"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listEntities operation with and without retries enabled + @Test + public void testListEntitiesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListEntitiesWOptions(); + + assistantService.disableRetries(); + testListEntitiesWOptions(); + } + + // Test the listEntities operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEntitiesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listEntities(null).execute(); + } + + // Test the createEntity operation with a valid options model parameter + @Test + public void testCreateEntityWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String createEntityPath = "/v1/workspaces/testString/entities"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateEntityOptions model + CreateEntityOptions createEntityOptionsModel = + new CreateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .includeAudit(false) + .build(); + + // Invoke createEntity() with a valid options model and verify the result + Response response = assistantService.createEntity(createEntityOptionsModel).execute(); + assertNotNull(response); + Entity responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createEntityPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createEntity operation with and without retries enabled + @Test + public void testCreateEntityWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateEntityWOptions(); + + assistantService.disableRetries(); + testCreateEntityWOptions(); + } + + // Test the createEntity operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEntityNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createEntity(null).execute(); + } + + // Test the getEntity operation with a valid options model parameter + @Test + public void testGetEntityWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String getEntityPath = "/v1/workspaces/testString/entities/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetEntityOptions model + GetEntityOptions getEntityOptionsModel = + new GetEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(false) + .includeAudit(false) + .build(); + + // Invoke getEntity() with a valid options model and verify the result + Response response = assistantService.getEntity(getEntityOptionsModel).execute(); + assertNotNull(response); + Entity responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getEntityPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getEntity operation with and without retries enabled + @Test + public void testGetEntityWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetEntityWOptions(); + + assistantService.disableRetries(); + testGetEntityWOptions(); + } + + // Test the getEntity operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEntityNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getEntity(null).execute(); + } + + // Test the updateEntity operation with a valid options model parameter + @Test + public void testUpdateEntityWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String updateEntityPath = "/v1/workspaces/testString/entities/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the UpdateEntityOptions model + UpdateEntityOptions updateEntityOptionsModel = + new UpdateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .newEntity("testString") + .newDescription("testString") + .newMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .newFuzzyMatch(true) + .newValues(java.util.Arrays.asList(createValueModel)) + .append(false) + .includeAudit(false) + .build(); + + // Invoke updateEntity() with a valid options model and verify the result + Response response = assistantService.updateEntity(updateEntityOptionsModel).execute(); + assertNotNull(response); + Entity responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateEntityPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateEntity operation with and without retries enabled + @Test + public void testUpdateEntityWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateEntityWOptions(); + + assistantService.disableRetries(); + testUpdateEntityWOptions(); + } + + // Test the updateEntity operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEntityNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateEntity(null).execute(); + } + + // Test the deleteEntity operation with a valid options model parameter + @Test + public void testDeleteEntityWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteEntityPath = "/v1/workspaces/testString/entities/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteEntityOptions model + DeleteEntityOptions deleteEntityOptionsModel = + new DeleteEntityOptions.Builder().workspaceId("testString").entity("testString").build(); + + // Invoke deleteEntity() with a valid options model and verify the result + Response response = assistantService.deleteEntity(deleteEntityOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteEntityPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteEntity operation with and without retries enabled + @Test + public void testDeleteEntityWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteEntityWOptions(); + + assistantService.disableRetries(); + testDeleteEntityWOptions(); + } + + // Test the deleteEntity operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEntityNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteEntity(null).execute(); + } + + // Test the listMentions operation with a valid options model parameter + @Test + public void testListMentionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"examples\": [{\"text\": \"text\", \"intent\": \"intent\", \"location\": [8]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listMentionsPath = "/v1/workspaces/testString/entities/testString/mentions"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListMentionsOptions model + ListMentionsOptions listMentionsOptionsModel = + new ListMentionsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(false) + .includeAudit(false) + .build(); + + // Invoke listMentions() with a valid options model and verify the result + Response response = + assistantService.listMentions(listMentionsOptionsModel).execute(); + assertNotNull(response); + EntityMentionCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listMentionsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listMentions operation with and without retries enabled + @Test + public void testListMentionsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListMentionsWOptions(); + + assistantService.disableRetries(); + testListMentionsWOptions(); + } + + // Test the listMentions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListMentionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listMentions(null).execute(); + } + + // Test the listValues operation with a valid options model parameter + @Test + public void testListValuesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"values\": [{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listValuesPath = "/v1/workspaces/testString/entities/testString/values"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListValuesOptions model + ListValuesOptions listValuesOptionsModel = + new ListValuesOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(false) + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("value") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listValues() with a valid options model and verify the result + Response response = + assistantService.listValues(listValuesOptionsModel).execute(); + assertNotNull(response); + ValueCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listValuesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "value"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listValues operation with and without retries enabled + @Test + public void testListValuesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListValuesWOptions(); + + assistantService.disableRetries(); + testListValuesWOptions(); + } + + // Test the listValues operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListValuesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listValues(null).execute(); + } + + // Test the createValue operation with a valid options model parameter + @Test + public void testCreateValueWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createValuePath = "/v1/workspaces/testString/entities/testString/values"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateValueOptions model + CreateValueOptions createValueOptionsModel = + new CreateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .includeAudit(false) + .build(); + + // Invoke createValue() with a valid options model and verify the result + Response response = assistantService.createValue(createValueOptionsModel).execute(); + assertNotNull(response); + Value responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createValuePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createValue operation with and without retries enabled + @Test + public void testCreateValueWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateValueWOptions(); + + assistantService.disableRetries(); + testCreateValueWOptions(); + } + + // Test the createValue operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateValueNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createValue(null).execute(); + } + + // Test the getValue operation with a valid options model parameter + @Test + public void testGetValueWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getValuePath = "/v1/workspaces/testString/entities/testString/values/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetValueOptions model + GetValueOptions getValueOptionsModel = + new GetValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .export(false) + .includeAudit(false) + .build(); + + // Invoke getValue() with a valid options model and verify the result + Response response = assistantService.getValue(getValueOptionsModel).execute(); + assertNotNull(response); + Value responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getValuePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getValue operation with and without retries enabled + @Test + public void testGetValueWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetValueWOptions(); + + assistantService.disableRetries(); + testGetValueWOptions(); + } + + // Test the getValue operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetValueNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getValue(null).execute(); + } + + // Test the updateValue operation with a valid options model parameter + @Test + public void testUpdateValueWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"value\": \"value\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String updateValuePath = "/v1/workspaces/testString/entities/testString/values/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateValueOptions model + UpdateValueOptions updateValueOptionsModel = + new UpdateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .newValue("testString") + .newMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .newType("synonyms") + .newSynonyms(java.util.Arrays.asList("testString")) + .newPatterns(java.util.Arrays.asList("testString")) + .append(false) + .includeAudit(false) + .build(); + + // Invoke updateValue() with a valid options model and verify the result + Response response = assistantService.updateValue(updateValueOptionsModel).execute(); + assertNotNull(response); + Value responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateValuePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateValue operation with and without retries enabled + @Test + public void testUpdateValueWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateValueWOptions(); + + assistantService.disableRetries(); + testUpdateValueWOptions(); + } + + // Test the updateValue operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateValueNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateValue(null).execute(); + } + + // Test the deleteValue operation with a valid options model parameter + @Test + public void testDeleteValueWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteValuePath = "/v1/workspaces/testString/entities/testString/values/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteValueOptions model + DeleteValueOptions deleteValueOptionsModel = + new DeleteValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .build(); + + // Invoke deleteValue() with a valid options model and verify the result + Response response = assistantService.deleteValue(deleteValueOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteValuePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteValue operation with and without retries enabled + @Test + public void testDeleteValueWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteValueWOptions(); + + assistantService.disableRetries(); + testDeleteValueWOptions(); + } + + // Test the deleteValue operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteValueNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteValue(null).execute(); + } + + // Test the listSynonyms operation with a valid options model parameter + @Test + public void testListSynonymsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"synonyms\": [{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listSynonymsPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListSynonymsOptions model + ListSynonymsOptions listSynonymsOptionsModel = + new ListSynonymsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("synonym") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listSynonyms() with a valid options model and verify the result + Response response = + assistantService.listSynonyms(listSynonymsOptionsModel).execute(); + assertNotNull(response); + SynonymCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listSynonymsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "synonym"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listSynonyms operation with and without retries enabled + @Test + public void testListSynonymsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListSynonymsWOptions(); + + assistantService.disableRetries(); + testListSynonymsWOptions(); + } + + // Test the listSynonyms operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListSynonymsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listSynonyms(null).execute(); + } + + // Test the createSynonym operation with a valid options model parameter + @Test + public void testCreateSynonymWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateSynonymOptions model + CreateSynonymOptions createSynonymOptionsModel = + new CreateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(false) + .build(); + + // Invoke createSynonym() with a valid options model and verify the result + Response response = + assistantService.createSynonym(createSynonymOptionsModel).execute(); + assertNotNull(response); + Synonym responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createSynonymPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createSynonym operation with and without retries enabled + @Test + public void testCreateSynonymWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateSynonymWOptions(); + + assistantService.disableRetries(); + testCreateSynonymWOptions(); + } + + // Test the createSynonym operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSynonymNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createSynonym(null).execute(); + } + + // Test the getSynonym operation with a valid options model parameter + @Test + public void testGetSynonymWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetSynonymOptions model + GetSynonymOptions getSynonymOptionsModel = + new GetSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(false) + .build(); + + // Invoke getSynonym() with a valid options model and verify the result + Response response = assistantService.getSynonym(getSynonymOptionsModel).execute(); + assertNotNull(response); + Synonym responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getSynonymPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getSynonym operation with and without retries enabled + @Test + public void testGetSynonymWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetSynonymWOptions(); + + assistantService.disableRetries(); + testGetSynonymWOptions(); + } + + // Test the getSynonym operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSynonymNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getSynonym(null).execute(); + } + + // Test the updateSynonym operation with a valid options model parameter + @Test + public void testUpdateSynonymWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String updateSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateSynonymOptions model + UpdateSynonymOptions updateSynonymOptionsModel = + new UpdateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .newSynonym("testString") + .includeAudit(false) + .build(); + + // Invoke updateSynonym() with a valid options model and verify the result + Response response = + assistantService.updateSynonym(updateSynonymOptionsModel).execute(); + assertNotNull(response); + Synonym responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateSynonymPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateSynonym operation with and without retries enabled + @Test + public void testUpdateSynonymWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateSynonymWOptions(); + + assistantService.disableRetries(); + testUpdateSynonymWOptions(); + } + + // Test the updateSynonym operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSynonymNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateSynonym(null).execute(); + } + + // Test the deleteSynonym operation with a valid options model parameter + @Test + public void testDeleteSynonymWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteSynonymOptions model + DeleteSynonymOptions deleteSynonymOptionsModel = + new DeleteSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .build(); + + // Invoke deleteSynonym() with a valid options model and verify the result + Response response = assistantService.deleteSynonym(deleteSynonymOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteSynonymPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteSynonym operation with and without retries enabled + @Test + public void testDeleteSynonymWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteSynonymWOptions(); + + assistantService.disableRetries(); + testDeleteSynonymWOptions(); + } + + // Test the deleteSynonym operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSynonymNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteSynonym(null).execute(); + } + + // Test the listDialogNodes operation with a valid options model parameter + @Test + public void testListDialogNodesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listDialogNodesPath = "/v1/workspaces/testString/dialog_nodes"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListDialogNodesOptions model + ListDialogNodesOptions listDialogNodesOptionsModel = + new ListDialogNodesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("dialog_node") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listDialogNodes() with a valid options model and verify the result + Response response = + assistantService.listDialogNodes(listDialogNodesOptionsModel).execute(); + assertNotNull(response); + DialogNodeCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDialogNodesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "dialog_node"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listDialogNodes operation with and without retries enabled + @Test + public void testListDialogNodesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListDialogNodesWOptions(); + + assistantService.disableRetries(); + testListDialogNodesWOptions(); + } + + // Test the listDialogNodes operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDialogNodesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listDialogNodes(null).execute(); + } + + // Test the createDialogNode operation with a valid options model parameter + @Test + public void testCreateDialogNodeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createDialogNodePath = "/v1/workspaces/testString/dialog_nodes"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the DialogNodeOutputTextValuesElement model + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the CreateDialogNodeOptions model + CreateDialogNodeOptions createDialogNodeOptionsModel = + new CreateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .includeAudit(false) + .build(); + + // Invoke createDialogNode() with a valid options model and verify the result + Response response = + assistantService.createDialogNode(createDialogNodeOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createDialogNodePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createDialogNode operation with and without retries enabled + @Test + public void testCreateDialogNodeWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateDialogNodeWOptions(); + + assistantService.disableRetries(); + testCreateDialogNodeWOptions(); + } + + // Test the createDialogNode operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDialogNodeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createDialogNode(null).execute(); + } + + // Test the getDialogNode operation with a valid options model parameter + @Test + public void testGetDialogNodeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetDialogNodeOptions model + GetDialogNodeOptions getDialogNodeOptionsModel = + new GetDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .includeAudit(false) + .build(); + + // Invoke getDialogNode() with a valid options model and verify the result + Response response = + assistantService.getDialogNode(getDialogNodeOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDialogNodePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getDialogNode operation with and without retries enabled + @Test + public void testGetDialogNodeWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetDialogNodeWOptions(); + + assistantService.disableRetries(); + testGetDialogNodeWOptions(); + } + + // Test the getDialogNode operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDialogNodeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getDialogNode(null).execute(); + } + + // Test the updateDialogNode operation with a valid options model parameter + @Test + public void testUpdateDialogNodeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"text\", \"values\": [{\"text\": \"text\"}], \"selection_policy\": \"sequential\", \"delimiter\": \"\n\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"anyKey\": \"anyValue\"}}}, \"metadata\": {\"anyKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String updateDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DialogNodeOutputTextValuesElement model + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + + // Construct an instance of the ResponseGenericChannel model + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the UpdateDialogNodeOptions model + UpdateDialogNodeOptions updateDialogNodeOptionsModel = + new UpdateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .newDialogNode("testString") + .newDescription("testString") + .newConditions("testString") + .newParent("testString") + .newPreviousSibling("testString") + .newOutput(dialogNodeOutputModel) + .newContext(dialogNodeContextModel) + .newMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .newNextStep(dialogNodeNextStepModel) + .newTitle("testString") + .newType("standard") + .newEventName("focus") + .newVariable("testString") + .newActions(java.util.Arrays.asList(dialogNodeActionModel)) + .newDigressIn("not_available") + .newDigressOut("allow_returning") + .newDigressOutSlots("not_allowed") + .newUserLabel("testString") + .newDisambiguationOptOut(false) + .includeAudit(false) + .build(); + + // Invoke updateDialogNode() with a valid options model and verify the result + Response response = + assistantService.updateDialogNode(updateDialogNodeOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDialogNodePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the updateDialogNode operation with and without retries enabled + @Test + public void testUpdateDialogNodeWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateDialogNodeWOptions(); + + assistantService.disableRetries(); + testUpdateDialogNodeWOptions(); + } + + // Test the updateDialogNode operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateDialogNode(null).execute(); + } + + // Test the deleteDialogNode operation with a valid options model parameter + @Test + public void testDeleteDialogNodeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteDialogNodeOptions model + DeleteDialogNodeOptions deleteDialogNodeOptionsModel = + new DeleteDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .build(); + + // Invoke deleteDialogNode() with a valid options model and verify the result + Response response = + assistantService.deleteDialogNode(deleteDialogNodeOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDialogNodePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteDialogNode operation with and without retries enabled + @Test + public void testDeleteDialogNodeWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteDialogNodeWOptions(); + + assistantService.disableRetries(); + testDeleteDialogNodeWOptions(); + } + + // Test the deleteDialogNode operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDialogNodeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteDialogNode(null).execute(); + } + + // Test the listLogs operation with a valid options model parameter + @Test + public void testListLogsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"logs\": [{\"request\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": false, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"anyKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"chat\"}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"user_id\": \"userId\"}, \"response\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": false, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"anyKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"chat\"}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"user_id\": \"userId\"}, \"log_id\": \"logId\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"workspace_id\": \"workspaceId\", \"language\": \"language\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + String listLogsPath = "/v1/workspaces/testString/logs"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListLogsOptions model + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .workspaceId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .build(); + + // Invoke listLogs() with a valid options model and verify the result + Response response = assistantService.listLogs(listLogsOptionsModel).execute(); + assertNotNull(response); + LogCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLogsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(query.get("cursor"), "testString"); + } + + // Test the listLogs operation with and without retries enabled + @Test + public void testListLogsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListLogsWOptions(); + + assistantService.disableRetries(); + testListLogsWOptions(); + } + + // Test the listLogs operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listLogs(null).execute(); + } + + // Test the listAllLogs operation with a valid options model parameter + @Test + public void testListAllLogsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"logs\": [{\"request\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": false, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"anyKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"chat\"}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"user_id\": \"userId\"}, \"response\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": false, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"anyKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"chat\"}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"user_id\": \"userId\"}, \"log_id\": \"logId\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"workspace_id\": \"workspaceId\", \"language\": \"language\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + String listAllLogsPath = "/v1/logs"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListAllLogsOptions model + ListAllLogsOptions listAllLogsOptionsModel = + new ListAllLogsOptions.Builder() + .filter("testString") + .sort("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .build(); + + // Invoke listAllLogs() with a valid options model and verify the result + Response response = + assistantService.listAllLogs(listAllLogsOptionsModel).execute(); + assertNotNull(response); + LogCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAllLogsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(query.get("cursor"), "testString"); + } + + // Test the listAllLogs operation with and without retries enabled + @Test + public void testListAllLogsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListAllLogsWOptions(); + + assistantService.disableRetries(); + testListAllLogsWOptions(); + } + + // Test the listAllLogs operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAllLogsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listAllLogs(null).execute(); + } + + // Test the deleteUserData operation with a valid options model parameter + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + server.enqueue(new MockResponse().setResponseCode(202).setBody(mockResponseBody)); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke deleteUserData() with a valid options model and verify the result + Response response = assistantService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + } + + // Test the deleteUserData operation with and without retries enabled + @Test + public void testDeleteUserDataWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteUserDataWOptions(); + + assistantService.disableRetries(); + testDeleteUserDataWOptions(); + } + + // Test the deleteUserData operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteUserData(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + assistantService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + assistantService = new Assistant(version, serviceName, authenticator); + String url = server.url("/").toString(); + assistantService.setServiceUrl(url); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/EntitiesIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/EntitiesIT.java index 7dc6089bb69..1bd5b5a0463 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/EntitiesIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/EntitiesIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -12,6 +12,12 @@ */ package com.ibm.watson.assistant.v1; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.service.exception.NotFoundException; import com.ibm.watson.assistant.v1.model.CreateEntityOptions; import com.ibm.watson.assistant.v1.model.CreateValue; @@ -23,30 +29,29 @@ import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; import com.ibm.watson.assistant.v1.model.Value; import com.ibm.watson.common.RetryRunner; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - +/** The Class EntitiesIT. */ @RunWith(RetryRunner.class) public class EntitiesIT extends AssistantServiceTest { private Assistant service; private String workspaceId; + /** + * Sets up the tests. + * + * @throws Exception the exception + */ @Override @Before public void setUp() throws Exception { @@ -55,9 +60,7 @@ public void setUp() throws Exception { this.workspaceId = getWorkspaceId(); } - /** - * Test createEntity. - */ + /** Test createEntity. */ @Test public void testCreateEntity() { @@ -92,14 +95,13 @@ public void testCreateEntity() { fail(ex.getMessage()); } finally { // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); service.deleteEntity(deleteOptions).execute().getResult(); } } - /** - * Test deleteEntity. - */ + /** Test deleteEntity. */ @Test public void testDeleteEntity() { @@ -116,12 +118,14 @@ public void testDeleteEntity() { assertNull(response.getMetadata()); assertTrue(response.isFuzzyMatch() == null || response.isFuzzyMatch().equals(Boolean.FALSE)); } catch (Exception ex) { - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); service.deleteEntity(deleteOptions).execute().getResult(); fail(ex.getMessage()); } - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); service.deleteEntity(deleteOptions).execute().getResult(); try { @@ -134,9 +138,7 @@ public void testDeleteEntity() { } } - /** - * Test getEntity. - */ + /** Test getEntity. */ @Test public void testGetEntity() { @@ -156,10 +158,8 @@ public void testGetEntity() { Date start = new Date(); try { - GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity) - .export(true) - .includeAudit(true) - .build(); + GetEntityOptions getOptions = + new GetEntityOptions.Builder(workspaceId, entity).export(true).includeAudit(true).build(); Entity response = service.getEntity(getOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getEntity()); @@ -188,14 +188,13 @@ public void testGetEntity() { fail(ex.getMessage()); } finally { // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); service.deleteEntity(deleteOptions).execute().getResult(); } } - /** - * Test listEntities. - */ + /** Test listEntities. */ @Test @Ignore("To be run locally until we fix the Rate limitation issue") public void testListEntities() { @@ -214,14 +213,15 @@ public void testListEntities() { // Now add an entity and make sure we get it back String entityDescription = "Description of " + entity; String entityValue = "Value of " + entity; - CreateEntityOptions options = new CreateEntityOptions.Builder(workspaceId, entity) - .description(entityDescription) - .addValues(new CreateValue.Builder(entityValue).build()) - .build(); + CreateEntityOptions options = + new CreateEntityOptions.Builder(workspaceId, entity) + .description(entityDescription) + .addValues(new CreateValue.Builder(entityValue).build()) + .build(); service.createEntity(options).execute().getResult(); - ListEntitiesOptions listOptions2 = listOptions.newBuilder() - .sort("-updated").pageLimit(5L).export(true).build(); + ListEntitiesOptions listOptions2 = + listOptions.newBuilder().sort("-updated").pageLimit(5L).export(true).build(); EntityCollection response2 = service.listEntities(listOptions2).execute().getResult(); assertNotNull(response2); assertNotNull(response2.getEntities()); @@ -245,14 +245,13 @@ public void testListEntities() { fail(ex.getMessage()); } finally { // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); service.deleteEntity(deleteOptions).execute().getResult(); } } - /** - * Test listEntities with pagination. - */ + /** Test listEntities with pagination. */ @Test @Ignore("To be run locally until we fix the Rate limitation issue") public void testListEntitiesWithPaging() { @@ -260,15 +259,14 @@ public void testListEntitiesWithPaging() { String entity1 = "Hello" + UUID.randomUUID().toString(); // gotta be unique String entity2 = "Goodbye" + UUID.randomUUID().toString(); // gotta be unique - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity1).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity1).build(); service.createEntity(createOptions).execute().getResult(); service.createEntity(createOptions.newBuilder().entity(entity2).build()).execute().getResult(); try { - ListEntitiesOptions listOptions = new ListEntitiesOptions.Builder(workspaceId) - .sort("entity") - .pageLimit(1L) - .build(); + ListEntitiesOptions listOptions = + new ListEntitiesOptions.Builder(workspaceId).sort("entity").pageLimit(1L).build(); EntityCollection response = service.listEntities(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getEntities()); @@ -287,7 +285,11 @@ public void testListEntitiesWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listEntities(listOptions.newBuilder().cursor(cursor).build()).execute().getResult(); + response = + service + .listEntities(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); } assertNotNull(ieResponse); @@ -295,15 +297,17 @@ public void testListEntitiesWithPaging() { fail(ex.getMessage()); } finally { // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity1).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity1).build(); service.deleteEntity(deleteOptions).execute().getResult(); - service.deleteEntity(deleteOptions.newBuilder().entity(entity2).build()).execute().getResult(); + service + .deleteEntity(deleteOptions.newBuilder().entity(entity2).build()) + .execute() + .getResult(); } } - /** - * Test updateEntity. - */ + /** Test updateEntity. */ @Test public void testUpdateEntity() { @@ -324,7 +328,8 @@ public void testUpdateEntity() { String metadataValue2 = "value for " + entity2; entityMetadata2.put("key", metadataValue2); - UpdateEntityOptions.Builder updateOptionsBuilder = new UpdateEntityOptions.Builder(workspaceId, entity); + UpdateEntityOptions.Builder updateOptionsBuilder = + new UpdateEntityOptions.Builder(workspaceId, entity); updateOptionsBuilder.newEntity(entity2); updateOptionsBuilder.newDescription(entityDescription2); updateOptionsBuilder.addValue(new CreateValue.Builder().value(entityValue2).build()); @@ -348,7 +353,8 @@ public void testUpdateEntity() { fail(ex.getMessage()); } finally { // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity2).build(); + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity2).build(); service.deleteEntity(deleteOptions).execute().getResult(); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/SynonymsIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/SynonymsIT.java index 92ba1a3d337..5de2b4487dc 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/SynonymsIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/SynonymsIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2019. + * (C) Copyright IBM Corp. 2018, 2020. * * 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 @@ -12,6 +12,12 @@ */ package com.ibm.watson.assistant.v1; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.service.exception.NotFoundException; import com.ibm.watson.assistant.v1.model.CreateEntityOptions; import com.ibm.watson.assistant.v1.model.CreateSynonymOptions; @@ -23,24 +29,23 @@ import com.ibm.watson.assistant.v1.model.SynonymCollection; import com.ibm.watson.assistant.v1.model.UpdateSynonymOptions; import com.ibm.watson.common.RetryRunner; +import java.util.Date; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.Date; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - +/** The Class SynonymsIT. */ @RunWith(RetryRunner.class) public class SynonymsIT extends AssistantServiceTest { private Assistant service; private String workspaceId; + /** + * Sets up the tests. + * + * @throws Exception the exception + */ @Override @Before public void setUp() throws Exception { @@ -49,9 +54,7 @@ public void setUp() throws Exception { this.workspaceId = getWorkspaceId(); } - /** - * Test createSynonym. - */ + /** Test createSynonym. */ @Test public void testCreateSynonym() { @@ -60,7 +63,8 @@ public void testCreateSynonym() { String synonym = "OJ"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -68,19 +72,21 @@ public void testCreateSynonym() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .synonym(synonym) - .build(); + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue) + .synonym(synonym) + .build(); Synonym response = service.createSynonym(createOptions).execute().getResult(); try { @@ -91,15 +97,13 @@ public void testCreateSynonym() { fail(ex.getMessage()); } finally { // Clean up - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); service.deleteSynonym(deleteOptions).execute().getResult(); } } - /** - * Test deleteSynonym. - */ + /** Test deleteSynonym. */ @Test public void testDeleteSynonym() { @@ -108,7 +112,8 @@ public void testDeleteSynonym() { String synonym = "OJ"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -116,15 +121,16 @@ public void testDeleteSynonym() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); Synonym response = service.createSynonym(createOptions).execute().getResult(); try { @@ -132,22 +138,24 @@ public void testDeleteSynonym() { assertNotNull(response.synonym()); assertEquals(response.synonym(), synonym); } catch (Exception ex) { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); service.deleteSynonym(deleteOptions).execute().getResult(); fail(ex.getMessage()); } - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .synonym(synonym) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue) + .synonym(synonym) + .build(); service.deleteSynonym(deleteOptions).execute().getResult(); try { - GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); + GetSynonymOptions getOptions = + new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); service.getSynonym(getOptions).execute().getResult(); fail("deleteSynonym failed"); } catch (Exception ex) { @@ -156,9 +164,7 @@ public void testDeleteSynonym() { } } - /** - * Test getSynonym. - */ + /** Test getSynonym. */ @Test public void testGetSynonym() { @@ -167,7 +173,8 @@ public void testGetSynonym() { String synonym = "OJ"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -175,7 +182,8 @@ public void testGetSynonym() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -184,14 +192,15 @@ public void testGetSynonym() { Date start = new Date(); - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); service.createSynonym(createOptions).execute().getResult(); try { - GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .includeAudit(true) - .build(); + GetSynonymOptions getOptions = + new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) + .includeAudit(true) + .build(); Synonym response = service.getSynonym(getOptions).execute().getResult(); assertNotNull(response); @@ -208,15 +217,13 @@ public void testGetSynonym() { } catch (Exception ex) { fail(ex.getMessage()); } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); service.deleteSynonym(deleteOptions).execute().getResult(); } } - /** - * Test listSynonyms. - */ + /** Test listSynonyms. */ @Test public void testListSynonyms() { @@ -226,7 +233,8 @@ public void testListSynonyms() { String synonym2 = "joe"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -234,7 +242,8 @@ public void testListSynonyms() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -242,21 +251,25 @@ public void testListSynonyms() { } try { - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); service.createSynonym(createOptions).execute().getResult(); - service.createSynonym(createOptions.newBuilder().synonym(synonym2).build()).execute().getResult(); + service + .createSynonym(createOptions.newBuilder().synonym(synonym2).build()) + .execute() + .getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } try { - ListSynonymsOptions listOptions = new ListSynonymsOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .build(); + ListSynonymsOptions listOptions = + new ListSynonymsOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue) + .build(); final SynonymCollection response = service.listSynonyms(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getSynonyms()); @@ -273,7 +286,8 @@ public void testListSynonyms() { // Should not be paginated, but just to be sure if (response.getPagination().getNextUrl() == null) { - //assertTrue(response.getSynonyms().stream().filter(r -> r.getSynonym().equals(synonym1)).count() == 1); + // assertTrue(response.getSynonyms().stream().filter(r -> + // r.getSynonym().equals(synonym1)).count() == 1); boolean found1 = false; boolean found2 = false; for (Synonym synonymResponse : response.getSynonyms()) { @@ -286,16 +300,17 @@ public void testListSynonyms() { } catch (Exception ex) { fail(ex.getMessage()); } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); service.deleteSynonym(deleteOptions).execute().getResult(); - service.deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()).execute().getResult(); + service + .deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()) + .execute() + .getResult(); } } - /** - * Test listSynonyms with pagination. - */ + /** Test listSynonyms with pagination. */ @Test public void testListSynonymsWithPaging() { @@ -305,7 +320,8 @@ public void testListSynonymsWithPaging() { String synonym2 = "joe"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -313,15 +329,16 @@ public void testListSynonymsWithPaging() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); try { service.createSynonym(createOptions).execute().getResult(); } catch (Exception ex) { @@ -329,26 +346,32 @@ public void testListSynonymsWithPaging() { assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } try { - service.createSynonym(createOptions.newBuilder().synonym(synonym2).build()).execute().getResult(); + service + .createSynonym(createOptions.newBuilder().synonym(synonym2).build()) + .execute() + .getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } try { - ListSynonymsOptions.Builder listOptionsBuilder = new ListSynonymsOptions.Builder(workspaceId, entity, - entityValue); + ListSynonymsOptions.Builder listOptionsBuilder = + new ListSynonymsOptions.Builder(workspaceId, entity, entityValue); listOptionsBuilder.sort("modified"); listOptionsBuilder.pageLimit(1L); - SynonymCollection response = service.listSynonyms(listOptionsBuilder.build()).execute().getResult(); + SynonymCollection response = + service.listSynonyms(listOptionsBuilder.build()).execute().getResult(); assertNotNull(response); assertNotNull(response.getPagination()); assertNotNull(response.getPagination().getRefreshUrl()); assertNotNull(response.getPagination().getNextUrl()); assertNotNull(response.getPagination().getNextCursor()); - boolean found1 = false, found2 = false; + boolean found1 = false; + boolean found2 = false; + while (true) { assertNotNull(response.getSynonyms()); assertTrue(response.getSynonyms().size() == 1); @@ -358,7 +381,8 @@ public void testListSynonymsWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listSynonyms(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); + response = + service.listSynonyms(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); } assertTrue(found1 && found2); @@ -366,16 +390,17 @@ public void testListSynonymsWithPaging() { } catch (Exception ex) { fail(ex.getMessage()); } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); service.deleteSynonym(deleteOptions).execute().getResult(); - service.deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()).execute().getResult(); + service + .deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()) + .execute() + .getResult(); } } - /** - * Test updateSynonym. - */ + /** Test updateSynonym. */ @Test public void testUpdateSynonym() { @@ -385,7 +410,8 @@ public void testUpdateSynonym() { String synonym2 = "mud"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -393,7 +419,8 @@ public void testUpdateSynonym() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -401,21 +428,22 @@ public void testUpdateSynonym() { } try { - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); service.createSynonym(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - UpdateSynonymOptions updateOptions = new UpdateSynonymOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .synonym(synonym1) - .newSynonym(synonym2) - .build(); + UpdateSynonymOptions updateOptions = + new UpdateSynonymOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue) + .synonym(synonym1) + .newSynonym(synonym2) + .build(); Synonym response = service.updateSynonym(updateOptions).execute().getResult(); try { @@ -426,8 +454,8 @@ public void testUpdateSynonym() { fail(ex.getMessage()); } finally { // Clean up - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym2) - .build(); + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym2).build(); service.deleteSynonym(deleteOptions).execute().getResult(); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/ValuesIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/ValuesIT.java index d94ba5948a7..32b5bbb1145 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/ValuesIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/ValuesIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2019. + * (C) Copyright IBM Corp. 2018, 2020. * * 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 @@ -12,6 +12,12 @@ */ package com.ibm.watson.assistant.v1; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.service.exception.NotFoundException; import com.ibm.watson.assistant.v1.model.CreateEntityOptions; import com.ibm.watson.assistant.v1.model.CreateValueOptions; @@ -22,29 +28,28 @@ import com.ibm.watson.assistant.v1.model.Value; import com.ibm.watson.assistant.v1.model.ValueCollection; import com.ibm.watson.common.RetryRunner; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - +/** The Class ValuesIT. */ @RunWith(RetryRunner.class) public class ValuesIT extends AssistantServiceTest { private Assistant service; private String workspaceId; + /** + * Sets up the tests. + * + * @throws Exception the exception + */ @Override @Before public void setUp() throws Exception { @@ -53,9 +58,7 @@ public void setUp() throws Exception { this.workspaceId = getWorkspaceId(); } - /** - * Test createValue. - */ + /** Test createValue. */ @Test public void testCreateValue() { @@ -68,19 +71,21 @@ public void testCreateValue() { valueMetadata.put("key", metadataValue); try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateValueOptions createOptions = new CreateValueOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .metadata(valueMetadata) - .build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue) + .metadata(valueMetadata) + .build(); Value response = service.createValue(createOptions).execute().getResult(); try { @@ -97,14 +102,13 @@ public void testCreateValue() { fail(ex.getMessage()); } finally { // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); service.deleteValue(deleteOptions).execute().getResult(); } } - /** - * Test deleteValue. - */ + /** Test deleteValue. */ @Test public void testDeleteValue() { @@ -112,14 +116,16 @@ public void testDeleteValue() { String entityValue = "coffee" + UUID.randomUUID().toString(); try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); Value response = service.createValue(createOptions).execute().getResult(); try { @@ -129,20 +135,23 @@ public void testDeleteValue() { assertNull(response.metadata()); } catch (Exception ex) { // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); service.deleteValue(deleteOptions).execute().getResult(); fail(ex.getMessage()); } - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue) + .build(); service.deleteValue(deleteOptions).execute().getResult(); try { - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue).build(); + GetValueOptions getOptions = + new GetValueOptions.Builder(workspaceId, entity, entityValue).build(); service.getValue(getOptions).execute().getResult(); fail("deleteValue failed"); } catch (Exception ex) { @@ -151,9 +160,7 @@ public void testDeleteValue() { } } - /** - * Test getValue. - */ + /** Test getValue. */ @Test public void testGetValue() { @@ -163,25 +170,28 @@ public void testGetValue() { String synonym2 = "joe"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue) - .synonyms(new ArrayList(Arrays.asList(synonym1, synonym2))) - .build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue) + .synonyms(new ArrayList(Arrays.asList(synonym1, synonym2))) + .build(); service.createValue(createOptions).execute().getResult(); Date start = new Date(); try { - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue) - .export(true) - .includeAudit(true) - .build(); + GetValueOptions getOptions = + new GetValueOptions.Builder(workspaceId, entity, entityValue) + .export(true) + .includeAudit(true) + .build(); Value response = service.getValue(getOptions).execute().getResult(); assertNotNull(response); @@ -203,14 +213,13 @@ public void testGetValue() { } catch (Exception ex) { fail(ex.getMessage()); } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); service.deleteValue(deleteOptions).execute().getResult(); } } - /** - * Test listValues. - */ + /** Test listValues. */ @Test public void testListValues() { @@ -219,14 +228,16 @@ public void testListValues() { String entityValue2 = "orange juice"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); try { service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { @@ -235,17 +246,18 @@ public void testListValues() { } try { - service.createValue(createOptions.newBuilder().value(entityValue2).build()).execute().getResult(); + service + .createValue(createOptions.newBuilder().value(entityValue2).build()) + .execute() + .getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } try { - ListValuesOptions listOptions = new ListValuesOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .build(); + ListValuesOptions listOptions = + new ListValuesOptions.Builder().workspaceId(workspaceId).entity(entity).build(); final ValueCollection response = service.listValues(listOptions).execute().getResult(); assertNotNull(response); assertNotNull(response.getValues()); @@ -262,7 +274,8 @@ public void testListValues() { // Should not be paginated, but just to be sure if (response.getPagination().getNextUrl() == null) { - //assertTrue(response.getValues().stream().filter(r -> r.getValue().equals(synonym1)).count() == 1); + // assertTrue(response.getValues().stream().filter(r -> + // r.getValue().equals(synonym1)).count() == 1); boolean found1 = false; boolean found2 = false; for (Value valueResponse : response.getValues()) { @@ -275,15 +288,17 @@ public void testListValues() { } catch (Exception ex) { fail(ex.getMessage()); } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); service.deleteValue(deleteOptions).execute().getResult(); - service.deleteValue(deleteOptions.newBuilder().value(entityValue2).build()).execute().getResult(); + service + .deleteValue(deleteOptions.newBuilder().value(entityValue2).build()) + .execute() + .getResult(); } } - /** - * Test listValues with pagination. - */ + /** Test listValues with pagination. */ @Test public void testListValuesWithPaging() { @@ -292,14 +307,16 @@ public void testListValuesWithPaging() { String entityValue2 = "orange juice"; try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); try { service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { @@ -308,19 +325,24 @@ public void testListValuesWithPaging() { } try { - service.createValue(createOptions.newBuilder().value(entityValue2).build()).execute().getResult(); + service + .createValue(createOptions.newBuilder().value(entityValue2).build()) + .execute() + .getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } try { - ListValuesOptions.Builder listOptionsBuilder = new ListValuesOptions.Builder(workspaceId, entity); + ListValuesOptions.Builder listOptionsBuilder = + new ListValuesOptions.Builder(workspaceId, entity); listOptionsBuilder.sort("updated"); listOptionsBuilder.pageLimit(1L); listOptionsBuilder.export(true); - ValueCollection response = service.listValues(listOptionsBuilder.build()).execute().getResult(); + ValueCollection response = + service.listValues(listOptionsBuilder.build()).execute().getResult(); assertNotNull(response); assertNotNull(response.getPagination()); assertNotNull(response.getPagination().getRefreshUrl()); @@ -338,7 +360,8 @@ public void testListValuesWithPaging() { break; } String cursor = response.getPagination().getNextCursor(); - response = service.listValues(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); + response = + service.listValues(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); } assertTrue(found1 && found2); @@ -346,15 +369,17 @@ public void testListValuesWithPaging() { } catch (Exception ex) { fail(ex.getMessage()); } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); service.deleteValue(deleteOptions).execute().getResult(); - service.deleteValue(deleteOptions.newBuilder().value(entityValue2).build()).execute().getResult(); + service + .deleteValue(deleteOptions.newBuilder().value(entityValue2).build()) + .execute() + .getResult(); } } - /** - * Test updateValue. - */ + /** Test updateValue. */ @Test public void testUpdateValue() { @@ -370,7 +395,8 @@ public void testUpdateValue() { valueMetadata.put("key", metadataValue); try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); + CreateEntityOptions createOptions = + new CreateEntityOptions.Builder(workspaceId, entity).build(); service.createEntity(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation @@ -378,21 +404,23 @@ public void testUpdateValue() { } try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); + CreateValueOptions createOptions = + new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); service.createValue(createOptions).execute().getResult(); } catch (Exception ex) { // Exception is okay if is for Unique Violation assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); } - UpdateValueOptions updateOptions = new UpdateValueOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue1) - .newValue(entityValue2) - .newSynonyms(new ArrayList<>(Arrays.asList(synonym1, synonym2))) - .newMetadata(valueMetadata) - .build(); + UpdateValueOptions updateOptions = + new UpdateValueOptions.Builder() + .workspaceId(workspaceId) + .entity(entity) + .value(entityValue1) + .newValue(entityValue2) + .newSynonyms(new ArrayList<>(Arrays.asList(synonym1, synonym2))) + .newMetadata(valueMetadata) + .build(); Value response = service.updateValue(updateOptions).execute().getResult(); try { @@ -400,10 +428,11 @@ public void testUpdateValue() { assertNotNull(response.value()); assertEquals(response.value(), entityValue2); - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue2) - .export(true) - .includeAudit(true) - .build(); + GetValueOptions getOptions = + new GetValueOptions.Builder(workspaceId, entity, entityValue2) + .export(true) + .includeAudit(true) + .build(); Value vResponse = service.getValue(getOptions).execute().getResult(); assertNotNull(vResponse); @@ -426,7 +455,8 @@ public void testUpdateValue() { fail(ex.getMessage()); } finally { // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue2).build(); + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue2).build(); service.deleteValue(deleteOptions).execute().getResult(); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/AgentAvailabilityMessageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/AgentAvailabilityMessageTest.java new file mode 100644 index 00000000000..f357615e15c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/AgentAvailabilityMessageTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AgentAvailabilityMessage model. */ +public class AgentAvailabilityMessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAgentAvailabilityMessage() throws Throwable { + AgentAvailabilityMessage agentAvailabilityMessageModel = + new AgentAvailabilityMessage.Builder().message("testString").build(); + assertEquals(agentAvailabilityMessageModel.message(), "testString"); + + String json = TestUtilities.serialize(agentAvailabilityMessageModel); + + AgentAvailabilityMessage agentAvailabilityMessageModelNew = + TestUtilities.deserialize(json, AgentAvailabilityMessage.class); + assertTrue(agentAvailabilityMessageModelNew instanceof AgentAvailabilityMessage); + assertEquals(agentAvailabilityMessageModelNew.message(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptionsTest.java new file mode 100644 index 00000000000..4df75ba9864 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOptions model. */ +public class BulkClassifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOptions() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .workspaceId("testString") + .input(java.util.Arrays.asList(bulkClassifyUtteranceModel)) + .build(); + assertEquals(bulkClassifyOptionsModel.workspaceId(), "testString"); + assertEquals( + bulkClassifyOptionsModel.input(), java.util.Arrays.asList(bulkClassifyUtteranceModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyOptionsError() throws Throwable { + new BulkClassifyOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutputTest.java new file mode 100644 index 00000000000..dc8b601d3dd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutputTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOutput model. */ +public class BulkClassifyOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOutput() throws Throwable { + BulkClassifyOutput bulkClassifyOutputModel = new BulkClassifyOutput(); + assertNull(bulkClassifyOutputModel.getInput()); + assertNull(bulkClassifyOutputModel.getEntities()); + assertNull(bulkClassifyOutputModel.getIntents()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponseTest.java new file mode 100644 index 00000000000..d4cc84c09a4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyResponse model. */ +public class BulkClassifyResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyResponse() throws Throwable { + BulkClassifyResponse bulkClassifyResponseModel = new BulkClassifyResponse(); + assertNull(bulkClassifyResponseModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtteranceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtteranceTest.java new file mode 100644 index 00000000000..814a0f698c5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtteranceTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyUtterance model. */ +public class BulkClassifyUtteranceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyUtterance() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + String json = TestUtilities.serialize(bulkClassifyUtteranceModel); + + BulkClassifyUtterance bulkClassifyUtteranceModelNew = + TestUtilities.deserialize(json, BulkClassifyUtterance.class); + assertTrue(bulkClassifyUtteranceModelNew instanceof BulkClassifyUtterance); + assertEquals(bulkClassifyUtteranceModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyUtteranceError() throws Throwable { + new BulkClassifyUtterance.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CaptureGroupTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CaptureGroupTest.java new file mode 100644 index 00000000000..1a46f0a8a8b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CaptureGroupTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CaptureGroup model. */ +public class CaptureGroupTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCaptureGroup() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + String json = TestUtilities.serialize(captureGroupModel); + + CaptureGroup captureGroupModelNew = TestUtilities.deserialize(json, CaptureGroup.class); + assertTrue(captureGroupModelNew instanceof CaptureGroup); + assertEquals(captureGroupModelNew.group(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCaptureGroupError() throws Throwable { + new CaptureGroup.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferInfoTest.java new file mode 100644 index 00000000000..64f360662db --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferInfoTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ChannelTransferInfo model. */ +public class ChannelTransferInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testChannelTransferInfo() throws Throwable { + ChannelTransferTargetChat channelTransferTargetChatModel = + new ChannelTransferTargetChat.Builder().url("testString").build(); + assertEquals(channelTransferTargetChatModel.url(), "testString"); + + ChannelTransferTarget channelTransferTargetModel = + new ChannelTransferTarget.Builder().chat(channelTransferTargetChatModel).build(); + assertEquals(channelTransferTargetModel.chat(), channelTransferTargetChatModel); + + ChannelTransferInfo channelTransferInfoModel = + new ChannelTransferInfo.Builder().target(channelTransferTargetModel).build(); + assertEquals(channelTransferInfoModel.target(), channelTransferTargetModel); + + String json = TestUtilities.serialize(channelTransferInfoModel); + + ChannelTransferInfo channelTransferInfoModelNew = + TestUtilities.deserialize(json, ChannelTransferInfo.class); + assertTrue(channelTransferInfoModelNew instanceof ChannelTransferInfo); + assertEquals( + channelTransferInfoModelNew.target().toString(), channelTransferTargetModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testChannelTransferInfoError() throws Throwable { + new ChannelTransferInfo.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetChatTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetChatTest.java new file mode 100644 index 00000000000..f42bd02010d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetChatTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ChannelTransferTargetChat model. */ +public class ChannelTransferTargetChatTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testChannelTransferTargetChat() throws Throwable { + ChannelTransferTargetChat channelTransferTargetChatModel = + new ChannelTransferTargetChat.Builder().url("testString").build(); + assertEquals(channelTransferTargetChatModel.url(), "testString"); + + String json = TestUtilities.serialize(channelTransferTargetChatModel); + + ChannelTransferTargetChat channelTransferTargetChatModelNew = + TestUtilities.deserialize(json, ChannelTransferTargetChat.class); + assertTrue(channelTransferTargetChatModelNew instanceof ChannelTransferTargetChat); + assertEquals(channelTransferTargetChatModelNew.url(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetTest.java new file mode 100644 index 00000000000..af22642f493 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ChannelTransferTargetTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ChannelTransferTarget model. */ +public class ChannelTransferTargetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testChannelTransferTarget() throws Throwable { + ChannelTransferTargetChat channelTransferTargetChatModel = + new ChannelTransferTargetChat.Builder().url("testString").build(); + assertEquals(channelTransferTargetChatModel.url(), "testString"); + + ChannelTransferTarget channelTransferTargetModel = + new ChannelTransferTarget.Builder().chat(channelTransferTargetChatModel).build(); + assertEquals(channelTransferTargetModel.chat(), channelTransferTargetChatModel); + + String json = TestUtilities.serialize(channelTransferTargetModel); + + ChannelTransferTarget channelTransferTargetModelNew = + TestUtilities.deserialize(json, ChannelTransferTarget.class); + assertTrue(channelTransferTargetModelNew instanceof ChannelTransferTarget); + assertEquals( + channelTransferTargetModelNew.chat().toString(), channelTransferTargetChatModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ContextTest.java new file mode 100644 index 00000000000..6fc609b4af7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ContextTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Context model. */ +public class ContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContext() throws Throwable { + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system(java.util.Collections.singletonMap("anyKey", "anyValue")) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + assertEquals(contextModel.getConversationId(), "testString"); + assertEquals( + contextModel.getSystem(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(contextModel.getMetadata(), messageContextMetadataModel); + assertEquals(contextModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(contextModel); + + Context contextModelNew = TestUtilities.deserialize(json, Context.class); + assertTrue(contextModelNew instanceof Context); + assertEquals(contextModelNew.getConversationId(), "testString"); + assertEquals( + contextModelNew.getSystem().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(contextModelNew.getMetadata().toString(), messageContextMetadataModel.toString()); + assertEquals(contextModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleCollectionTest.java new file mode 100644 index 00000000000..400b8a58445 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CounterexampleCollection model. */ +public class CounterexampleCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCounterexampleCollection() throws Throwable { + CounterexampleCollection counterexampleCollectionModel = new CounterexampleCollection(); + assertNull(counterexampleCollectionModel.getCounterexamples()); + assertNull(counterexampleCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleTest.java new file mode 100644 index 00000000000..4e8a74fdaae --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Counterexample model. */ +public class CounterexampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCounterexample() throws Throwable { + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + String json = TestUtilities.serialize(counterexampleModel); + + Counterexample counterexampleModelNew = TestUtilities.deserialize(json, Counterexample.class); + assertTrue(counterexampleModelNew instanceof Counterexample); + assertEquals(counterexampleModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCounterexampleError() throws Throwable { + new Counterexample.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptionsTest.java new file mode 100644 index 00000000000..8c47aa5806e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCounterexampleOptions model. */ +public class CreateCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCounterexampleOptions() throws Throwable { + CreateCounterexampleOptions createCounterexampleOptionsModel = + new CreateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(false) + .build(); + assertEquals(createCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(createCounterexampleOptionsModel.text(), "testString"); + assertEquals(createCounterexampleOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCounterexampleOptionsError() throws Throwable { + new CreateCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptionsTest.java new file mode 100644 index 00000000000..d36c94327d9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptionsTest.java @@ -0,0 +1,174 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateDialogNodeOptions model. */ +public class CreateDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateDialogNodeOptions() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + CreateDialogNodeOptions createDialogNodeOptionsModel = + new CreateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .includeAudit(false) + .build(); + assertEquals(createDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(createDialogNodeOptionsModel.dialogNode(), "testString"); + assertEquals(createDialogNodeOptionsModel.description(), "testString"); + assertEquals(createDialogNodeOptionsModel.conditions(), "testString"); + assertEquals(createDialogNodeOptionsModel.parent(), "testString"); + assertEquals(createDialogNodeOptionsModel.previousSibling(), "testString"); + assertEquals(createDialogNodeOptionsModel.output(), dialogNodeOutputModel); + assertEquals(createDialogNodeOptionsModel.context(), dialogNodeContextModel); + assertEquals( + createDialogNodeOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createDialogNodeOptionsModel.nextStep(), dialogNodeNextStepModel); + assertEquals(createDialogNodeOptionsModel.title(), "testString"); + assertEquals(createDialogNodeOptionsModel.type(), "standard"); + assertEquals(createDialogNodeOptionsModel.eventName(), "focus"); + assertEquals(createDialogNodeOptionsModel.variable(), "testString"); + assertEquals( + createDialogNodeOptionsModel.actions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(createDialogNodeOptionsModel.digressIn(), "not_available"); + assertEquals(createDialogNodeOptionsModel.digressOut(), "allow_returning"); + assertEquals(createDialogNodeOptionsModel.digressOutSlots(), "not_allowed"); + assertEquals(createDialogNodeOptionsModel.userLabel(), "testString"); + assertEquals(createDialogNodeOptionsModel.disambiguationOptOut(), Boolean.valueOf(false)); + assertEquals(createDialogNodeOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDialogNodeOptionsError() throws Throwable { + new CreateDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityOptionsTest.java new file mode 100644 index 00000000000..2ecccc2bcab --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityOptionsTest.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEntityOptions model. */ +public class CreateEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEntityOptions() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + CreateEntityOptions createEntityOptionsModel = + new CreateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .includeAudit(false) + .build(); + assertEquals(createEntityOptionsModel.workspaceId(), "testString"); + assertEquals(createEntityOptionsModel.entity(), "testString"); + assertEquals(createEntityOptionsModel.description(), "testString"); + assertEquals( + createEntityOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createEntityOptionsModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals(createEntityOptionsModel.values(), java.util.Arrays.asList(createValueModel)); + assertEquals(createEntityOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEntityOptionsError() throws Throwable { + new CreateEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityTest.java new file mode 100644 index 00000000000..f31144230c9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityTest.java @@ -0,0 +1,79 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEntity model. */ +public class CreateEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEntity() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals(createEntityModel.values(), java.util.Arrays.asList(createValueModel)); + + String json = TestUtilities.serialize(createEntityModel); + + CreateEntity createEntityModelNew = TestUtilities.deserialize(json, CreateEntity.class); + assertTrue(createEntityModelNew instanceof CreateEntity); + assertEquals(createEntityModelNew.entity(), "testString"); + assertEquals(createEntityModelNew.description(), "testString"); + assertEquals( + createEntityModelNew.metadata().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(createEntityModelNew.fuzzyMatch(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEntityError() throws Throwable { + new CreateEntity.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateExampleOptionsTest.java new file mode 100644 index 00000000000..af9740a23f7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateExampleOptionsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateExampleOptions model. */ +public class CreateExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateExampleOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + CreateExampleOptions createExampleOptionsModel = + new CreateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .includeAudit(false) + .build(); + assertEquals(createExampleOptionsModel.workspaceId(), "testString"); + assertEquals(createExampleOptionsModel.intent(), "testString"); + assertEquals(createExampleOptionsModel.text(), "testString"); + assertEquals(createExampleOptionsModel.mentions(), java.util.Arrays.asList(mentionModel)); + assertEquals(createExampleOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExampleOptionsError() throws Throwable { + new CreateExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentOptionsTest.java new file mode 100644 index 00000000000..2220daced95 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentOptionsTest.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateIntentOptions model. */ +public class CreateIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateIntentOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + CreateIntentOptions createIntentOptionsModel = + new CreateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .includeAudit(false) + .build(); + assertEquals(createIntentOptionsModel.workspaceId(), "testString"); + assertEquals(createIntentOptionsModel.intent(), "testString"); + assertEquals(createIntentOptionsModel.description(), "testString"); + assertEquals(createIntentOptionsModel.examples(), java.util.Arrays.asList(exampleModel)); + assertEquals(createIntentOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateIntentOptionsError() throws Throwable { + new CreateIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentTest.java new file mode 100644 index 00000000000..fb78bcd7ec6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateIntent model. */ +public class CreateIntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateIntent() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals(createIntentModel.examples(), java.util.Arrays.asList(exampleModel)); + + String json = TestUtilities.serialize(createIntentModel); + + CreateIntent createIntentModelNew = TestUtilities.deserialize(json, CreateIntent.class); + assertTrue(createIntentModelNew instanceof CreateIntent); + assertEquals(createIntentModelNew.intent(), "testString"); + assertEquals(createIntentModelNew.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateIntentError() throws Throwable { + new CreateIntent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptionsTest.java new file mode 100644 index 00000000000..83a9cd7d37c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateSynonymOptions model. */ +public class CreateSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateSynonymOptions() throws Throwable { + CreateSynonymOptions createSynonymOptionsModel = + new CreateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(false) + .build(); + assertEquals(createSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(createSynonymOptionsModel.entity(), "testString"); + assertEquals(createSynonymOptionsModel.value(), "testString"); + assertEquals(createSynonymOptionsModel.synonym(), "testString"); + assertEquals(createSynonymOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSynonymOptionsError() throws Throwable { + new CreateSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueOptionsTest.java new file mode 100644 index 00000000000..05adc44d3dd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueOptionsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateValueOptions model. */ +public class CreateValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateValueOptions() throws Throwable { + CreateValueOptions createValueOptionsModel = + new CreateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .includeAudit(false) + .build(); + assertEquals(createValueOptionsModel.workspaceId(), "testString"); + assertEquals(createValueOptionsModel.entity(), "testString"); + assertEquals(createValueOptionsModel.value(), "testString"); + assertEquals( + createValueOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueOptionsModel.type(), "synonyms"); + assertEquals(createValueOptionsModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueOptionsModel.patterns(), java.util.Arrays.asList("testString")); + assertEquals(createValueOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateValueOptionsError() throws Throwable { + new CreateValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueTest.java new file mode 100644 index 00000000000..5782409602d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateValue model. */ +public class CreateValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateValue() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(createValueModel); + + CreateValue createValueModelNew = TestUtilities.deserialize(json, CreateValue.class); + assertTrue(createValueModelNew instanceof CreateValue); + assertEquals(createValueModelNew.value(), "testString"); + assertEquals( + createValueModelNew.metadata().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(createValueModelNew.type(), "synonyms"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateValueError() throws Throwable { + new CreateValue.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceAsyncOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceAsyncOptionsTest.java new file mode 100644 index 00000000000..cd0c2c36b37 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceAsyncOptionsTest.java @@ -0,0 +1,334 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateWorkspaceAsyncOptions model. */ +public class CreateWorkspaceAsyncOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateWorkspaceAsyncOptions() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals(dialogNodeModel.actions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(false)); + + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + assertEquals(workspaceSystemSettingsNlpModel.model(), "testString"); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + assertEquals(workspaceSystemSettingsModel.getTooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.getDisambiguation(), + workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.getHumanAgentAssist(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(workspaceSystemSettingsModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals( + workspaceSystemSettingsModel.getSystemEntities(), + workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.getOffTopic(), workspaceSystemSettingsOffTopicModel); + assertEquals(workspaceSystemSettingsModel.getNlp(), workspaceSystemSettingsNlpModel); + assertEquals(workspaceSystemSettingsModel.get("foo"), "testString"); + + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals(webhookModel.headers(), java.util.Arrays.asList(webhookHeaderModel)); + + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals(createIntentModel.examples(), java.util.Arrays.asList(exampleModel)); + + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals(createEntityModel.values(), java.util.Arrays.asList(createValueModel)); + + CreateWorkspaceAsyncOptions createWorkspaceAsyncOptionsModel = + new CreateWorkspaceAsyncOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .build(); + assertEquals(createWorkspaceAsyncOptionsModel.name(), "testString"); + assertEquals(createWorkspaceAsyncOptionsModel.description(), "testString"); + assertEquals(createWorkspaceAsyncOptionsModel.language(), "testString"); + assertEquals( + createWorkspaceAsyncOptionsModel.dialogNodes(), java.util.Arrays.asList(dialogNodeModel)); + assertEquals( + createWorkspaceAsyncOptionsModel.counterexamples(), + java.util.Arrays.asList(counterexampleModel)); + assertEquals( + createWorkspaceAsyncOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createWorkspaceAsyncOptionsModel.learningOptOut(), Boolean.valueOf(false)); + assertEquals(createWorkspaceAsyncOptionsModel.systemSettings(), workspaceSystemSettingsModel); + assertEquals( + createWorkspaceAsyncOptionsModel.webhooks(), java.util.Arrays.asList(webhookModel)); + assertEquals( + createWorkspaceAsyncOptionsModel.intents(), java.util.Arrays.asList(createIntentModel)); + assertEquals( + createWorkspaceAsyncOptionsModel.entities(), java.util.Arrays.asList(createEntityModel)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptionsTest.java new file mode 100644 index 00000000000..7fd16e271ba --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptionsTest.java @@ -0,0 +1,334 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateWorkspaceOptions model. */ +public class CreateWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateWorkspaceOptions() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals(dialogNodeModel.actions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(false)); + + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + assertEquals(workspaceSystemSettingsNlpModel.model(), "testString"); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + assertEquals(workspaceSystemSettingsModel.getTooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.getDisambiguation(), + workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.getHumanAgentAssist(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(workspaceSystemSettingsModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals( + workspaceSystemSettingsModel.getSystemEntities(), + workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.getOffTopic(), workspaceSystemSettingsOffTopicModel); + assertEquals(workspaceSystemSettingsModel.getNlp(), workspaceSystemSettingsNlpModel); + assertEquals(workspaceSystemSettingsModel.get("foo"), "testString"); + + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals(webhookModel.headers(), java.util.Arrays.asList(webhookHeaderModel)); + + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals(createIntentModel.examples(), java.util.Arrays.asList(exampleModel)); + + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals(createEntityModel.values(), java.util.Arrays.asList(createValueModel)); + + CreateWorkspaceOptions createWorkspaceOptionsModel = + new CreateWorkspaceOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .includeAudit(false) + .build(); + assertEquals(createWorkspaceOptionsModel.name(), "testString"); + assertEquals(createWorkspaceOptionsModel.description(), "testString"); + assertEquals(createWorkspaceOptionsModel.language(), "testString"); + assertEquals( + createWorkspaceOptionsModel.dialogNodes(), java.util.Arrays.asList(dialogNodeModel)); + assertEquals( + createWorkspaceOptionsModel.counterexamples(), + java.util.Arrays.asList(counterexampleModel)); + assertEquals( + createWorkspaceOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createWorkspaceOptionsModel.learningOptOut(), Boolean.valueOf(false)); + assertEquals(createWorkspaceOptionsModel.systemSettings(), workspaceSystemSettingsModel); + assertEquals(createWorkspaceOptionsModel.webhooks(), java.util.Arrays.asList(webhookModel)); + assertEquals(createWorkspaceOptionsModel.intents(), java.util.Arrays.asList(createIntentModel)); + assertEquals( + createWorkspaceOptionsModel.entities(), java.util.Arrays.asList(createEntityModel)); + assertEquals(createWorkspaceOptionsModel.includeAudit(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptionsTest.java new file mode 100644 index 00000000000..51c586a9269 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCounterexampleOptions model. */ +public class DeleteCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCounterexampleOptions() throws Throwable { + DeleteCounterexampleOptions deleteCounterexampleOptionsModel = + new DeleteCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .build(); + assertEquals(deleteCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(deleteCounterexampleOptionsModel.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCounterexampleOptionsError() throws Throwable { + new DeleteCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptionsTest.java new file mode 100644 index 00000000000..ef84d6961d7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDialogNodeOptions model. */ +public class DeleteDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDialogNodeOptions() throws Throwable { + DeleteDialogNodeOptions deleteDialogNodeOptionsModel = + new DeleteDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .build(); + assertEquals(deleteDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(deleteDialogNodeOptionsModel.dialogNode(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDialogNodeOptionsError() throws Throwable { + new DeleteDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptionsTest.java new file mode 100644 index 00000000000..dfb0feb2cb6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteEntityOptions model. */ +public class DeleteEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteEntityOptions() throws Throwable { + DeleteEntityOptions deleteEntityOptionsModel = + new DeleteEntityOptions.Builder().workspaceId("testString").entity("testString").build(); + assertEquals(deleteEntityOptionsModel.workspaceId(), "testString"); + assertEquals(deleteEntityOptionsModel.entity(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEntityOptionsError() throws Throwable { + new DeleteEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptionsTest.java new file mode 100644 index 00000000000..105fe378e5d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteExampleOptions model. */ +public class DeleteExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteExampleOptions() throws Throwable { + DeleteExampleOptions deleteExampleOptionsModel = + new DeleteExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .build(); + assertEquals(deleteExampleOptionsModel.workspaceId(), "testString"); + assertEquals(deleteExampleOptionsModel.intent(), "testString"); + assertEquals(deleteExampleOptionsModel.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExampleOptionsError() throws Throwable { + new DeleteExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptionsTest.java new file mode 100644 index 00000000000..3ab37d0c679 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteIntentOptions model. */ +public class DeleteIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteIntentOptions() throws Throwable { + DeleteIntentOptions deleteIntentOptionsModel = + new DeleteIntentOptions.Builder().workspaceId("testString").intent("testString").build(); + assertEquals(deleteIntentOptionsModel.workspaceId(), "testString"); + assertEquals(deleteIntentOptionsModel.intent(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteIntentOptionsError() throws Throwable { + new DeleteIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptionsTest.java new file mode 100644 index 00000000000..9677f0b3325 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteSynonymOptions model. */ +public class DeleteSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteSynonymOptions() throws Throwable { + DeleteSynonymOptions deleteSynonymOptionsModel = + new DeleteSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .build(); + assertEquals(deleteSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(deleteSynonymOptionsModel.entity(), "testString"); + assertEquals(deleteSynonymOptionsModel.value(), "testString"); + assertEquals(deleteSynonymOptionsModel.synonym(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSynonymOptionsError() throws Throwable { + new DeleteSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..3c4cae4ea21 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteValueOptionsTest.java new file mode 100644 index 00000000000..cadaf27fb21 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteValueOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteValueOptions model. */ +public class DeleteValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteValueOptions() throws Throwable { + DeleteValueOptions deleteValueOptionsModel = + new DeleteValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .build(); + assertEquals(deleteValueOptionsModel.workspaceId(), "testString"); + assertEquals(deleteValueOptionsModel.entity(), "testString"); + assertEquals(deleteValueOptionsModel.value(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteValueOptionsError() throws Throwable { + new DeleteValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptionsTest.java new file mode 100644 index 00000000000..d1cb9765310 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteWorkspaceOptions model. */ +public class DeleteWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteWorkspaceOptions() throws Throwable { + DeleteWorkspaceOptions deleteWorkspaceOptionsModel = + new DeleteWorkspaceOptions.Builder().workspaceId("testString").build(); + assertEquals(deleteWorkspaceOptionsModel.workspaceId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWorkspaceOptionsError() throws Throwable { + new DeleteWorkspaceOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeActionTest.java new file mode 100644 index 00000000000..f38921923c0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeActionTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeAction model. */ +public class DialogNodeActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeAction() throws Throwable { + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + String json = TestUtilities.serialize(dialogNodeActionModel); + + DialogNodeAction dialogNodeActionModelNew = + TestUtilities.deserialize(json, DialogNodeAction.class); + assertTrue(dialogNodeActionModelNew instanceof DialogNodeAction); + assertEquals(dialogNodeActionModelNew.name(), "testString"); + assertEquals(dialogNodeActionModelNew.type(), "client"); + assertEquals( + dialogNodeActionModelNew.parameters().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(dialogNodeActionModelNew.resultVariable(), "testString"); + assertEquals(dialogNodeActionModelNew.credentials(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeActionError() throws Throwable { + new DialogNodeAction.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeCollectionTest.java new file mode 100644 index 00000000000..815397fff98 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeCollection model. */ +public class DialogNodeCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeCollection() throws Throwable { + DialogNodeCollection dialogNodeCollectionModel = new DialogNodeCollection(); + assertNull(dialogNodeCollectionModel.getDialogNodes()); + assertNull(dialogNodeCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeContextTest.java new file mode 100644 index 00000000000..d3654880b11 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeContextTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeContext model. */ +public class DialogNodeContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeContext() throws Throwable { + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(dialogNodeContextModel); + + DialogNodeContext dialogNodeContextModelNew = + TestUtilities.deserialize(json, DialogNodeContext.class); + assertTrue(dialogNodeContextModelNew instanceof DialogNodeContext); + assertEquals(dialogNodeContextModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStepTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStepTest.java new file mode 100644 index 00000000000..f8869a129f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStepTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeNextStep model. */ +public class DialogNodeNextStepTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeNextStep() throws Throwable { + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + String json = TestUtilities.serialize(dialogNodeNextStepModel); + + DialogNodeNextStep dialogNodeNextStepModelNew = + TestUtilities.deserialize(json, DialogNodeNextStep.class); + assertTrue(dialogNodeNextStepModelNew instanceof DialogNodeNextStep); + assertEquals(dialogNodeNextStepModelNew.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModelNew.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModelNew.selector(), "condition"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeNextStepError() throws Throwable { + new DialogNodeNextStep.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfoTest.java new file mode 100644 index 00000000000..f4384f033c7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfoTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputConnectToAgentTransferInfo model. */ +public class DialogNodeOutputConnectToAgentTransferInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputConnectToAgentTransferInfo() throws Throwable { + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo.Builder() + .target( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .build(); + assertEquals( + dialogNodeOutputConnectToAgentTransferInfoModel.target(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + + String json = TestUtilities.serialize(dialogNodeOutputConnectToAgentTransferInfoModel); + + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModelNew = + TestUtilities.deserialize(json, DialogNodeOutputConnectToAgentTransferInfo.class); + assertTrue( + dialogNodeOutputConnectToAgentTransferInfoModelNew + instanceof DialogNodeOutputConnectToAgentTransferInfo); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeAudioTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeAudioTest.java new file mode 100644 index 00000000000..5fba7f9c592 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeAudioTest.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeAudioTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeAudio() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.Builder() + .responseType("audio") + .source("testString") + .title("testString") + .description("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .channelOptions(java.util.Collections.singletonMap("anyKey", "anyValue")) + .altText("testString") + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.responseType(), "audio"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.description(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.channelOptions(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel.altText(), "testString"); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew.responseType(), "audio"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew.description(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew + .channelOptions() + .toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeAudioModelNew.altText(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeAudioError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeAudio.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferTest.java new file mode 100644 index 00000000000..0820c94544b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferTest.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2021, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer model. + */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer() + throws Throwable { + ChannelTransferTargetChat channelTransferTargetChatModel = + new ChannelTransferTargetChat.Builder().url("testString").build(); + assertEquals(channelTransferTargetChatModel.url(), "testString"); + + ChannelTransferTarget channelTransferTargetModel = + new ChannelTransferTarget.Builder().chat(channelTransferTargetChatModel).build(); + assertEquals(channelTransferTargetModel.chat(), channelTransferTargetChatModel); + + ChannelTransferInfo channelTransferInfoModel = + new ChannelTransferInfo.Builder().target(channelTransferTargetModel).build(); + assertEquals(channelTransferInfoModel.target(), channelTransferTargetModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.Builder() + .responseType("channel_transfer") + .messageToUser("testString") + .transferInfo(channelTransferInfoModel) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModel.responseType(), + "channel_transfer"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModel.messageToUser(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModel.transferInfo(), + channelTransferInfoModel); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModelNew.responseType(), + "channel_transfer"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModelNew.messageToUser(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferModelNew + .transferInfo() + .toString(), + channelTransferInfoModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransferError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeChannelTransfer.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest.java new file mode 100644 index 00000000000..55fecc2980a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent model. + */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent() + throws Throwable { + AgentAvailabilityMessage agentAvailabilityMessageModel = + new AgentAvailabilityMessage.Builder().message("testString").build(); + assertEquals(agentAvailabilityMessageModel.message(), "testString"); + + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo.Builder() + .target( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .build(); + assertEquals( + dialogNodeOutputConnectToAgentTransferInfoModel.target(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.Builder() + .responseType("connect_to_agent") + .messageToHumanAgent("testString") + .agentAvailable(agentAvailabilityMessageModel) + .agentUnavailable(agentAvailabilityMessageModel) + .transferInfo(dialogNodeOutputConnectToAgentTransferInfoModel) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.responseType(), + "connect_to_agent"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel + .messageToHumanAgent(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.agentAvailable(), + agentAvailabilityMessageModel); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.agentUnavailable(), + agentAvailabilityMessageModel); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.transferInfo(), + dialogNodeOutputConnectToAgentTransferInfoModel); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew.responseType(), + "connect_to_agent"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .messageToHumanAgent(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .agentAvailable() + .toString(), + agentAvailabilityMessageModel.toString()); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .agentUnavailable() + .toString(), + agentAvailabilityMessageModel.toString()); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .transferInfo() + .toString(), + dialogNodeOutputConnectToAgentTransferInfoModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeIframeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeIframeTest.java new file mode 100644 index 00000000000..2e65ae1a964 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeIframeTest.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeIframeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeIframe() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.Builder() + .responseType("iframe") + .source("testString") + .title("testString") + .description("testString") + .imageUrl("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel.responseType(), "iframe"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel.description(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel.imageUrl(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew.responseType(), "iframe"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew.description(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeIframeModelNew.imageUrl(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeIframeError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeIframe.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest.java new file mode 100644 index 00000000000..47dc79aeb04 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest.java @@ -0,0 +1,88 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeImage() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeImage + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.Builder() + .responseType("image") + .source("testString") + .title("testString") + .description("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .altText("testString") + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.responseType(), "image"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.description(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.altText(), "testString"); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeImage + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeImage); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.responseType(), "image"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.description(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.altText(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeImageError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest.java new file mode 100644 index 00000000000..c2949e3fedb --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest.java @@ -0,0 +1,225 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeOption() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + java.util.Arrays.asList(runtimeEntityModel)); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeOption + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options(java.util.Arrays.asList(dialogNodeOutputOptionsElementModel)) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.responseType(), "option"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.description(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.preference(), "dropdown"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.options(), + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel)); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeOption + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeOption); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.responseType(), "option"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.description(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.preference(), "dropdown"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeOptionError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest.java new file mode 100644 index 00000000000..a899839f67b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest.java @@ -0,0 +1,80 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypePause model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypePause() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypePause + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypePause.Builder() + .responseType("pause") + .time(Long.valueOf("26")) + .typing(true) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.responseType(), "pause"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.time(), Long.valueOf("26")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.typing(), + Boolean.valueOf(true)); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypePause + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypePause.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypePause); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew.responseType(), "pause"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew.time(), + Long.valueOf("26")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew.typing(), + Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypePauseError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypePause.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest.java new file mode 100644 index 00000000000..625744ec3ef --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill() + throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("2018-12-03") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.responseType(), + "search_skill"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.query(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.queryType(), + "natural_language"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.filter(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.discoveryVersion(), + "2018-12-03"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.responseType(), + "search_skill"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.query(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.queryType(), + "natural_language"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.filter(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.discoveryVersion(), + "2018-12-03"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest.java new file mode 100644 index 00000000000..6fa494a7ed2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest.java @@ -0,0 +1,86 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeText() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.selectionPolicy(), + "sequential"); + assertEquals(dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeText.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeText); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew.selectionPolicy(), + "sequential"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew.delimiter(), "\\n"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeTextError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedTest.java new file mode 100644 index 00000000000..15ddeeff632 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedTest.java @@ -0,0 +1,81 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined() + throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.Builder() + .responseType("user_defined") + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModel.responseType(), + "user_defined"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModelNew.responseType(), + "user_defined"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedModelNew + .userDefined() + .toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefinedError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeUserDefined.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeVideoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeVideoTest.java new file mode 100644 index 00000000000..5ce37592514 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeVideoTest.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeVideoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeVideo() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder() + .responseType("video") + .source("testString") + .title("testString") + .description("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .channelOptions(java.util.Collections.singletonMap("anyKey", "anyValue")) + .altText("testString") + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.responseType(), "video"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.description(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.channelOptions(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel.altText(), "testString"); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew.responseType(), "video"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew.description(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew + .channelOptions() + .toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeVideoModelNew.altText(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeVideoError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericTest.java new file mode 100644 index 00000000000..eef69f5cfe0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGeneric model. */ +public class DialogNodeOutputGenericTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testDialogNodeOutputGeneric() throws Throwable { + DialogNodeOutputGeneric dialogNodeOutputGenericModel = new DialogNodeOutputGeneric(); + assertNotNull(dialogNodeOutputGenericModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiersTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiersTest.java new file mode 100644 index 00000000000..c2d7a76c608 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiersTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputModifiers model. */ +public class DialogNodeOutputModifiersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputModifiers() throws Throwable { + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(dialogNodeOutputModifiersModel); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModelNew = + TestUtilities.deserialize(json, DialogNodeOutputModifiers.class); + assertTrue(dialogNodeOutputModifiersModelNew instanceof DialogNodeOutputModifiers); + assertEquals(dialogNodeOutputModifiersModelNew.overwrite(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementTest.java new file mode 100644 index 00000000000..d31892aef10 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementTest.java @@ -0,0 +1,185 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElement model. */ +public class DialogNodeOutputOptionsElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElement() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + java.util.Arrays.asList(runtimeEntityModel)); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + String json = TestUtilities.serialize(dialogNodeOutputOptionsElementModel); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModelNew = + TestUtilities.deserialize(json, DialogNodeOutputOptionsElement.class); + assertTrue(dialogNodeOutputOptionsElementModelNew instanceof DialogNodeOutputOptionsElement); + assertEquals(dialogNodeOutputOptionsElementModelNew.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModelNew.value().toString(), + dialogNodeOutputOptionsElementValueModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputOptionsElementError() throws Throwable { + new DialogNodeOutputOptionsElement.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValueTest.java new file mode 100644 index 00000000000..2fe57d4f586 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValueTest.java @@ -0,0 +1,171 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElementValue model. */ +public class DialogNodeOutputOptionsElementValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElementValue() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + java.util.Arrays.asList(runtimeEntityModel)); + + String json = TestUtilities.serialize(dialogNodeOutputOptionsElementValueModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModelNew = + TestUtilities.deserialize(json, DialogNodeOutputOptionsElementValue.class); + assertTrue( + dialogNodeOutputOptionsElementValueModelNew instanceof DialogNodeOutputOptionsElementValue); + assertEquals( + dialogNodeOutputOptionsElementValueModelNew.input().toString(), + messageInputModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTest.java new file mode 100644 index 00000000000..1d26581aedd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTest.java @@ -0,0 +1,91 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutput model. */ +public class DialogNodeOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutput() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(dialogNodeOutputModel); + + DialogNodeOutput dialogNodeOutputModelNew = + TestUtilities.deserialize(json, DialogNodeOutput.class); + assertTrue(dialogNodeOutputModelNew instanceof DialogNodeOutput); + assertEquals( + dialogNodeOutputModelNew.getModifiers().toString(), + dialogNodeOutputModifiersModel.toString()); + assertEquals(dialogNodeOutputModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElementTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElementTest.java new file mode 100644 index 00000000000..6e76ba0d3b6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElementTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputTextValuesElement model. */ +public class DialogNodeOutputTextValuesElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputTextValuesElement() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + String json = TestUtilities.serialize(dialogNodeOutputTextValuesElementModel); + + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModelNew = + TestUtilities.deserialize(json, DialogNodeOutputTextValuesElement.class); + assertTrue( + dialogNodeOutputTextValuesElementModelNew instanceof DialogNodeOutputTextValuesElement); + assertEquals(dialogNodeOutputTextValuesElementModelNew.text(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeTest.java new file mode 100644 index 00000000000..44cd564430e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeTest.java @@ -0,0 +1,193 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNode model. */ +public class DialogNodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNode() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals(dialogNodeModel.actions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(dialogNodeModel); + + DialogNode dialogNodeModelNew = TestUtilities.deserialize(json, DialogNode.class); + assertTrue(dialogNodeModelNew instanceof DialogNode); + assertEquals(dialogNodeModelNew.dialogNode(), "testString"); + assertEquals(dialogNodeModelNew.description(), "testString"); + assertEquals(dialogNodeModelNew.conditions(), "testString"); + assertEquals(dialogNodeModelNew.parent(), "testString"); + assertEquals(dialogNodeModelNew.previousSibling(), "testString"); + assertEquals(dialogNodeModelNew.output().toString(), dialogNodeOutputModel.toString()); + assertEquals(dialogNodeModelNew.context().toString(), dialogNodeContextModel.toString()); + assertEquals( + dialogNodeModelNew.metadata().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(dialogNodeModelNew.nextStep().toString(), dialogNodeNextStepModel.toString()); + assertEquals(dialogNodeModelNew.title(), "testString"); + assertEquals(dialogNodeModelNew.type(), "standard"); + assertEquals(dialogNodeModelNew.eventName(), "focus"); + assertEquals(dialogNodeModelNew.variable(), "testString"); + assertEquals(dialogNodeModelNew.digressIn(), "not_available"); + assertEquals(dialogNodeModelNew.digressOut(), "allow_returning"); + assertEquals(dialogNodeModelNew.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModelNew.userLabel(), "testString"); + assertEquals(dialogNodeModelNew.disambiguationOptOut(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeError() throws Throwable { + new DialogNode.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetailsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetailsTest.java new file mode 100644 index 00000000000..0bd486d3d2a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetailsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeVisitedDetails model. */ +public class DialogNodeVisitedDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeVisitedDetails() throws Throwable { + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + String json = TestUtilities.serialize(dialogNodeVisitedDetailsModel); + + DialogNodeVisitedDetails dialogNodeVisitedDetailsModelNew = + TestUtilities.deserialize(json, DialogNodeVisitedDetails.class); + assertTrue(dialogNodeVisitedDetailsModelNew instanceof DialogNodeVisitedDetails); + assertEquals(dialogNodeVisitedDetailsModelNew.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModelNew.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModelNew.conditions(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionTest.java new file mode 100644 index 00000000000..56d3f7d5246 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionTest.java @@ -0,0 +1,189 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestion model. */ +public class DialogSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestion() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogSuggestionValue dialogSuggestionValueModel = + new DialogSuggestionValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogSuggestionValueModel.input(), messageInputModel); + assertEquals(dialogSuggestionValueModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogSuggestionValueModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + + DialogSuggestion dialogSuggestionModel = + new DialogSuggestion.Builder() + .label("testString") + .value(dialogSuggestionValueModel) + .output(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogNode("testString") + .build(); + assertEquals(dialogSuggestionModel.label(), "testString"); + assertEquals(dialogSuggestionModel.value(), dialogSuggestionValueModel); + assertEquals( + dialogSuggestionModel.output(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogSuggestionModel.dialogNode(), "testString"); + + String json = TestUtilities.serialize(dialogSuggestionModel); + + DialogSuggestion dialogSuggestionModelNew = + TestUtilities.deserialize(json, DialogSuggestion.class); + assertTrue(dialogSuggestionModelNew instanceof DialogSuggestion); + assertEquals(dialogSuggestionModelNew.label(), "testString"); + assertEquals( + dialogSuggestionModelNew.value().toString(), dialogSuggestionValueModel.toString()); + assertEquals( + dialogSuggestionModelNew.output().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(dialogSuggestionModelNew.dialogNode(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogSuggestionError() throws Throwable { + new DialogSuggestion.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValueTest.java new file mode 100644 index 00000000000..52bb935147a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValueTest.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestionValue model. */ +public class DialogSuggestionValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestionValue() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogSuggestionValue dialogSuggestionValueModel = + new DialogSuggestionValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogSuggestionValueModel.input(), messageInputModel); + assertEquals(dialogSuggestionValueModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogSuggestionValueModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + + String json = TestUtilities.serialize(dialogSuggestionValueModel); + + DialogSuggestionValue dialogSuggestionValueModelNew = + TestUtilities.deserialize(json, DialogSuggestionValue.class); + assertTrue(dialogSuggestionValueModelNew instanceof DialogSuggestionValue); + assertEquals(dialogSuggestionValueModelNew.input().toString(), messageInputModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityCollectionTest.java new file mode 100644 index 00000000000..51329a0b15a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityCollection model. */ +public class EntityCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityCollection() throws Throwable { + EntityCollection entityCollectionModel = new EntityCollection(); + assertNull(entityCollectionModel.getEntities()); + assertNull(entityCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionCollectionTest.java new file mode 100644 index 00000000000..520cf6a1455 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityMentionCollection model. */ +public class EntityMentionCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityMentionCollection() throws Throwable { + EntityMentionCollection entityMentionCollectionModel = new EntityMentionCollection(); + assertNull(entityMentionCollectionModel.getExamples()); + assertNull(entityMentionCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionTest.java new file mode 100644 index 00000000000..ca0f0ff7da3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityMention model. */ +public class EntityMentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityMention() throws Throwable { + EntityMention entityMentionModel = new EntityMention(); + assertNull(entityMentionModel.getText()); + assertNull(entityMentionModel.getIntent()); + assertNull(entityMentionModel.getLocation()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityTest.java new file mode 100644 index 00000000000..c707585f9f9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Entity model. */ +public class EntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntity() throws Throwable { + Entity entityModel = new Entity(); + assertNull(entityModel.getEntity()); + assertNull(entityModel.getDescription()); + assertNull(entityModel.getMetadata()); + assertNull(entityModel.isFuzzyMatch()); + assertNull(entityModel.getValues()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleCollectionTest.java new file mode 100644 index 00000000000..a95f93ca2e2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ExampleCollection model. */ +public class ExampleCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExampleCollection() throws Throwable { + ExampleCollection exampleCollectionModel = new ExampleCollection(); + assertNull(exampleCollectionModel.getExamples()); + assertNull(exampleCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleTest.java new file mode 100644 index 00000000000..96b874b8437 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Example model. */ +public class ExampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExample() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + String json = TestUtilities.serialize(exampleModel); + + Example exampleModelNew = TestUtilities.deserialize(json, Example.class); + assertTrue(exampleModelNew instanceof Example); + assertEquals(exampleModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExampleError() throws Throwable { + new Example.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExportWorkspaceAsyncOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExportWorkspaceAsyncOptionsTest.java new file mode 100644 index 00000000000..9dbac78a1f8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExportWorkspaceAsyncOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ExportWorkspaceAsyncOptions model. */ +public class ExportWorkspaceAsyncOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExportWorkspaceAsyncOptions() throws Throwable { + ExportWorkspaceAsyncOptions exportWorkspaceAsyncOptionsModel = + new ExportWorkspaceAsyncOptions.Builder() + .workspaceId("testString") + .includeAudit(false) + .sort("stable") + .verbose(false) + .build(); + assertEquals(exportWorkspaceAsyncOptionsModel.workspaceId(), "testString"); + assertEquals(exportWorkspaceAsyncOptionsModel.includeAudit(), Boolean.valueOf(false)); + assertEquals(exportWorkspaceAsyncOptionsModel.sort(), "stable"); + assertEquals(exportWorkspaceAsyncOptionsModel.verbose(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExportWorkspaceAsyncOptionsError() throws Throwable { + new ExportWorkspaceAsyncOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptionsTest.java new file mode 100644 index 00000000000..d424181cf1b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCounterexampleOptions model. */ +public class GetCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCounterexampleOptions() throws Throwable { + GetCounterexampleOptions getCounterexampleOptionsModel = + new GetCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(false) + .build(); + assertEquals(getCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(getCounterexampleOptionsModel.text(), "testString"); + assertEquals(getCounterexampleOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCounterexampleOptionsError() throws Throwable { + new GetCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptionsTest.java new file mode 100644 index 00000000000..2f6a6c92a50 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDialogNodeOptions model. */ +public class GetDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDialogNodeOptions() throws Throwable { + GetDialogNodeOptions getDialogNodeOptionsModel = + new GetDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .includeAudit(false) + .build(); + assertEquals(getDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(getDialogNodeOptionsModel.dialogNode(), "testString"); + assertEquals(getDialogNodeOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDialogNodeOptionsError() throws Throwable { + new GetDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetEntityOptionsTest.java new file mode 100644 index 00000000000..91fd0a12e60 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetEntityOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetEntityOptions model. */ +public class GetEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetEntityOptions() throws Throwable { + GetEntityOptions getEntityOptionsModel = + new GetEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(false) + .includeAudit(false) + .build(); + assertEquals(getEntityOptionsModel.workspaceId(), "testString"); + assertEquals(getEntityOptionsModel.entity(), "testString"); + assertEquals(getEntityOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(getEntityOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEntityOptionsError() throws Throwable { + new GetEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetExampleOptionsTest.java new file mode 100644 index 00000000000..5cd9ebe1804 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetExampleOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetExampleOptions model. */ +public class GetExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetExampleOptions() throws Throwable { + GetExampleOptions getExampleOptionsModel = + new GetExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .includeAudit(false) + .build(); + assertEquals(getExampleOptionsModel.workspaceId(), "testString"); + assertEquals(getExampleOptionsModel.intent(), "testString"); + assertEquals(getExampleOptionsModel.text(), "testString"); + assertEquals(getExampleOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetExampleOptionsError() throws Throwable { + new GetExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetIntentOptionsTest.java new file mode 100644 index 00000000000..41be179224d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetIntentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetIntentOptions model. */ +public class GetIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetIntentOptions() throws Throwable { + GetIntentOptions getIntentOptionsModel = + new GetIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .export(false) + .includeAudit(false) + .build(); + assertEquals(getIntentOptionsModel.workspaceId(), "testString"); + assertEquals(getIntentOptionsModel.intent(), "testString"); + assertEquals(getIntentOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(getIntentOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetIntentOptionsError() throws Throwable { + new GetIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetSynonymOptionsTest.java new file mode 100644 index 00000000000..601c17eb864 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetSynonymOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetSynonymOptions model. */ +public class GetSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetSynonymOptions() throws Throwable { + GetSynonymOptions getSynonymOptionsModel = + new GetSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(false) + .build(); + assertEquals(getSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(getSynonymOptionsModel.entity(), "testString"); + assertEquals(getSynonymOptionsModel.value(), "testString"); + assertEquals(getSynonymOptionsModel.synonym(), "testString"); + assertEquals(getSynonymOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSynonymOptionsError() throws Throwable { + new GetSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetValueOptionsTest.java new file mode 100644 index 00000000000..c50b3d924d4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetValueOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetValueOptions model. */ +public class GetValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetValueOptions() throws Throwable { + GetValueOptions getValueOptionsModel = + new GetValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .export(false) + .includeAudit(false) + .build(); + assertEquals(getValueOptionsModel.workspaceId(), "testString"); + assertEquals(getValueOptionsModel.entity(), "testString"); + assertEquals(getValueOptionsModel.value(), "testString"); + assertEquals(getValueOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(getValueOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetValueOptionsError() throws Throwable { + new GetValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptionsTest.java new file mode 100644 index 00000000000..8d24040730b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetWorkspaceOptions model. */ +public class GetWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetWorkspaceOptions() throws Throwable { + GetWorkspaceOptions getWorkspaceOptionsModel = + new GetWorkspaceOptions.Builder() + .workspaceId("testString") + .export(false) + .includeAudit(false) + .sort("stable") + .build(); + assertEquals(getWorkspaceOptionsModel.workspaceId(), "testString"); + assertEquals(getWorkspaceOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(getWorkspaceOptionsModel.includeAudit(), Boolean.valueOf(false)); + assertEquals(getWorkspaceOptionsModel.sort(), "stable"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWorkspaceOptionsError() throws Throwable { + new GetWorkspaceOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentCollectionTest.java new file mode 100644 index 00000000000..7325ad1f0fe --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IntentCollection model. */ +public class IntentCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIntentCollection() throws Throwable { + IntentCollection intentCollectionModel = new IntentCollection(); + assertNull(intentCollectionModel.getIntents()); + assertNull(intentCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentTest.java new file mode 100644 index 00000000000..e2969aa0402 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Intent model. */ +public class IntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIntent() throws Throwable { + Intent intentModel = new Intent(); + assertNull(intentModel.getIntent()); + assertNull(intentModel.getDescription()); + assertNull(intentModel.getExamples()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptionsTest.java new file mode 100644 index 00000000000..1bfa1dc7d58 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAllLogsOptions model. */ +public class ListAllLogsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAllLogsOptions() throws Throwable { + ListAllLogsOptions listAllLogsOptionsModel = + new ListAllLogsOptions.Builder() + .filter("testString") + .sort("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .build(); + assertEquals(listAllLogsOptionsModel.filter(), "testString"); + assertEquals(listAllLogsOptionsModel.sort(), "testString"); + assertEquals(listAllLogsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listAllLogsOptionsModel.cursor(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAllLogsOptionsError() throws Throwable { + new ListAllLogsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptionsTest.java new file mode 100644 index 00000000000..dddfbde8890 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCounterexamplesOptions model. */ +public class ListCounterexamplesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCounterexamplesOptions() throws Throwable { + ListCounterexamplesOptions listCounterexamplesOptionsModel = + new ListCounterexamplesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("text") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listCounterexamplesOptionsModel.workspaceId(), "testString"); + assertEquals(listCounterexamplesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listCounterexamplesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listCounterexamplesOptionsModel.sort(), "text"); + assertEquals(listCounterexamplesOptionsModel.cursor(), "testString"); + assertEquals(listCounterexamplesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCounterexamplesOptionsError() throws Throwable { + new ListCounterexamplesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptionsTest.java new file mode 100644 index 00000000000..c4e7e46f4f6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDialogNodesOptions model. */ +public class ListDialogNodesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDialogNodesOptions() throws Throwable { + ListDialogNodesOptions listDialogNodesOptionsModel = + new ListDialogNodesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("dialog_node") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listDialogNodesOptionsModel.workspaceId(), "testString"); + assertEquals(listDialogNodesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listDialogNodesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listDialogNodesOptionsModel.sort(), "dialog_node"); + assertEquals(listDialogNodesOptionsModel.cursor(), "testString"); + assertEquals(listDialogNodesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDialogNodesOptionsError() throws Throwable { + new ListDialogNodesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptionsTest.java new file mode 100644 index 00000000000..8c20a6aea10 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEntitiesOptions model. */ +public class ListEntitiesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEntitiesOptions() throws Throwable { + ListEntitiesOptions listEntitiesOptionsModel = + new ListEntitiesOptions.Builder() + .workspaceId("testString") + .export(false) + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("entity") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listEntitiesOptionsModel.workspaceId(), "testString"); + assertEquals(listEntitiesOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(listEntitiesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listEntitiesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listEntitiesOptionsModel.sort(), "entity"); + assertEquals(listEntitiesOptionsModel.cursor(), "testString"); + assertEquals(listEntitiesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEntitiesOptionsError() throws Throwable { + new ListEntitiesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListExamplesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListExamplesOptionsTest.java new file mode 100644 index 00000000000..59343f810d0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListExamplesOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListExamplesOptions model. */ +public class ListExamplesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListExamplesOptions() throws Throwable { + ListExamplesOptions listExamplesOptionsModel = + new ListExamplesOptions.Builder() + .workspaceId("testString") + .intent("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("text") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listExamplesOptionsModel.workspaceId(), "testString"); + assertEquals(listExamplesOptionsModel.intent(), "testString"); + assertEquals(listExamplesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listExamplesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listExamplesOptionsModel.sort(), "text"); + assertEquals(listExamplesOptionsModel.cursor(), "testString"); + assertEquals(listExamplesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExamplesOptionsError() throws Throwable { + new ListExamplesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListIntentsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListIntentsOptionsTest.java new file mode 100644 index 00000000000..3c8dd54b3f9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListIntentsOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListIntentsOptions model. */ +public class ListIntentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListIntentsOptions() throws Throwable { + ListIntentsOptions listIntentsOptionsModel = + new ListIntentsOptions.Builder() + .workspaceId("testString") + .export(false) + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("intent") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listIntentsOptionsModel.workspaceId(), "testString"); + assertEquals(listIntentsOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(listIntentsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listIntentsOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listIntentsOptionsModel.sort(), "intent"); + assertEquals(listIntentsOptionsModel.cursor(), "testString"); + assertEquals(listIntentsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListIntentsOptionsError() throws Throwable { + new ListIntentsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListLogsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListLogsOptionsTest.java new file mode 100644 index 00000000000..45612f0680d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListLogsOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLogsOptions model. */ +public class ListLogsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLogsOptions() throws Throwable { + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .workspaceId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .build(); + assertEquals(listLogsOptionsModel.workspaceId(), "testString"); + assertEquals(listLogsOptionsModel.sort(), "testString"); + assertEquals(listLogsOptionsModel.filter(), "testString"); + assertEquals(listLogsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listLogsOptionsModel.cursor(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsOptionsError() throws Throwable { + new ListLogsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListMentionsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListMentionsOptionsTest.java new file mode 100644 index 00000000000..11b6eb18562 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListMentionsOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListMentionsOptions model. */ +public class ListMentionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListMentionsOptions() throws Throwable { + ListMentionsOptions listMentionsOptionsModel = + new ListMentionsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(false) + .includeAudit(false) + .build(); + assertEquals(listMentionsOptionsModel.workspaceId(), "testString"); + assertEquals(listMentionsOptionsModel.entity(), "testString"); + assertEquals(listMentionsOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(listMentionsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListMentionsOptionsError() throws Throwable { + new ListMentionsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptionsTest.java new file mode 100644 index 00000000000..d9f372e30ee --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListSynonymsOptions model. */ +public class ListSynonymsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListSynonymsOptions() throws Throwable { + ListSynonymsOptions listSynonymsOptionsModel = + new ListSynonymsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("synonym") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listSynonymsOptionsModel.workspaceId(), "testString"); + assertEquals(listSynonymsOptionsModel.entity(), "testString"); + assertEquals(listSynonymsOptionsModel.value(), "testString"); + assertEquals(listSynonymsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listSynonymsOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listSynonymsOptionsModel.sort(), "synonym"); + assertEquals(listSynonymsOptionsModel.cursor(), "testString"); + assertEquals(listSynonymsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListSynonymsOptionsError() throws Throwable { + new ListSynonymsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListValuesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListValuesOptionsTest.java new file mode 100644 index 00000000000..5a65f22aaff --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListValuesOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListValuesOptions model. */ +public class ListValuesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListValuesOptions() throws Throwable { + ListValuesOptions listValuesOptionsModel = + new ListValuesOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(false) + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("value") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listValuesOptionsModel.workspaceId(), "testString"); + assertEquals(listValuesOptionsModel.entity(), "testString"); + assertEquals(listValuesOptionsModel.export(), Boolean.valueOf(false)); + assertEquals(listValuesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listValuesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listValuesOptionsModel.sort(), "value"); + assertEquals(listValuesOptionsModel.cursor(), "testString"); + assertEquals(listValuesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListValuesOptionsError() throws Throwable { + new ListValuesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptionsTest.java new file mode 100644 index 00000000000..445ce074a1a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListWorkspacesOptions model. */ +public class ListWorkspacesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListWorkspacesOptions() throws Throwable { + ListWorkspacesOptions listWorkspacesOptionsModel = + new ListWorkspacesOptions.Builder() + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listWorkspacesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listWorkspacesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listWorkspacesOptionsModel.sort(), "name"); + assertEquals(listWorkspacesOptionsModel.cursor(), "testString"); + assertEquals(listWorkspacesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogCollectionTest.java new file mode 100644 index 00000000000..0b07e77e869 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogCollection model. */ +public class LogCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogCollection() throws Throwable { + LogCollection logCollectionModel = new LogCollection(); + assertNull(logCollectionModel.getLogs()); + assertNull(logCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageSourceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageSourceTest.java new file mode 100644 index 00000000000..817d2d33b70 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageSourceTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessageSource model. */ +public class LogMessageSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessageSource() throws Throwable { + LogMessageSource logMessageSourceModel = + new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build(); + assertEquals(logMessageSourceModel.type(), "dialog_node"); + assertEquals(logMessageSourceModel.dialogNode(), "testString"); + + String json = TestUtilities.serialize(logMessageSourceModel); + + LogMessageSource logMessageSourceModelNew = + TestUtilities.deserialize(json, LogMessageSource.class); + assertTrue(logMessageSourceModelNew instanceof LogMessageSource); + assertEquals(logMessageSourceModelNew.type(), "dialog_node"); + assertEquals(logMessageSourceModelNew.dialogNode(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageTest.java new file mode 100644 index 00000000000..8e069d3ccb7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessage model. */ +public class LogMessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessage() throws Throwable { + LogMessageSource logMessageSourceModel = + new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build(); + assertEquals(logMessageSourceModel.type(), "dialog_node"); + assertEquals(logMessageSourceModel.dialogNode(), "testString"); + + LogMessage logMessageModel = + new LogMessage.Builder() + .level("info") + .msg("testString") + .code("testString") + .source(logMessageSourceModel) + .build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + assertEquals(logMessageModel.code(), "testString"); + assertEquals(logMessageModel.source(), logMessageSourceModel); + + String json = TestUtilities.serialize(logMessageModel); + + LogMessage logMessageModelNew = TestUtilities.deserialize(json, LogMessage.class); + assertTrue(logMessageModelNew instanceof LogMessage); + assertEquals(logMessageModelNew.level(), "info"); + assertEquals(logMessageModelNew.msg(), "testString"); + assertEquals(logMessageModelNew.code(), "testString"); + assertEquals(logMessageModelNew.source().toString(), logMessageSourceModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testLogMessageError() throws Throwable { + new LogMessage.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogPaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogPaginationTest.java new file mode 100644 index 00000000000..68a794c3e7b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogPaginationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogPagination model. */ +public class LogPaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogPagination() throws Throwable { + LogPagination logPaginationModel = new LogPagination(); + assertNull(logPaginationModel.getNextUrl()); + assertNull(logPaginationModel.getMatched()); + assertNull(logPaginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogTest.java new file mode 100644 index 00000000000..05e878467f6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Log model. */ +public class LogTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLog() throws Throwable { + Log logModel = new Log(); + assertNull(logModel.getRequest()); + assertNull(logModel.getResponse()); + assertNull(logModel.getLogId()); + assertNull(logModel.getRequestTimestamp()); + assertNull(logModel.getResponseTimestamp()); + assertNull(logModel.getWorkspaceId()); + assertNull(logModel.getLanguage()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MentionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MentionTest.java new file mode 100644 index 00000000000..f4ec6b615ad --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MentionTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Mention model. */ +public class MentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMention() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + String json = TestUtilities.serialize(mentionModel); + + Mention mentionModelNew = TestUtilities.deserialize(json, Mention.class); + assertTrue(mentionModelNew instanceof Mention); + assertEquals(mentionModelNew.entity(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMentionError() throws Throwable { + new Mention.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageContextMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageContextMetadataTest.java new file mode 100644 index 00000000000..452986f59be --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageContextMetadataTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextMetadata model. */ +public class MessageContextMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextMetadata() throws Throwable { + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + String json = TestUtilities.serialize(messageContextMetadataModel); + + MessageContextMetadata messageContextMetadataModelNew = + TestUtilities.deserialize(json, MessageContextMetadata.class); + assertTrue(messageContextMetadataModelNew instanceof MessageContextMetadata); + assertEquals(messageContextMetadataModelNew.deployment(), "testString"); + assertEquals(messageContextMetadataModelNew.userId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageInputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageInputTest.java new file mode 100644 index 00000000000..e0217f42e4e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageInputTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInput model. */ +public class MessageInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInput() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(messageInputModel); + + MessageInput messageInputModelNew = TestUtilities.deserialize(json, MessageInput.class); + assertTrue(messageInputModelNew instanceof MessageInput); + assertEquals(messageInputModelNew.getText(), "testString"); + assertEquals(messageInputModelNew.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModelNew.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageOptionsTest.java new file mode 100644 index 00000000000..b5233350c63 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageOptionsTest.java @@ -0,0 +1,252 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOptions model. */ +public class MessageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOptions() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system(java.util.Collections.singletonMap("anyKey", "anyValue")) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + assertEquals(contextModel.getConversationId(), "testString"); + assertEquals( + contextModel.getSystem(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(contextModel.getMetadata(), messageContextMetadataModel); + assertEquals(contextModel.get("foo"), "testString"); + + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + LogMessageSource logMessageSourceModel = + new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build(); + assertEquals(logMessageSourceModel.type(), "dialog_node"); + assertEquals(logMessageSourceModel.dialogNode(), "testString"); + + LogMessage logMessageModel = + new LogMessage.Builder() + .level("info") + .msg("testString") + .code("testString") + .source(logMessageSourceModel) + .build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + assertEquals(logMessageModel.code(), "testString"); + assertEquals(logMessageModel.source(), logMessageSourceModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeText runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeText.Builder() + .responseType("text") + .text("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericModel.responseType(), "text"); + assertEquals(runtimeResponseGenericModel.text(), "testString"); + assertEquals( + runtimeResponseGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(java.util.Arrays.asList("testString")) + .nodesVisitedDetails(java.util.Arrays.asList(dialogNodeVisitedDetailsModel)) + .logMessages(java.util.Arrays.asList(logMessageModel)) + .generic(java.util.Arrays.asList(runtimeResponseGenericModel)) + .add("foo", "testString") + .build(); + assertEquals(outputDataModel.getNodesVisited(), java.util.Arrays.asList("testString")); + assertEquals( + outputDataModel.getNodesVisitedDetails(), + java.util.Arrays.asList(dialogNodeVisitedDetailsModel)); + assertEquals(outputDataModel.getLogMessages(), java.util.Arrays.asList(logMessageModel)); + assertEquals( + outputDataModel.getGeneric(), java.util.Arrays.asList(runtimeResponseGenericModel)); + assertEquals(outputDataModel.get("foo"), "testString"); + + MessageOptions messageOptionsModel = + new MessageOptions.Builder() + .workspaceId("testString") + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .alternateIntents(false) + .context(contextModel) + .output(outputDataModel) + .userId("testString") + .nodesVisitedDetails(false) + .build(); + assertEquals(messageOptionsModel.workspaceId(), "testString"); + assertEquals(messageOptionsModel.input(), messageInputModel); + assertEquals(messageOptionsModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(messageOptionsModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(messageOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageOptionsModel.context(), contextModel); + assertEquals(messageOptionsModel.output(), outputDataModel); + assertEquals(messageOptionsModel.userId(), "testString"); + assertEquals(messageOptionsModel.nodesVisitedDetails(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageOptionsError() throws Throwable { + new MessageOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageRequestTest.java new file mode 100644 index 00000000000..3972bb243a6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageRequestTest.java @@ -0,0 +1,253 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageRequest model. */ +public class MessageRequestTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageRequest() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system(java.util.Collections.singletonMap("anyKey", "anyValue")) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + assertEquals(contextModel.getConversationId(), "testString"); + assertEquals( + contextModel.getSystem(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(contextModel.getMetadata(), messageContextMetadataModel); + assertEquals(contextModel.get("foo"), "testString"); + + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + LogMessageSource logMessageSourceModel = + new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build(); + assertEquals(logMessageSourceModel.type(), "dialog_node"); + assertEquals(logMessageSourceModel.dialogNode(), "testString"); + + LogMessage logMessageModel = + new LogMessage.Builder() + .level("info") + .msg("testString") + .code("testString") + .source(logMessageSourceModel) + .build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + assertEquals(logMessageModel.code(), "testString"); + assertEquals(logMessageModel.source(), logMessageSourceModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeText runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeText.Builder() + .responseType("text") + .text("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericModel.responseType(), "text"); + assertEquals(runtimeResponseGenericModel.text(), "testString"); + assertEquals( + runtimeResponseGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(java.util.Arrays.asList("testString")) + .nodesVisitedDetails(java.util.Arrays.asList(dialogNodeVisitedDetailsModel)) + .logMessages(java.util.Arrays.asList(logMessageModel)) + .generic(java.util.Arrays.asList(runtimeResponseGenericModel)) + .add("foo", "testString") + .build(); + assertEquals(outputDataModel.getNodesVisited(), java.util.Arrays.asList("testString")); + assertEquals( + outputDataModel.getNodesVisitedDetails(), + java.util.Arrays.asList(dialogNodeVisitedDetailsModel)); + assertEquals(outputDataModel.getLogMessages(), java.util.Arrays.asList(logMessageModel)); + assertEquals( + outputDataModel.getGeneric(), java.util.Arrays.asList(runtimeResponseGenericModel)); + assertEquals(outputDataModel.get("foo"), "testString"); + + MessageRequest messageRequestModel = + new MessageRequest.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .alternateIntents(false) + .context(contextModel) + .output(outputDataModel) + .userId("testString") + .build(); + assertEquals(messageRequestModel.input(), messageInputModel); + assertEquals(messageRequestModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(messageRequestModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(messageRequestModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageRequestModel.context(), contextModel); + assertEquals(messageRequestModel.output(), outputDataModel); + assertEquals(messageRequestModel.userId(), "testString"); + + String json = TestUtilities.serialize(messageRequestModel); + + MessageRequest messageRequestModelNew = TestUtilities.deserialize(json, MessageRequest.class); + assertTrue(messageRequestModelNew instanceof MessageRequest); + assertEquals(messageRequestModelNew.input().toString(), messageInputModel.toString()); + assertEquals(messageRequestModelNew.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageRequestModelNew.context().toString(), contextModel.toString()); + assertEquals(messageRequestModelNew.output().toString(), outputDataModel.toString()); + assertEquals(messageRequestModelNew.userId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageResponseTest.java new file mode 100644 index 00000000000..805f19ac76c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageResponseTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageResponse model. */ +public class MessageResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageResponse() throws Throwable { + MessageResponse messageResponseModel = new MessageResponse(); + assertNull(messageResponseModel.getInput()); + assertNull(messageResponseModel.getIntents()); + assertNull(messageResponseModel.getEntities()); + assertNull(messageResponseModel.isAlternateIntents()); + assertNull(messageResponseModel.getContext()); + assertNull(messageResponseModel.getOutput()); + assertNull(messageResponseModel.getUserId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/OutputDataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/OutputDataTest.java new file mode 100644 index 00000000000..f9eefb2a9fd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/OutputDataTest.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the OutputData model. */ +public class OutputDataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testOutputData() throws Throwable { + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + LogMessageSource logMessageSourceModel = + new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build(); + assertEquals(logMessageSourceModel.type(), "dialog_node"); + assertEquals(logMessageSourceModel.dialogNode(), "testString"); + + LogMessage logMessageModel = + new LogMessage.Builder() + .level("info") + .msg("testString") + .code("testString") + .source(logMessageSourceModel) + .build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + assertEquals(logMessageModel.code(), "testString"); + assertEquals(logMessageModel.source(), logMessageSourceModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeText runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeText.Builder() + .responseType("text") + .text("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericModel.responseType(), "text"); + assertEquals(runtimeResponseGenericModel.text(), "testString"); + assertEquals( + runtimeResponseGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(java.util.Arrays.asList("testString")) + .nodesVisitedDetails(java.util.Arrays.asList(dialogNodeVisitedDetailsModel)) + .logMessages(java.util.Arrays.asList(logMessageModel)) + .generic(java.util.Arrays.asList(runtimeResponseGenericModel)) + .add("foo", "testString") + .build(); + assertEquals(outputDataModel.getNodesVisited(), java.util.Arrays.asList("testString")); + assertEquals( + outputDataModel.getNodesVisitedDetails(), + java.util.Arrays.asList(dialogNodeVisitedDetailsModel)); + assertEquals(outputDataModel.getLogMessages(), java.util.Arrays.asList(logMessageModel)); + assertEquals( + outputDataModel.getGeneric(), java.util.Arrays.asList(runtimeResponseGenericModel)); + assertEquals(outputDataModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(outputDataModel); + + OutputData outputDataModelNew = TestUtilities.deserialize(json, OutputData.class); + assertTrue(outputDataModelNew instanceof OutputData); + assertEquals(outputDataModelNew.get("foo"), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testOutputDataError() throws Throwable { + new OutputData.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/PaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/PaginationTest.java new file mode 100644 index 00000000000..a0c812a84b8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/PaginationTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Pagination model. */ +public class PaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPagination() throws Throwable { + Pagination paginationModel = new Pagination(); + assertNull(paginationModel.getRefreshUrl()); + assertNull(paginationModel.getNextUrl()); + assertNull(paginationModel.getTotal()); + assertNull(paginationModel.getMatched()); + assertNull(paginationModel.getRefreshCursor()); + assertNull(paginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ResponseGenericChannelTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ResponseGenericChannelTest.java new file mode 100644 index 00000000000..9ac6623cfb3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ResponseGenericChannelTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResponseGenericChannel model. */ +public class ResponseGenericChannelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResponseGenericChannel() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + String json = TestUtilities.serialize(responseGenericChannelModel); + + ResponseGenericChannel responseGenericChannelModelNew = + TestUtilities.deserialize(json, ResponseGenericChannel.class); + assertTrue(responseGenericChannelModelNew instanceof ResponseGenericChannel); + assertEquals(responseGenericChannelModelNew.channel(), "chat"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternativeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternativeTest.java new file mode 100644 index 00000000000..2eb058e5009 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternativeTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityAlternative model. */ +public class RuntimeEntityAlternativeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityAlternative() throws Throwable { + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeEntityAlternativeModel); + + RuntimeEntityAlternative runtimeEntityAlternativeModelNew = + TestUtilities.deserialize(json, RuntimeEntityAlternative.class); + assertTrue(runtimeEntityAlternativeModelNew instanceof RuntimeEntityAlternative); + assertEquals(runtimeEntityAlternativeModelNew.value(), "testString"); + assertEquals(runtimeEntityAlternativeModelNew.confidence(), Double.valueOf("72.5")); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretationTest.java new file mode 100644 index 00000000000..e0f9570575f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretationTest.java @@ -0,0 +1,121 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityInterpretation model. */ +public class RuntimeEntityInterpretationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityInterpretation() throws Throwable { + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + String json = TestUtilities.serialize(runtimeEntityInterpretationModel); + + RuntimeEntityInterpretation runtimeEntityInterpretationModelNew = + TestUtilities.deserialize(json, RuntimeEntityInterpretation.class); + assertTrue(runtimeEntityInterpretationModelNew instanceof RuntimeEntityInterpretation); + assertEquals(runtimeEntityInterpretationModelNew.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModelNew.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.timezone(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRoleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRoleTest.java new file mode 100644 index 00000000000..e63705f19b6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRoleTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityRole model. */ +public class RuntimeEntityRoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityRole() throws Throwable { + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + String json = TestUtilities.serialize(runtimeEntityRoleModel); + + RuntimeEntityRole runtimeEntityRoleModelNew = + TestUtilities.deserialize(json, RuntimeEntityRole.class); + assertTrue(runtimeEntityRoleModelNew instanceof RuntimeEntityRole); + assertEquals(runtimeEntityRoleModelNew.type(), "date_from"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityTest.java new file mode 100644 index 00000000000..f3ba8fe9e74 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityTest.java @@ -0,0 +1,147 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntity model. */ +public class RuntimeEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntity() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + String json = TestUtilities.serialize(runtimeEntityModel); + + RuntimeEntity runtimeEntityModelNew = TestUtilities.deserialize(json, RuntimeEntity.class); + assertTrue(runtimeEntityModelNew instanceof RuntimeEntity); + assertEquals(runtimeEntityModelNew.entity(), "testString"); + assertEquals(runtimeEntityModelNew.value(), "testString"); + assertEquals(runtimeEntityModelNew.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModelNew.interpretation().toString(), + runtimeEntityInterpretationModel.toString()); + assertEquals(runtimeEntityModelNew.role().toString(), runtimeEntityRoleModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeEntityError() throws Throwable { + new RuntimeEntity.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeIntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeIntentTest.java new file mode 100644 index 00000000000..e7c1fd0acf2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeIntentTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeIntent model. */ +public class RuntimeIntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeIntent() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeIntentModel); + + RuntimeIntent runtimeIntentModelNew = TestUtilities.deserialize(json, RuntimeIntent.class); + assertTrue(runtimeIntentModelNew instanceof RuntimeIntent); + assertEquals(runtimeIntentModelNew.intent(), "testString"); + assertEquals(runtimeIntentModelNew.confidence(), Double.valueOf("72.5")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeIntentError() throws Throwable { + new RuntimeIntent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeAudioTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeAudioTest.java new file mode 100644 index 00000000000..391721b90c8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeAudioTest.java @@ -0,0 +1,83 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeAudio model. */ +public class RuntimeResponseGenericRuntimeResponseTypeAudioTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeAudio() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeAudio + runtimeResponseGenericRuntimeResponseTypeAudioModel = + new RuntimeResponseGenericRuntimeResponseTypeAudio.Builder() + .responseType("audio") + .source("testString") + .title("testString") + .description("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .channelOptions(java.util.Collections.singletonMap("anyKey", "anyValue")) + .altText("testString") + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModel.responseType(), "audio"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModel.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModel.description(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeAudioModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeAudioModel.channelOptions(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModel.altText(), "testString"); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeAudioModel); + + RuntimeResponseGenericRuntimeResponseTypeAudio + runtimeResponseGenericRuntimeResponseTypeAudioModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeAudio.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeAudioModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeAudio); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModelNew.responseType(), "audio"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModelNew.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeAudioModelNew.description(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeAudioModelNew.channelOptions().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(runtimeResponseGenericRuntimeResponseTypeAudioModelNew.altText(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeAudioError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeAudio.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest.java new file mode 100644 index 00000000000..b4b7d01d4d6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest.java @@ -0,0 +1,95 @@ +/* + * (C) Copyright IBM Corp. 2021, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer model. */ +public class RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeChannelTransfer() throws Throwable { + ChannelTransferTargetChat channelTransferTargetChatModel = + new ChannelTransferTargetChat.Builder().url("testString").build(); + assertEquals(channelTransferTargetChatModel.url(), "testString"); + + ChannelTransferTarget channelTransferTargetModel = + new ChannelTransferTarget.Builder().chat(channelTransferTargetChatModel).build(); + assertEquals(channelTransferTargetModel.chat(), channelTransferTargetChatModel); + + ChannelTransferInfo channelTransferInfoModel = + new ChannelTransferInfo.Builder().target(channelTransferTargetModel).build(); + assertEquals(channelTransferInfoModel.target(), channelTransferTargetModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + runtimeResponseGenericRuntimeResponseTypeChannelTransferModel = + new RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.Builder() + .responseType("channel_transfer") + .messageToUser("testString") + .transferInfo(channelTransferInfoModel) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.responseType(), + "channel_transfer"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.messageToUser(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.transferInfo(), + channelTransferInfoModel); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeChannelTransferModel); + + RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + runtimeResponseGenericRuntimeResponseTypeChannelTransferModelNew = + TestUtilities.deserialize( + json, RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeChannelTransfer); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModelNew.responseType(), + "channel_transfer"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModelNew.messageToUser(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeChannelTransferModelNew.transferInfo().toString(), + channelTransferInfoModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeChannelTransferError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeChannelTransfer.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java new file mode 100644 index 00000000000..5535ab4e9fc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java @@ -0,0 +1,124 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent model. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeConnectToAgent() throws Throwable { + AgentAvailabilityMessage agentAvailabilityMessageModel = + new AgentAvailabilityMessage.Builder().message("testString").build(); + assertEquals(agentAvailabilityMessageModel.message(), "testString"); + + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo.Builder() + .target( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .build(); + assertEquals( + dialogNodeOutputConnectToAgentTransferInfoModel.target(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel = + new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.Builder() + .responseType("connect_to_agent") + .messageToHumanAgent("testString") + .agentAvailable(agentAvailabilityMessageModel) + .agentUnavailable(agentAvailabilityMessageModel) + .transferInfo(dialogNodeOutputConnectToAgentTransferInfoModel) + .topic("testString") + .dialogNode("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.responseType(), + "connect_to_agent"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.messageToHumanAgent(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentAvailable(), + agentAvailabilityMessageModel); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentUnavailable(), + agentAvailabilityMessageModel); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.transferInfo(), + dialogNodeOutputConnectToAgentTransferInfoModel); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.topic(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.dialogNode(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel); + + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew = + TestUtilities.deserialize( + json, RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeConnectToAgent); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.responseType(), + "connect_to_agent"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.messageToHumanAgent(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.agentAvailable().toString(), + agentAvailabilityMessageModel.toString()); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew + .agentUnavailable() + .toString(), + agentAvailabilityMessageModel.toString()); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.transferInfo().toString(), + dialogNodeOutputConnectToAgentTransferInfoModel.toString()); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.topic(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.dialogNode(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeConnectToAgentError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeIframeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeIframeTest.java new file mode 100644 index 00000000000..fe4a298d910 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeIframeTest.java @@ -0,0 +1,76 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeIframe model. */ +public class RuntimeResponseGenericRuntimeResponseTypeIframeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeIframe() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeIframe + runtimeResponseGenericRuntimeResponseTypeIframeModel = + new RuntimeResponseGenericRuntimeResponseTypeIframe.Builder() + .responseType("iframe") + .source("testString") + .title("testString") + .description("testString") + .imageUrl("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModel.responseType(), "iframe"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModel.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModel.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModel.imageUrl(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeIframeModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeIframeModel); + + RuntimeResponseGenericRuntimeResponseTypeIframe + runtimeResponseGenericRuntimeResponseTypeIframeModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeIframe.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeIframeModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeIframe); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModelNew.responseType(), "iframe"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModelNew.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeIframeModelNew.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeIframeModelNew.imageUrl(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeIframeError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeIframe.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java new file mode 100644 index 00000000000..f943ffac04f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java @@ -0,0 +1,76 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeImage model. */ +public class RuntimeResponseGenericRuntimeResponseTypeImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeImage() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeImage + runtimeResponseGenericRuntimeResponseTypeImageModel = + new RuntimeResponseGenericRuntimeResponseTypeImage.Builder() + .responseType("image") + .source("testString") + .title("testString") + .description("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .altText("testString") + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.responseType(), "image"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.description(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeImageModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.altText(), "testString"); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeImageModel); + + RuntimeResponseGenericRuntimeResponseTypeImage + runtimeResponseGenericRuntimeResponseTypeImageModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeImage.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeImageModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeImage); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.responseType(), "image"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeImageModelNew.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.altText(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeImageError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeImage.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java new file mode 100644 index 00000000000..82c45a254f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java @@ -0,0 +1,214 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeOption model. */ +public class RuntimeResponseGenericRuntimeResponseTypeOptionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeOption() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + java.util.Arrays.asList(runtimeEntityModel)); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeOption + runtimeResponseGenericRuntimeResponseTypeOptionModel = + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options(java.util.Arrays.asList(dialogNodeOutputOptionsElementModel)) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.responseType(), "option"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.preference(), "dropdown"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeOptionModel.options(), + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel)); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeOptionModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeOptionModel); + + RuntimeResponseGenericRuntimeResponseTypeOption + runtimeResponseGenericRuntimeResponseTypeOptionModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeOption.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeOptionModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeOption); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModelNew.responseType(), "option"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeOptionModelNew.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModelNew.preference(), "dropdown"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeOptionError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java new file mode 100644 index 00000000000..75fded55374 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypePause model. */ +public class RuntimeResponseGenericRuntimeResponseTypePauseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypePause() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypePause + runtimeResponseGenericRuntimeResponseTypePauseModel = + new RuntimeResponseGenericRuntimeResponseTypePause.Builder() + .responseType("pause") + .time(Long.valueOf("26")) + .typing(true) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModel.responseType(), "pause"); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModel.time(), Long.valueOf("26")); + assertEquals( + runtimeResponseGenericRuntimeResponseTypePauseModel.typing(), Boolean.valueOf(true)); + assertEquals( + runtimeResponseGenericRuntimeResponseTypePauseModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypePauseModel); + + RuntimeResponseGenericRuntimeResponseTypePause + runtimeResponseGenericRuntimeResponseTypePauseModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypePause.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypePauseModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypePause); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModelNew.responseType(), "pause"); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModelNew.time(), Long.valueOf("26")); + assertEquals( + runtimeResponseGenericRuntimeResponseTypePauseModelNew.typing(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypePauseError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypePause.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java new file mode 100644 index 00000000000..09b69b654f6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java @@ -0,0 +1,211 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeSuggestion model. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeSuggestion() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogSuggestionValue dialogSuggestionValueModel = + new DialogSuggestionValue.Builder() + .input(messageInputModel) + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .build(); + assertEquals(dialogSuggestionValueModel.input(), messageInputModel); + assertEquals(dialogSuggestionValueModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + dialogSuggestionValueModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + + DialogSuggestion dialogSuggestionModel = + new DialogSuggestion.Builder() + .label("testString") + .value(dialogSuggestionValueModel) + .output(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogNode("testString") + .build(); + assertEquals(dialogSuggestionModel.label(), "testString"); + assertEquals(dialogSuggestionModel.value(), dialogSuggestionValueModel); + assertEquals( + dialogSuggestionModel.output(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogSuggestionModel.dialogNode(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeSuggestion + runtimeResponseGenericRuntimeResponseTypeSuggestionModel = + new RuntimeResponseGenericRuntimeResponseTypeSuggestion.Builder() + .responseType("suggestion") + .title("testString") + .suggestions(java.util.Arrays.asList(dialogSuggestionModel)) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModel.responseType(), "suggestion"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModel.suggestions(), + java.util.Arrays.asList(dialogSuggestionModel)); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeSuggestionModel); + + RuntimeResponseGenericRuntimeResponseTypeSuggestion + runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew = + TestUtilities.deserialize( + json, RuntimeResponseGenericRuntimeResponseTypeSuggestion.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeSuggestion); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew.responseType(), "suggestion"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew.title(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeSuggestionError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeSuggestion.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java new file mode 100644 index 00000000000..cb0e3afc80f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeText model. */ +public class RuntimeResponseGenericRuntimeResponseTypeTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeText() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeText + runtimeResponseGenericRuntimeResponseTypeTextModel = + new RuntimeResponseGenericRuntimeResponseTypeText.Builder() + .responseType("text") + .text("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModel.responseType(), "text"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModel.text(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeTextModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeTextModel); + + RuntimeResponseGenericRuntimeResponseTypeText + runtimeResponseGenericRuntimeResponseTypeTextModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeText.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeTextModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeText); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModelNew.responseType(), "text"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeTextError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeText.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest.java new file mode 100644 index 00000000000..e358f075877 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest.java @@ -0,0 +1,75 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeUserDefined model. */ +public class RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeUserDefined() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeUserDefined + runtimeResponseGenericRuntimeResponseTypeUserDefinedModel = + new RuntimeResponseGenericRuntimeResponseTypeUserDefined.Builder() + .responseType("user_defined") + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeUserDefinedModel.responseType(), "user_defined"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeUserDefinedModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeUserDefinedModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + String json = + TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeUserDefinedModel); + + RuntimeResponseGenericRuntimeResponseTypeUserDefined + runtimeResponseGenericRuntimeResponseTypeUserDefinedModelNew = + TestUtilities.deserialize( + json, RuntimeResponseGenericRuntimeResponseTypeUserDefined.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeUserDefinedModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeUserDefined); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeUserDefinedModelNew.responseType(), + "user_defined"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeUserDefinedModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeUserDefinedError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeUserDefined.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeVideoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeVideoTest.java new file mode 100644 index 00000000000..afd2a60f335 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeVideoTest.java @@ -0,0 +1,83 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeVideo model. */ +public class RuntimeResponseGenericRuntimeResponseTypeVideoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeVideo() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + RuntimeResponseGenericRuntimeResponseTypeVideo + runtimeResponseGenericRuntimeResponseTypeVideoModel = + new RuntimeResponseGenericRuntimeResponseTypeVideo.Builder() + .responseType("video") + .source("testString") + .title("testString") + .description("testString") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .channelOptions(java.util.Collections.singletonMap("anyKey", "anyValue")) + .altText("testString") + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModel.responseType(), "video"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModel.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModel.description(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeVideoModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeVideoModel.channelOptions(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModel.altText(), "testString"); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeVideoModel); + + RuntimeResponseGenericRuntimeResponseTypeVideo + runtimeResponseGenericRuntimeResponseTypeVideoModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeVideo.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeVideoModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeVideo); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModelNew.responseType(), "video"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModelNew.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeVideoModelNew.description(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeVideoModelNew.channelOptions().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(runtimeResponseGenericRuntimeResponseTypeVideoModelNew.altText(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeVideoError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeVideo.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericTest.java new file mode 100644 index 00000000000..711db1a5356 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGeneric model. */ +public class RuntimeResponseGenericTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testRuntimeResponseGeneric() throws Throwable { + RuntimeResponseGeneric runtimeResponseGenericModel = new RuntimeResponseGeneric(); + assertNotNull(runtimeResponseGenericModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/StatusErrorTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/StatusErrorTest.java new file mode 100644 index 00000000000..2b35ae3c883 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/StatusErrorTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatusError model. */ +public class StatusErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatusError() throws Throwable { + StatusError statusErrorModel = new StatusError.Builder().message("testString").build(); + assertEquals(statusErrorModel.message(), "testString"); + + String json = TestUtilities.serialize(statusErrorModel); + + StatusError statusErrorModelNew = TestUtilities.deserialize(json, StatusError.class); + assertTrue(statusErrorModelNew instanceof StatusError); + assertEquals(statusErrorModelNew.message(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymCollectionTest.java new file mode 100644 index 00000000000..ac4a76d891f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SynonymCollection model. */ +public class SynonymCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSynonymCollection() throws Throwable { + SynonymCollection synonymCollectionModel = new SynonymCollection(); + assertNull(synonymCollectionModel.getSynonyms()); + assertNull(synonymCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymTest.java new file mode 100644 index 00000000000..eac82e3d965 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Synonym model. */ +public class SynonymTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSynonym() throws Throwable { + Synonym synonymModel = new Synonym.Builder().synonym("testString").build(); + assertEquals(synonymModel.synonym(), "testString"); + + String json = TestUtilities.serialize(synonymModel); + + Synonym synonymModelNew = TestUtilities.deserialize(json, Synonym.class); + assertTrue(synonymModelNew instanceof Synonym); + assertEquals(synonymModelNew.synonym(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSynonymError() throws Throwable { + new Synonym.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptionsTest.java new file mode 100644 index 00000000000..f9d397ff7ec --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCounterexampleOptions model. */ +public class UpdateCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCounterexampleOptions() throws Throwable { + UpdateCounterexampleOptions updateCounterexampleOptionsModel = + new UpdateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .newText("testString") + .includeAudit(false) + .build(); + assertEquals(updateCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(updateCounterexampleOptionsModel.text(), "testString"); + assertEquals(updateCounterexampleOptionsModel.newText(), "testString"); + assertEquals(updateCounterexampleOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCounterexampleOptionsError() throws Throwable { + new UpdateCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java new file mode 100644 index 00000000000..3281986e39f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDialogNodeNullableOptions model. */ +public class UpdateDialogNodeNullableOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDialogNodeNullableOptions() throws Throwable { + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptionsModel = + new UpdateDialogNodeNullableOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .body( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .includeAudit(true) + .build(); + assertEquals(updateDialogNodeNullableOptionsModel.workspaceId(), "testString"); + assertEquals(updateDialogNodeNullableOptionsModel.dialogNode(), "testString"); + assertEquals( + updateDialogNodeNullableOptionsModel.body(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateDialogNodeNullableOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNullableOptionsError() throws Throwable { + new UpdateDialogNodeNullableOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptionsTest.java new file mode 100644 index 00000000000..73542d418c8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptionsTest.java @@ -0,0 +1,176 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDialogNodeOptions model. */ +public class UpdateDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDialogNodeOptions() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + UpdateDialogNodeOptions updateDialogNodeOptionsModel = + new UpdateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .newDialogNode("testString") + .newDescription("testString") + .newConditions("testString") + .newParent("testString") + .newPreviousSibling("testString") + .newOutput(dialogNodeOutputModel) + .newContext(dialogNodeContextModel) + .newMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .newNextStep(dialogNodeNextStepModel) + .newTitle("testString") + .newType("standard") + .newEventName("focus") + .newVariable("testString") + .newActions(java.util.Arrays.asList(dialogNodeActionModel)) + .newDigressIn("not_available") + .newDigressOut("allow_returning") + .newDigressOutSlots("not_allowed") + .newUserLabel("testString") + .newDisambiguationOptOut(false) + .includeAudit(false) + .build(); + assertEquals(updateDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(updateDialogNodeOptionsModel.dialogNode(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newDialogNode(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newDescription(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newConditions(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newParent(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newPreviousSibling(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newOutput(), dialogNodeOutputModel); + assertEquals(updateDialogNodeOptionsModel.newContext(), dialogNodeContextModel); + assertEquals( + updateDialogNodeOptionsModel.newMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateDialogNodeOptionsModel.newNextStep(), dialogNodeNextStepModel); + assertEquals(updateDialogNodeOptionsModel.newTitle(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newType(), "standard"); + assertEquals(updateDialogNodeOptionsModel.newEventName(), "focus"); + assertEquals(updateDialogNodeOptionsModel.newVariable(), "testString"); + assertEquals( + updateDialogNodeOptionsModel.newActions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(updateDialogNodeOptionsModel.newDigressIn(), "not_available"); + assertEquals(updateDialogNodeOptionsModel.newDigressOut(), "allow_returning"); + assertEquals(updateDialogNodeOptionsModel.newDigressOutSlots(), "not_allowed"); + assertEquals(updateDialogNodeOptionsModel.newUserLabel(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newDisambiguationOptOut(), Boolean.valueOf(false)); + assertEquals(updateDialogNodeOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeOptionsError() throws Throwable { + new UpdateDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java new file mode 100644 index 00000000000..aa162f1076d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java @@ -0,0 +1,366 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDialogNode model. */ +public class UpdateDialogNodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDialogNode() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + UpdateDialogNode updateDialogNodeModel = + new UpdateDialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + assertEquals(updateDialogNodeModel.dialogNode(), "testString"); + assertEquals(updateDialogNodeModel.description(), "testString"); + assertEquals(updateDialogNodeModel.conditions(), "testString"); + assertEquals(updateDialogNodeModel.parent(), "testString"); + assertEquals(updateDialogNodeModel.previousSibling(), "testString"); + assertEquals(updateDialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(updateDialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + updateDialogNodeModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateDialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(updateDialogNodeModel.title(), "testString"); + assertEquals(updateDialogNodeModel.type(), "standard"); + assertEquals(updateDialogNodeModel.eventName(), "focus"); + assertEquals(updateDialogNodeModel.variable(), "testString"); + assertEquals( + updateDialogNodeModel.actions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(updateDialogNodeModel.digressIn(), "not_available"); + assertEquals(updateDialogNodeModel.digressOut(), "allow_returning"); + assertEquals(updateDialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(updateDialogNodeModel.userLabel(), "testString"); + assertEquals(updateDialogNodeModel.disambiguationOptOut(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(updateDialogNodeModel); + + UpdateDialogNode updateDialogNodeModelNew = + TestUtilities.deserialize(json, UpdateDialogNode.class); + assertTrue(updateDialogNodeModelNew instanceof UpdateDialogNode); + assertEquals(updateDialogNodeModelNew.dialogNode(), "testString"); + assertEquals(updateDialogNodeModelNew.description(), "testString"); + assertEquals(updateDialogNodeModelNew.conditions(), "testString"); + assertEquals(updateDialogNodeModelNew.parent(), "testString"); + assertEquals(updateDialogNodeModelNew.previousSibling(), "testString"); + assertEquals(updateDialogNodeModelNew.output().toString(), dialogNodeOutputModel.toString()); + assertEquals(updateDialogNodeModelNew.context().toString(), dialogNodeContextModel.toString()); + assertEquals( + updateDialogNodeModelNew.nextStep().toString(), dialogNodeNextStepModel.toString()); + assertEquals(updateDialogNodeModelNew.title(), "testString"); + assertEquals(updateDialogNodeModelNew.type(), "standard"); + assertEquals(updateDialogNodeModelNew.eventName(), "focus"); + assertEquals(updateDialogNodeModelNew.variable(), "testString"); + assertEquals(updateDialogNodeModelNew.digressIn(), "not_available"); + assertEquals(updateDialogNodeModelNew.digressOut(), "allow_returning"); + assertEquals(updateDialogNodeModelNew.digressOutSlots(), "not_allowed"); + assertEquals(updateDialogNodeModelNew.userLabel(), "testString"); + assertEquals(updateDialogNodeModelNew.disambiguationOptOut(), Boolean.valueOf(true)); + } + + @Test + public void testUpdateDialogNodeNullable() throws Throwable { + + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + + UpdateDialogNode updateDialogNodeModel = + new UpdateDialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + + Map mergePatch = updateDialogNodeModel.asPatch(); + + assertEquals(mergePatch.get("dialog_node"), "testString"); + assertEquals(mergePatch.get("description"), "testString"); + assertEquals(mergePatch.get("conditions"), "testString"); + assertEquals(mergePatch.get("parent"), "testString"); + assertEquals(mergePatch.get("previous_sibling"), "testString"); + assertTrue(mergePatch.containsKey("output")); + assertTrue(mergePatch.containsKey("context")); + assertTrue(mergePatch.containsKey("metadata")); + assertTrue(mergePatch.containsKey("next_step")); + assertEquals(mergePatch.get("title"), "testString"); + assertEquals(mergePatch.get("type"), "standard"); + assertEquals(mergePatch.get("event_name"), "focus"); + assertEquals(mergePatch.get("variable"), "testString"); + assertTrue(mergePatch.containsKey("actions")); + assertEquals(mergePatch.get("digress_in"), "not_available"); + assertEquals(mergePatch.get("digress_out"), "allow_returning"); + assertEquals(mergePatch.get("digress_out_slots"), "not_allowed"); + assertEquals(mergePatch.get("user_label"), "testString"); + assertTrue(mergePatch.containsKey("disambiguation_opt_out")); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptionsTest.java new file mode 100644 index 00000000000..16cc58443ba --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptionsTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEntityOptions model. */ +public class UpdateEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEntityOptions() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + UpdateEntityOptions updateEntityOptionsModel = + new UpdateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .newEntity("testString") + .newDescription("testString") + .newMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .newFuzzyMatch(true) + .newValues(java.util.Arrays.asList(createValueModel)) + .append(false) + .includeAudit(false) + .build(); + assertEquals(updateEntityOptionsModel.workspaceId(), "testString"); + assertEquals(updateEntityOptionsModel.entity(), "testString"); + assertEquals(updateEntityOptionsModel.newEntity(), "testString"); + assertEquals(updateEntityOptionsModel.newDescription(), "testString"); + assertEquals( + updateEntityOptionsModel.newMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateEntityOptionsModel.newFuzzyMatch(), Boolean.valueOf(true)); + assertEquals(updateEntityOptionsModel.newValues(), java.util.Arrays.asList(createValueModel)); + assertEquals(updateEntityOptionsModel.append(), Boolean.valueOf(false)); + assertEquals(updateEntityOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEntityOptionsError() throws Throwable { + new UpdateEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptionsTest.java new file mode 100644 index 00000000000..ca564ebfc76 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptionsTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateExampleOptions model. */ +public class UpdateExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateExampleOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + UpdateExampleOptions updateExampleOptionsModel = + new UpdateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .newText("testString") + .newMentions(java.util.Arrays.asList(mentionModel)) + .includeAudit(false) + .build(); + assertEquals(updateExampleOptionsModel.workspaceId(), "testString"); + assertEquals(updateExampleOptionsModel.intent(), "testString"); + assertEquals(updateExampleOptionsModel.text(), "testString"); + assertEquals(updateExampleOptionsModel.newText(), "testString"); + assertEquals(updateExampleOptionsModel.newMentions(), java.util.Arrays.asList(mentionModel)); + assertEquals(updateExampleOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateExampleOptionsError() throws Throwable { + new UpdateExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptionsTest.java new file mode 100644 index 00000000000..22bcf0cb695 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptionsTest.java @@ -0,0 +1,72 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateIntentOptions model. */ +public class UpdateIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateIntentOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + UpdateIntentOptions updateIntentOptionsModel = + new UpdateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .newIntent("testString") + .newDescription("testString") + .newExamples(java.util.Arrays.asList(exampleModel)) + .append(false) + .includeAudit(false) + .build(); + assertEquals(updateIntentOptionsModel.workspaceId(), "testString"); + assertEquals(updateIntentOptionsModel.intent(), "testString"); + assertEquals(updateIntentOptionsModel.newIntent(), "testString"); + assertEquals(updateIntentOptionsModel.newDescription(), "testString"); + assertEquals(updateIntentOptionsModel.newExamples(), java.util.Arrays.asList(exampleModel)); + assertEquals(updateIntentOptionsModel.append(), Boolean.valueOf(false)); + assertEquals(updateIntentOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateIntentOptionsError() throws Throwable { + new UpdateIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptionsTest.java new file mode 100644 index 00000000000..dd459ba12e1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateSynonymOptions model. */ +public class UpdateSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateSynonymOptions() throws Throwable { + UpdateSynonymOptions updateSynonymOptionsModel = + new UpdateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .newSynonym("testString") + .includeAudit(false) + .build(); + assertEquals(updateSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(updateSynonymOptionsModel.entity(), "testString"); + assertEquals(updateSynonymOptionsModel.value(), "testString"); + assertEquals(updateSynonymOptionsModel.synonym(), "testString"); + assertEquals(updateSynonymOptionsModel.newSynonym(), "testString"); + assertEquals(updateSynonymOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSynonymOptionsError() throws Throwable { + new UpdateSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateValueOptionsTest.java new file mode 100644 index 00000000000..2f4c5da5805 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateValueOptionsTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateValueOptions model. */ +public class UpdateValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateValueOptions() throws Throwable { + UpdateValueOptions updateValueOptionsModel = + new UpdateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .newValue("testString") + .newMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .newType("synonyms") + .newSynonyms(java.util.Arrays.asList("testString")) + .newPatterns(java.util.Arrays.asList("testString")) + .append(false) + .includeAudit(false) + .build(); + assertEquals(updateValueOptionsModel.workspaceId(), "testString"); + assertEquals(updateValueOptionsModel.entity(), "testString"); + assertEquals(updateValueOptionsModel.value(), "testString"); + assertEquals(updateValueOptionsModel.newValue(), "testString"); + assertEquals( + updateValueOptionsModel.newMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateValueOptionsModel.newType(), "synonyms"); + assertEquals(updateValueOptionsModel.newSynonyms(), java.util.Arrays.asList("testString")); + assertEquals(updateValueOptionsModel.newPatterns(), java.util.Arrays.asList("testString")); + assertEquals(updateValueOptionsModel.append(), Boolean.valueOf(false)); + assertEquals(updateValueOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateValueOptionsError() throws Throwable { + new UpdateValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceAsyncOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceAsyncOptionsTest.java new file mode 100644 index 00000000000..b73583215ef --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceAsyncOptionsTest.java @@ -0,0 +1,343 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateWorkspaceAsyncOptions model. */ +public class UpdateWorkspaceAsyncOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateWorkspaceAsyncOptions() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals(dialogNodeModel.actions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(false)); + + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + assertEquals(workspaceSystemSettingsNlpModel.model(), "testString"); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + assertEquals(workspaceSystemSettingsModel.getTooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.getDisambiguation(), + workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.getHumanAgentAssist(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(workspaceSystemSettingsModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals( + workspaceSystemSettingsModel.getSystemEntities(), + workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.getOffTopic(), workspaceSystemSettingsOffTopicModel); + assertEquals(workspaceSystemSettingsModel.getNlp(), workspaceSystemSettingsNlpModel); + assertEquals(workspaceSystemSettingsModel.get("foo"), "testString"); + + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals(webhookModel.headers(), java.util.Arrays.asList(webhookHeaderModel)); + + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals(createIntentModel.examples(), java.util.Arrays.asList(exampleModel)); + + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals(createEntityModel.values(), java.util.Arrays.asList(createValueModel)); + + UpdateWorkspaceAsyncOptions updateWorkspaceAsyncOptionsModel = + new UpdateWorkspaceAsyncOptions.Builder() + .workspaceId("testString") + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .append(false) + .build(); + assertEquals(updateWorkspaceAsyncOptionsModel.workspaceId(), "testString"); + assertEquals(updateWorkspaceAsyncOptionsModel.name(), "testString"); + assertEquals(updateWorkspaceAsyncOptionsModel.description(), "testString"); + assertEquals(updateWorkspaceAsyncOptionsModel.language(), "testString"); + assertEquals( + updateWorkspaceAsyncOptionsModel.dialogNodes(), java.util.Arrays.asList(dialogNodeModel)); + assertEquals( + updateWorkspaceAsyncOptionsModel.counterexamples(), + java.util.Arrays.asList(counterexampleModel)); + assertEquals( + updateWorkspaceAsyncOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateWorkspaceAsyncOptionsModel.learningOptOut(), Boolean.valueOf(false)); + assertEquals(updateWorkspaceAsyncOptionsModel.systemSettings(), workspaceSystemSettingsModel); + assertEquals( + updateWorkspaceAsyncOptionsModel.webhooks(), java.util.Arrays.asList(webhookModel)); + assertEquals( + updateWorkspaceAsyncOptionsModel.intents(), java.util.Arrays.asList(createIntentModel)); + assertEquals( + updateWorkspaceAsyncOptionsModel.entities(), java.util.Arrays.asList(createEntityModel)); + assertEquals(updateWorkspaceAsyncOptionsModel.append(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateWorkspaceAsyncOptionsError() throws Throwable { + new UpdateWorkspaceAsyncOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptionsTest.java new file mode 100644 index 00000000000..9e60b5e9eff --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptionsTest.java @@ -0,0 +1,343 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateWorkspaceOptions model. */ +public class UpdateWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateWorkspaceOptions() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + ResponseGenericChannel responseGenericChannelModel = + new ResponseGenericChannel.Builder().channel("chat").build(); + assertEquals(responseGenericChannelModel.channel(), "chat"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values(java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)) + .selectionPolicy("sequential") + .delimiter("\\n") + .channels(java.util.Arrays.asList(responseGenericChannelModel)) + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericModel.values(), + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel)); + assertEquals(dialogNodeOutputGenericModel.selectionPolicy(), "sequential"); + assertEquals(dialogNodeOutputGenericModel.delimiter(), "\\n"); + assertEquals( + dialogNodeOutputGenericModel.channels(), + java.util.Arrays.asList(responseGenericChannelModel)); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic(java.util.Arrays.asList(dialogNodeOutputGenericModel)) + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), java.util.Arrays.asList(dialogNodeOutputGenericModel)); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + java.util.Collections.singletonMap( + "key1", java.util.Collections.singletonMap("anyKey", "anyValue"))); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters(java.util.Collections.singletonMap("anyKey", "anyValue")) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions(java.util.Arrays.asList(dialogNodeActionModel)) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(false) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals(dialogNodeModel.actions(), java.util.Arrays.asList(dialogNodeActionModel)); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(false)); + + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + assertEquals(workspaceSystemSettingsNlpModel.model(), "testString"); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + assertEquals(workspaceSystemSettingsModel.getTooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.getDisambiguation(), + workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.getHumanAgentAssist(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(workspaceSystemSettingsModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals( + workspaceSystemSettingsModel.getSystemEntities(), + workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.getOffTopic(), workspaceSystemSettingsOffTopicModel); + assertEquals(workspaceSystemSettingsModel.getNlp(), workspaceSystemSettingsNlpModel); + assertEquals(workspaceSystemSettingsModel.get("foo"), "testString"); + + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals(webhookModel.headers(), java.util.Arrays.asList(webhookHeaderModel)); + + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals(mentionModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(java.util.Arrays.asList(mentionModel)) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals(exampleModel.mentions(), java.util.Arrays.asList(mentionModel)); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(java.util.Arrays.asList(exampleModel)) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals(createIntentModel.examples(), java.util.Arrays.asList(exampleModel)); + + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .type("synonyms") + .synonyms(java.util.Arrays.asList("testString")) + .patterns(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals(createValueModel.synonyms(), java.util.Arrays.asList("testString")); + assertEquals(createValueModel.patterns(), java.util.Arrays.asList("testString")); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .fuzzyMatch(true) + .values(java.util.Arrays.asList(createValueModel)) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals(createEntityModel.values(), java.util.Arrays.asList(createValueModel)); + + UpdateWorkspaceOptions updateWorkspaceOptionsModel = + new UpdateWorkspaceOptions.Builder() + .workspaceId("testString") + .name("testString") + .description("testString") + .language("testString") + .dialogNodes(java.util.Arrays.asList(dialogNodeModel)) + .counterexamples(java.util.Arrays.asList(counterexampleModel)) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .learningOptOut(false) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(java.util.Arrays.asList(webhookModel)) + .intents(java.util.Arrays.asList(createIntentModel)) + .entities(java.util.Arrays.asList(createEntityModel)) + .append(false) + .includeAudit(false) + .build(); + assertEquals(updateWorkspaceOptionsModel.workspaceId(), "testString"); + assertEquals(updateWorkspaceOptionsModel.name(), "testString"); + assertEquals(updateWorkspaceOptionsModel.description(), "testString"); + assertEquals(updateWorkspaceOptionsModel.language(), "testString"); + assertEquals( + updateWorkspaceOptionsModel.dialogNodes(), java.util.Arrays.asList(dialogNodeModel)); + assertEquals( + updateWorkspaceOptionsModel.counterexamples(), + java.util.Arrays.asList(counterexampleModel)); + assertEquals( + updateWorkspaceOptionsModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateWorkspaceOptionsModel.learningOptOut(), Boolean.valueOf(false)); + assertEquals(updateWorkspaceOptionsModel.systemSettings(), workspaceSystemSettingsModel); + assertEquals(updateWorkspaceOptionsModel.webhooks(), java.util.Arrays.asList(webhookModel)); + assertEquals(updateWorkspaceOptionsModel.intents(), java.util.Arrays.asList(createIntentModel)); + assertEquals( + updateWorkspaceOptionsModel.entities(), java.util.Arrays.asList(createEntityModel)); + assertEquals(updateWorkspaceOptionsModel.append(), Boolean.valueOf(false)); + assertEquals(updateWorkspaceOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateWorkspaceOptionsError() throws Throwable { + new UpdateWorkspaceOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueCollectionTest.java new file mode 100644 index 00000000000..07a20c468b8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ValueCollection model. */ +public class ValueCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testValueCollection() throws Throwable { + ValueCollection valueCollectionModel = new ValueCollection(); + assertNull(valueCollectionModel.getValues()); + assertNull(valueCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueTest.java new file mode 100644 index 00000000000..3cea67302c8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Value model. */ +public class ValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testValueError() throws Throwable { + new Value.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookHeaderTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookHeaderTest.java new file mode 100644 index 00000000000..ea77dc56b95 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookHeaderTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WebhookHeader model. */ +public class WebhookHeaderTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWebhookHeader() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + String json = TestUtilities.serialize(webhookHeaderModel); + + WebhookHeader webhookHeaderModelNew = TestUtilities.deserialize(json, WebhookHeader.class); + assertTrue(webhookHeaderModelNew instanceof WebhookHeader); + assertEquals(webhookHeaderModelNew.name(), "testString"); + assertEquals(webhookHeaderModelNew.value(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWebhookHeaderError() throws Throwable { + new WebhookHeader.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookTest.java new file mode 100644 index 00000000000..3d486898b55 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Webhook model. */ +public class WebhookTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWebhook() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers(java.util.Arrays.asList(webhookHeaderModel)) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals(webhookModel.headers(), java.util.Arrays.asList(webhookHeaderModel)); + + String json = TestUtilities.serialize(webhookModel); + + Webhook webhookModelNew = TestUtilities.deserialize(json, Webhook.class); + assertTrue(webhookModelNew instanceof Webhook); + assertEquals(webhookModelNew.url(), "testString"); + assertEquals(webhookModelNew.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWebhookError() throws Throwable { + new Webhook.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCollectionTest.java new file mode 100644 index 00000000000..50bdcfaa35b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceCollection model. */ +public class WorkspaceCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceCollection() throws Throwable { + WorkspaceCollection workspaceCollectionModel = new WorkspaceCollection(); + assertNull(workspaceCollectionModel.getWorkspaces()); + assertNull(workspaceCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCountsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCountsTest.java new file mode 100644 index 00000000000..5d85f69a8db --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCountsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceCounts model. */ +public class WorkspaceCountsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceCounts() throws Throwable { + WorkspaceCounts workspaceCountsModel = new WorkspaceCounts(); + assertNull(workspaceCountsModel.getIntent()); + assertNull(workspaceCountsModel.getEntity()); + assertNull(workspaceCountsModel.getNode()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguationTest.java new file mode 100644 index 00000000000..5c28765d0fe --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguationTest.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsDisambiguation model. */ +public class WorkspaceSystemSettingsDisambiguationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsDisambiguation() throws Throwable { + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + String json = TestUtilities.serialize(workspaceSystemSettingsDisambiguationModel); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsDisambiguation.class); + assertTrue( + workspaceSystemSettingsDisambiguationModelNew + instanceof WorkspaceSystemSettingsDisambiguation); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.prompt(), "testString"); + assertEquals( + workspaceSystemSettingsDisambiguationModelNew.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.maxSuggestions(), Long.valueOf("1")); + assertEquals( + workspaceSystemSettingsDisambiguationModelNew.suggestionTextPolicy(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsNlpTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsNlpTest.java new file mode 100644 index 00000000000..a8e786ae2ae --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsNlpTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsNlp model. */ +public class WorkspaceSystemSettingsNlpTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsNlp() throws Throwable { + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + assertEquals(workspaceSystemSettingsNlpModel.model(), "testString"); + + String json = TestUtilities.serialize(workspaceSystemSettingsNlpModel); + + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsNlp.class); + assertTrue(workspaceSystemSettingsNlpModelNew instanceof WorkspaceSystemSettingsNlp); + assertEquals(workspaceSystemSettingsNlpModelNew.model(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopicTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopicTest.java new file mode 100644 index 00000000000..eaaf526ec7d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopicTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsOffTopic model. */ +public class WorkspaceSystemSettingsOffTopicTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsOffTopic() throws Throwable { + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(workspaceSystemSettingsOffTopicModel); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsOffTopic.class); + assertTrue(workspaceSystemSettingsOffTopicModelNew instanceof WorkspaceSystemSettingsOffTopic); + assertEquals(workspaceSystemSettingsOffTopicModelNew.enabled(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntitiesTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntitiesTest.java new file mode 100644 index 00000000000..1d7c5452c84 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntitiesTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsSystemEntities model. */ +public class WorkspaceSystemSettingsSystemEntitiesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsSystemEntities() throws Throwable { + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(workspaceSystemSettingsSystemEntitiesModel); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsSystemEntities.class); + assertTrue( + workspaceSystemSettingsSystemEntitiesModelNew + instanceof WorkspaceSystemSettingsSystemEntities); + assertEquals(workspaceSystemSettingsSystemEntitiesModelNew.enabled(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTest.java new file mode 100644 index 00000000000..366ddc35044 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTest.java @@ -0,0 +1,123 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettings model. */ +public class WorkspaceSystemSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettings() throws Throwable { + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(false) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(false)); + + WorkspaceSystemSettingsNlp workspaceSystemSettingsNlpModel = + new WorkspaceSystemSettingsNlp.Builder().model("testString").build(); + assertEquals(workspaceSystemSettingsNlpModel.model(), "testString"); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist(java.util.Collections.singletonMap("anyKey", "anyValue")) + .spellingSuggestions(false) + .spellingAutoCorrect(false) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .nlp(workspaceSystemSettingsNlpModel) + .add("foo", "testString") + .build(); + assertEquals(workspaceSystemSettingsModel.getTooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.getDisambiguation(), + workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.getHumanAgentAssist(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(workspaceSystemSettingsModel.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsModel.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals( + workspaceSystemSettingsModel.getSystemEntities(), + workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.getOffTopic(), workspaceSystemSettingsOffTopicModel); + assertEquals(workspaceSystemSettingsModel.getNlp(), workspaceSystemSettingsNlpModel); + assertEquals(workspaceSystemSettingsModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(workspaceSystemSettingsModel); + + WorkspaceSystemSettings workspaceSystemSettingsModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettings.class); + assertTrue(workspaceSystemSettingsModelNew instanceof WorkspaceSystemSettings); + assertEquals( + workspaceSystemSettingsModelNew.getTooling().toString(), + workspaceSystemSettingsToolingModel.toString()); + assertEquals( + workspaceSystemSettingsModelNew.getDisambiguation().toString(), + workspaceSystemSettingsDisambiguationModel.toString()); + assertEquals( + workspaceSystemSettingsModelNew.getHumanAgentAssist().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(workspaceSystemSettingsModelNew.isSpellingSuggestions(), Boolean.valueOf(false)); + assertEquals(workspaceSystemSettingsModelNew.isSpellingAutoCorrect(), Boolean.valueOf(false)); + assertEquals( + workspaceSystemSettingsModelNew.getSystemEntities().toString(), + workspaceSystemSettingsSystemEntitiesModel.toString()); + assertEquals( + workspaceSystemSettingsModelNew.getOffTopic().toString(), + workspaceSystemSettingsOffTopicModel.toString()); + assertEquals( + workspaceSystemSettingsModelNew.getNlp().toString(), + workspaceSystemSettingsNlpModel.toString()); + assertEquals(workspaceSystemSettingsModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsToolingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsToolingTest.java new file mode 100644 index 00000000000..eb3851f10a4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsToolingTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsTooling model. */ +public class WorkspaceSystemSettingsToolingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsTooling() throws Throwable { + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(workspaceSystemSettingsToolingModel); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsTooling.class); + assertTrue(workspaceSystemSettingsToolingModelNew instanceof WorkspaceSystemSettingsTooling); + assertEquals( + workspaceSystemSettingsToolingModelNew.storeGenericResponses(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceTest.java new file mode 100644 index 00000000000..3026e7494ff --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Workspace model. */ +public class WorkspaceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspace() throws Throwable { + Workspace workspaceModel = new Workspace(); + assertNull(workspaceModel.getName()); + assertNull(workspaceModel.getDescription()); + assertNull(workspaceModel.getLanguage()); + assertNull(workspaceModel.getDialogNodes()); + assertNull(workspaceModel.getCounterexamples()); + assertNull(workspaceModel.getMetadata()); + assertNull(workspaceModel.isLearningOptOut()); + assertNull(workspaceModel.getSystemSettings()); + assertNull(workspaceModel.getWebhooks()); + assertNull(workspaceModel.getIntents()); + assertNull(workspaceModel.getEntities()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/testng.xml b/assistant/src/test/java/com/ibm/watson/assistant/v1/testng.xml new file mode 100644 index 00000000000..0fba653a9e7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/utils/TestUtilities.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..d6fbde1a6b4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/utils/TestUtilities.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java index c2b49542510..7bdebf092ed 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2025. * * 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 @@ -12,34 +12,36 @@ */ package com.ibm.watson.assistant.v2; -import com.ibm.watson.assistant.v2.model.CreateSessionOptions; -import com.ibm.watson.assistant.v2.model.DeleteSessionOptions; -import com.ibm.watson.assistant.v2.model.MessageContext; -import com.ibm.watson.assistant.v2.model.MessageInput; -import com.ibm.watson.assistant.v2.model.MessageInputOptions; -import com.ibm.watson.assistant.v2.model.MessageOptions; -import com.ibm.watson.assistant.v2.model.MessageResponse; -import com.ibm.watson.assistant.v2.model.RuntimeResponseGeneric; -import com.ibm.watson.assistant.v2.model.SessionResponse; +import static org.junit.Assert.*; + +import com.ibm.watson.assistant.v2.model.*; +import com.ibm.watson.assistant.v2.model.ListLogsOptions.Builder; import com.ibm.watson.common.RetryRunner; +import com.launchdarkly.eventsource.StreamException; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Integration tests for Assistant v2. - */ +/** Integration tests for Assistant v2. */ @RunWith(RetryRunner.class) public class AssistantServiceIT extends AssistantServiceTest { private Assistant service; private String assistantId; + private static final String RESOURCE = "src/test/resources/assistant/"; + + /** + * Sets up the tests. + * + * @throws Exception the exception + */ @Override @Before public void setUp() throws Exception { @@ -48,49 +50,45 @@ public void setUp() throws Exception { this.assistantId = getAssistantId(); } - /** - * Ignoring while I wait to get access to a new instance for Java SDK testing. - */ + /** Test send messages. */ @Test public void testSendMessages() { // get session ID - CreateSessionOptions createSessionOptions = new CreateSessionOptions.Builder() - .assistantId(assistantId) - .build(); - SessionResponse sessionResponse = service.createSession(createSessionOptions).execute().getResult(); + CreateSessionOptions createSessionOptions = + new CreateSessionOptions.Builder().assistantId(assistantId).build(); + SessionResponse sessionResponse = + service.createSession(createSessionOptions).execute().getResult(); String sessionId = sessionResponse.getSessionId(); - final List messages = Arrays.asList( - "I want some pizza.", - "I'd like 3 pizzas.", - "Large"); + final List messages = Arrays.asList("Hello"); MessageContext context = new MessageContext.Builder().build(); try { // send messages for (String message : messages) { - MessageInputOptions inputOptions = new MessageInputOptions.Builder() - .debug(true) - .build(); - MessageInput input = new MessageInput.Builder() - .text(message) - .messageType(MessageInput.MessageType.TEXT) - .options(inputOptions) - .build(); - MessageOptions messageOptions = new MessageOptions.Builder() - .assistantId(assistantId) - .sessionId(sessionId) - .input(input) - .context(context) - .build(); - MessageResponse messageResponse = service.message(messageOptions).execute().getResult(); + MessageInputOptions inputOptions = new MessageInputOptions.Builder().debug(true).build(); + MessageInput input = + new MessageInput.Builder() + .text(message) + .messageType(MessageInput.MessageType.TEXT) + .options(inputOptions) + .build(); + MessageOptions messageOptions = + new MessageOptions.Builder() + .assistantId(assistantId) + .sessionId(sessionId) + .input(input) + .context(context) + .build(); + StatefulMessageResponse messageResponse = + service.message(messageOptions).execute().getResult(); // message assertions List genericResponses = messageResponse.getOutput().getGeneric(); assertNotNull(genericResponses); boolean foundTextResponse = false; for (RuntimeResponseGeneric generic : genericResponses) { - if (generic.responseType().equals(RuntimeResponseGeneric.ResponseType.TEXT)) { + if (generic.responseType().equals("text")) { foundTextResponse = true; break; } @@ -99,16 +97,484 @@ public void testSendMessages() { assertNotNull(messageResponse.getOutput().getEntities()); assertNotNull(messageResponse.getOutput().getIntents()); assertNotNull(messageResponse.getOutput().getDebug()); + assertNotNull(messageResponse.getContext().skills().actionsSkill()); context = messageResponse.getContext(); } } finally { // delete session - DeleteSessionOptions deleteSessionOptions = new DeleteSessionOptions.Builder() - .assistantId(assistantId) - .sessionId(sessionId) - .build(); + DeleteSessionOptions deleteSessionOptions = + new DeleteSessionOptions.Builder().assistantId(assistantId).sessionId(sessionId).build(); service.deleteSession(deleteSessionOptions).execute(); } } + + /** Test send message stateless. */ + @Test + public void testSendMessageStateless() { + // get session ID + CreateSessionOptions createSessionOptions = + new CreateSessionOptions.Builder().assistantId(assistantId).build(); + SessionResponse sessionResponse = + service.createSession(createSessionOptions).execute().getResult(); + String sessionId = sessionResponse.getSessionId(); + + final List messages = Arrays.asList("Hello"); + StatelessMessageContext context = new StatelessMessageContext.Builder().build(); + + try { + // send messages + for (String message : messages) { + StatelessMessageInputOptions inputOptions = + new StatelessMessageInputOptions.Builder().debug(true).build(); + StatelessMessageInput input = + new StatelessMessageInput.Builder() + .text(message) + .messageType(MessageInput.MessageType.TEXT) + .options(inputOptions) + .build(); + MessageStatelessOptions messageOptions = + new MessageStatelessOptions.Builder() + .assistantId(assistantId) + .input(input) + .context(context) + .build(); + StatelessMessageResponse messageResponse = + service.messageStateless(messageOptions).execute().getResult(); + + // message assertions + List genericResponses = messageResponse.getOutput().getGeneric(); + assertNotNull(genericResponses); + boolean foundTextResponse = false; + for (RuntimeResponseGeneric generic : genericResponses) { + if (generic.responseType().equals("text")) { + foundTextResponse = true; + break; + } + } + assertTrue(foundTextResponse); + assertNotNull(messageResponse.getOutput().getEntities()); + assertNotNull(messageResponse.getOutput().getIntents()); + assertNotNull(messageResponse.getOutput().getDebug()); + + context = messageResponse.getContext(); + } + } finally { + // delete session + DeleteSessionOptions deleteSessionOptions = + new DeleteSessionOptions.Builder().assistantId(assistantId).sessionId(sessionId).build(); + service.deleteSession(deleteSessionOptions).execute(); + } + } + + /** Test List Logs. */ + // @Test + public void testListLogs() { + // list logs sorted by timestamp and that contain the text Hello + Builder builder = new ListLogsOptions.Builder(); + builder.assistantId(assistantId); + builder.sort("request_timestamp"); + builder.filter("request.input.text::\"Hello\""); + builder.pageLimit(5); + + LogCollection logCollection = service.listLogs(builder.build()).execute().getResult(); + + assertNotNull(logCollection); + assertTrue(logCollection.getLogs().get(0).getRequest().getInput().text().contains("Hello")); + assertTrue(logCollection.getLogs().get(0).getLanguage().equals("en")); + } + + /** Test bulk classify */ + @Ignore + @Test + public void testBulkClassify() { + BulkClassifyUtterance bulkClassifyUtterance = + new BulkClassifyUtterance.Builder().text("text text").build(); + BulkClassifyOptions bulkClassifyOptions = + new BulkClassifyOptions.Builder() + .addInput(bulkClassifyUtterance) + .skillId("{skillId}") + .build(); + BulkClassifyResponse response = service.bulkClassify(bulkClassifyOptions).execute().getResult(); + + assertNotNull(response); + } + + /** Test RuntimeResponseGenericRuntimeResponseTypeChannelTransfer. */ + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeChannelTransfer() { + + // get session ID + CreateSessionOptions createSessionOptions = + new CreateSessionOptions.Builder().assistantId(assistantId).build(); + SessionResponse sessionResponse = + service.createSession(createSessionOptions).execute().getResult(); + String sessionId = sessionResponse.getSessionId(); + + final List messages = Arrays.asList("test sdk"); + MessageContext context = new MessageContext.Builder().build(); + + MessageInputOptions inputOptions = new MessageInputOptions.Builder().debug(true).build(); + MessageInput input = + new MessageInput.Builder() + .text("test sdk") + .messageType(MessageInput.MessageType.TEXT) + .options(inputOptions) + .build(); + MessageOptions messageOptions = + new MessageOptions.Builder() + .assistantId(assistantId) + .sessionId(sessionId) + .input(input) + .context(context) + .build(); + StatefulMessageResponse response = service.message(messageOptions).execute().getResult(); + + RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + runtimeResponseGenericRuntimeResponseTypeChannelTransfer = + (RuntimeResponseGenericRuntimeResponseTypeChannelTransfer) + response.getOutput().getGeneric().get(0); + + assertNotNull(runtimeResponseGenericRuntimeResponseTypeChannelTransfer.transferInfo()); + } + + /** Test List Environments and Get Environment */ + @Test + public void testGettingEnvironments() { + ListEnvironmentsOptions listEnvironmentOptions = + new ListEnvironmentsOptions.Builder().assistantId(assistantId).build(); + + EnvironmentCollection environments = + service.listEnvironments(listEnvironmentOptions).execute().getResult(); + + assertNotNull(environments); + assertNotNull(environments.getEnvironments().get(1).getName()); + assertNotNull(environments.getEnvironments().get(1).getEnvironmentId()); + + String environmentId = environments.getEnvironments().get(1).getEnvironmentId(); + + GetEnvironmentOptions getEnvironmentOptions = + new GetEnvironmentOptions.Builder() + .assistantId(assistantId) + .environmentId(environmentId) + .build(); + + Environment environment = service.getEnvironment(getEnvironmentOptions).execute().getResult(); + + assertNotNull(environment); + assertNotNull(environment.getName()); + assertNotNull(environment.getEnvironmentId()); + } + + /** Test List Releases and Get Release */ + @Test + public void testGettingReleases() { + ListReleasesOptions listReleasesOptions = + new ListReleasesOptions.Builder().assistantId(assistantId).build(); + + ReleaseCollection releases = service.listReleases(listReleasesOptions).execute().getResult(); + + assertNotNull(releases); + assertNotNull(releases.getReleases().get(0).status()); + assertNotNull(releases.getReleases().get(0).release()); + + String releaseId = releases.getReleases().get(0).release(); + + GetReleaseOptions getReleasesOptions = + new GetReleaseOptions.Builder().assistantId(assistantId).release(releaseId).build(); + + Release release = service.getRelease(getReleasesOptions).execute().getResult(); + + assertNotNull(release); + assertEquals("Available", release.status()); + } + + /** Test Provider API */ + @Test + public void testProviders() { + ListProvidersOptions listProviderOptions = new ListProvidersOptions.Builder().build(); + ProviderCollection listProvidersResponse = + service.listProviders(listProviderOptions).execute().getResult(); + String providerId = + listProvidersResponse.getConversationalSkillProviders().get(0).getProviderId(); + assertNotNull(listProvidersResponse); + assertNotNull(providerId); + + ArrayList serverList = new ArrayList<>(); + serverList.add( + new ProviderSpecificationServersItem.Builder() + .url("https://myProCodeProvider.com") + .build()); + + ProviderSpecification providerSpecification = + new ProviderSpecification.Builder().servers(serverList).build(); + + ProviderAuthenticationTypeAndValue password = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("test").build(); + ProviderPrivateAuthenticationBasicFlow basicFlow = + new ProviderPrivateAuthenticationBasicFlow.Builder().password(password).build(); + ProviderPrivate providerPrivate = + new ProviderPrivate.Builder().authentication(basicFlow).build(); + + // service.setServiceUrl("http://localhost:9001"); + + UpdateProviderOptions updateProvidersOptions = + new UpdateProviderOptions.Builder() + .providerId(providerId) + .specification(providerSpecification) + .xPrivate(providerPrivate) + .build(); + ProviderResponse updateProvidersResponse = + service.updateProvider(updateProvidersOptions).execute().getResult(); + assertNotNull(updateProvidersResponse); + } + + /** Test Import/Export Release API */ + @Test + public void testImportRelease() throws IOException { + InputStream testFile = new FileInputStream(RESOURCE + "demo_wa_V4.zip"); + CreateReleaseImportOptions importOptions = + new CreateReleaseImportOptions.Builder().assistantId(assistantId).body(testFile).build(); + CreateAssistantReleaseImportResponse importResponse = + service.createReleaseImport(importOptions).execute().getResult(); + assertNotNull(importResponse); + } + + @Test + public void testDownloadExportRelease() throws IOException { + DownloadReleaseExportOptions exportOptions = + new DownloadReleaseExportOptions.Builder().assistantId(assistantId).release("1").build(); + CreateReleaseExportWithStatusErrors exportResponse = + service.downloadReleaseExport(exportOptions).execute().getResult(); + assertNotNull(exportResponse); + } + + @Test + public void testDownloadExportReleaseStream() throws IOException { + DownloadReleaseExportOptions exportOptions = + new DownloadReleaseExportOptions.Builder().assistantId(assistantId).release("1").build(); + InputStream exportReleaseStream = + service.downloadReleaseExportAsStream(exportOptions).execute().getResult(); + assertNotNull(exportReleaseStream); + } + + @Test + public void testMessageStreamStateless() throws IOException, StreamException { + MessageInput messageInput = + new MessageInput.Builder() + .messageType("text") + .text("can you list the steps to create a custom extension?") + .build(); + MessageStreamStatelessOptions messageStreamStatelessOptions = + new MessageStreamStatelessOptions.Builder() + .assistantId("99a74576-47de-42a9-ab05-9dd98978809b") + .environmentId("03dce212-1aa3-436a-a747-8717a96ded5a") + .userId("Angelo") + .input(messageInput) + .build(); + InputStream inputStream = + service.messageStreamStateless(messageStreamStatelessOptions).execute().getResult(); + + MessageEventDeserializer messageDeserializer = + new MessageEventDeserializer.Builder(inputStream).build(); + for (StatelessMessageStreamResponse message : messageDeserializer.statelessMessages()) { + if (message.getPartialItem() != null) { + assertNotNull(message.getPartialItem().getText()); + } else if (message.getCompleteItem() != null) { + assertNotNull(message.getCompleteItem().text()); + } else if (message.getFinalResponse() != null) { + assertNotNull(message.getFinalResponse().getOutput()); + assertNotNull(message.getFinalResponse().getOutput()); + } + } + } + + /** Test Deploy Releases. */ + // @Test + public void testDeployRelease() { + String environmentId = "TBD"; + String releaseId = "TBD"; + + DeployReleaseOptions deployReleasesOptions = + new DeployReleaseOptions.Builder() + .assistantId(assistantId) + .release(releaseId) + .environmentId(environmentId) + .build(); + + Environment release = service.deployRelease(deployReleasesOptions).execute().getResult(); + + assertNotNull(release); + assertNotNull(release); + assertNotNull(release.getName()); + assertNotNull(release.getEnvironmentId()); + } + + /** Test Assistant CRUD operations */ + // @Test + public void testAssistantCRUDOperations() { + // Create Assistant + + CreateAssistantOptions createAssistantOptions = + new CreateAssistantOptions.Builder() + .name("Java SDK Test Assistant") + .description("Created by the Integration Test suite for the Java SDK") + .language("en") + .build(); + + AssistantData createAssistantResult = + service.createAssistant(createAssistantOptions).execute().getResult(); + + assertNotNull(createAssistantResult); + assertNotNull(createAssistantResult.assistantId()); + assertEquals("Java SDK Test Assistant", createAssistantResult.name()); + assertNotNull(createAssistantResult.assistantSkills()); + assertNotNull(createAssistantResult.assistantEnvironments()); + assertEquals( + "Created by the Integration Test suite for the Java SDK", + createAssistantResult.description()); + assertEquals("en", createAssistantResult.language()); + + // List Assistants + + ListAssistantsOptions listAssistantsOptions = + new ListAssistantsOptions.Builder() + .pageLimit(5) + .includeCount(true) + .sort("name") + .includeAudit(true) + .build(); + + AssistantCollection listAssistantsResponse = + service.listAssistants(listAssistantsOptions).execute().getResult(); + + assertNotNull(listAssistantsResponse); + assertNotNull(listAssistantsResponse.getAssistants()); + assertNotNull(listAssistantsResponse.getPagination()); + + // Delete Assistant + + DeleteAssistantOptions deleteAssistantOptions = + new DeleteAssistantOptions.Builder() + .assistantId(createAssistantResult.assistantId()) + .build(); + + int deleteResponseCode = + service.deleteAssistant(deleteAssistantOptions).execute().getStatusCode(); + + assertEquals(200, deleteResponseCode); + } + + /** Test Skills CRUD operations */ + // @Test + public void testSkillsCRUDOperations() { + // Bootstrap new assistant and get default skill + + CreateAssistantOptions createAssistantOptions = + new CreateAssistantOptions.Builder() + .name("Java SDK Test Assistant") + .description("Created by the Integration Test suite for the Java SDK") + .language("en") + .build(); + + AssistantData createAssistantResult = + service.createAssistant(createAssistantOptions).execute().getResult(); + + String assistantId = createAssistantResult.assistantId(); + String skillId = createAssistantResult.assistantSkills().get(0).skillId(); + + // Get skill + + GetSkillOptions getSkillOptions = + new GetSkillOptions.Builder().assistantId(assistantId).skillId(skillId).build(); + + Skill getSkillResult = service.getSkill(getSkillOptions).execute().getResult(); + + assertNotNull(getSkillResult); + assertEquals(skillId, getSkillResult.getSkillId()); + assertEquals(assistantId, getSkillResult.getAssistantId()); + + // Update skill + + UpdateSkillOptions updateSkillOptions = + new UpdateSkillOptions.Builder() + .assistantId(assistantId) + .skillId(skillId) + .name("Updated Java SDK Skill") + .description("Updated by the Skill CRUD integration tests") + .build(); + + Skill updateSkillResult = service.updateSkill(updateSkillOptions).execute().getResult(); + + assertNotNull(updateSkillResult); + assertEquals(assistantId, updateSkillResult.getAssistantId()); + assertEquals(skillId, updateSkillResult.getSkillId()); + assertEquals("Updated Java SDK Skill", updateSkillResult.getName()); + assertEquals("Updated by the Skill CRUD integration tests", updateSkillResult.getDescription()); + + // Import skill + + SkillImport skillImport = + new SkillImport.Builder() + .name("Watson Java SDK Import Skill") + .description("Testing the import skill endpoint") + .language("en") + .type("action") + .build(); + + List skillsToImport = new ArrayList(); + skillsToImport.add(skillImport); + + ImportSkillsOptions importSkillsOptions = + new ImportSkillsOptions.Builder() + .assistantId(assistantId) + .assistantSkills(skillsToImport) + .build(); + + SkillsAsyncRequestStatus skillImportResult = + service.importSkills(importSkillsOptions).execute().getResult(); + + assertNotNull(skillImportResult); + assertEquals(assistantId, skillImportResult.getAssistantId()); + assertNotNull(skillImportResult.getStatus()); + + String importStatus = skillImportResult.getStatus(); + + // poll for available status + + ImportSkillsStatusOptions importSkillsStatusOptions = + new ImportSkillsStatusOptions.Builder().assistantId(assistantId).build(); + + while (importStatus != SkillsAsyncRequestStatus.Status.COMPLETED) { + skillImportResult = + service.importSkillsStatus(importSkillsStatusOptions).execute().getResult(); + importStatus = skillImportResult.getStatus(); + + assertNotEquals(SkillsAsyncRequestStatus.Status.FAILED, importStatus); + } + + assertEquals(SkillsAsyncRequestStatus.Status.COMPLETED, importStatus); + + // Export skill + + ExportSkillsOptions exportSkillsOptions = + new ExportSkillsOptions.Builder().assistantId(assistantId).includeAudit(true).build(); + + SkillsExport skillsExportResult = + service.exportSkills(exportSkillsOptions).execute().getResult(); + + assertNotNull(skillsExportResult); + assertNotNull(skillsExportResult.getAssistantSkills()); + assertNotNull(skillsExportResult.getAssistantState()); + + // Tear down created assistant + + DeleteAssistantOptions deleteAssistantOptions = + new DeleteAssistantOptions.Builder().assistantId(assistantId).build(); + + int deleteResponseCode = + service.deleteAssistant(deleteAssistantOptions).execute().getStatusCode(); + + assertEquals(200, deleteResponseCode); + } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceTest.java index 1772e5b00b3..1bbc38e47d2 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2019. + * (C) Copyright IBM Corp. 2018, 2022. * * 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 @@ -15,40 +15,64 @@ import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.common.WatsonServiceTest; +import java.util.Date; import org.junit.Assume; import org.junit.Before; -import java.util.Date; - +/** The Class AssistantServiceTest. */ public class AssistantServiceTest extends WatsonServiceTest { private Assistant service; private String assistantId; + /** + * Gets the service. + * + * @return the service + */ public Assistant getService() { return this.service; } + /** + * Gets the assistant id. + * + * @return the assistant id + */ public String getAssistantId() { return this.assistantId; } + /** + * Sets up the tests. + * + * @throws Exception the exception + */ /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - String apiKey = getProperty("assistant.apikey"); - assistantId = getProperty("assistant.assistant_id"); + String apiKey = System.getenv("ASSISTANT_APIKEY"); + assistantId = System.getenv("ASSISTANT_ASSISTANT_ID"); + String serviceUrl = System.getenv("ASSISTANT_URL"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); + if (apiKey == null) { + apiKey = getProperty("assistant_v2.apikey"); + assistantId = getProperty("assistant_v2.assistant_id"); + serviceUrl = getProperty("assistant.url"); + } + + Assume.assumeFalse( + "ASSISTANT_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey == null); Authenticator authenticator = new IamAuthenticator(apiKey); service = new Assistant("2019-02-28", authenticator); - service.setServiceUrl(getProperty("assistant.url")); + service.setServiceUrl(serviceUrl); service.setDefaultHeaders(getDefaultHeaders()); } @@ -56,6 +80,10 @@ public void setUp() throws Exception { /** * return `true` if ldate before rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful */ public boolean fuzzyBefore(Date ldate, Date rdate) { return (ldate.getTime() - rdate.getTime()) < tolerance; @@ -63,9 +91,12 @@ public boolean fuzzyBefore(Date ldate, Date rdate) { /** * return `true` if ldate after rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful */ public boolean fuzzyAfter(Date ldate, Date rdate) { return (rdate.getTime() - ldate.getTime()) < tolerance; } - } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java index 8c62dead7e3..4e25f0d8d3d 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2025. * * 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 @@ -10,376 +10,3169 @@ * 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.assistant.v2; +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.model.AssistantCollection; +import com.ibm.watson.assistant.v2.model.AssistantData; +import com.ibm.watson.assistant.v2.model.AssistantState; +import com.ibm.watson.assistant.v2.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v2.model.BulkClassifyResponse; +import com.ibm.watson.assistant.v2.model.BulkClassifyUtterance; import com.ibm.watson.assistant.v2.model.CaptureGroup; +import com.ibm.watson.assistant.v2.model.CreateAssistantOptions; +import com.ibm.watson.assistant.v2.model.CreateAssistantReleaseImportResponse; +import com.ibm.watson.assistant.v2.model.CreateProviderOptions; +import com.ibm.watson.assistant.v2.model.CreateReleaseExportOptions; +import com.ibm.watson.assistant.v2.model.CreateReleaseExportWithStatusErrors; +import com.ibm.watson.assistant.v2.model.CreateReleaseImportOptions; +import com.ibm.watson.assistant.v2.model.CreateReleaseOptions; import com.ibm.watson.assistant.v2.model.CreateSessionOptions; +import com.ibm.watson.assistant.v2.model.DeleteAssistantOptions; +import com.ibm.watson.assistant.v2.model.DeleteReleaseOptions; import com.ibm.watson.assistant.v2.model.DeleteSessionOptions; -import com.ibm.watson.assistant.v2.model.DialogLogMessage; -import com.ibm.watson.assistant.v2.model.DialogNodeAction; +import com.ibm.watson.assistant.v2.model.DeleteUserDataOptions; +import com.ibm.watson.assistant.v2.model.DeployReleaseOptions; +import com.ibm.watson.assistant.v2.model.DownloadReleaseExportOptions; +import com.ibm.watson.assistant.v2.model.Environment; +import com.ibm.watson.assistant.v2.model.EnvironmentCollection; +import com.ibm.watson.assistant.v2.model.EnvironmentSkill; +import com.ibm.watson.assistant.v2.model.ExportSkillsOptions; +import com.ibm.watson.assistant.v2.model.GetEnvironmentOptions; +import com.ibm.watson.assistant.v2.model.GetReleaseImportStatusOptions; +import com.ibm.watson.assistant.v2.model.GetReleaseOptions; +import com.ibm.watson.assistant.v2.model.GetSkillOptions; +import com.ibm.watson.assistant.v2.model.ImportSkillsOptions; +import com.ibm.watson.assistant.v2.model.ImportSkillsStatusOptions; +import com.ibm.watson.assistant.v2.model.ListAssistantsOptions; +import com.ibm.watson.assistant.v2.model.ListEnvironmentsOptions; +import com.ibm.watson.assistant.v2.model.ListLogsOptions; +import com.ibm.watson.assistant.v2.model.ListProvidersOptions; +import com.ibm.watson.assistant.v2.model.ListReleasesOptions; +import com.ibm.watson.assistant.v2.model.LogCollection; import com.ibm.watson.assistant.v2.model.MessageContext; +import com.ibm.watson.assistant.v2.model.MessageContextActionSkill; +import com.ibm.watson.assistant.v2.model.MessageContextDialogSkill; import com.ibm.watson.assistant.v2.model.MessageContextGlobal; import com.ibm.watson.assistant.v2.model.MessageContextGlobalSystem; +import com.ibm.watson.assistant.v2.model.MessageContextSkillSystem; import com.ibm.watson.assistant.v2.model.MessageContextSkills; import com.ibm.watson.assistant.v2.model.MessageInput; +import com.ibm.watson.assistant.v2.model.MessageInputAttachment; import com.ibm.watson.assistant.v2.model.MessageInputOptions; +import com.ibm.watson.assistant.v2.model.MessageInputOptionsSpelling; import com.ibm.watson.assistant.v2.model.MessageOptions; -import com.ibm.watson.assistant.v2.model.MessageOutputDebug; -import com.ibm.watson.assistant.v2.model.MessageResponse; +import com.ibm.watson.assistant.v2.model.MessageStatelessOptions; +import com.ibm.watson.assistant.v2.model.MessageStreamOptions; +import com.ibm.watson.assistant.v2.model.MessageStreamStatelessOptions; +import com.ibm.watson.assistant.v2.model.MonitorAssistantReleaseImportArtifactResponse; +import com.ibm.watson.assistant.v2.model.ProviderAuthenticationOAuth2; +import com.ibm.watson.assistant.v2.model.ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password; +import com.ibm.watson.assistant.v2.model.ProviderAuthenticationOAuth2PasswordUsername; +import com.ibm.watson.assistant.v2.model.ProviderAuthenticationTypeAndValue; +import com.ibm.watson.assistant.v2.model.ProviderCollection; +import com.ibm.watson.assistant.v2.model.ProviderPrivate; +import com.ibm.watson.assistant.v2.model.ProviderPrivateAuthenticationBearerFlow; +import com.ibm.watson.assistant.v2.model.ProviderResponse; +import com.ibm.watson.assistant.v2.model.ProviderSpecification; +import com.ibm.watson.assistant.v2.model.ProviderSpecificationComponents; +import com.ibm.watson.assistant.v2.model.ProviderSpecificationComponentsSecuritySchemes; +import com.ibm.watson.assistant.v2.model.ProviderSpecificationComponentsSecuritySchemesBasic; +import com.ibm.watson.assistant.v2.model.ProviderSpecificationServersItem; +import com.ibm.watson.assistant.v2.model.Release; +import com.ibm.watson.assistant.v2.model.ReleaseCollection; +import com.ibm.watson.assistant.v2.model.RequestAnalytics; import com.ibm.watson.assistant.v2.model.RuntimeEntity; +import com.ibm.watson.assistant.v2.model.RuntimeEntityAlternative; +import com.ibm.watson.assistant.v2.model.RuntimeEntityInterpretation; +import com.ibm.watson.assistant.v2.model.RuntimeEntityRole; import com.ibm.watson.assistant.v2.model.RuntimeIntent; -import com.ibm.watson.assistant.v2.model.RuntimeResponseGeneric; +import com.ibm.watson.assistant.v2.model.SearchSettings; +import com.ibm.watson.assistant.v2.model.SearchSettingsClientSideSearch; +import com.ibm.watson.assistant.v2.model.SearchSettingsConversationalSearch; +import com.ibm.watson.assistant.v2.model.SearchSettingsConversationalSearchResponseLength; +import com.ibm.watson.assistant.v2.model.SearchSettingsConversationalSearchSearchConfidence; +import com.ibm.watson.assistant.v2.model.SearchSettingsDiscovery; +import com.ibm.watson.assistant.v2.model.SearchSettingsDiscoveryAuthentication; +import com.ibm.watson.assistant.v2.model.SearchSettingsElasticSearch; +import com.ibm.watson.assistant.v2.model.SearchSettingsMessages; +import com.ibm.watson.assistant.v2.model.SearchSettingsSchemaMapping; +import com.ibm.watson.assistant.v2.model.SearchSettingsServerSideSearch; import com.ibm.watson.assistant.v2.model.SessionResponse; -import com.ibm.watson.common.WatsonServiceUnitTest; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; +import com.ibm.watson.assistant.v2.model.Skill; +import com.ibm.watson.assistant.v2.model.SkillImport; +import com.ibm.watson.assistant.v2.model.SkillsAsyncRequestStatus; +import com.ibm.watson.assistant.v2.model.SkillsExport; +import com.ibm.watson.assistant.v2.model.StatefulMessageResponse; +import com.ibm.watson.assistant.v2.model.StatelessMessageContext; +import com.ibm.watson.assistant.v2.model.StatelessMessageContextGlobal; +import com.ibm.watson.assistant.v2.model.StatelessMessageContextSkills; +import com.ibm.watson.assistant.v2.model.StatelessMessageContextSkillsActionsSkill; +import com.ibm.watson.assistant.v2.model.StatelessMessageInput; +import com.ibm.watson.assistant.v2.model.StatelessMessageInputOptions; +import com.ibm.watson.assistant.v2.model.StatelessMessageResponse; +import com.ibm.watson.assistant.v2.model.UpdateEnvironmentOptions; +import com.ibm.watson.assistant.v2.model.UpdateEnvironmentOrchestration; +import com.ibm.watson.assistant.v2.model.UpdateProviderOptions; +import com.ibm.watson.assistant.v2.model.UpdateSkillOptions; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +/** Unit test class for the Assistant service. */ +public class AssistantTest { -/** - * Unit tests for Assistant v2. - */ -public class AssistantTest extends WatsonServiceUnitTest { - private static final String ASSISTANT_ID = "assistant_id"; - private static final String SESSION_ID = "session_id"; - private static final String TIMEZONE = "timezone"; - private static final Long TURN_COUNT = 10L; - private static final String USER_ID = "user_id"; - private static final String GROUP = "group"; - private static final List LOCATION = Arrays.asList(1L, 2L); - private static final Double CONFIDENCE = 0.0; - private static final String ENTITY = "entity"; - private static final Map MAP = new HashMap<>(); - private static final String VALUE = "value"; - private static final String INTENT = "intent"; - private static final String TEXT = "text"; - private static final String SUGGESTION_ID = "suggestion_id"; - private static final String MESSAGE = "message"; - private static final String CONDITIONS = "conditions"; - private static final String TITLE = "title"; - private static final String DIALOG_NODE = "dialog_node"; - private static final String NAME = "name"; - private static final String RESULT_VARIABLE = "result_variable"; - private static final String CREDENTIALS = "credentials"; - private static final String DESCRIPTION = "description"; - private static final Long TIME = 1234L; - private static final String SOURCE = "source"; - private static final String TOPIC = "topic"; - private static final String LABEL = "label"; - - private static final String VERSION = "2018-09-20"; - private static final String RESOURCE = "src/test/resources/assistant/"; - private static final String MESSAGE_PATH = String.format( - "/v2/assistants/%s/sessions/%s/message?version=%s", - ASSISTANT_ID, - SESSION_ID, - VERSION); - private static final String CREATE_SESSION_PATH = String.format( - "/v2/assistants/%s/sessions?version=%s", - ASSISTANT_ID, - VERSION); - private static final String DELETE_SESSION_PATH = String.format( - "/v2/assistants/%s/sessions/%s?version=%s", - ASSISTANT_ID, - SESSION_ID, - VERSION); + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Assistant assistantService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // Set mock values for global params + String version = "testString"; + new Assistant(version, serviceName, null); + } + + // Test the getter for the version global parameter + @Test + public void testGetVersion() throws Throwable { + assertEquals(assistantService.getVersion(), "testString"); + } + + // Test the createProvider operation with a valid options model parameter + @Test + public void testCreateProviderWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"provider_id\": \"providerId\", \"specification\": {\"servers\": [{\"url\": \"url\"}], \"components\": {\"securitySchemes\": {\"authentication_method\": \"basic\", \"basic\": {\"username\": {\"type\": \"value\", \"value\": \"value\"}}, \"oauth2\": {\"preferred_flow\": \"password\", \"flows\": {\"token_url\": \"tokenUrl\", \"refresh_url\": \"refreshUrl\", \"client_auth_type\": \"Body\", \"content_type\": \"contentType\", \"header_prefix\": \"headerPrefix\", \"username\": {\"type\": \"value\", \"value\": \"value\"}}}}}}}"; + String createProviderPath = "/v2/providers"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ProviderSpecificationServersItem model + ProviderSpecificationServersItem providerSpecificationServersItemModel = + new ProviderSpecificationServersItem.Builder().url("testString").build(); + + // Construct an instance of the ProviderAuthenticationTypeAndValue model + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + + // Construct an instance of the ProviderSpecificationComponentsSecuritySchemesBasic model + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + + // Construct an instance of the ProviderAuthenticationOAuth2PasswordUsername model + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + + // Construct an instance of the + // ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password model + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + + // Construct an instance of the ProviderAuthenticationOAuth2 model + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + + // Construct an instance of the ProviderSpecificationComponentsSecuritySchemes model + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + + // Construct an instance of the ProviderSpecificationComponents model + ProviderSpecificationComponents providerSpecificationComponentsModel = + new ProviderSpecificationComponents.Builder() + .securitySchemes(providerSpecificationComponentsSecuritySchemesModel) + .build(); + + // Construct an instance of the ProviderSpecification model + ProviderSpecification providerSpecificationModel = + new ProviderSpecification.Builder() + .servers(java.util.Arrays.asList(providerSpecificationServersItemModel)) + .components(providerSpecificationComponentsModel) + .build(); + + // Construct an instance of the ProviderPrivateAuthenticationBearerFlow model + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationModel = + new ProviderPrivateAuthenticationBearerFlow.Builder() + .token(providerAuthenticationTypeAndValueModel) + .build(); + + // Construct an instance of the ProviderPrivate model + ProviderPrivate providerPrivateModel = + new ProviderPrivate.Builder().authentication(providerPrivateAuthenticationModel).build(); + + // Construct an instance of the CreateProviderOptions model + CreateProviderOptions createProviderOptionsModel = + new CreateProviderOptions.Builder() + .providerId("testString") + .specification(providerSpecificationModel) + .xPrivate(providerPrivateModel) + .build(); + + // Invoke createProvider() with a valid options model and verify the result + Response response = + assistantService.createProvider(createProviderOptionsModel).execute(); + assertNotNull(response); + ProviderResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createProviderPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createProvider operation with and without retries enabled + @Test + public void testCreateProviderWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateProviderWOptions(); + + assistantService.disableRetries(); + testCreateProviderWOptions(); + } + + // Test the createProvider operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateProviderNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createProvider(null).execute(); + } + + // Test the listProviders operation with a valid options model parameter + @Test + public void testListProvidersWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"conversational_skill_providers\": [{\"provider_id\": \"providerId\", \"specification\": {\"servers\": [{\"url\": \"url\"}], \"components\": {\"securitySchemes\": {\"authentication_method\": \"basic\", \"basic\": {\"username\": {\"type\": \"value\", \"value\": \"value\"}}, \"oauth2\": {\"preferred_flow\": \"password\", \"flows\": {\"token_url\": \"tokenUrl\", \"refresh_url\": \"refreshUrl\", \"client_auth_type\": \"Body\", \"content_type\": \"contentType\", \"header_prefix\": \"headerPrefix\", \"username\": {\"type\": \"value\", \"value\": \"value\"}}}}}}}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listProvidersPath = "/v2/providers"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListProvidersOptions model + ListProvidersOptions listProvidersOptionsModel = + new ListProvidersOptions.Builder() + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listProviders() with a valid options model and verify the result + Response response = + assistantService.listProviders(listProvidersOptionsModel).execute(); + assertNotNull(response); + ProviderCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listProvidersPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "name"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listProviders operation with and without retries enabled + @Test + public void testListProvidersWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListProvidersWOptions(); + + assistantService.disableRetries(); + testListProvidersWOptions(); + } + + // Test the updateProvider operation with a valid options model parameter + @Test + public void testUpdateProviderWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"provider_id\": \"providerId\", \"specification\": {\"servers\": [{\"url\": \"url\"}], \"components\": {\"securitySchemes\": {\"authentication_method\": \"basic\", \"basic\": {\"username\": {\"type\": \"value\", \"value\": \"value\"}}, \"oauth2\": {\"preferred_flow\": \"password\", \"flows\": {\"token_url\": \"tokenUrl\", \"refresh_url\": \"refreshUrl\", \"client_auth_type\": \"Body\", \"content_type\": \"contentType\", \"header_prefix\": \"headerPrefix\", \"username\": {\"type\": \"value\", \"value\": \"value\"}}}}}}}"; + String updateProviderPath = "/v2/providers/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ProviderSpecificationServersItem model + ProviderSpecificationServersItem providerSpecificationServersItemModel = + new ProviderSpecificationServersItem.Builder().url("testString").build(); + + // Construct an instance of the ProviderAuthenticationTypeAndValue model + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + + // Construct an instance of the ProviderSpecificationComponentsSecuritySchemesBasic model + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + + // Construct an instance of the ProviderAuthenticationOAuth2PasswordUsername model + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + + // Construct an instance of the + // ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password model + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + + // Construct an instance of the ProviderAuthenticationOAuth2 model + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + + // Construct an instance of the ProviderSpecificationComponentsSecuritySchemes model + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + + // Construct an instance of the ProviderSpecificationComponents model + ProviderSpecificationComponents providerSpecificationComponentsModel = + new ProviderSpecificationComponents.Builder() + .securitySchemes(providerSpecificationComponentsSecuritySchemesModel) + .build(); + + // Construct an instance of the ProviderSpecification model + ProviderSpecification providerSpecificationModel = + new ProviderSpecification.Builder() + .servers(java.util.Arrays.asList(providerSpecificationServersItemModel)) + .components(providerSpecificationComponentsModel) + .build(); + + // Construct an instance of the ProviderPrivateAuthenticationBearerFlow model + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationModel = + new ProviderPrivateAuthenticationBearerFlow.Builder() + .token(providerAuthenticationTypeAndValueModel) + .build(); + + // Construct an instance of the ProviderPrivate model + ProviderPrivate providerPrivateModel = + new ProviderPrivate.Builder().authentication(providerPrivateAuthenticationModel).build(); + + // Construct an instance of the UpdateProviderOptions model + UpdateProviderOptions updateProviderOptionsModel = + new UpdateProviderOptions.Builder() + .providerId("testString") + .specification(providerSpecificationModel) + .xPrivate(providerPrivateModel) + .build(); + + // Invoke updateProvider() with a valid options model and verify the result + Response response = + assistantService.updateProvider(updateProviderOptionsModel).execute(); + assertNotNull(response); + ProviderResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateProviderPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateProvider operation with and without retries enabled + @Test + public void testUpdateProviderWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateProviderWOptions(); + + assistantService.disableRetries(); + testUpdateProviderWOptions(); + } + + // Test the updateProvider operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateProviderNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateProvider(null).execute(); + } + + // Test the createAssistant operation with a valid options model parameter + @Test + public void testCreateAssistantWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"assistant_id\": \"assistantId\", \"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"assistant_skills\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\"}], \"assistant_environments\": [{\"name\": \"name\", \"environment_id\": \"environmentId\", \"environment\": \"draft\"}]}"; + String createAssistantPath = "/v2/assistants"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateAssistantOptions model + CreateAssistantOptions createAssistantOptionsModel = + new CreateAssistantOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .build(); + + // Invoke createAssistant() with a valid options model and verify the result + Response response = + assistantService.createAssistant(createAssistantOptionsModel).execute(); + assertNotNull(response); + AssistantData responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createAssistantPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createAssistant operation with and without retries enabled + @Test + public void testCreateAssistantWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateAssistantWOptions(); + + assistantService.disableRetries(); + testCreateAssistantWOptions(); + } + + // Test the listAssistants operation with a valid options model parameter + @Test + public void testListAssistantsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"assistants\": [{\"assistant_id\": \"assistantId\", \"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"assistant_skills\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\"}], \"assistant_environments\": [{\"name\": \"name\", \"environment_id\": \"environmentId\", \"environment\": \"draft\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listAssistantsPath = "/v2/assistants"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListAssistantsOptions model + ListAssistantsOptions listAssistantsOptionsModel = + new ListAssistantsOptions.Builder() + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listAssistants() with a valid options model and verify the result + Response response = + assistantService.listAssistants(listAssistantsOptionsModel).execute(); + assertNotNull(response); + AssistantCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAssistantsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "name"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listAssistants operation with and without retries enabled + @Test + public void testListAssistantsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListAssistantsWOptions(); + + assistantService.disableRetries(); + testListAssistantsWOptions(); + } + + // Test the deleteAssistant operation with a valid options model parameter + @Test + public void testDeleteAssistantWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteAssistantPath = "/v2/assistants/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteAssistantOptions model + DeleteAssistantOptions deleteAssistantOptionsModel = + new DeleteAssistantOptions.Builder().assistantId("testString").build(); + + // Invoke deleteAssistant() with a valid options model and verify the result + Response response = + assistantService.deleteAssistant(deleteAssistantOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteAssistantPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteAssistant operation with and without retries enabled + @Test + public void testDeleteAssistantWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteAssistantWOptions(); + + assistantService.disableRetries(); + testDeleteAssistantWOptions(); + } + + // Test the deleteAssistant operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAssistantNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteAssistant(null).execute(); + } + + // Test the createSession operation with a valid options model parameter + @Test + public void testCreateSessionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"session_id\": \"sessionId\"}"; + String createSessionPath = "/v2/assistants/testString/environments/testString/sessions"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the RequestAnalytics model + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + + // Construct an instance of the CreateSessionOptions model + CreateSessionOptions createSessionOptionsModel = + new CreateSessionOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .analytics(requestAnalyticsModel) + .build(); + + // Invoke createSession() with a valid options model and verify the result + Response response = + assistantService.createSession(createSessionOptionsModel).execute(); + assertNotNull(response); + SessionResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createSessionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createSession operation with and without retries enabled + @Test + public void testCreateSessionWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateSessionWOptions(); - private MessageResponse messageResponse; - private SessionResponse sessionResponse; - - private Assistant service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - MAP.put("key", "value"); - - messageResponse = loadFixture(RESOURCE + "message_response.json", MessageResponse.class); - sessionResponse = loadFixture(RESOURCE + "session_response.json", SessionResponse.class); - - service = new Assistant(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } - - @Test - public void testCaptureGroup() { - CaptureGroup captureGroup = new CaptureGroup.Builder() - .group(GROUP) - .location(LOCATION) - .build(); - - assertEquals(GROUP, captureGroup.group()); - assertEquals(LOCATION, captureGroup.location()); - } - - @Test - public void testCreateSessionOptions() { - CreateSessionOptions createSessionOptions = new CreateSessionOptions.Builder() - .assistantId(ASSISTANT_ID) - .build(); - createSessionOptions = createSessionOptions.newBuilder().build(); - - assertEquals(ASSISTANT_ID, createSessionOptions.assistantId()); - } - - @Test - public void testDeleteSessionOptions() { - DeleteSessionOptions deleteSessionOptions = new DeleteSessionOptions.Builder() - .assistantId(ASSISTANT_ID) - .sessionId(SESSION_ID) - .build(); - deleteSessionOptions = deleteSessionOptions.newBuilder().build(); - - assertEquals(ASSISTANT_ID, deleteSessionOptions.assistantId()); - assertEquals(SESSION_ID, deleteSessionOptions.sessionId()); - } - - @Test - public void testMessageContextGlobalSystem() { - MessageContextGlobalSystem messageContextGlobalSystem = new MessageContextGlobalSystem.Builder() - .timezone(TIMEZONE) - .turnCount(TURN_COUNT) - .userId(USER_ID) - .build(); - - assertEquals(TIMEZONE, messageContextGlobalSystem.timezone()); - assertEquals(TURN_COUNT, messageContextGlobalSystem.turnCount()); - assertEquals(USER_ID, messageContextGlobalSystem.userId()); - } - - @Test - public void testMessageContextGlobal() { - MessageContextGlobalSystem messageContextGlobalSystem = new MessageContextGlobalSystem.Builder().build(); - - MessageContextGlobal messageContextGlobal = new MessageContextGlobal.Builder() - .system(messageContextGlobalSystem) - .build(); + assistantService.disableRetries(); + testCreateSessionWOptions(); + } + + // Test the createSession operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSessionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createSession(null).execute(); + } + + // Test the deleteSession operation with a valid options model parameter + @Test + public void testDeleteSessionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteSessionPath = + "/v2/assistants/testString/environments/testString/sessions/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteSessionOptions model + DeleteSessionOptions deleteSessionOptionsModel = + new DeleteSessionOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .sessionId("testString") + .build(); + + // Invoke deleteSession() with a valid options model and verify the result + Response response = assistantService.deleteSession(deleteSessionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); - assertEquals(messageContextGlobalSystem, messageContextGlobal.system()); + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteSessionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the deleteSession operation with and without retries enabled @Test - public void testMessageContext() { - MessageContextGlobal messageContextGlobal = new MessageContextGlobal.Builder().build(); - MessageContextSkills messageContextSkills = new MessageContextSkills(); + public void testDeleteSessionWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteSessionWOptions(); - MessageContext messageContext = new MessageContext.Builder() - .global(messageContextGlobal) - .skills(messageContextSkills) - .build(); + assistantService.disableRetries(); + testDeleteSessionWOptions(); + } - assertEquals(messageContextGlobal, messageContext.global()); - assertEquals(messageContextSkills, messageContext.skills()); + // Test the deleteSession operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSessionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteSession(null).execute(); } + // Test the message operation with a valid options model parameter @Test - public void testMessageInput() { - RuntimeEntity entity1 = new RuntimeEntity.Builder() - .entity(ENTITY) - .location(LOCATION) - .value(VALUE) - .build(); - RuntimeEntity entity2 = new RuntimeEntity.Builder() - .entity(ENTITY) - .location(LOCATION) - .value(VALUE) - .build(); - List entityList = new ArrayList<>(); - entityList.add(entity1); - RuntimeIntent intent1 = new RuntimeIntent.Builder() - .confidence(CONFIDENCE) - .intent(INTENT) - .build(); - RuntimeIntent intent2 = new RuntimeIntent.Builder() - .confidence(CONFIDENCE) - .intent(INTENT) - .build(); - List intentList = new ArrayList<>(); - intentList.add(intent1); - MessageInputOptions inputOptions = new MessageInputOptions.Builder().build(); + public void testMessageWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"output\": {\"generic\": [{\"response_type\": \"conversation_search\", \"text\": \"text\", \"citations_title\": \"citationsTitle\", \"citations\": [{\"title\": \"title\", \"text\": \"text\", \"body\": \"body\", \"search_result_index\": 17, \"ranges\": [{\"start\": 5, \"end\": 3}]}], \"confidence_scores\": {\"threshold\": 9, \"pre_gen\": 6, \"post_gen\": 7, \"extractiveness\": 14}, \"response_length_option\": \"responseLengthOption\", \"search_results\": [{\"result_metadata\": {\"document_retrieval_source\": \"documentRetrievalSource\", \"score\": 5}, \"id\": \"id\", \"title\": \"title\", \"body\": \"body\"}], \"disclaimer\": \"disclaimer\"}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}, \"llm_metadata\": [{\"task\": \"task\", \"model_id\": \"modelId\"}]}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\", \"masked_output\": {\"generic\": [{\"response_type\": \"conversation_search\", \"text\": \"text\", \"citations_title\": \"citationsTitle\", \"citations\": [{\"title\": \"title\", \"text\": \"text\", \"body\": \"body\", \"search_result_index\": 17, \"ranges\": [{\"start\": 5, \"end\": 3}]}], \"confidence_scores\": {\"threshold\": 9, \"pre_gen\": 6, \"post_gen\": 7, \"extractiveness\": 14}, \"response_length_option\": \"responseLengthOption\", \"search_results\": [{\"result_metadata\": {\"document_retrieval_source\": \"documentRetrievalSource\", \"score\": 5}, \"id\": \"id\", \"title\": \"title\", \"body\": \"body\"}], \"disclaimer\": \"disclaimer\"}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}, \"llm_metadata\": [{\"task\": \"task\", \"model_id\": \"modelId\"}]}, \"masked_input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"async_callout\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}}"; + String messagePath = + "/v2/assistants/testString/environments/testString/sessions/testString/message"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + + // Construct an instance of the MessageInputAttachment model + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + + // Construct an instance of the RequestAnalytics model + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + + // Construct an instance of the MessageInputOptionsSpelling model + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + + // Construct an instance of the MessageInputOptions model + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + + // Construct an instance of the MessageInput model + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + + // Construct an instance of the MessageContextGlobalSystem model + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + + // Construct an instance of the MessageContextGlobal model + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + + // Construct an instance of the MessageContextSkillSystem model + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageContextDialogSkill model + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + + // Construct an instance of the MessageContextActionSkill model + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageContextSkills model + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + + // Construct an instance of the MessageContext model + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageOptions model + MessageOptions messageOptionsModel = + new MessageOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .sessionId("testString") + .input(messageInputModel) + .context(messageContextModel) + .userId("testString") + .build(); + + // Invoke message() with a valid options model and verify the result + Response response = + assistantService.message(messageOptionsModel).execute(); + assertNotNull(response); + StatefulMessageResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messagePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } - MessageInput messageInput = new MessageInput.Builder() - .messageType(MessageInput.MessageType.TEXT) - .entities(entityList) - .addEntity(entity2) - .intents(intentList) - .addIntent(intent2) - .options(inputOptions) - .suggestionId(SUGGESTION_ID) - .text(TEXT) - .build(); - messageInput = messageInput.newBuilder().build(); + // Test the message operation with and without retries enabled + @Test + public void testMessageWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testMessageWOptions(); - entityList.add(entity2); - intentList.add(intent2); - assertEquals(MessageInput.MessageType.TEXT, messageInput.messageType()); - assertEquals(entityList, messageInput.entities()); - assertEquals(intentList, messageInput.intents()); - assertEquals(inputOptions, messageInput.options()); - assertEquals(SUGGESTION_ID, messageInput.suggestionId()); - assertEquals(TEXT, messageInput.text()); - } - - @Test - public void testMessageInputOptions() { - MessageInputOptions inputOptions = new MessageInputOptions.Builder() - .alternateIntents(true) - .debug(true) - .restart(true) - .returnContext(true) - .build(); - - assertTrue(inputOptions.alternateIntents()); - assertTrue(inputOptions.debug()); - assertTrue(inputOptions.restart()); - assertTrue(inputOptions.returnContext()); - } - - @Test - public void testMessageOptions() { - MessageContext messageContext = new MessageContext.Builder().build(); - MessageInput messageInput = new MessageInput.Builder().build(); - - MessageOptions messageOptions = new MessageOptions.Builder() - .assistantId(ASSISTANT_ID) - .context(messageContext) - .input(messageInput) - .sessionId(SESSION_ID) - .build(); - messageOptions = messageOptions.newBuilder().build(); - - assertEquals(ASSISTANT_ID, messageOptions.assistantId()); - assertEquals(messageContext, messageOptions.context()); - assertEquals(messageInput, messageOptions.input()); - assertEquals(SESSION_ID, messageOptions.sessionId()); - } - - @Test - public void testRuntimeEntity() { - CaptureGroup captureGroup = new CaptureGroup.Builder() - .group(GROUP) - .build(); - List captureGroupList = Collections.singletonList(captureGroup); - - RuntimeEntity runtimeEntity = new RuntimeEntity.Builder() - .confidence(CONFIDENCE) - .entity(ENTITY) - .groups(captureGroupList) - .location(LOCATION) - .metadata(MAP) - .value(VALUE) - .build(); - - assertEquals(CONFIDENCE, runtimeEntity.confidence()); - assertEquals(ENTITY, runtimeEntity.entity()); - assertEquals(captureGroupList, runtimeEntity.groups()); - assertEquals(LOCATION, runtimeEntity.location()); - assertEquals(MAP, runtimeEntity.metadata()); - assertEquals(VALUE, runtimeEntity.value()); - } - - @Test - public void testRuntimeIntent() { - RuntimeIntent runtimeIntent = new RuntimeIntent.Builder() - .confidence(CONFIDENCE) - .intent(INTENT) - .build(); - - assertEquals(CONFIDENCE, runtimeIntent.confidence()); - assertEquals(INTENT, runtimeIntent.intent()); - } - - @Test - public void testMessage() throws InterruptedException { - server.enqueue(jsonResponse(messageResponse)); - - MessageOptions messageOptions = new MessageOptions.Builder() - .assistantId(ASSISTANT_ID) - .sessionId(SESSION_ID) - .build(); - MessageResponse response = service.message(messageOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(MESSAGE_PATH, request.getPath()); - assertNotNull(response.getContext()); - assertNotNull(response.getOutput()); + assistantService.disableRetries(); + testMessageWOptions(); + } - assertEquals(DialogNodeAction.Type.CLIENT, response.getOutput().getActions().get(0).getType()); - assertEquals(NAME, response.getOutput().getActions().get(0).getName()); - assertEquals(MAP, response.getOutput().getActions().get(0).getParameters()); - assertEquals(RESULT_VARIABLE, response.getOutput().getActions().get(0).getResultVariable()); - assertEquals(CREDENTIALS, response.getOutput().getActions().get(0).getCredentials()); - assertEquals(MessageOutputDebug.BranchExitedReason.COMPLETED, - response.getOutput().getDebug().getBranchExitedReason()); - assertEquals(DialogLogMessage.Level.INFO, response.getOutput().getDebug().getLogMessages().get(0).getLevel()); - assertEquals(MESSAGE, response.getOutput().getDebug().getLogMessages().get(0).getMessage()); - assertEquals(CONDITIONS, response.getOutput().getDebug().getNodesVisited().get(0).getConditions()); - assertEquals(TITLE, response.getOutput().getDebug().getNodesVisited().get(0).getTitle()); - assertEquals(DIALOG_NODE, response.getOutput().getDebug().getNodesVisited().get(0).getDialogNode()); - assertTrue(response.getOutput().getDebug().isBranchExited()); - assertEquals(DESCRIPTION, response.getOutput().getGeneric().get(0).description()); - assertEquals(RuntimeResponseGeneric.ResponseType.TEXT, - response.getOutput().getGeneric().get(0).responseType()); - assertEquals(RuntimeResponseGeneric.Preference.BUTTON, - response.getOutput().getGeneric().get(0).preference()); - assertEquals(TEXT, response.getOutput().getGeneric().get(0).text()); - assertEquals(TIME, response.getOutput().getGeneric().get(0).time()); - assertTrue(response.getOutput().getGeneric().get(0).typing()); - assertEquals(SOURCE, response.getOutput().getGeneric().get(0).source()); - assertEquals(TITLE, response.getOutput().getGeneric().get(0).title()); - assertEquals(MESSAGE, response.getOutput().getGeneric().get(0).messageToHumanAgent()); - assertEquals(TOPIC, response.getOutput().getGeneric().get(0).topic()); - assertEquals(LABEL, response.getOutput().getGeneric().get(0).options().get(0).getLabel()); - assertNotNull(response.getOutput().getGeneric().get(0).options().get(0).getValue().getInput()); - assertEquals(LABEL, response.getOutput().getGeneric().get(0).suggestions().get(0).getLabel()); - assertNotNull(response.getOutput().getGeneric().get(0).suggestions().get(0).getValue()); + // Test the message operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.message(null).execute(); } + // Test the messageStateless operation with a valid options model parameter @Test - public void testCreateSession() throws InterruptedException { - server.enqueue(jsonResponse(sessionResponse)); + public void testMessageStatelessWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"output\": {\"generic\": [{\"response_type\": \"conversation_search\", \"text\": \"text\", \"citations_title\": \"citationsTitle\", \"citations\": [{\"title\": \"title\", \"text\": \"text\", \"body\": \"body\", \"search_result_index\": 17, \"ranges\": [{\"start\": 5, \"end\": 3}]}], \"confidence_scores\": {\"threshold\": 9, \"pre_gen\": 6, \"post_gen\": 7, \"extractiveness\": 14}, \"response_length_option\": \"responseLengthOption\", \"search_results\": [{\"result_metadata\": {\"document_retrieval_source\": \"documentRetrievalSource\", \"score\": 5}, \"id\": \"id\", \"title\": \"title\", \"body\": \"body\"}], \"disclaimer\": \"disclaimer\"}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}, \"llm_metadata\": [{\"task\": \"task\", \"model_id\": \"modelId\"}]}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}, \"private_action_variables\": {\"anyKey\": \"anyValue\"}, \"private_skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"masked_output\": {\"generic\": [{\"response_type\": \"conversation_search\", \"text\": \"text\", \"citations_title\": \"citationsTitle\", \"citations\": [{\"title\": \"title\", \"text\": \"text\", \"body\": \"body\", \"search_result_index\": 17, \"ranges\": [{\"start\": 5, \"end\": 3}]}], \"confidence_scores\": {\"threshold\": 9, \"pre_gen\": 6, \"post_gen\": 7, \"extractiveness\": 14}, \"response_length_option\": \"responseLengthOption\", \"search_results\": [{\"result_metadata\": {\"document_retrieval_source\": \"documentRetrievalSource\", \"score\": 5}, \"id\": \"id\", \"title\": \"title\", \"body\": \"body\"}], \"disclaimer\": \"disclaimer\"}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}, \"llm_metadata\": [{\"task\": \"task\", \"model_id\": \"modelId\"}]}, \"masked_input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"async_callout\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}, \"user_id\": \"userId\"}"; + String messageStatelessPath = "/v2/assistants/testString/environments/testString/message"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + + // Construct an instance of the MessageInputAttachment model + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + + // Construct an instance of the RequestAnalytics model + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + + // Construct an instance of the MessageInputOptionsSpelling model + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); - CreateSessionOptions createSessionOptions = new CreateSessionOptions.Builder() - .assistantId(ASSISTANT_ID) - .build(); - SessionResponse response = service.createSession(createSessionOptions).execute().getResult(); + // Construct an instance of the StatelessMessageInputOptions model + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .build(); + + // Construct an instance of the StatelessMessageInput model + StatelessMessageInput statelessMessageInputModel = + new StatelessMessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(statelessMessageInputOptionsModel) + .build(); + + // Construct an instance of the MessageContextGlobalSystem model + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + + // Construct an instance of the StatelessMessageContextGlobal model + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + + // Construct an instance of the MessageContextSkillSystem model + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageContextDialogSkill model + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + + // Construct an instance of the StatelessMessageContextSkillsActionsSkill model + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the StatelessMessageContextSkills model + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) + .build(); + + // Construct an instance of the StatelessMessageContext model + StatelessMessageContext statelessMessageContextModel = + new StatelessMessageContext.Builder() + .global(statelessMessageContextGlobalModel) + .skills(statelessMessageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageStatelessOptions model + MessageStatelessOptions messageStatelessOptionsModel = + new MessageStatelessOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .input(statelessMessageInputModel) + .context(statelessMessageContextModel) + .userId("testString") + .build(); + + // Invoke messageStateless() with a valid options model and verify the result + Response response = + assistantService.messageStateless(messageStatelessOptionsModel).execute(); + assertNotNull(response); + StatelessMessageResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messageStatelessPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the messageStateless operation with and without retries enabled + @Test + public void testMessageStatelessWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testMessageStatelessWOptions(); + + assistantService.disableRetries(); + testMessageStatelessWOptions(); + } + + // Test the messageStateless operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStatelessNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.messageStateless(null).execute(); + } + + // Test the messageStream operation with a valid options model parameter + @Test + public void testMessageStreamWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "This is a mock binary response."; + String messageStreamPath = + "/v2/assistants/testString/environments/testString/sessions/testString/message_stream"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "text/event-stream") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + + // Construct an instance of the MessageInputAttachment model + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + + // Construct an instance of the RequestAnalytics model + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + + // Construct an instance of the MessageInputOptionsSpelling model + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + + // Construct an instance of the MessageInputOptions model + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + // Construct an instance of the MessageInput model + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + + // Construct an instance of the MessageContextGlobalSystem model + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + + // Construct an instance of the MessageContextGlobal model + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + + // Construct an instance of the MessageContextSkillSystem model + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageContextDialogSkill model + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + + // Construct an instance of the MessageContextActionSkill model + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageContextSkills model + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + + // Construct an instance of the MessageContext model + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageStreamOptions model + MessageStreamOptions messageStreamOptionsModel = + new MessageStreamOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .sessionId("testString") + .input(messageInputModel) + .context(messageContextModel) + .userId("testString") + .build(); + + // Invoke messageStream() with a valid options model and verify the result + Response response = + assistantService.messageStream(messageStreamOptionsModel).execute(); assertNotNull(response); - assertEquals(CREATE_SESSION_PATH, request.getPath()); + try (InputStream responseObj = response.getResult(); ) { + assertNotNull(responseObj); + } - assertEquals(SESSION_ID, response.getSessionId()); + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messageStreamPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the messageStream operation with and without retries enabled @Test - public void testDeleteSession() throws InterruptedException { + public void testMessageStreamWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testMessageStreamWOptions(); + + assistantService.disableRetries(); + testMessageStreamWOptions(); + } + + // Test the messageStream operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); + assistantService.messageStream(null).execute(); + } + + // Test the messageStreamStateless operation with a valid options model parameter + @Test + public void testMessageStreamStatelessWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "This is a mock binary response."; + String messageStreamStatelessPath = + "/v2/assistants/testString/environments/testString/message_stream"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "text/event-stream") + .setResponseCode(200) + .setBody(mockResponseBody)); - DeleteSessionOptions deleteSessionOptions = new DeleteSessionOptions.Builder() - .assistantId(ASSISTANT_ID) - .sessionId(SESSION_ID) - .build(); - service.deleteSession(deleteSessionOptions).execute().getResult(); + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + + // Construct an instance of the MessageInputAttachment model + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + + // Construct an instance of the RequestAnalytics model + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + + // Construct an instance of the MessageInputOptionsSpelling model + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + + // Construct an instance of the MessageInputOptions model + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + + // Construct an instance of the MessageInput model + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + + // Construct an instance of the MessageContextGlobalSystem model + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + + // Construct an instance of the MessageContextGlobal model + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + + // Construct an instance of the MessageContextSkillSystem model + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageContextDialogSkill model + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + + // Construct an instance of the MessageContextActionSkill model + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageContextSkills model + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + + // Construct an instance of the MessageContext model + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the MessageStreamStatelessOptions model + MessageStreamStatelessOptions messageStreamStatelessOptionsModel = + new MessageStreamStatelessOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .input(messageInputModel) + .context(messageContextModel) + .userId("testString") + .build(); + + // Invoke messageStreamStateless() with a valid options model and verify the result + Response response = + assistantService.messageStreamStateless(messageStreamStatelessOptionsModel).execute(); + assertNotNull(response); + try (InputStream responseObj = response.getResult(); ) { + assertNotNull(responseObj); + } + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messageStreamStatelessPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the messageStreamStateless operation with and without retries enabled + @Test + public void testMessageStreamStatelessWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testMessageStreamStatelessWOptions(); + + assistantService.disableRetries(); + testMessageStreamStatelessWOptions(); + } + + // Test the messageStreamStateless operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStreamStatelessNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.messageStreamStateless(null).execute(); + } + + // Test the bulkClassify operation with a valid options model parameter + @Test + public void testBulkClassifyWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"output\": [{\"input\": {\"text\": \"text\"}, \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}]}]}"; + String bulkClassifyPath = "/v2/skills/testString/workspace/bulk_classify"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the BulkClassifyUtterance model + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + + // Construct an instance of the BulkClassifyOptions model + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .skillId("testString") + .input(java.util.Arrays.asList(bulkClassifyUtteranceModel)) + .build(); + + // Invoke bulkClassify() with a valid options model and verify the result + Response response = + assistantService.bulkClassify(bulkClassifyOptionsModel).execute(); + assertNotNull(response); + BulkClassifyResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, bulkClassifyPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the bulkClassify operation with and without retries enabled + @Test + public void testBulkClassifyWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testBulkClassifyWOptions(); + + assistantService.disableRetries(); + testBulkClassifyWOptions(); + } + + // Test the bulkClassify operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.bulkClassify(null).execute(); + } + + // Test the listLogs operation with a valid options model parameter + @Test + public void testListLogsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"logs\": [{\"log_id\": \"logId\", \"request\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"async_callout\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}, \"response\": {\"output\": {\"generic\": [{\"response_type\": \"conversation_search\", \"text\": \"text\", \"citations_title\": \"citationsTitle\", \"citations\": [{\"title\": \"title\", \"text\": \"text\", \"body\": \"body\", \"search_result_index\": 17, \"ranges\": [{\"start\": 5, \"end\": 3}]}], \"confidence_scores\": {\"threshold\": 9, \"pre_gen\": 6, \"post_gen\": 7, \"extractiveness\": 14}, \"response_length_option\": \"responseLengthOption\", \"search_results\": [{\"result_metadata\": {\"document_retrieval_source\": \"documentRetrievalSource\", \"score\": 5}, \"id\": \"id\", \"title\": \"title\", \"body\": \"body\"}], \"disclaimer\": \"disclaimer\"}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}, \"llm_metadata\": [{\"task\": \"task\", \"model_id\": \"modelId\"}]}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}, \"assistant_id\": \"assistantId\", \"session_id\": \"sessionId\", \"skill_id\": \"skillId\", \"snapshot\": \"snapshot\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"language\": \"language\", \"customer_id\": \"customerId\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + String listLogsPath = "/v2/assistants/testString/logs"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListLogsOptions model + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .assistantId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .build(); + + // Invoke listLogs() with a valid options model and verify the result + Response response = assistantService.listLogs(listLogsOptionsModel).execute(); + assertNotNull(response); + LogCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLogsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(query.get("cursor"), "testString"); + } + + // Test the listLogs operation with and without retries enabled + @Test + public void testListLogsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListLogsWOptions(); + + assistantService.disableRetries(); + testListLogsWOptions(); + } + + // Test the listLogs operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listLogs(null).execute(); + } + + // Test the deleteUserData operation with a valid options model parameter + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteUserDataPath = "/v2/user_data"; + server.enqueue(new MockResponse().setResponseCode(202).setBody(mockResponseBody)); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke deleteUserData() with a valid options model and verify the result + Response response = assistantService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + } + + // Test the deleteUserData operation with and without retries enabled + @Test + public void testDeleteUserDataWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteUserDataWOptions(); + + assistantService.disableRetries(); + testDeleteUserDataWOptions(); + } + + // Test the deleteUserData operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteUserData(null).execute(); + } + + // Test the listEnvironments operation with a valid options model parameter + @Test + public void testListEnvironmentsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"environments\": [{\"name\": \"name\", \"description\": \"description\", \"assistant_id\": \"assistantId\", \"environment_id\": \"environmentId\", \"environment\": \"environment\", \"release_reference\": {\"release\": \"release\"}, \"orchestration\": {\"search_skill_fallback\": false}, \"session_timeout\": 10, \"integration_references\": [{\"integration_id\": \"integrationId\", \"type\": \"type\"}], \"skill_references\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"disabled\": true, \"snapshot\": \"snapshot\", \"skill_reference\": \"skillReference\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listEnvironmentsPath = "/v2/assistants/testString/environments"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListEnvironmentsOptions model + ListEnvironmentsOptions listEnvironmentsOptionsModel = + new ListEnvironmentsOptions.Builder() + .assistantId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listEnvironments() with a valid options model and verify the result + Response response = + assistantService.listEnvironments(listEnvironmentsOptionsModel).execute(); + assertNotNull(response); + EnvironmentCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listEnvironmentsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "name"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listEnvironments operation with and without retries enabled + @Test + public void testListEnvironmentsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListEnvironmentsWOptions(); + + assistantService.disableRetries(); + testListEnvironmentsWOptions(); + } + + // Test the listEnvironments operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEnvironmentsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listEnvironments(null).execute(); + } + + // Test the getEnvironment operation with a valid options model parameter + @Test + public void testGetEnvironmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"assistant_id\": \"assistantId\", \"environment_id\": \"environmentId\", \"environment\": \"environment\", \"release_reference\": {\"release\": \"release\"}, \"orchestration\": {\"search_skill_fallback\": false}, \"session_timeout\": 10, \"integration_references\": [{\"integration_id\": \"integrationId\", \"type\": \"type\"}], \"skill_references\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"disabled\": true, \"snapshot\": \"snapshot\", \"skill_reference\": \"skillReference\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getEnvironmentPath = "/v2/assistants/testString/environments/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetEnvironmentOptions model + GetEnvironmentOptions getEnvironmentOptionsModel = + new GetEnvironmentOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .includeAudit(false) + .build(); + + // Invoke getEnvironment() with a valid options model and verify the result + Response response = + assistantService.getEnvironment(getEnvironmentOptionsModel).execute(); + assertNotNull(response); + Environment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getEnvironmentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getEnvironment operation with and without retries enabled + @Test + public void testGetEnvironmentWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetEnvironmentWOptions(); + + assistantService.disableRetries(); + testGetEnvironmentWOptions(); + } + + // Test the getEnvironment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnvironmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getEnvironment(null).execute(); + } + + // Test the updateEnvironment operation with a valid options model parameter + @Test + public void testUpdateEnvironmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"assistant_id\": \"assistantId\", \"environment_id\": \"environmentId\", \"environment\": \"environment\", \"release_reference\": {\"release\": \"release\"}, \"orchestration\": {\"search_skill_fallback\": false}, \"session_timeout\": 10, \"integration_references\": [{\"integration_id\": \"integrationId\", \"type\": \"type\"}], \"skill_references\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"disabled\": true, \"snapshot\": \"snapshot\", \"skill_reference\": \"skillReference\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String updateEnvironmentPath = "/v2/assistants/testString/environments/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateEnvironmentOrchestration model + UpdateEnvironmentOrchestration updateEnvironmentOrchestrationModel = + new UpdateEnvironmentOrchestration.Builder().searchSkillFallback(true).build(); + + // Construct an instance of the EnvironmentSkill model + EnvironmentSkill environmentSkillModel = + new EnvironmentSkill.Builder() + .skillId("testString") + .type("dialog") + .disabled(true) + .snapshot("testString") + .skillReference("testString") + .build(); + + // Construct an instance of the UpdateEnvironmentOptions model + UpdateEnvironmentOptions updateEnvironmentOptionsModel = + new UpdateEnvironmentOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .name("testString") + .description("testString") + .orchestration(updateEnvironmentOrchestrationModel) + .sessionTimeout(Long.valueOf("10")) + .skillReferences(java.util.Arrays.asList(environmentSkillModel)) + .build(); + + // Invoke updateEnvironment() with a valid options model and verify the result + Response response = + assistantService.updateEnvironment(updateEnvironmentOptionsModel).execute(); + assertNotNull(response); + Environment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateEnvironmentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateEnvironment operation with and without retries enabled + @Test + public void testUpdateEnvironmentWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateEnvironmentWOptions(); + + assistantService.disableRetries(); + testUpdateEnvironmentWOptions(); + } + + // Test the updateEnvironment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnvironmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateEnvironment(null).execute(); + } + + // Test the createRelease operation with a valid options model parameter + @Test + public void testCreateReleaseWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"release\": \"release\", \"description\": \"description\", \"environment_references\": [{\"name\": \"name\", \"environment_id\": \"environmentId\", \"environment\": \"draft\"}], \"content\": {\"skills\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"snapshot\": \"snapshot\"}]}, \"status\": \"Available\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createReleasePath = "/v2/assistants/testString/releases"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateReleaseOptions model + CreateReleaseOptions createReleaseOptionsModel = + new CreateReleaseOptions.Builder() + .assistantId("testString") + .description("testString") + .build(); + + // Invoke createRelease() with a valid options model and verify the result + Response response = + assistantService.createRelease(createReleaseOptionsModel).execute(); + assertNotNull(response); + Release responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createReleasePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createRelease operation with and without retries enabled + @Test + public void testCreateReleaseWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateReleaseWOptions(); + + assistantService.disableRetries(); + testCreateReleaseWOptions(); + } + + // Test the createRelease operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateReleaseNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createRelease(null).execute(); + } + + // Test the listReleases operation with a valid options model parameter + @Test + public void testListReleasesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"releases\": [{\"release\": \"release\", \"description\": \"description\", \"environment_references\": [{\"name\": \"name\", \"environment_id\": \"environmentId\", \"environment\": \"draft\"}], \"content\": {\"skills\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"snapshot\": \"snapshot\"}]}, \"status\": \"Available\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listReleasesPath = "/v2/assistants/testString/releases"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListReleasesOptions model + ListReleasesOptions listReleasesOptionsModel = + new ListReleasesOptions.Builder() + .assistantId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + + // Invoke listReleases() with a valid options model and verify the result + Response response = + assistantService.listReleases(listReleasesOptionsModel).execute(); + assertNotNull(response); + ReleaseCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listReleasesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false)); + assertEquals(query.get("sort"), "name"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the listReleases operation with and without retries enabled + @Test + public void testListReleasesWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testListReleasesWOptions(); + + assistantService.disableRetries(); + testListReleasesWOptions(); + } + + // Test the listReleases operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListReleasesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.listReleases(null).execute(); + } + + // Test the getRelease operation with a valid options model parameter + @Test + public void testGetReleaseWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"release\": \"release\", \"description\": \"description\", \"environment_references\": [{\"name\": \"name\", \"environment_id\": \"environmentId\", \"environment\": \"draft\"}], \"content\": {\"skills\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"snapshot\": \"snapshot\"}]}, \"status\": \"Available\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getReleasePath = "/v2/assistants/testString/releases/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetReleaseOptions model + GetReleaseOptions getReleaseOptionsModel = + new GetReleaseOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + + // Invoke getRelease() with a valid options model and verify the result + Response response = assistantService.getRelease(getReleaseOptionsModel).execute(); + assertNotNull(response); + Release responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getReleasePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getRelease operation with and without retries enabled + @Test + public void testGetReleaseWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetReleaseWOptions(); + + assistantService.disableRetries(); + testGetReleaseWOptions(); + } + + // Test the getRelease operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetReleaseNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getRelease(null).execute(); + } + + // Test the deleteRelease operation with a valid options model parameter + @Test + public void testDeleteReleaseWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteReleasePath = "/v2/assistants/testString/releases/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteReleaseOptions model + DeleteReleaseOptions deleteReleaseOptionsModel = + new DeleteReleaseOptions.Builder().assistantId("testString").release("testString").build(); + + // Invoke deleteRelease() with a valid options model and verify the result + Response response = assistantService.deleteRelease(deleteReleaseOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteReleasePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteRelease operation with and without retries enabled + @Test + public void testDeleteReleaseWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteReleaseWOptions(); + + assistantService.disableRetries(); + testDeleteReleaseWOptions(); + } + + // Test the deleteRelease operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteReleaseNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deleteRelease(null).execute(); + } + + // Test the deployRelease operation with a valid options model parameter + @Test + public void testDeployReleaseWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"assistant_id\": \"assistantId\", \"environment_id\": \"environmentId\", \"environment\": \"environment\", \"release_reference\": {\"release\": \"release\"}, \"orchestration\": {\"search_skill_fallback\": false}, \"session_timeout\": 10, \"integration_references\": [{\"integration_id\": \"integrationId\", \"type\": \"type\"}], \"skill_references\": [{\"skill_id\": \"skillId\", \"type\": \"dialog\", \"disabled\": true, \"snapshot\": \"snapshot\", \"skill_reference\": \"skillReference\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String deployReleasePath = "/v2/assistants/testString/releases/testString/deploy"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeployReleaseOptions model + DeployReleaseOptions deployReleaseOptionsModel = + new DeployReleaseOptions.Builder() + .assistantId("testString") + .release("testString") + .environmentId("testString") + .includeAudit(false) + .build(); + + // Invoke deployRelease() with a valid options model and verify the result + Response response = + assistantService.deployRelease(deployReleaseOptionsModel).execute(); + assertNotNull(response); + Environment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deployReleasePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the deployRelease operation with and without retries enabled + @Test + public void testDeployReleaseWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeployReleaseWOptions(); + + assistantService.disableRetries(); + testDeployReleaseWOptions(); + } + + // Test the deployRelease operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeployReleaseNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.deployRelease(null).execute(); + } + + // Test the createReleaseExport operation with a valid options model parameter + @Test + public void testCreateReleaseExportWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"status\": \"Available\", \"task_id\": \"taskId\", \"assistant_id\": \"assistantId\", \"release\": \"release\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"status_errors\": [{\"message\": \"message\"}], \"status_description\": \"statusDescription\"}"; + String createReleaseExportPath = "/v2/assistants/testString/releases/testString/export"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateReleaseExportOptions model + CreateReleaseExportOptions createReleaseExportOptionsModel = + new CreateReleaseExportOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + + // Invoke createReleaseExport() with a valid options model and verify the result + Response response = + assistantService.createReleaseExport(createReleaseExportOptionsModel).execute(); + assertNotNull(response); + CreateReleaseExportWithStatusErrors responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createReleaseExportPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createReleaseExport operation with and without retries enabled + @Test + public void testCreateReleaseExportWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateReleaseExportWOptions(); + + assistantService.disableRetries(); + testCreateReleaseExportWOptions(); + } + + // Test the createReleaseExport operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateReleaseExportNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createReleaseExport(null).execute(); + } + + // Test the downloadReleaseExport operation with a valid options model parameter + @Test + public void testDownloadReleaseExportWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"status\": \"Available\", \"task_id\": \"taskId\", \"assistant_id\": \"assistantId\", \"release\": \"release\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"status_errors\": [{\"message\": \"message\"}], \"status_description\": \"statusDescription\"}"; + String downloadReleaseExportPath = "/v2/assistants/testString/releases/testString/export"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DownloadReleaseExportOptions model + DownloadReleaseExportOptions downloadReleaseExportOptionsModel = + new DownloadReleaseExportOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + + // Invoke downloadReleaseExport() with a valid options model and verify the result + Response response = + assistantService.downloadReleaseExport(downloadReleaseExportOptionsModel).execute(); + assertNotNull(response); + CreateReleaseExportWithStatusErrors responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, downloadReleaseExportPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the downloadReleaseExport operation with and without retries enabled + @Test + public void testDownloadReleaseExportWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDownloadReleaseExportWOptions(); + + assistantService.disableRetries(); + testDownloadReleaseExportWOptions(); + } + + // Test the downloadReleaseExport operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDownloadReleaseExportNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.downloadReleaseExport(null).execute(); + } + + // Test the downloadReleaseExportAsStream operation with a valid options model parameter + @Test + public void testDownloadReleaseExportAsStreamWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "This is a mock binary response."; + String downloadReleaseExportAsStreamPath = + "/v2/assistants/testString/releases/testString/export"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/octet-stream") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DownloadReleaseExportOptions model + DownloadReleaseExportOptions downloadReleaseExportOptionsModel = + new DownloadReleaseExportOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + + // Invoke downloadReleaseExportAsStream() with a valid options model and verify the result + Response response = + assistantService.downloadReleaseExportAsStream(downloadReleaseExportOptionsModel).execute(); + assertNotNull(response); + try (InputStream responseObj = response.getResult(); ) { + assertNotNull(responseObj); + } + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, downloadReleaseExportAsStreamPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the downloadReleaseExportAsStream operation with and without retries enabled + @Test + public void testDownloadReleaseExportAsStreamWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDownloadReleaseExportAsStreamWOptions(); + + assistantService.disableRetries(); + testDownloadReleaseExportAsStreamWOptions(); + } + + // Test the downloadReleaseExportAsStream operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDownloadReleaseExportAsStreamNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.downloadReleaseExportAsStream(null).execute(); + } + + // Test the createReleaseImport operation with a valid options model parameter + @Test + public void testCreateReleaseImportWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"status\": \"Failed\", \"task_id\": \"taskId\", \"assistant_id\": \"assistantId\", \"skill_impact_in_draft\": [\"action\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String createReleaseImportPath = "/v2/assistants/testString/import"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateReleaseImportOptions model + CreateReleaseImportOptions createReleaseImportOptionsModel = + new CreateReleaseImportOptions.Builder() + .assistantId("testString") + .body(TestUtilities.createMockStream("This is a mock file.")) + .includeAudit(false) + .build(); + + // Invoke createReleaseImport() with a valid options model and verify the result + Response response = + assistantService.createReleaseImport(createReleaseImportOptionsModel).execute(); + assertNotNull(response); + CreateAssistantReleaseImportResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createReleaseImportPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the createReleaseImport operation with and without retries enabled + @Test + public void testCreateReleaseImportWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testCreateReleaseImportWOptions(); + + assistantService.disableRetries(); + testCreateReleaseImportWOptions(); + } + + // Test the createReleaseImport operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateReleaseImportNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.createReleaseImport(null).execute(); + } + + // Test the getReleaseImportStatus operation with a valid options model parameter + @Test + public void testGetReleaseImportStatusWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"status\": \"Completed\", \"task_id\": \"taskId\", \"assistant_id\": \"assistantId\", \"status_errors\": [{\"message\": \"message\"}], \"status_description\": \"statusDescription\", \"skill_impact_in_draft\": [\"action\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}"; + String getReleaseImportStatusPath = "/v2/assistants/testString/import"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetReleaseImportStatusOptions model + GetReleaseImportStatusOptions getReleaseImportStatusOptionsModel = + new GetReleaseImportStatusOptions.Builder() + .assistantId("testString") + .includeAudit(false) + .build(); + + // Invoke getReleaseImportStatus() with a valid options model and verify the result + Response response = + assistantService.getReleaseImportStatus(getReleaseImportStatusOptionsModel).execute(); + assertNotNull(response); + MonitorAssistantReleaseImportArtifactResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getReleaseImportStatusPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the getReleaseImportStatus operation with and without retries enabled + @Test + public void testGetReleaseImportStatusWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetReleaseImportStatusWOptions(); + + assistantService.disableRetries(); + testGetReleaseImportStatusWOptions(); + } + + // Test the getReleaseImportStatus operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetReleaseImportStatusNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getReleaseImportStatus(null).execute(); + } + + // Test the getSkill operation with a valid options model parameter + @Test + public void testGetSkillWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"workspace\": {\"anyKey\": \"anyValue\"}, \"skill_id\": \"skillId\", \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"status_description\": \"statusDescription\", \"dialog_settings\": {\"anyKey\": \"anyValue\"}, \"assistant_id\": \"assistantId\", \"workspace_id\": \"workspaceId\", \"environment_id\": \"environmentId\", \"valid\": false, \"next_snapshot_version\": \"nextSnapshotVersion\", \"search_settings\": {\"discovery\": {\"instance_id\": \"instanceId\", \"project_id\": \"projectId\", \"url\": \"url\", \"max_primary_results\": 10000, \"max_total_results\": 10000, \"confidence_threshold\": 0.0, \"highlight\": false, \"find_answers\": false, \"authentication\": {\"basic\": \"basic\", \"bearer\": \"bearer\"}}, \"messages\": {\"success\": \"success\", \"error\": \"error\", \"no_result\": \"noResult\"}, \"schema_mapping\": {\"url\": \"url\", \"body\": \"body\", \"title\": \"title\"}, \"elastic_search\": {\"url\": \"url\", \"port\": \"port\", \"username\": \"username\", \"password\": \"password\", \"index\": \"index\", \"filter\": [\"anyValue\"], \"query_body\": {\"anyKey\": \"anyValue\"}, \"managed_index\": \"managedIndex\", \"apikey\": \"apikey\"}, \"conversational_search\": {\"enabled\": true, \"response_length\": {\"option\": \"moderate\"}, \"search_confidence\": {\"threshold\": \"less_often\"}}, \"server_side_search\": {\"url\": \"url\", \"port\": \"port\", \"username\": \"username\", \"password\": \"password\", \"filter\": \"filter\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"apikey\": \"apikey\", \"no_auth\": true, \"auth_type\": \"basic\"}, \"client_side_search\": {\"filter\": \"filter\", \"metadata\": {\"anyKey\": \"anyValue\"}}}, \"warnings\": [{\"code\": \"code\", \"path\": \"path\", \"message\": \"message\"}], \"language\": \"language\", \"type\": \"action\"}"; + String getSkillPath = "/v2/assistants/testString/skills/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetSkillOptions model + GetSkillOptions getSkillOptionsModel = + new GetSkillOptions.Builder().assistantId("testString").skillId("testString").build(); + + // Invoke getSkill() with a valid options model and verify the result + Response response = assistantService.getSkill(getSkillOptionsModel).execute(); + assertNotNull(response); + Skill responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getSkillPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getSkill operation with and without retries enabled + @Test + public void testGetSkillWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testGetSkillWOptions(); + + assistantService.disableRetries(); + testGetSkillWOptions(); + } + + // Test the getSkill operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSkillNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.getSkill(null).execute(); + } + + // Test the updateSkill operation with a valid options model parameter + @Test + public void testUpdateSkillWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"workspace\": {\"anyKey\": \"anyValue\"}, \"skill_id\": \"skillId\", \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"status_description\": \"statusDescription\", \"dialog_settings\": {\"anyKey\": \"anyValue\"}, \"assistant_id\": \"assistantId\", \"workspace_id\": \"workspaceId\", \"environment_id\": \"environmentId\", \"valid\": false, \"next_snapshot_version\": \"nextSnapshotVersion\", \"search_settings\": {\"discovery\": {\"instance_id\": \"instanceId\", \"project_id\": \"projectId\", \"url\": \"url\", \"max_primary_results\": 10000, \"max_total_results\": 10000, \"confidence_threshold\": 0.0, \"highlight\": false, \"find_answers\": false, \"authentication\": {\"basic\": \"basic\", \"bearer\": \"bearer\"}}, \"messages\": {\"success\": \"success\", \"error\": \"error\", \"no_result\": \"noResult\"}, \"schema_mapping\": {\"url\": \"url\", \"body\": \"body\", \"title\": \"title\"}, \"elastic_search\": {\"url\": \"url\", \"port\": \"port\", \"username\": \"username\", \"password\": \"password\", \"index\": \"index\", \"filter\": [\"anyValue\"], \"query_body\": {\"anyKey\": \"anyValue\"}, \"managed_index\": \"managedIndex\", \"apikey\": \"apikey\"}, \"conversational_search\": {\"enabled\": true, \"response_length\": {\"option\": \"moderate\"}, \"search_confidence\": {\"threshold\": \"less_often\"}}, \"server_side_search\": {\"url\": \"url\", \"port\": \"port\", \"username\": \"username\", \"password\": \"password\", \"filter\": \"filter\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"apikey\": \"apikey\", \"no_auth\": true, \"auth_type\": \"basic\"}, \"client_side_search\": {\"filter\": \"filter\", \"metadata\": {\"anyKey\": \"anyValue\"}}}, \"warnings\": [{\"code\": \"code\", \"path\": \"path\", \"message\": \"message\"}], \"language\": \"language\", \"type\": \"action\"}"; + String updateSkillPath = "/v2/assistants/testString/skills/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the SearchSettingsDiscoveryAuthentication model + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + + // Construct an instance of the SearchSettingsDiscovery model + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + + // Construct an instance of the SearchSettingsMessages model + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + + // Construct an instance of the SearchSettingsSchemaMapping model + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + + // Construct an instance of the SearchSettingsElasticSearch model + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + + // Construct an instance of the SearchSettingsConversationalSearchResponseLength model + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + + // Construct an instance of the SearchSettingsConversationalSearchSearchConfidence model + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + + // Construct an instance of the SearchSettingsConversationalSearch model + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + + // Construct an instance of the SearchSettingsServerSideSearch model + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + + // Construct an instance of the SearchSettingsClientSideSearch model + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the SearchSettings model + SearchSettings searchSettingsModel = + new SearchSettings.Builder() + .discovery(searchSettingsDiscoveryModel) + .messages(searchSettingsMessagesModel) + .schemaMapping(searchSettingsSchemaMappingModel) + .elasticSearch(searchSettingsElasticSearchModel) + .conversationalSearch(searchSettingsConversationalSearchModel) + .serverSideSearch(searchSettingsServerSideSearchModel) + .clientSideSearch(searchSettingsClientSideSearchModel) + .build(); + + // Construct an instance of the UpdateSkillOptions model + UpdateSkillOptions updateSkillOptionsModel = + new UpdateSkillOptions.Builder() + .assistantId("testString") + .skillId("testString") + .name("testString") + .description("testString") + .workspace(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogSettings(java.util.Collections.singletonMap("anyKey", "anyValue")) + .searchSettings(searchSettingsModel) + .build(); + + // Invoke updateSkill() with a valid options model and verify the result + Response response = assistantService.updateSkill(updateSkillOptionsModel).execute(); + assertNotNull(response); + Skill responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateSkillPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateSkill operation with and without retries enabled + @Test + public void testUpdateSkillWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testUpdateSkillWOptions(); + + assistantService.disableRetries(); + testUpdateSkillWOptions(); + } + + // Test the updateSkill operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSkillNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.updateSkill(null).execute(); + } + + // Test the exportSkills operation with a valid options model parameter + @Test + public void testExportSkillsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"assistant_skills\": [{\"name\": \"name\", \"description\": \"description\", \"workspace\": {\"anyKey\": \"anyValue\"}, \"skill_id\": \"skillId\", \"status\": \"Available\", \"status_errors\": [{\"message\": \"message\"}], \"status_description\": \"statusDescription\", \"dialog_settings\": {\"anyKey\": \"anyValue\"}, \"assistant_id\": \"assistantId\", \"workspace_id\": \"workspaceId\", \"environment_id\": \"environmentId\", \"valid\": false, \"next_snapshot_version\": \"nextSnapshotVersion\", \"search_settings\": {\"discovery\": {\"instance_id\": \"instanceId\", \"project_id\": \"projectId\", \"url\": \"url\", \"max_primary_results\": 10000, \"max_total_results\": 10000, \"confidence_threshold\": 0.0, \"highlight\": false, \"find_answers\": false, \"authentication\": {\"basic\": \"basic\", \"bearer\": \"bearer\"}}, \"messages\": {\"success\": \"success\", \"error\": \"error\", \"no_result\": \"noResult\"}, \"schema_mapping\": {\"url\": \"url\", \"body\": \"body\", \"title\": \"title\"}, \"elastic_search\": {\"url\": \"url\", \"port\": \"port\", \"username\": \"username\", \"password\": \"password\", \"index\": \"index\", \"filter\": [\"anyValue\"], \"query_body\": {\"anyKey\": \"anyValue\"}, \"managed_index\": \"managedIndex\", \"apikey\": \"apikey\"}, \"conversational_search\": {\"enabled\": true, \"response_length\": {\"option\": \"moderate\"}, \"search_confidence\": {\"threshold\": \"less_often\"}}, \"server_side_search\": {\"url\": \"url\", \"port\": \"port\", \"username\": \"username\", \"password\": \"password\", \"filter\": \"filter\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"apikey\": \"apikey\", \"no_auth\": true, \"auth_type\": \"basic\"}, \"client_side_search\": {\"filter\": \"filter\", \"metadata\": {\"anyKey\": \"anyValue\"}}}, \"warnings\": [{\"code\": \"code\", \"path\": \"path\", \"message\": \"message\"}], \"language\": \"language\", \"type\": \"action\"}], \"assistant_state\": {\"action_disabled\": true, \"dialog_disabled\": true}}"; + String exportSkillsPath = "/v2/assistants/testString/skills_export"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ExportSkillsOptions model + ExportSkillsOptions exportSkillsOptionsModel = + new ExportSkillsOptions.Builder().assistantId("testString").includeAudit(false).build(); + + // Invoke exportSkills() with a valid options model and verify the result + Response response = + assistantService.exportSkills(exportSkillsOptionsModel).execute(); + assertNotNull(response); + SkillsExport responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, exportSkillsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the exportSkills operation with and without retries enabled + @Test + public void testExportSkillsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testExportSkillsWOptions(); + + assistantService.disableRetries(); + testExportSkillsWOptions(); + } + + // Test the exportSkills operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExportSkillsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.exportSkills(null).execute(); + } + + // Test the importSkills operation with a valid options model parameter + @Test + public void testImportSkillsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"assistant_id\": \"assistantId\", \"status\": \"Available\", \"status_description\": \"statusDescription\", \"status_errors\": [{\"message\": \"message\"}]}"; + String importSkillsPath = "/v2/assistants/testString/skills_import"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the SearchSettingsDiscoveryAuthentication model + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + + // Construct an instance of the SearchSettingsDiscovery model + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + + // Construct an instance of the SearchSettingsMessages model + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + + // Construct an instance of the SearchSettingsSchemaMapping model + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + + // Construct an instance of the SearchSettingsElasticSearch model + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + + // Construct an instance of the SearchSettingsConversationalSearchResponseLength model + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + + // Construct an instance of the SearchSettingsConversationalSearchSearchConfidence model + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + + // Construct an instance of the SearchSettingsConversationalSearch model + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + + // Construct an instance of the SearchSettingsServerSideSearch model + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + + // Construct an instance of the SearchSettingsClientSideSearch model + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the SearchSettings model + SearchSettings searchSettingsModel = + new SearchSettings.Builder() + .discovery(searchSettingsDiscoveryModel) + .messages(searchSettingsMessagesModel) + .schemaMapping(searchSettingsSchemaMappingModel) + .elasticSearch(searchSettingsElasticSearchModel) + .conversationalSearch(searchSettingsConversationalSearchModel) + .serverSideSearch(searchSettingsServerSideSearchModel) + .clientSideSearch(searchSettingsClientSideSearchModel) + .build(); + + // Construct an instance of the SkillImport model + SkillImport skillImportModel = + new SkillImport.Builder() + .name("testString") + .description("testString") + .workspace(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogSettings(java.util.Collections.singletonMap("anyKey", "anyValue")) + .searchSettings(searchSettingsModel) + .language("testString") + .type("action") + .build(); + + // Construct an instance of the AssistantState model + AssistantState assistantStateModel = + new AssistantState.Builder().actionDisabled(true).dialogDisabled(true).build(); + + // Construct an instance of the ImportSkillsOptions model + ImportSkillsOptions importSkillsOptionsModel = + new ImportSkillsOptions.Builder() + .assistantId("testString") + .assistantSkills(java.util.Arrays.asList(skillImportModel)) + .assistantState(assistantStateModel) + .includeAudit(false) + .build(); + + // Invoke importSkills() with a valid options model and verify the result + Response response = + assistantService.importSkills(importSkillsOptionsModel).execute(); + assertNotNull(response); + SkillsAsyncRequestStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, importSkillsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false)); + } + + // Test the importSkills operation with and without retries enabled + @Test + public void testImportSkillsWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testImportSkillsWOptions(); + + assistantService.disableRetries(); + testImportSkillsWOptions(); + } + + // Test the importSkills operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testImportSkillsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.importSkills(null).execute(); + } + + // Test the importSkillsStatus operation with a valid options model parameter + @Test + public void testImportSkillsStatusWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"assistant_id\": \"assistantId\", \"status\": \"Available\", \"status_description\": \"statusDescription\", \"status_errors\": [{\"message\": \"message\"}]}"; + String importSkillsStatusPath = "/v2/assistants/testString/skills_import/status"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ImportSkillsStatusOptions model + ImportSkillsStatusOptions importSkillsStatusOptionsModel = + new ImportSkillsStatusOptions.Builder().assistantId("testString").build(); + + // Invoke importSkillsStatus() with a valid options model and verify the result + Response response = + assistantService.importSkillsStatus(importSkillsStatusOptionsModel).execute(); + assertNotNull(response); + SkillsAsyncRequestStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, importSkillsStatusPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the importSkillsStatus operation with and without retries enabled + @Test + public void testImportSkillsStatusWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testImportSkillsStatusWOptions(); + + assistantService.disableRetries(); + testImportSkillsStatusWOptions(); + } + + // Test the importSkillsStatus operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testImportSkillsStatusNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + assistantService.importSkillsStatus(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + assistantService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; - assertEquals(DELETE_SESSION_PATH, request.getPath()); + final Authenticator authenticator = new NoAuthAuthenticator(); + assistantService = new Assistant(version, serviceName, authenticator); + String url = server.url("/").toString(); + assistantService.setServiceUrl(url); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AgentAvailabilityMessageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AgentAvailabilityMessageTest.java new file mode 100644 index 00000000000..bf6427611a7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AgentAvailabilityMessageTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AgentAvailabilityMessage model. */ +public class AgentAvailabilityMessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAgentAvailabilityMessage() throws Throwable { + AgentAvailabilityMessage agentAvailabilityMessageModel = new AgentAvailabilityMessage(); + assertNull(agentAvailabilityMessageModel.getMessage()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantCollectionTest.java new file mode 100644 index 00000000000..c3a7e5f81aa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AssistantCollection model. */ +public class AssistantCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAssistantCollection() throws Throwable { + AssistantCollection assistantCollectionModel = new AssistantCollection(); + assertNull(assistantCollectionModel.getAssistants()); + assertNull(assistantCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantDataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantDataTest.java new file mode 100644 index 00000000000..a630a7366e5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantDataTest.java @@ -0,0 +1,56 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AssistantData model. */ +public class AssistantDataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAssistantData() throws Throwable { + AssistantData assistantDataModel = + new AssistantData.Builder() + .name("testString") + .description("testString") + .language("testString") + .build(); + assertEquals(assistantDataModel.name(), "testString"); + assertEquals(assistantDataModel.description(), "testString"); + assertEquals(assistantDataModel.language(), "testString"); + + String json = TestUtilities.serialize(assistantDataModel); + + AssistantData assistantDataModelNew = TestUtilities.deserialize(json, AssistantData.class); + assertTrue(assistantDataModelNew instanceof AssistantData); + assertEquals(assistantDataModelNew.name(), "testString"); + assertEquals(assistantDataModelNew.description(), "testString"); + assertEquals(assistantDataModelNew.language(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAssistantDataError() throws Throwable { + new AssistantData.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantSkillTest.java new file mode 100644 index 00000000000..79370bd13b9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantSkillTest.java @@ -0,0 +1,50 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AssistantSkill model. */ +public class AssistantSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAssistantSkill() throws Throwable { + AssistantSkill assistantSkillModel = + new AssistantSkill.Builder().skillId("testString").type("dialog").build(); + assertEquals(assistantSkillModel.skillId(), "testString"); + assertEquals(assistantSkillModel.type(), "dialog"); + + String json = TestUtilities.serialize(assistantSkillModel); + + AssistantSkill assistantSkillModelNew = TestUtilities.deserialize(json, AssistantSkill.class); + assertTrue(assistantSkillModelNew instanceof AssistantSkill); + assertEquals(assistantSkillModelNew.skillId(), "testString"); + assertEquals(assistantSkillModelNew.type(), "dialog"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAssistantSkillError() throws Throwable { + new AssistantSkill.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantStateTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantStateTest.java new file mode 100644 index 00000000000..723fcaa8114 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/AssistantStateTest.java @@ -0,0 +1,50 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AssistantState model. */ +public class AssistantStateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAssistantState() throws Throwable { + AssistantState assistantStateModel = + new AssistantState.Builder().actionDisabled(true).dialogDisabled(true).build(); + assertEquals(assistantStateModel.actionDisabled(), Boolean.valueOf(true)); + assertEquals(assistantStateModel.dialogDisabled(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(assistantStateModel); + + AssistantState assistantStateModelNew = TestUtilities.deserialize(json, AssistantState.class); + assertTrue(assistantStateModelNew instanceof AssistantState); + assertEquals(assistantStateModelNew.actionDisabled(), Boolean.valueOf(true)); + assertEquals(assistantStateModelNew.dialogDisabled(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAssistantStateError() throws Throwable { + new AssistantState.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentOrchestrationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentOrchestrationTest.java new file mode 100644 index 00000000000..ee3e0eeb935 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentOrchestrationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BaseEnvironmentOrchestration model. */ +public class BaseEnvironmentOrchestrationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBaseEnvironmentOrchestration() throws Throwable { + BaseEnvironmentOrchestration baseEnvironmentOrchestrationModel = + new BaseEnvironmentOrchestration(); + assertNull(baseEnvironmentOrchestrationModel.isSearchSkillFallback()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentReleaseReferenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentReleaseReferenceTest.java new file mode 100644 index 00000000000..e38bd36b50f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BaseEnvironmentReleaseReferenceTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BaseEnvironmentReleaseReference model. */ +public class BaseEnvironmentReleaseReferenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBaseEnvironmentReleaseReference() throws Throwable { + BaseEnvironmentReleaseReference baseEnvironmentReleaseReferenceModel = + new BaseEnvironmentReleaseReference(); + assertNull(baseEnvironmentReleaseReferenceModel.getRelease()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptionsTest.java new file mode 100644 index 00000000000..f193cabe465 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOptions model. */ +public class BulkClassifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOptions() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .skillId("testString") + .input(java.util.Arrays.asList(bulkClassifyUtteranceModel)) + .build(); + assertEquals(bulkClassifyOptionsModel.skillId(), "testString"); + assertEquals( + bulkClassifyOptionsModel.input(), java.util.Arrays.asList(bulkClassifyUtteranceModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyOptionsError() throws Throwable { + new BulkClassifyOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutputTest.java new file mode 100644 index 00000000000..5e605fa42ca --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutputTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOutput model. */ +public class BulkClassifyOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOutput() throws Throwable { + BulkClassifyOutput bulkClassifyOutputModel = new BulkClassifyOutput(); + assertNull(bulkClassifyOutputModel.getInput()); + assertNull(bulkClassifyOutputModel.getEntities()); + assertNull(bulkClassifyOutputModel.getIntents()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponseTest.java new file mode 100644 index 00000000000..61f003e3a7f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyResponse model. */ +public class BulkClassifyResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyResponse() throws Throwable { + BulkClassifyResponse bulkClassifyResponseModel = new BulkClassifyResponse(); + assertNull(bulkClassifyResponseModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtteranceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtteranceTest.java new file mode 100644 index 00000000000..ae772dafdd0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtteranceTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyUtterance model. */ +public class BulkClassifyUtteranceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyUtterance() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + String json = TestUtilities.serialize(bulkClassifyUtteranceModel); + + BulkClassifyUtterance bulkClassifyUtteranceModelNew = + TestUtilities.deserialize(json, BulkClassifyUtterance.class); + assertTrue(bulkClassifyUtteranceModelNew instanceof BulkClassifyUtterance); + assertEquals(bulkClassifyUtteranceModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyUtteranceError() throws Throwable { + new BulkClassifyUtterance.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CaptureGroupTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CaptureGroupTest.java new file mode 100644 index 00000000000..d2936244306 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CaptureGroupTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CaptureGroup model. */ +public class CaptureGroupTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCaptureGroup() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + String json = TestUtilities.serialize(captureGroupModel); + + CaptureGroup captureGroupModelNew = TestUtilities.deserialize(json, CaptureGroup.class); + assertTrue(captureGroupModelNew instanceof CaptureGroup); + assertEquals(captureGroupModelNew.group(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCaptureGroupError() throws Throwable { + new CaptureGroup.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferInfoTest.java new file mode 100644 index 00000000000..1003fe8dc85 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferInfoTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ChannelTransferInfo model. */ +public class ChannelTransferInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testChannelTransferInfo() throws Throwable { + ChannelTransferInfo channelTransferInfoModel = new ChannelTransferInfo(); + assertNull(channelTransferInfoModel.getTarget()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetChatTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetChatTest.java new file mode 100644 index 00000000000..27123bf3465 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetChatTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ChannelTransferTargetChat model. */ +public class ChannelTransferTargetChatTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testChannelTransferTargetChat() throws Throwable { + ChannelTransferTargetChat channelTransferTargetChatModel = new ChannelTransferTargetChat(); + assertNull(channelTransferTargetChatModel.getUrl()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetTest.java new file mode 100644 index 00000000000..61b350775b1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ChannelTransferTargetTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ChannelTransferTarget model. */ +public class ChannelTransferTargetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testChannelTransferTarget() throws Throwable { + ChannelTransferTarget channelTransferTargetModel = new ChannelTransferTarget(); + assertNull(channelTransferTargetModel.getChat()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ClientActionParametersTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ClientActionParametersTest.java new file mode 100644 index 00000000000..f785d5c0cf5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ClientActionParametersTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClientActionParameters model. */ +public class ClientActionParametersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClientActionParameters() throws Throwable { + ClientActionParameters clientActionParametersModel = new ClientActionParameters(); + assertNull(clientActionParametersModel.getAccountId()); + assertNull(clientActionParametersModel.getHash()); + assertNull(clientActionParametersModel.getAlias()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ClientActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ClientActionTest.java new file mode 100644 index 00000000000..cb55edf5a1c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ClientActionTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClientAction model. */ +public class ClientActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClientAction() throws Throwable { + ClientAction clientActionModel = new ClientAction(); + assertNull(clientActionModel.getName()); + assertNull(clientActionModel.getResultVariable()); + assertNull(clientActionModel.getType()); + assertNull(clientActionModel.getSkill()); + assertNull(clientActionModel.getParameters()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java new file mode 100644 index 00000000000..5708ace7d94 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2024, 2026. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CompleteItem model. */ +public class CompleteItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCompleteItem() throws Throwable { + CompleteItem completeItemModel = new CompleteItem(); + assertNull(completeItemModel.responseType()); + assertNull(completeItemModel.text()); + assertNull(completeItemModel.citationsTitle()); + assertNull(completeItemModel.citations()); + assertNull(completeItemModel.confidenceScores()); + assertNull(completeItemModel.responseLengthOption()); + assertNull(completeItemModel.searchResults()); + assertNull(completeItemModel.disclaimer()); + assertNull(completeItemModel.channels()); + assertNull(completeItemModel.time()); + assertNull(completeItemModel.typing()); + assertNull(completeItemModel.source()); + assertNull(completeItemModel.title()); + assertNull(completeItemModel.description()); + assertNull(completeItemModel.altText()); + assertNull(completeItemModel.preference()); + assertNull(completeItemModel.options()); + assertNull(completeItemModel.messageToHumanAgent()); + assertNull(completeItemModel.agentAvailable()); + assertNull(completeItemModel.agentUnavailable()); + assertNull(completeItemModel.topic()); + assertNull(completeItemModel.suggestions()); + assertNull(completeItemModel.messageToUser()); + assertNull(completeItemModel.header()); + assertNull(completeItemModel.primaryResults()); + assertNull(completeItemModel.additionalResults()); + assertNull(completeItemModel.userDefined()); + assertNull(completeItemModel.channelOptions()); + assertNull(completeItemModel.imageUrl()); + assertNull(completeItemModel.commandInfo()); + assertNull(completeItemModel.getStreamingMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateAssistantOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateAssistantOptionsTest.java new file mode 100644 index 00000000000..9af814306fa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateAssistantOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateAssistantOptions model. */ +public class CreateAssistantOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateAssistantOptions() throws Throwable { + CreateAssistantOptions createAssistantOptionsModel = + new CreateAssistantOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .build(); + assertEquals(createAssistantOptionsModel.name(), "testString"); + assertEquals(createAssistantOptionsModel.description(), "testString"); + assertEquals(createAssistantOptionsModel.language(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateAssistantReleaseImportResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateAssistantReleaseImportResponseTest.java new file mode 100644 index 00000000000..692a000677f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateAssistantReleaseImportResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateAssistantReleaseImportResponse model. */ +public class CreateAssistantReleaseImportResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateAssistantReleaseImportResponse() throws Throwable { + CreateAssistantReleaseImportResponse createAssistantReleaseImportResponseModel = + new CreateAssistantReleaseImportResponse(); + assertNull(createAssistantReleaseImportResponseModel.getSkillImpactInDraft()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateProviderOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateProviderOptionsTest.java new file mode 100644 index 00000000000..0f5361001e1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateProviderOptionsTest.java @@ -0,0 +1,146 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateProviderOptions model. */ +public class CreateProviderOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateProviderOptions() throws Throwable { + ProviderSpecificationServersItem providerSpecificationServersItemModel = + new ProviderSpecificationServersItem.Builder().url("testString").build(); + assertEquals(providerSpecificationServersItemModel.url(), "testString"); + + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModel.username(), + providerAuthenticationTypeAndValueModel); + + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals(providerAuthenticationOAuth2FlowsModel.tokenUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.refreshUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.clientAuthType(), "Body"); + assertEquals(providerAuthenticationOAuth2FlowsModel.contentType(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.headerPrefix(), "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + assertEquals(providerAuthenticationOAuth2Model.preferredFlow(), "password"); + assertEquals(providerAuthenticationOAuth2Model.flows(), providerAuthenticationOAuth2FlowsModel); + + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.authenticationMethod(), "basic"); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.basic(), + providerSpecificationComponentsSecuritySchemesBasicModel); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.oauth2(), + providerAuthenticationOAuth2Model); + + ProviderSpecificationComponents providerSpecificationComponentsModel = + new ProviderSpecificationComponents.Builder() + .securitySchemes(providerSpecificationComponentsSecuritySchemesModel) + .build(); + assertEquals( + providerSpecificationComponentsModel.securitySchemes(), + providerSpecificationComponentsSecuritySchemesModel); + + ProviderSpecification providerSpecificationModel = + new ProviderSpecification.Builder() + .servers(java.util.Arrays.asList(providerSpecificationServersItemModel)) + .components(providerSpecificationComponentsModel) + .build(); + assertEquals( + providerSpecificationModel.servers(), + java.util.Arrays.asList(providerSpecificationServersItemModel)); + assertEquals(providerSpecificationModel.components(), providerSpecificationComponentsModel); + + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationModel = + new ProviderPrivateAuthenticationBearerFlow.Builder() + .token(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerPrivateAuthenticationModel.token(), providerAuthenticationTypeAndValueModel); + + ProviderPrivate providerPrivateModel = + new ProviderPrivate.Builder().authentication(providerPrivateAuthenticationModel).build(); + assertEquals(providerPrivateModel.authentication(), providerPrivateAuthenticationModel); + + CreateProviderOptions createProviderOptionsModel = + new CreateProviderOptions.Builder() + .providerId("testString") + .specification(providerSpecificationModel) + .xPrivate(providerPrivateModel) + .build(); + assertEquals(createProviderOptionsModel.providerId(), "testString"); + assertEquals(createProviderOptionsModel.specification(), providerSpecificationModel); + assertEquals(createProviderOptionsModel.xPrivate(), providerPrivateModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateProviderOptionsError() throws Throwable { + new CreateProviderOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportOptionsTest.java new file mode 100644 index 00000000000..7c999e079ae --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateReleaseExportOptions model. */ +public class CreateReleaseExportOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateReleaseExportOptions() throws Throwable { + CreateReleaseExportOptions createReleaseExportOptionsModel = + new CreateReleaseExportOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + assertEquals(createReleaseExportOptionsModel.assistantId(), "testString"); + assertEquals(createReleaseExportOptionsModel.release(), "testString"); + assertEquals(createReleaseExportOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateReleaseExportOptionsError() throws Throwable { + new CreateReleaseExportOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportWithStatusErrorsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportWithStatusErrorsTest.java new file mode 100644 index 00000000000..c92d47417f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseExportWithStatusErrorsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateReleaseExportWithStatusErrors model. */ +public class CreateReleaseExportWithStatusErrorsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateReleaseExportWithStatusErrors() throws Throwable { + CreateReleaseExportWithStatusErrors createReleaseExportWithStatusErrorsModel = + new CreateReleaseExportWithStatusErrors(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseImportOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseImportOptionsTest.java new file mode 100644 index 00000000000..0af03867ffc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseImportOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateReleaseImportOptions model. */ +public class CreateReleaseImportOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateReleaseImportOptions() throws Throwable { + CreateReleaseImportOptions createReleaseImportOptionsModel = + new CreateReleaseImportOptions.Builder() + .assistantId("testString") + .body(TestUtilities.createMockStream("This is a mock file.")) + .includeAudit(false) + .build(); + assertEquals(createReleaseImportOptionsModel.assistantId(), "testString"); + assertEquals( + IOUtils.toString(createReleaseImportOptionsModel.body()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createReleaseImportOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateReleaseImportOptionsError() throws Throwable { + new CreateReleaseImportOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseOptionsTest.java new file mode 100644 index 00000000000..4119e63a645 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateReleaseOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateReleaseOptions model. */ +public class CreateReleaseOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateReleaseOptions() throws Throwable { + CreateReleaseOptions createReleaseOptionsModel = + new CreateReleaseOptions.Builder() + .assistantId("testString") + .description("testString") + .build(); + assertEquals(createReleaseOptionsModel.assistantId(), "testString"); + assertEquals(createReleaseOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateReleaseOptionsError() throws Throwable { + new CreateReleaseOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateSessionOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateSessionOptionsTest.java new file mode 100644 index 00000000000..89d51537a6b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateSessionOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateSessionOptions model. */ +public class CreateSessionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateSessionOptions() throws Throwable { + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + CreateSessionOptions createSessionOptionsModel = + new CreateSessionOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .analytics(requestAnalyticsModel) + .build(); + assertEquals(createSessionOptionsModel.assistantId(), "testString"); + assertEquals(createSessionOptionsModel.environmentId(), "testString"); + assertEquals(createSessionOptionsModel.analytics(), requestAnalyticsModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSessionOptionsError() throws Throwable { + new CreateSessionOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteAssistantOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteAssistantOptionsTest.java new file mode 100644 index 00000000000..76513f6f747 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteAssistantOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteAssistantOptions model. */ +public class DeleteAssistantOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteAssistantOptions() throws Throwable { + DeleteAssistantOptions deleteAssistantOptionsModel = + new DeleteAssistantOptions.Builder().assistantId("testString").build(); + assertEquals(deleteAssistantOptionsModel.assistantId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAssistantOptionsError() throws Throwable { + new DeleteAssistantOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteReleaseOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteReleaseOptionsTest.java new file mode 100644 index 00000000000..ee098d441c3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteReleaseOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteReleaseOptions model. */ +public class DeleteReleaseOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteReleaseOptions() throws Throwable { + DeleteReleaseOptions deleteReleaseOptionsModel = + new DeleteReleaseOptions.Builder().assistantId("testString").release("testString").build(); + assertEquals(deleteReleaseOptionsModel.assistantId(), "testString"); + assertEquals(deleteReleaseOptionsModel.release(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteReleaseOptionsError() throws Throwable { + new DeleteReleaseOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptionsTest.java new file mode 100644 index 00000000000..de5c02dbffa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteSessionOptions model. */ +public class DeleteSessionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteSessionOptions() throws Throwable { + DeleteSessionOptions deleteSessionOptionsModel = + new DeleteSessionOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .sessionId("testString") + .build(); + assertEquals(deleteSessionOptionsModel.assistantId(), "testString"); + assertEquals(deleteSessionOptionsModel.environmentId(), "testString"); + assertEquals(deleteSessionOptionsModel.sessionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSessionOptionsError() throws Throwable { + new DeleteSessionOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..69dd32f109a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeployReleaseOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeployReleaseOptionsTest.java new file mode 100644 index 00000000000..82fb1922166 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeployReleaseOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeployReleaseOptions model. */ +public class DeployReleaseOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeployReleaseOptions() throws Throwable { + DeployReleaseOptions deployReleaseOptionsModel = + new DeployReleaseOptions.Builder() + .assistantId("testString") + .release("testString") + .environmentId("testString") + .includeAudit(false) + .build(); + assertEquals(deployReleaseOptionsModel.assistantId(), "testString"); + assertEquals(deployReleaseOptionsModel.release(), "testString"); + assertEquals(deployReleaseOptionsModel.environmentId(), "testString"); + assertEquals(deployReleaseOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeployReleaseOptionsError() throws Throwable { + new DeployReleaseOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogLogMessageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogLogMessageTest.java new file mode 100644 index 00000000000..e3e69e77891 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogLogMessageTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogLogMessage model. */ +public class DialogLogMessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogLogMessage() throws Throwable { + DialogLogMessage dialogLogMessageModel = new DialogLogMessage(); + assertNull(dialogLogMessageModel.getLevel()); + assertNull(dialogLogMessageModel.getMessage()); + assertNull(dialogLogMessageModel.getCode()); + assertNull(dialogLogMessageModel.getSource()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeActionTest.java new file mode 100644 index 00000000000..4b996c1f137 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeActionTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeAction model. */ +public class DialogNodeActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeAction() throws Throwable { + DialogNodeAction dialogNodeActionModel = new DialogNodeAction(); + assertNull(dialogNodeActionModel.getName()); + assertNull(dialogNodeActionModel.getType()); + assertNull(dialogNodeActionModel.getParameters()); + assertNull(dialogNodeActionModel.getResultVariable()); + assertNull(dialogNodeActionModel.getCredentials()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfoTest.java new file mode 100644 index 00000000000..7ee6eeb6dd0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfoTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputConnectToAgentTransferInfo model. */ +public class DialogNodeOutputConnectToAgentTransferInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputConnectToAgentTransferInfo() throws Throwable { + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo(); + assertNull(dialogNodeOutputConnectToAgentTransferInfoModel.getTarget()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementTest.java new file mode 100644 index 00000000000..9e12a1fd1a0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElement model. */ +public class DialogNodeOutputOptionsElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElement() throws Throwable { + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement(); + assertNull(dialogNodeOutputOptionsElementModel.getLabel()); + assertNull(dialogNodeOutputOptionsElementModel.getValue()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValueTest.java new file mode 100644 index 00000000000..e494832edf0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValueTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElementValue model. */ +public class DialogNodeOutputOptionsElementValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElementValue() throws Throwable { + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue(); + assertNull(dialogNodeOutputOptionsElementValueModel.getInput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeVisitedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeVisitedTest.java new file mode 100644 index 00000000000..e9b4b06058b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeVisitedTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeVisited model. */ +public class DialogNodeVisitedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeVisited() throws Throwable { + DialogNodeVisited dialogNodeVisitedModel = new DialogNodeVisited(); + assertNull(dialogNodeVisitedModel.getDialogNode()); + assertNull(dialogNodeVisitedModel.getTitle()); + assertNull(dialogNodeVisitedModel.getConditions()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionTest.java new file mode 100644 index 00000000000..cefeb960a49 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestion model. */ +public class DialogSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestion() throws Throwable { + DialogSuggestion dialogSuggestionModel = new DialogSuggestion(); + assertNull(dialogSuggestionModel.getLabel()); + assertNull(dialogSuggestionModel.getValue()); + assertNull(dialogSuggestionModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValueTest.java new file mode 100644 index 00000000000..5b864405be6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValueTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestionValue model. */ +public class DialogSuggestionValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestionValue() throws Throwable { + DialogSuggestionValue dialogSuggestionValueModel = new DialogSuggestionValue(); + assertNull(dialogSuggestionValueModel.getInput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DownloadReleaseExportOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DownloadReleaseExportOptionsTest.java new file mode 100644 index 00000000000..2cfaf56597d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DownloadReleaseExportOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DownloadReleaseExportOptions model. */ +public class DownloadReleaseExportOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDownloadReleaseExportOptions() throws Throwable { + DownloadReleaseExportOptions downloadReleaseExportOptionsModel = + new DownloadReleaseExportOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + assertEquals(downloadReleaseExportOptionsModel.assistantId(), "testString"); + assertEquals(downloadReleaseExportOptionsModel.release(), "testString"); + assertEquals(downloadReleaseExportOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDownloadReleaseExportOptionsError() throws Throwable { + new DownloadReleaseExportOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfoTest.java new file mode 100644 index 00000000000..a07f30242aa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfoTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DtmfCommandInfo model. */ +public class DtmfCommandInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDtmfCommandInfo() throws Throwable { + DtmfCommandInfo dtmfCommandInfoModel = new DtmfCommandInfo(); + assertNull(dtmfCommandInfoModel.getType()); + assertNull(dtmfCommandInfoModel.getParameters()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentCollectionTest.java new file mode 100644 index 00000000000..470cb69ff9e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnvironmentCollection model. */ +public class EnvironmentCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironmentCollection() throws Throwable { + EnvironmentCollection environmentCollectionModel = new EnvironmentCollection(); + assertNull(environmentCollectionModel.getEnvironments()); + assertNull(environmentCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentOrchestrationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentOrchestrationTest.java new file mode 100644 index 00000000000..0c70ea2b772 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentOrchestrationTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnvironmentOrchestration model. */ +public class EnvironmentOrchestrationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironmentOrchestration() throws Throwable { + EnvironmentOrchestration environmentOrchestrationModel = new EnvironmentOrchestration(); + assertNull(environmentOrchestrationModel.isSearchSkillFallback()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentReferenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentReferenceTest.java new file mode 100644 index 00000000000..0b38609bcb5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentReferenceTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnvironmentReference model. */ +public class EnvironmentReferenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironmentReference() throws Throwable { + EnvironmentReference environmentReferenceModel = + new EnvironmentReference.Builder().name("testString").build(); + assertEquals(environmentReferenceModel.name(), "testString"); + + String json = TestUtilities.serialize(environmentReferenceModel); + + EnvironmentReference environmentReferenceModelNew = + TestUtilities.deserialize(json, EnvironmentReference.class); + assertTrue(environmentReferenceModelNew instanceof EnvironmentReference); + assertEquals(environmentReferenceModelNew.name(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentReleaseReferenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentReleaseReferenceTest.java new file mode 100644 index 00000000000..d4b7735504a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentReleaseReferenceTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnvironmentReleaseReference model. */ +public class EnvironmentReleaseReferenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironmentReleaseReference() throws Throwable { + EnvironmentReleaseReference environmentReleaseReferenceModel = + new EnvironmentReleaseReference(); + assertNull(environmentReleaseReferenceModel.getRelease()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentSkillTest.java new file mode 100644 index 00000000000..d846432ee5d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentSkillTest.java @@ -0,0 +1,63 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnvironmentSkill model. */ +public class EnvironmentSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironmentSkill() throws Throwable { + EnvironmentSkill environmentSkillModel = + new EnvironmentSkill.Builder() + .skillId("testString") + .type("dialog") + .disabled(true) + .snapshot("testString") + .skillReference("testString") + .build(); + assertEquals(environmentSkillModel.skillId(), "testString"); + assertEquals(environmentSkillModel.type(), "dialog"); + assertEquals(environmentSkillModel.disabled(), Boolean.valueOf(true)); + assertEquals(environmentSkillModel.snapshot(), "testString"); + assertEquals(environmentSkillModel.skillReference(), "testString"); + + String json = TestUtilities.serialize(environmentSkillModel); + + EnvironmentSkill environmentSkillModelNew = + TestUtilities.deserialize(json, EnvironmentSkill.class); + assertTrue(environmentSkillModelNew instanceof EnvironmentSkill); + assertEquals(environmentSkillModelNew.skillId(), "testString"); + assertEquals(environmentSkillModelNew.type(), "dialog"); + assertEquals(environmentSkillModelNew.disabled(), Boolean.valueOf(true)); + assertEquals(environmentSkillModelNew.snapshot(), "testString"); + assertEquals(environmentSkillModelNew.skillReference(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testEnvironmentSkillError() throws Throwable { + new EnvironmentSkill.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentTest.java new file mode 100644 index 00000000000..a5acfd414a6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/EnvironmentTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Environment model. */ +public class EnvironmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironment() throws Throwable { + Environment environmentModel = new Environment(); + assertNull(environmentModel.getName()); + assertNull(environmentModel.getDescription()); + assertNull(environmentModel.getOrchestration()); + assertNull(environmentModel.getSessionTimeout()); + assertNull(environmentModel.getSkillReferences()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ExportSkillsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ExportSkillsOptionsTest.java new file mode 100644 index 00000000000..224cbd8d7e6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ExportSkillsOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ExportSkillsOptions model. */ +public class ExportSkillsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExportSkillsOptions() throws Throwable { + ExportSkillsOptions exportSkillsOptionsModel = + new ExportSkillsOptions.Builder().assistantId("testString").includeAudit(false).build(); + assertEquals(exportSkillsOptionsModel.assistantId(), "testString"); + assertEquals(exportSkillsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExportSkillsOptionsError() throws Throwable { + new ExportSkillsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/FinalResponseOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/FinalResponseOutputTest.java new file mode 100644 index 00000000000..7887a248955 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/FinalResponseOutputTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FinalResponseOutput model. */ +public class FinalResponseOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFinalResponseOutput() throws Throwable { + FinalResponseOutput finalResponseOutputModel = new FinalResponseOutput(); + assertNull(finalResponseOutputModel.getGeneric()); + assertNull(finalResponseOutputModel.getIntents()); + assertNull(finalResponseOutputModel.getEntities()); + assertNull(finalResponseOutputModel.getActions()); + assertNull(finalResponseOutputModel.getDebug()); + assertNull(finalResponseOutputModel.getUserDefined()); + assertNull(finalResponseOutputModel.getSpelling()); + assertNull(finalResponseOutputModel.getLlmMetadata()); + assertNull(finalResponseOutputModel.getStreamingMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/FinalResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/FinalResponseTest.java new file mode 100644 index 00000000000..25a7caaa201 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/FinalResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FinalResponse model. */ +public class FinalResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFinalResponse() throws Throwable { + FinalResponse finalResponseModel = new FinalResponse(); + assertNull(finalResponseModel.getOutput()); + assertNull(finalResponseModel.getContext()); + assertNull(finalResponseModel.getUserId()); + assertNull(finalResponseModel.getMaskedOutput()); + assertNull(finalResponseModel.getMaskedInput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskConfidenceScoresTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskConfidenceScoresTest.java new file mode 100644 index 00000000000..316b7dceacb --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskConfidenceScoresTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GenerativeAITaskConfidenceScores model. */ +public class GenerativeAITaskConfidenceScoresTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGenerativeAITaskConfidenceScores() throws Throwable { + GenerativeAITaskConfidenceScores generativeAiTaskConfidenceScoresModel = + new GenerativeAITaskConfidenceScores(); + assertNull(generativeAiTaskConfidenceScoresModel.getPreGen()); + assertNull(generativeAiTaskConfidenceScoresModel.getPreGenThreshold()); + assertNull(generativeAiTaskConfidenceScoresModel.getPostGen()); + assertNull(generativeAiTaskConfidenceScoresModel.getPostGenThreshold()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskContentGroundedAnsweringTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskContentGroundedAnsweringTest.java new file mode 100644 index 00000000000..aea5012576b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskContentGroundedAnsweringTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GenerativeAITaskContentGroundedAnswering model. */ +public class GenerativeAITaskContentGroundedAnsweringTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGenerativeAITaskContentGroundedAnswering() throws Throwable { + GenerativeAITaskContentGroundedAnswering generativeAiTaskContentGroundedAnsweringModel = + new GenerativeAITaskContentGroundedAnswering(); + assertNull(generativeAiTaskContentGroundedAnsweringModel.getTask()); + assertNull(generativeAiTaskContentGroundedAnsweringModel.isIsIdkResponse()); + assertNull(generativeAiTaskContentGroundedAnsweringModel.isIsHapDetected()); + assertNull(generativeAiTaskContentGroundedAnsweringModel.getConfidenceScores()); + assertNull(generativeAiTaskContentGroundedAnsweringModel.getOriginalResponse()); + assertNull(generativeAiTaskContentGroundedAnsweringModel.getInferredQuery()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskGeneralPurposeAnsweringTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskGeneralPurposeAnsweringTest.java new file mode 100644 index 00000000000..f1475bab523 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskGeneralPurposeAnsweringTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GenerativeAITaskGeneralPurposeAnswering model. */ +public class GenerativeAITaskGeneralPurposeAnsweringTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGenerativeAITaskGeneralPurposeAnswering() throws Throwable { + GenerativeAITaskGeneralPurposeAnswering generativeAiTaskGeneralPurposeAnsweringModel = + new GenerativeAITaskGeneralPurposeAnswering(); + assertNull(generativeAiTaskGeneralPurposeAnsweringModel.getTask()); + assertNull(generativeAiTaskGeneralPurposeAnsweringModel.isIsIdkResponse()); + assertNull(generativeAiTaskGeneralPurposeAnsweringModel.isIsHapDetected()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskTest.java new file mode 100644 index 00000000000..534205cdf50 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GenerativeAITaskTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GenerativeAITask model. */ +public class GenerativeAITaskTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testGenerativeAITask() throws Throwable { + GenerativeAITask generativeAiTaskModel = new GenerativeAITask(); + assertNotNull(generativeAiTaskModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetEnvironmentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetEnvironmentOptionsTest.java new file mode 100644 index 00000000000..1d0121f8678 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetEnvironmentOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetEnvironmentOptions model. */ +public class GetEnvironmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetEnvironmentOptions() throws Throwable { + GetEnvironmentOptions getEnvironmentOptionsModel = + new GetEnvironmentOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .includeAudit(false) + .build(); + assertEquals(getEnvironmentOptionsModel.assistantId(), "testString"); + assertEquals(getEnvironmentOptionsModel.environmentId(), "testString"); + assertEquals(getEnvironmentOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnvironmentOptionsError() throws Throwable { + new GetEnvironmentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetReleaseImportStatusOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetReleaseImportStatusOptionsTest.java new file mode 100644 index 00000000000..12c843ba57b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetReleaseImportStatusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetReleaseImportStatusOptions model. */ +public class GetReleaseImportStatusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetReleaseImportStatusOptions() throws Throwable { + GetReleaseImportStatusOptions getReleaseImportStatusOptionsModel = + new GetReleaseImportStatusOptions.Builder() + .assistantId("testString") + .includeAudit(false) + .build(); + assertEquals(getReleaseImportStatusOptionsModel.assistantId(), "testString"); + assertEquals(getReleaseImportStatusOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetReleaseImportStatusOptionsError() throws Throwable { + new GetReleaseImportStatusOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetReleaseOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetReleaseOptionsTest.java new file mode 100644 index 00000000000..291384133dd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetReleaseOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetReleaseOptions model. */ +public class GetReleaseOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetReleaseOptions() throws Throwable { + GetReleaseOptions getReleaseOptionsModel = + new GetReleaseOptions.Builder() + .assistantId("testString") + .release("testString") + .includeAudit(false) + .build(); + assertEquals(getReleaseOptionsModel.assistantId(), "testString"); + assertEquals(getReleaseOptionsModel.release(), "testString"); + assertEquals(getReleaseOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetReleaseOptionsError() throws Throwable { + new GetReleaseOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetSkillOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetSkillOptionsTest.java new file mode 100644 index 00000000000..6d2738229ff --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/GetSkillOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetSkillOptions model. */ +public class GetSkillOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetSkillOptions() throws Throwable { + GetSkillOptions getSkillOptionsModel = + new GetSkillOptions.Builder().assistantId("testString").skillId("testString").build(); + assertEquals(getSkillOptionsModel.assistantId(), "testString"); + assertEquals(getSkillOptionsModel.skillId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSkillOptionsError() throws Throwable { + new GetSkillOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ImportSkillsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ImportSkillsOptionsTest.java new file mode 100644 index 00000000000..2ac8d5ed152 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ImportSkillsOptionsTest.java @@ -0,0 +1,233 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImportSkillsOptions model. */ +public class ImportSkillsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImportSkillsOptions() throws Throwable { + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + assertEquals(searchSettingsDiscoveryAuthenticationModel.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModel.bearer(), "testString"); + + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + assertEquals(searchSettingsDiscoveryModel.instanceId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.projectId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.url(), "testString"); + assertEquals(searchSettingsDiscoveryModel.maxPrimaryResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.maxTotalResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.confidenceThreshold(), Double.valueOf("0.0")); + assertEquals(searchSettingsDiscoveryModel.highlight(), Boolean.valueOf(true)); + assertEquals(searchSettingsDiscoveryModel.findAnswers(), Boolean.valueOf(true)); + assertEquals( + searchSettingsDiscoveryModel.authentication(), searchSettingsDiscoveryAuthenticationModel); + + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + assertEquals(searchSettingsMessagesModel.success(), "testString"); + assertEquals(searchSettingsMessagesModel.error(), "testString"); + assertEquals(searchSettingsMessagesModel.noResult(), "testString"); + + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + assertEquals(searchSettingsSchemaMappingModel.url(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.body(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.title(), "testString"); + + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + assertEquals(searchSettingsElasticSearchModel.url(), "testString"); + assertEquals(searchSettingsElasticSearchModel.port(), "testString"); + assertEquals(searchSettingsElasticSearchModel.username(), "testString"); + assertEquals(searchSettingsElasticSearchModel.password(), "testString"); + assertEquals(searchSettingsElasticSearchModel.index(), "testString"); + assertEquals(searchSettingsElasticSearchModel.filter(), java.util.Arrays.asList("testString")); + assertEquals( + searchSettingsElasticSearchModel.queryBody(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsElasticSearchModel.managedIndex(), "testString"); + assertEquals(searchSettingsElasticSearchModel.apikey(), "testString"); + + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + assertEquals(searchSettingsConversationalSearchResponseLengthModel.option(), "moderate"); + + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + assertEquals(searchSettingsConversationalSearchSearchConfidenceModel.threshold(), "less_often"); + + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + assertEquals(searchSettingsConversationalSearchModel.enabled(), Boolean.valueOf(true)); + assertEquals( + searchSettingsConversationalSearchModel.responseLength(), + searchSettingsConversationalSearchResponseLengthModel); + assertEquals( + searchSettingsConversationalSearchModel.searchConfidence(), + searchSettingsConversationalSearchSearchConfidenceModel); + + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + assertEquals(searchSettingsServerSideSearchModel.url(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.port(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.username(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.password(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsServerSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsServerSideSearchModel.apikey(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.noAuth(), Boolean.valueOf(true)); + assertEquals(searchSettingsServerSideSearchModel.authType(), "basic"); + + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(searchSettingsClientSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsClientSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + SearchSettings searchSettingsModel = + new SearchSettings.Builder() + .discovery(searchSettingsDiscoveryModel) + .messages(searchSettingsMessagesModel) + .schemaMapping(searchSettingsSchemaMappingModel) + .elasticSearch(searchSettingsElasticSearchModel) + .conversationalSearch(searchSettingsConversationalSearchModel) + .serverSideSearch(searchSettingsServerSideSearchModel) + .clientSideSearch(searchSettingsClientSideSearchModel) + .build(); + assertEquals(searchSettingsModel.discovery(), searchSettingsDiscoveryModel); + assertEquals(searchSettingsModel.messages(), searchSettingsMessagesModel); + assertEquals(searchSettingsModel.schemaMapping(), searchSettingsSchemaMappingModel); + assertEquals(searchSettingsModel.elasticSearch(), searchSettingsElasticSearchModel); + assertEquals( + searchSettingsModel.conversationalSearch(), searchSettingsConversationalSearchModel); + assertEquals(searchSettingsModel.serverSideSearch(), searchSettingsServerSideSearchModel); + assertEquals(searchSettingsModel.clientSideSearch(), searchSettingsClientSideSearchModel); + + SkillImport skillImportModel = + new SkillImport.Builder() + .name("testString") + .description("testString") + .workspace(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogSettings(java.util.Collections.singletonMap("anyKey", "anyValue")) + .searchSettings(searchSettingsModel) + .language("testString") + .type("action") + .build(); + assertEquals(skillImportModel.name(), "testString"); + assertEquals(skillImportModel.description(), "testString"); + assertEquals( + skillImportModel.workspace(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + skillImportModel.dialogSettings(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(skillImportModel.searchSettings(), searchSettingsModel); + assertEquals(skillImportModel.language(), "testString"); + assertEquals(skillImportModel.type(), "action"); + + AssistantState assistantStateModel = + new AssistantState.Builder().actionDisabled(true).dialogDisabled(true).build(); + assertEquals(assistantStateModel.actionDisabled(), Boolean.valueOf(true)); + assertEquals(assistantStateModel.dialogDisabled(), Boolean.valueOf(true)); + + ImportSkillsOptions importSkillsOptionsModel = + new ImportSkillsOptions.Builder() + .assistantId("testString") + .assistantSkills(java.util.Arrays.asList(skillImportModel)) + .assistantState(assistantStateModel) + .includeAudit(false) + .build(); + assertEquals(importSkillsOptionsModel.assistantId(), "testString"); + assertEquals( + importSkillsOptionsModel.assistantSkills(), java.util.Arrays.asList(skillImportModel)); + assertEquals(importSkillsOptionsModel.assistantState(), assistantStateModel); + assertEquals(importSkillsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testImportSkillsOptionsError() throws Throwable { + new ImportSkillsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ImportSkillsStatusOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ImportSkillsStatusOptionsTest.java new file mode 100644 index 00000000000..745145eb1ba --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ImportSkillsStatusOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImportSkillsStatusOptions model. */ +public class ImportSkillsStatusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImportSkillsStatusOptions() throws Throwable { + ImportSkillsStatusOptions importSkillsStatusOptionsModel = + new ImportSkillsStatusOptions.Builder().assistantId("testString").build(); + assertEquals(importSkillsStatusOptionsModel.assistantId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testImportSkillsStatusOptionsError() throws Throwable { + new ImportSkillsStatusOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/IntegrationReferenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/IntegrationReferenceTest.java new file mode 100644 index 00000000000..83f536645ba --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/IntegrationReferenceTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IntegrationReference model. */ +public class IntegrationReferenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIntegrationReference() throws Throwable { + IntegrationReference integrationReferenceModel = + new IntegrationReference.Builder().integrationId("testString").type("testString").build(); + assertEquals(integrationReferenceModel.integrationId(), "testString"); + assertEquals(integrationReferenceModel.type(), "testString"); + + String json = TestUtilities.serialize(integrationReferenceModel); + + IntegrationReference integrationReferenceModelNew = + TestUtilities.deserialize(json, IntegrationReference.class); + assertTrue(integrationReferenceModelNew instanceof IntegrationReference); + assertEquals(integrationReferenceModelNew.integrationId(), "testString"); + assertEquals(integrationReferenceModelNew.type(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListAssistantsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListAssistantsOptionsTest.java new file mode 100644 index 00000000000..c5b4b97bcd9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListAssistantsOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAssistantsOptions model. */ +public class ListAssistantsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAssistantsOptions() throws Throwable { + ListAssistantsOptions listAssistantsOptionsModel = + new ListAssistantsOptions.Builder() + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listAssistantsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listAssistantsOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listAssistantsOptionsModel.sort(), "name"); + assertEquals(listAssistantsOptionsModel.cursor(), "testString"); + assertEquals(listAssistantsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListEnvironmentsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListEnvironmentsOptionsTest.java new file mode 100644 index 00000000000..cbe42ecde90 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListEnvironmentsOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEnvironmentsOptions model. */ +public class ListEnvironmentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEnvironmentsOptions() throws Throwable { + ListEnvironmentsOptions listEnvironmentsOptionsModel = + new ListEnvironmentsOptions.Builder() + .assistantId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listEnvironmentsOptionsModel.assistantId(), "testString"); + assertEquals(listEnvironmentsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listEnvironmentsOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listEnvironmentsOptionsModel.sort(), "name"); + assertEquals(listEnvironmentsOptionsModel.cursor(), "testString"); + assertEquals(listEnvironmentsOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEnvironmentsOptionsError() throws Throwable { + new ListEnvironmentsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListLogsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListLogsOptionsTest.java new file mode 100644 index 00000000000..7197f0504b8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListLogsOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLogsOptions model. */ +public class ListLogsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLogsOptions() throws Throwable { + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .assistantId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .build(); + assertEquals(listLogsOptionsModel.assistantId(), "testString"); + assertEquals(listLogsOptionsModel.sort(), "testString"); + assertEquals(listLogsOptionsModel.filter(), "testString"); + assertEquals(listLogsOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listLogsOptionsModel.cursor(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsOptionsError() throws Throwable { + new ListLogsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListProvidersOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListProvidersOptionsTest.java new file mode 100644 index 00000000000..80d68b43216 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListProvidersOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListProvidersOptions model. */ +public class ListProvidersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListProvidersOptions() throws Throwable { + ListProvidersOptions listProvidersOptionsModel = + new ListProvidersOptions.Builder() + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listProvidersOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listProvidersOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listProvidersOptionsModel.sort(), "name"); + assertEquals(listProvidersOptionsModel.cursor(), "testString"); + assertEquals(listProvidersOptionsModel.includeAudit(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListReleasesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListReleasesOptionsTest.java new file mode 100644 index 00000000000..59127356f20 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListReleasesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListReleasesOptions model. */ +public class ListReleasesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListReleasesOptions() throws Throwable { + ListReleasesOptions listReleasesOptionsModel = + new ListReleasesOptions.Builder() + .assistantId("testString") + .pageLimit(Long.valueOf("100")) + .includeCount(false) + .sort("name") + .cursor("testString") + .includeAudit(false) + .build(); + assertEquals(listReleasesOptionsModel.assistantId(), "testString"); + assertEquals(listReleasesOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listReleasesOptionsModel.includeCount(), Boolean.valueOf(false)); + assertEquals(listReleasesOptionsModel.sort(), "name"); + assertEquals(listReleasesOptionsModel.cursor(), "testString"); + assertEquals(listReleasesOptionsModel.includeAudit(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListReleasesOptionsError() throws Throwable { + new ListReleasesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogCollectionTest.java new file mode 100644 index 00000000000..9356c9fb5bd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogCollection model. */ +public class LogCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogCollection() throws Throwable { + LogCollection logCollectionModel = new LogCollection(); + assertNull(logCollectionModel.getLogs()); + assertNull(logCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceActionTest.java new file mode 100644 index 00000000000..967cf2c0708 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceActionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessageSourceAction model. */ +public class LogMessageSourceActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessageSourceAction() throws Throwable { + LogMessageSourceAction logMessageSourceActionModel = new LogMessageSourceAction(); + assertNull(logMessageSourceActionModel.getType()); + assertNull(logMessageSourceActionModel.getAction()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceDialogNodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceDialogNodeTest.java new file mode 100644 index 00000000000..5c5afacc7e8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceDialogNodeTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessageSourceDialogNode model. */ +public class LogMessageSourceDialogNodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessageSourceDialogNode() throws Throwable { + LogMessageSourceDialogNode logMessageSourceDialogNodeModel = new LogMessageSourceDialogNode(); + assertNull(logMessageSourceDialogNodeModel.getType()); + assertNull(logMessageSourceDialogNodeModel.getDialogNode()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceHandlerTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceHandlerTest.java new file mode 100644 index 00000000000..b0a08250a89 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceHandlerTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessageSourceHandler model. */ +public class LogMessageSourceHandlerTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessageSourceHandler() throws Throwable { + LogMessageSourceHandler logMessageSourceHandlerModel = new LogMessageSourceHandler(); + assertNull(logMessageSourceHandlerModel.getType()); + assertNull(logMessageSourceHandlerModel.getAction()); + assertNull(logMessageSourceHandlerModel.getStep()); + assertNull(logMessageSourceHandlerModel.getHandler()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceStepTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceStepTest.java new file mode 100644 index 00000000000..be82d38a85d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceStepTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessageSourceStep model. */ +public class LogMessageSourceStepTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessageSourceStep() throws Throwable { + LogMessageSourceStep logMessageSourceStepModel = new LogMessageSourceStep(); + assertNull(logMessageSourceStepModel.getType()); + assertNull(logMessageSourceStepModel.getAction()); + assertNull(logMessageSourceStepModel.getStep()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceTest.java new file mode 100644 index 00000000000..4beed23bfd5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogMessageSourceTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessageSource model. */ +public class LogMessageSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testLogMessageSource() throws Throwable { + LogMessageSource logMessageSourceModel = new LogMessageSource(); + assertNotNull(logMessageSourceModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogPaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogPaginationTest.java new file mode 100644 index 00000000000..778ae5b7140 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogPaginationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogPagination model. */ +public class LogPaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogPagination() throws Throwable { + LogPagination logPaginationModel = new LogPagination(); + assertNull(logPaginationModel.getNextUrl()); + assertNull(logPaginationModel.getMatched()); + assertNull(logPaginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogRequestInputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogRequestInputTest.java new file mode 100644 index 00000000000..d088d4d39c7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogRequestInputTest.java @@ -0,0 +1,29 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; + +/** Unit test class for the LogRequestInput model. */ +public class LogRequestInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogRequestTest.java new file mode 100644 index 00000000000..4b8056f6d92 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogRequestTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogRequest model. */ +public class LogRequestTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogRequest() throws Throwable { + LogRequest logRequestModel = new LogRequest(); + assertNull(logRequestModel.getInput()); + assertNull(logRequestModel.getContext()); + assertNull(logRequestModel.getUserId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogResponseOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogResponseOutputTest.java new file mode 100644 index 00000000000..fad933fa0ec --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogResponseOutputTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogResponseOutput model. */ +public class LogResponseOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogResponseOutput() throws Throwable { + LogResponseOutput logResponseOutputModel = new LogResponseOutput(); + assertNull(logResponseOutputModel.getGeneric()); + assertNull(logResponseOutputModel.getIntents()); + assertNull(logResponseOutputModel.getEntities()); + assertNull(logResponseOutputModel.getActions()); + assertNull(logResponseOutputModel.getDebug()); + assertNull(logResponseOutputModel.getUserDefined()); + assertNull(logResponseOutputModel.getSpelling()); + assertNull(logResponseOutputModel.getLlmMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogResponseTest.java new file mode 100644 index 00000000000..f7a5bee12ad --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogResponseTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogResponse model. */ +public class LogResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogResponse() throws Throwable { + LogResponse logResponseModel = new LogResponse(); + assertNull(logResponseModel.getOutput()); + assertNull(logResponseModel.getContext()); + assertNull(logResponseModel.getUserId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogTest.java new file mode 100644 index 00000000000..1ab09f45063 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Log model. */ +public class LogTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLog() throws Throwable { + Log logModel = new Log(); + assertNull(logModel.getLogId()); + assertNull(logModel.getRequest()); + assertNull(logModel.getResponse()); + assertNull(logModel.getAssistantId()); + assertNull(logModel.getSessionId()); + assertNull(logModel.getSkillId()); + assertNull(logModel.getSnapshot()); + assertNull(logModel.getRequestTimestamp()); + assertNull(logModel.getResponseTimestamp()); + assertNull(logModel.getLanguage()); + assertNull(logModel.getCustomerId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkillTest.java new file mode 100644 index 00000000000..4035301d48d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkillTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextActionSkill model. */ +public class MessageContextActionSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextActionSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(messageContextActionSkillModel); + + MessageContextActionSkill messageContextActionSkillModelNew = + TestUtilities.deserialize(json, MessageContextActionSkill.class); + assertTrue(messageContextActionSkillModelNew instanceof MessageContextActionSkill); + assertEquals( + messageContextActionSkillModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextActionSkillModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + assertEquals( + messageContextActionSkillModelNew.actionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextActionSkillModelNew.skillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkillTest.java new file mode 100644 index 00000000000..81632a240d5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkillTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextDialogSkill model. */ +public class MessageContextDialogSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextDialogSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + String json = TestUtilities.serialize(messageContextDialogSkillModel); + + MessageContextDialogSkill messageContextDialogSkillModelNew = + TestUtilities.deserialize(json, MessageContextDialogSkill.class); + assertTrue(messageContextDialogSkillModelNew instanceof MessageContextDialogSkill); + assertEquals( + messageContextDialogSkillModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextDialogSkillModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStatelessTest.java new file mode 100644 index 00000000000..0ebd575d367 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStatelessTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextGlobalStateless model. */ +public class MessageContextGlobalStatelessTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextGlobalStateless() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + MessageContextGlobalStateless messageContextGlobalStatelessModel = + new MessageContextGlobalStateless.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(messageContextGlobalStatelessModel.system(), messageContextGlobalSystemModel); + assertEquals(messageContextGlobalStatelessModel.sessionId(), "testString"); + + String json = TestUtilities.serialize(messageContextGlobalStatelessModel); + + MessageContextGlobalStateless messageContextGlobalStatelessModelNew = + TestUtilities.deserialize(json, MessageContextGlobalStateless.class); + assertTrue(messageContextGlobalStatelessModelNew instanceof MessageContextGlobalStateless); + assertEquals( + messageContextGlobalStatelessModelNew.system().toString(), + messageContextGlobalSystemModel.toString()); + assertEquals(messageContextGlobalStatelessModelNew.sessionId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystemTest.java new file mode 100644 index 00000000000..ca607ec59a1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystemTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextGlobalSystem model. */ +public class MessageContextGlobalSystemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextGlobalSystem() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(messageContextGlobalSystemModel); + + MessageContextGlobalSystem messageContextGlobalSystemModelNew = + TestUtilities.deserialize(json, MessageContextGlobalSystem.class); + assertTrue(messageContextGlobalSystemModelNew instanceof MessageContextGlobalSystem); + assertEquals(messageContextGlobalSystemModelNew.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.userId(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModelNew.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModelNew.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.state(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.skipUserInput(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalTest.java new file mode 100644 index 00000000000..434c2222530 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextGlobal model. */ +public class MessageContextGlobalTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextGlobal() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + String json = TestUtilities.serialize(messageContextGlobalModel); + + MessageContextGlobal messageContextGlobalModelNew = + TestUtilities.deserialize(json, MessageContextGlobal.class); + assertTrue(messageContextGlobalModelNew instanceof MessageContextGlobal); + assertEquals( + messageContextGlobalModelNew.system().toString(), + messageContextGlobalSystemModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillActionTest.java new file mode 100644 index 00000000000..e0d4b27bf65 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillActionTest.java @@ -0,0 +1,77 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextSkillAction model. */ +public class MessageContextSkillActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextSkillAction() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkillAction messageContextSkillActionModel = + new MessageContextSkillAction.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextSkillActionModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextSkillActionModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextSkillActionModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(messageContextSkillActionModel); + + MessageContextSkillAction messageContextSkillActionModelNew = + TestUtilities.deserialize(json, MessageContextSkillAction.class); + assertTrue(messageContextSkillActionModelNew instanceof MessageContextSkillAction); + assertEquals( + messageContextSkillActionModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextSkillActionModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + assertEquals( + messageContextSkillActionModelNew.actionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextSkillActionModelNew.skillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillDialogTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillDialogTest.java new file mode 100644 index 00000000000..a1b356c7417 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillDialogTest.java @@ -0,0 +1,63 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextSkillDialog model. */ +public class MessageContextSkillDialogTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextSkillDialog() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkillDialog messageContextSkillDialogModel = + new MessageContextSkillDialog.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillDialogModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextSkillDialogModel.system(), messageContextSkillSystemModel); + + String json = TestUtilities.serialize(messageContextSkillDialogModel); + + MessageContextSkillDialog messageContextSkillDialogModelNew = + TestUtilities.deserialize(json, MessageContextSkillDialog.class); + assertTrue(messageContextSkillDialogModelNew instanceof MessageContextSkillDialog); + assertEquals( + messageContextSkillDialogModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextSkillDialogModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystemTest.java new file mode 100644 index 00000000000..af74ff19450 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystemTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextSkillSystem model. */ +public class MessageContextSkillSystemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextSkillSystem() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(messageContextSkillSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModelNew = + TestUtilities.deserialize(json, MessageContextSkillSystem.class); + assertTrue(messageContextSkillSystemModelNew instanceof MessageContextSkillSystem); + assertEquals(messageContextSkillSystemModelNew.getState(), "testString"); + assertEquals(messageContextSkillSystemModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java new file mode 100644 index 00000000000..3270ea50edf --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextSkills model. */ +public class MessageContextSkillsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextSkills() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); + + String json = TestUtilities.serialize(messageContextSkillsModel); + + MessageContextSkills messageContextSkillsModelNew = + TestUtilities.deserialize(json, MessageContextSkills.class); + assertTrue(messageContextSkillsModelNew instanceof MessageContextSkills); + assertEquals( + messageContextSkillsModelNew.mainSkill().toString(), + messageContextDialogSkillModel.toString()); + assertEquals( + messageContextSkillsModelNew.actionsSkill().toString(), + messageContextActionSkillModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java new file mode 100644 index 00000000000..7e9d8873b45 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java @@ -0,0 +1,123 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContext model. */ +public class MessageContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContext() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals(messageContextModel.skills(), messageContextSkillsModel); + assertEquals( + messageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(messageContextModel); + + MessageContext messageContextModelNew = TestUtilities.deserialize(json, MessageContext.class); + assertTrue(messageContextModelNew instanceof MessageContext); + assertEquals(messageContextModelNew.global().toString(), messageContextGlobalModel.toString()); + assertEquals(messageContextModelNew.skills().toString(), messageContextSkillsModel.toString()); + assertEquals( + messageContextModelNew.integrations().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputAttachmentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputAttachmentTest.java new file mode 100644 index 00000000000..94c6b207bca --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputAttachmentTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputAttachment model. */ +public class MessageInputAttachmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputAttachment() throws Throwable { + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + String json = TestUtilities.serialize(messageInputAttachmentModel); + + MessageInputAttachment messageInputAttachmentModelNew = + TestUtilities.deserialize(json, MessageInputAttachment.class); + assertTrue(messageInputAttachmentModelNew instanceof MessageInputAttachment); + assertEquals(messageInputAttachmentModelNew.url(), "testString"); + assertEquals(messageInputAttachmentModelNew.mediaType(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageInputAttachmentError() throws Throwable { + new MessageInputAttachment.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpellingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpellingTest.java new file mode 100644 index 00000000000..6f7f345a862 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpellingTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputOptionsSpelling model. */ +public class MessageInputOptionsSpellingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputOptionsSpelling() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(messageInputOptionsSpellingModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModelNew = + TestUtilities.deserialize(json, MessageInputOptionsSpelling.class); + assertTrue(messageInputOptionsSpellingModelNew instanceof MessageInputOptionsSpelling); + assertEquals(messageInputOptionsSpellingModelNew.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModelNew.autoCorrect(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsTest.java new file mode 100644 index 00000000000..636f4387931 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputOptions model. */ +public class MessageInputOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputOptions() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(messageInputOptionsModel); + + MessageInputOptions messageInputOptionsModelNew = + TestUtilities.deserialize(json, MessageInputOptions.class); + assertTrue(messageInputOptionsModelNew instanceof MessageInputOptions); + assertEquals(messageInputOptionsModelNew.restart(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModelNew.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModelNew.asyncCallout(), Boolean.valueOf(false)); + assertEquals( + messageInputOptionsModelNew.spelling().toString(), + messageInputOptionsSpellingModel.toString()); + assertEquals(messageInputOptionsModelNew.debug(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModelNew.returnContext(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModelNew.export(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputTest.java new file mode 100644 index 00000000000..d6309daf9d8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputTest.java @@ -0,0 +1,211 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInput model. */ +public class MessageInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInput() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(false)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "testString"); + assertEquals(messageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(messageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals( + messageInputModel.attachments(), java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(messageInputModel.analytics(), requestAnalyticsModel); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + String json = TestUtilities.serialize(messageInputModel); + + MessageInput messageInputModelNew = TestUtilities.deserialize(json, MessageInput.class); + assertTrue(messageInputModelNew instanceof MessageInput); + assertEquals(messageInputModelNew.messageType(), "text"); + assertEquals(messageInputModelNew.text(), "testString"); + assertEquals(messageInputModelNew.suggestionId(), "testString"); + assertEquals(messageInputModelNew.analytics().toString(), requestAnalyticsModel.toString()); + assertEquals(messageInputModelNew.options().toString(), messageInputOptionsModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java new file mode 100644 index 00000000000..1a409310be7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java @@ -0,0 +1,302 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOptions model. */ +public class MessageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOptions() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(false)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "testString"); + assertEquals(messageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(messageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals( + messageInputModel.attachments(), java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(messageInputModel.analytics(), requestAnalyticsModel); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals(messageContextModel.skills(), messageContextSkillsModel); + assertEquals( + messageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageOptions messageOptionsModel = + new MessageOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .sessionId("testString") + .input(messageInputModel) + .context(messageContextModel) + .userId("testString") + .build(); + assertEquals(messageOptionsModel.assistantId(), "testString"); + assertEquals(messageOptionsModel.environmentId(), "testString"); + assertEquals(messageOptionsModel.sessionId(), "testString"); + assertEquals(messageOptionsModel.input(), messageInputModel); + assertEquals(messageOptionsModel.context(), messageContextModel); + assertEquals(messageOptionsModel.userId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageOptionsError() throws Throwable { + new MessageOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTest.java new file mode 100644 index 00000000000..b4e6fb9d7e1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebug model. */ +public class MessageOutputDebugTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebug() throws Throwable { + MessageOutputDebug messageOutputDebugModel = new MessageOutputDebug(); + assertNull(messageOutputDebugModel.getNodesVisited()); + assertNull(messageOutputDebugModel.getLogMessages()); + assertNull(messageOutputDebugModel.isBranchExited()); + assertNull(messageOutputDebugModel.getBranchExitedReason()); + assertNull(messageOutputDebugModel.getTurnEvents()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTest.java new file mode 100644 index 00000000000..1e5f357f8cc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEvent model. */ +public class MessageOutputDebugTurnEventTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testMessageOutputDebugTurnEvent() throws Throwable { + MessageOutputDebugTurnEvent messageOutputDebugTurnEventModel = + new MessageOutputDebugTurnEvent(); + assertNotNull(messageOutputDebugTurnEventModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionFinishedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionFinishedTest.java new file mode 100644 index 00000000000..8afde3be6ac --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionFinishedTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventActionFinished model. */ +public class MessageOutputDebugTurnEventTurnEventActionFinishedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventActionFinished() throws Throwable { + MessageOutputDebugTurnEventTurnEventActionFinished + messageOutputDebugTurnEventTurnEventActionFinishedModel = + new MessageOutputDebugTurnEventTurnEventActionFinished(); + assertNull(messageOutputDebugTurnEventTurnEventActionFinishedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventActionFinishedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventActionFinishedModel.getActionStartTime()); + assertNull(messageOutputDebugTurnEventTurnEventActionFinishedModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventActionFinishedModel.getReason()); + assertNull(messageOutputDebugTurnEventTurnEventActionFinishedModel.getActionVariables()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionRoutingDeniedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionRoutingDeniedTest.java new file mode 100644 index 00000000000..6f0f42bbabc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionRoutingDeniedTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventActionRoutingDenied model. */ +public class MessageOutputDebugTurnEventTurnEventActionRoutingDeniedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventActionRoutingDenied() throws Throwable { + MessageOutputDebugTurnEventTurnEventActionRoutingDenied + messageOutputDebugTurnEventTurnEventActionRoutingDeniedModel = + new MessageOutputDebugTurnEventTurnEventActionRoutingDenied(); + assertNull(messageOutputDebugTurnEventTurnEventActionRoutingDeniedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventActionRoutingDeniedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventActionRoutingDeniedModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventActionRoutingDeniedModel.getReason()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionVisitedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionVisitedTest.java new file mode 100644 index 00000000000..0f5e18dd6f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventActionVisitedTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventActionVisited model. */ +public class MessageOutputDebugTurnEventTurnEventActionVisitedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventActionVisited() throws Throwable { + MessageOutputDebugTurnEventTurnEventActionVisited + messageOutputDebugTurnEventTurnEventActionVisitedModel = + new MessageOutputDebugTurnEventTurnEventActionVisited(); + assertNull(messageOutputDebugTurnEventTurnEventActionVisitedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventActionVisitedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventActionVisitedModel.getActionStartTime()); + assertNull(messageOutputDebugTurnEventTurnEventActionVisitedModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventActionVisitedModel.getReason()); + assertNull(messageOutputDebugTurnEventTurnEventActionVisitedModel.getResultVariable()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventCalloutTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventCalloutTest.java new file mode 100644 index 00000000000..ef56c1c524f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventCalloutTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventCallout model. */ +public class MessageOutputDebugTurnEventTurnEventCalloutTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventCallout() throws Throwable { + MessageOutputDebugTurnEventTurnEventCallout messageOutputDebugTurnEventTurnEventCalloutModel = + new MessageOutputDebugTurnEventTurnEventCallout(); + assertNull(messageOutputDebugTurnEventTurnEventCalloutModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventCalloutModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventCalloutModel.getCallout()); + assertNull(messageOutputDebugTurnEventTurnEventCalloutModel.getError()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventClientActionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventClientActionsTest.java new file mode 100644 index 00000000000..e49a835884f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventClientActionsTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventClientActions model. */ +public class MessageOutputDebugTurnEventTurnEventClientActionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventClientActions() throws Throwable { + MessageOutputDebugTurnEventTurnEventClientActions + messageOutputDebugTurnEventTurnEventClientActionsModel = + new MessageOutputDebugTurnEventTurnEventClientActions(); + assertNull(messageOutputDebugTurnEventTurnEventClientActionsModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventClientActionsModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventClientActionsModel.getClientActions()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventConversationalSearchEndTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventConversationalSearchEndTest.java new file mode 100644 index 00000000000..d2a25ea2a94 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventConversationalSearchEndTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventConversationalSearchEnd model. */ +public class MessageOutputDebugTurnEventTurnEventConversationalSearchEndTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventConversationalSearchEnd() throws Throwable { + MessageOutputDebugTurnEventTurnEventConversationalSearchEnd + messageOutputDebugTurnEventTurnEventConversationalSearchEndModel = + new MessageOutputDebugTurnEventTurnEventConversationalSearchEnd(); + assertNull(messageOutputDebugTurnEventTurnEventConversationalSearchEndModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventConversationalSearchEndModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventConversationalSearchEndModel.getConditionType()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventGenerativeAICalledTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventGenerativeAICalledTest.java new file mode 100644 index 00000000000..9d9868529a1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventGenerativeAICalledTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventGenerativeAICalled model. */ +public class MessageOutputDebugTurnEventTurnEventGenerativeAICalledTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventGenerativeAICalled() throws Throwable { + MessageOutputDebugTurnEventTurnEventGenerativeAICalled + messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel = + new MessageOutputDebugTurnEventTurnEventGenerativeAICalled(); + assertNull(messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel.getSource()); + assertNull( + messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel.getGenerativeAiStartTime()); + assertNull(messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel.getGenerativeAi()); + assertNull(messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel.getCallout()); + assertNull(messageOutputDebugTurnEventTurnEventGenerativeAiCalledModel.getMetrics()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventHandlerVisitedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventHandlerVisitedTest.java new file mode 100644 index 00000000000..7c32f6a1f8b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventHandlerVisitedTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventHandlerVisited model. */ +public class MessageOutputDebugTurnEventTurnEventHandlerVisitedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventHandlerVisited() throws Throwable { + MessageOutputDebugTurnEventTurnEventHandlerVisited + messageOutputDebugTurnEventTurnEventHandlerVisitedModel = + new MessageOutputDebugTurnEventTurnEventHandlerVisited(); + assertNull(messageOutputDebugTurnEventTurnEventHandlerVisitedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventHandlerVisitedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventHandlerVisitedModel.getActionStartTime()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventManualRouteTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventManualRouteTest.java new file mode 100644 index 00000000000..f81328abd60 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventManualRouteTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventManualRoute model. */ +public class MessageOutputDebugTurnEventTurnEventManualRouteTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventManualRoute() throws Throwable { + MessageOutputDebugTurnEventTurnEventManualRoute + messageOutputDebugTurnEventTurnEventManualRouteModel = + new MessageOutputDebugTurnEventTurnEventManualRoute(); + assertNull(messageOutputDebugTurnEventTurnEventManualRouteModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventManualRouteModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventManualRouteModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventManualRouteModel.getActionStartTime()); + assertNull(messageOutputDebugTurnEventTurnEventManualRouteModel.getRouteName()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventNodeVisitedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventNodeVisitedTest.java new file mode 100644 index 00000000000..1a3a4272ec6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventNodeVisitedTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventNodeVisited model. */ +public class MessageOutputDebugTurnEventTurnEventNodeVisitedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventNodeVisited() throws Throwable { + MessageOutputDebugTurnEventTurnEventNodeVisited + messageOutputDebugTurnEventTurnEventNodeVisitedModel = + new MessageOutputDebugTurnEventTurnEventNodeVisited(); + assertNull(messageOutputDebugTurnEventTurnEventNodeVisitedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventNodeVisitedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventNodeVisitedModel.getReason()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSearchTest.java new file mode 100644 index 00000000000..fed320cf3f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSearchTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventSearch model. */ +public class MessageOutputDebugTurnEventTurnEventSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventSearch() throws Throwable { + MessageOutputDebugTurnEventTurnEventSearch messageOutputDebugTurnEventTurnEventSearchModel = + new MessageOutputDebugTurnEventTurnEventSearch(); + assertNull(messageOutputDebugTurnEventTurnEventSearchModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventSearchModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventSearchModel.getError()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepAnsweredTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepAnsweredTest.java new file mode 100644 index 00000000000..1d983679e3d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepAnsweredTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventStepAnswered model. */ +public class MessageOutputDebugTurnEventTurnEventStepAnsweredTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventStepAnswered() throws Throwable { + MessageOutputDebugTurnEventTurnEventStepAnswered + messageOutputDebugTurnEventTurnEventStepAnsweredModel = + new MessageOutputDebugTurnEventTurnEventStepAnswered(); + assertNull(messageOutputDebugTurnEventTurnEventStepAnsweredModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventStepAnsweredModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventStepAnsweredModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventStepAnsweredModel.getActionStartTime()); + assertNull(messageOutputDebugTurnEventTurnEventStepAnsweredModel.isPrompted()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepVisitedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepVisitedTest.java new file mode 100644 index 00000000000..a31384a48af --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventStepVisitedTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventStepVisited model. */ +public class MessageOutputDebugTurnEventTurnEventStepVisitedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventStepVisited() throws Throwable { + MessageOutputDebugTurnEventTurnEventStepVisited + messageOutputDebugTurnEventTurnEventStepVisitedModel = + new MessageOutputDebugTurnEventTurnEventStepVisited(); + assertNull(messageOutputDebugTurnEventTurnEventStepVisitedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventStepVisitedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventStepVisitedModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventStepVisitedModel.getActionStartTime()); + assertNull(messageOutputDebugTurnEventTurnEventStepVisitedModel.isHasQuestion()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedTest.java new file mode 100644 index 00000000000..5bdd7225a96 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied model. */ +public class MessageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied() throws Throwable { + MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied + messageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedModel = + new MessageOutputDebugTurnEventTurnEventSuggestionIntentsDenied(); + assertNull(messageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventSuggestionIntentsDeniedModel.getIntentsDenied()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventTopicSwitchDeniedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventTopicSwitchDeniedTest.java new file mode 100644 index 00000000000..3d075dd9f46 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTurnEventTurnEventTopicSwitchDeniedTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebugTurnEventTurnEventTopicSwitchDenied model. */ +public class MessageOutputDebugTurnEventTurnEventTopicSwitchDeniedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebugTurnEventTurnEventTopicSwitchDenied() throws Throwable { + MessageOutputDebugTurnEventTurnEventTopicSwitchDenied + messageOutputDebugTurnEventTurnEventTopicSwitchDeniedModel = + new MessageOutputDebugTurnEventTurnEventTopicSwitchDenied(); + assertNull(messageOutputDebugTurnEventTurnEventTopicSwitchDeniedModel.getEvent()); + assertNull(messageOutputDebugTurnEventTurnEventTopicSwitchDeniedModel.getSource()); + assertNull(messageOutputDebugTurnEventTurnEventTopicSwitchDeniedModel.getConditionType()); + assertNull(messageOutputDebugTurnEventTurnEventTopicSwitchDeniedModel.getReason()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputLLMMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputLLMMetadataTest.java new file mode 100644 index 00000000000..f7d5cff5307 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputLLMMetadataTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputLLMMetadata model. */ +public class MessageOutputLLMMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputLLMMetadata() throws Throwable { + MessageOutputLLMMetadata messageOutputLlmMetadataModel = new MessageOutputLLMMetadata(); + assertNull(messageOutputLlmMetadataModel.getTask()); + assertNull(messageOutputLlmMetadataModel.getModelId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputSpellingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputSpellingTest.java new file mode 100644 index 00000000000..d8eee4cafa7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputSpellingTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputSpelling model. */ +public class MessageOutputSpellingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputSpelling() throws Throwable { + MessageOutputSpelling messageOutputSpellingModel = new MessageOutputSpelling(); + assertNull(messageOutputSpellingModel.getText()); + assertNull(messageOutputSpellingModel.getOriginalText()); + assertNull(messageOutputSpellingModel.getSuggestedText()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputTest.java new file mode 100644 index 00000000000..5a904ded4f4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020, 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutput model. */ +public class MessageOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutput() throws Throwable { + MessageOutput messageOutputModel = new MessageOutput(); + assertNull(messageOutputModel.getGeneric()); + assertNull(messageOutputModel.getIntents()); + assertNull(messageOutputModel.getEntities()); + assertNull(messageOutputModel.getActions()); + assertNull(messageOutputModel.getDebug()); + assertNull(messageOutputModel.getUserDefined()); + assertNull(messageOutputModel.getSpelling()); + assertNull(messageOutputModel.getLlmMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java new file mode 100644 index 00000000000..10a5b1d8f60 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java @@ -0,0 +1,313 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageStatelessOptions model. */ +public class MessageStatelessOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageStatelessOptions() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .build(); + assertEquals(statelessMessageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(statelessMessageInputOptionsModel.debug(), Boolean.valueOf(false)); + + StatelessMessageInput statelessMessageInputModel = + new StatelessMessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(statelessMessageInputOptionsModel) + .build(); + assertEquals(statelessMessageInputModel.messageType(), "text"); + assertEquals(statelessMessageInputModel.text(), "testString"); + assertEquals(statelessMessageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + statelessMessageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(statelessMessageInputModel.suggestionId(), "testString"); + assertEquals( + statelessMessageInputModel.attachments(), + java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(statelessMessageInputModel.analytics(), requestAnalyticsModel); + assertEquals(statelessMessageInputModel.options(), statelessMessageInputOptionsModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(statelessMessageContextGlobalModel.system(), messageContextGlobalSystemModel); + assertEquals(statelessMessageContextGlobalModel.sessionId(), "testString"); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) + .build(); + assertEquals(statelessMessageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals( + statelessMessageContextSkillsModel.actionsSkill(), + statelessMessageContextSkillsActionsSkillModel); + + StatelessMessageContext statelessMessageContextModel = + new StatelessMessageContext.Builder() + .global(statelessMessageContextGlobalModel) + .skills(statelessMessageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(statelessMessageContextModel.global(), statelessMessageContextGlobalModel); + assertEquals(statelessMessageContextModel.skills(), statelessMessageContextSkillsModel); + assertEquals( + statelessMessageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageStatelessOptions messageStatelessOptionsModel = + new MessageStatelessOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .input(statelessMessageInputModel) + .context(statelessMessageContextModel) + .userId("testString") + .build(); + assertEquals(messageStatelessOptionsModel.assistantId(), "testString"); + assertEquals(messageStatelessOptionsModel.environmentId(), "testString"); + assertEquals(messageStatelessOptionsModel.input(), statelessMessageInputModel); + assertEquals(messageStatelessOptionsModel.context(), statelessMessageContextModel); + assertEquals(messageStatelessOptionsModel.userId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStatelessOptionsError() throws Throwable { + new MessageStatelessOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamMetadataTest.java new file mode 100644 index 00000000000..56506432e9a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamMetadataTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageStreamMetadata model. */ +public class MessageStreamMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageStreamMetadata() throws Throwable { + MessageStreamMetadata messageStreamMetadataModel = new MessageStreamMetadata(); + assertNull(messageStreamMetadataModel.getStreamingMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamOptionsTest.java new file mode 100644 index 00000000000..73eaf1cf4f9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamOptionsTest.java @@ -0,0 +1,302 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageStreamOptions model. */ +public class MessageStreamOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageStreamOptions() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(false)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "testString"); + assertEquals(messageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(messageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals( + messageInputModel.attachments(), java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(messageInputModel.analytics(), requestAnalyticsModel); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals(messageContextModel.skills(), messageContextSkillsModel); + assertEquals( + messageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageStreamOptions messageStreamOptionsModel = + new MessageStreamOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .sessionId("testString") + .input(messageInputModel) + .context(messageContextModel) + .userId("testString") + .build(); + assertEquals(messageStreamOptionsModel.assistantId(), "testString"); + assertEquals(messageStreamOptionsModel.environmentId(), "testString"); + assertEquals(messageStreamOptionsModel.sessionId(), "testString"); + assertEquals(messageStreamOptionsModel.input(), messageInputModel); + assertEquals(messageStreamOptionsModel.context(), messageContextModel); + assertEquals(messageStreamOptionsModel.userId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStreamOptionsError() throws Throwable { + new MessageStreamOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamResponseTest.java new file mode 100644 index 00000000000..82c6eb113c8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageStreamResponse model. */ +public class MessageStreamResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testMessageStreamResponse() throws Throwable { + MessageStreamResponse messageStreamResponseModel = new MessageStreamResponse(); + assertNotNull(messageStreamResponseModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamStatelessOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamStatelessOptionsTest.java new file mode 100644 index 00000000000..da8efce94dd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStreamStatelessOptionsTest.java @@ -0,0 +1,300 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageStreamStatelessOptions model. */ +public class MessageStreamStatelessOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageStreamStatelessOptions() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .returnContext(false) + .export(false) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(false)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(false)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "testString"); + assertEquals(messageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(messageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals( + messageInputModel.attachments(), java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(messageInputModel.analytics(), requestAnalyticsModel); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageContextSkills messageContextSkillsModel = + new MessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) + .build(); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills(messageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals(messageContextModel.skills(), messageContextSkillsModel); + assertEquals( + messageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + MessageStreamStatelessOptions messageStreamStatelessOptionsModel = + new MessageStreamStatelessOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .input(messageInputModel) + .context(messageContextModel) + .userId("testString") + .build(); + assertEquals(messageStreamStatelessOptionsModel.assistantId(), "testString"); + assertEquals(messageStreamStatelessOptionsModel.environmentId(), "testString"); + assertEquals(messageStreamStatelessOptionsModel.input(), messageInputModel); + assertEquals(messageStreamStatelessOptionsModel.context(), messageContextModel); + assertEquals(messageStreamStatelessOptionsModel.userId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStreamStatelessOptionsError() throws Throwable { + new MessageStreamStatelessOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MetadataTest.java new file mode 100644 index 00000000000..ce7b2124f2f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MetadataTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Metadata model. */ +public class MetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetadata() throws Throwable { + Metadata metadataModel = new Metadata(); + assertNull(metadataModel.getId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MonitorAssistantReleaseImportArtifactResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MonitorAssistantReleaseImportArtifactResponseTest.java new file mode 100644 index 00000000000..42e54e1148a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MonitorAssistantReleaseImportArtifactResponseTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MonitorAssistantReleaseImportArtifactResponse model. */ +public class MonitorAssistantReleaseImportArtifactResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMonitorAssistantReleaseImportArtifactResponse() throws Throwable { + MonitorAssistantReleaseImportArtifactResponse + monitorAssistantReleaseImportArtifactResponseModel = + new MonitorAssistantReleaseImportArtifactResponse(); + assertNull(monitorAssistantReleaseImportArtifactResponseModel.getSkillImpactInDraft()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/PaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/PaginationTest.java new file mode 100644 index 00000000000..2fb6076f675 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/PaginationTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Pagination model. */ +public class PaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPagination() throws Throwable { + Pagination paginationModel = new Pagination(); + assertNull(paginationModel.getRefreshUrl()); + assertNull(paginationModel.getNextUrl()); + assertNull(paginationModel.getTotal()); + assertNull(paginationModel.getMatched()); + assertNull(paginationModel.getRefreshCursor()); + assertNull(paginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/PartialItemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/PartialItemTest.java new file mode 100644 index 00000000000..7cf518c58e5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/PartialItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PartialItem model. */ +public class PartialItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPartialItem() throws Throwable { + PartialItem partialItemModel = new PartialItem(); + assertNull(partialItemModel.getResponseType()); + assertNull(partialItemModel.getText()); + assertNull(partialItemModel.getStreamingMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeTest.java new file mode 100644 index 00000000000..a63e14594e1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeTest.java @@ -0,0 +1,121 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode model. + */ +public class ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode() + throws Throwable { + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .authorizationUrl("testString") + .redirectUri("testString") + .build(); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .tokenUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .refreshUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .clientAuthType(), + "Body"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .contentType(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .headerPrefix(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .authorizationUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel + .redirectUri(), + "testString"); + + String json = + TestUtilities.serialize( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModel); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew = + TestUtilities.deserialize( + json, + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode + .class); + assertTrue( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + instanceof + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCode); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .tokenUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .refreshUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .clientAuthType(), + "Body"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .contentType(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .headerPrefix(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .authorizationUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2AuthorizationCodeModelNew + .redirectUri(), + "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsTest.java new file mode 100644 index 00000000000..672b219b3d6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsTest.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the + * ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials model. + */ +public class ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials() + throws Throwable { + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + .Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .build(); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel + .tokenUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel + .refreshUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel + .clientAuthType(), + "Body"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel + .contentType(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel + .headerPrefix(), + "testString"); + + String json = + TestUtilities.serialize( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModel); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew = + TestUtilities.deserialize( + json, + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials + .class); + assertTrue( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew + instanceof + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentials); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew + .tokenUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew + .refreshUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew + .clientAuthType(), + "Body"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew + .contentType(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2ClientCredentialsModelNew + .headerPrefix(), + "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordTest.java new file mode 100644 index 00000000000..c49d5fa6fed --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordTest.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + * model. + */ +public class ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password() + throws Throwable { + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel.tokenUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel.refreshUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel.clientAuthType(), + "Body"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel.contentType(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel.headerPrefix(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + String json = + TestUtilities.serialize( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModel); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew = + TestUtilities.deserialize( + json, ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.class); + assertTrue( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew + instanceof ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew.tokenUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew.refreshUrl(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew + .clientAuthType(), + "Body"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew.contentType(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew + .headerPrefix(), + "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsProviderAuthenticationOAuth2PasswordModelNew + .username() + .toString(), + providerAuthenticationOAuth2PasswordUsernameModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsTest.java new file mode 100644 index 00000000000..d9fe8a29795 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2FlowsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderAuthenticationOAuth2Flows model. */ +public class ProviderAuthenticationOAuth2FlowsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testProviderAuthenticationOAuth2Flows() throws Throwable { + ProviderAuthenticationOAuth2Flows providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2Flows(); + assertNotNull(providerAuthenticationOAuth2FlowsModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2PasswordUsernameTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2PasswordUsernameTest.java new file mode 100644 index 00000000000..81e55d7ac9d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2PasswordUsernameTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderAuthenticationOAuth2PasswordUsername model. */ +public class ProviderAuthenticationOAuth2PasswordUsernameTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderAuthenticationOAuth2PasswordUsername() throws Throwable { + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + String json = TestUtilities.serialize(providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2PasswordUsername + providerAuthenticationOAuth2PasswordUsernameModelNew = + TestUtilities.deserialize(json, ProviderAuthenticationOAuth2PasswordUsername.class); + assertTrue( + providerAuthenticationOAuth2PasswordUsernameModelNew + instanceof ProviderAuthenticationOAuth2PasswordUsername); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModelNew.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModelNew.value(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2Test.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2Test.java new file mode 100644 index 00000000000..92ade353bee --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationOAuth2Test.java @@ -0,0 +1,78 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderAuthenticationOAuth2 model. */ +public class ProviderAuthenticationOAuth2Test { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderAuthenticationOAuth2() throws Throwable { + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals(providerAuthenticationOAuth2FlowsModel.tokenUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.refreshUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.clientAuthType(), "Body"); + assertEquals(providerAuthenticationOAuth2FlowsModel.contentType(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.headerPrefix(), "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + assertEquals(providerAuthenticationOAuth2Model.preferredFlow(), "password"); + assertEquals(providerAuthenticationOAuth2Model.flows(), providerAuthenticationOAuth2FlowsModel); + + String json = TestUtilities.serialize(providerAuthenticationOAuth2Model); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2ModelNew = + TestUtilities.deserialize(json, ProviderAuthenticationOAuth2.class); + assertTrue(providerAuthenticationOAuth2ModelNew instanceof ProviderAuthenticationOAuth2); + assertEquals(providerAuthenticationOAuth2ModelNew.preferredFlow(), "password"); + assertEquals( + providerAuthenticationOAuth2ModelNew.flows().toString(), + providerAuthenticationOAuth2FlowsModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationTypeAndValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationTypeAndValueTest.java new file mode 100644 index 00000000000..2cc0fcea245 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderAuthenticationTypeAndValueTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderAuthenticationTypeAndValue model. */ +public class ProviderAuthenticationTypeAndValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderAuthenticationTypeAndValue() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + String json = TestUtilities.serialize(providerAuthenticationTypeAndValueModel); + + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModelNew = + TestUtilities.deserialize(json, ProviderAuthenticationTypeAndValue.class); + assertTrue( + providerAuthenticationTypeAndValueModelNew instanceof ProviderAuthenticationTypeAndValue); + assertEquals(providerAuthenticationTypeAndValueModelNew.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModelNew.value(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderCollectionTest.java new file mode 100644 index 00000000000..b8706260de8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderCollection model. */ +public class ProviderCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderCollection() throws Throwable { + ProviderCollection providerCollectionModel = new ProviderCollection(); + assertNull(providerCollectionModel.getConversationalSkillProviders()); + assertNull(providerCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBasicFlowTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBasicFlowTest.java new file mode 100644 index 00000000000..e7951c79a3f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBasicFlowTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivateAuthenticationBasicFlow model. */ +public class ProviderPrivateAuthenticationBasicFlowTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderPrivateAuthenticationBasicFlow() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderPrivateAuthenticationBasicFlow providerPrivateAuthenticationBasicFlowModel = + new ProviderPrivateAuthenticationBasicFlow.Builder() + .password(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerPrivateAuthenticationBasicFlowModel.password(), + providerAuthenticationTypeAndValueModel); + + String json = TestUtilities.serialize(providerPrivateAuthenticationBasicFlowModel); + + ProviderPrivateAuthenticationBasicFlow providerPrivateAuthenticationBasicFlowModelNew = + TestUtilities.deserialize(json, ProviderPrivateAuthenticationBasicFlow.class); + assertTrue( + providerPrivateAuthenticationBasicFlowModelNew + instanceof ProviderPrivateAuthenticationBasicFlow); + assertEquals( + providerPrivateAuthenticationBasicFlowModelNew.password().toString(), + providerAuthenticationTypeAndValueModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBearerFlowTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBearerFlowTest.java new file mode 100644 index 00000000000..92861f6be11 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationBearerFlowTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivateAuthenticationBearerFlow model. */ +public class ProviderPrivateAuthenticationBearerFlowTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderPrivateAuthenticationBearerFlow() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationBearerFlowModel = + new ProviderPrivateAuthenticationBearerFlow.Builder() + .token(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerPrivateAuthenticationBearerFlowModel.token(), + providerAuthenticationTypeAndValueModel); + + String json = TestUtilities.serialize(providerPrivateAuthenticationBearerFlowModel); + + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationBearerFlowModelNew = + TestUtilities.deserialize(json, ProviderPrivateAuthenticationBearerFlow.class); + assertTrue( + providerPrivateAuthenticationBearerFlowModelNew + instanceof ProviderPrivateAuthenticationBearerFlow); + assertEquals( + providerPrivateAuthenticationBearerFlowModelNew.token().toString(), + providerAuthenticationTypeAndValueModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeTest.java new file mode 100644 index 00000000000..3f7fc712297 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeTest.java @@ -0,0 +1,106 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + * model. + */ +public +class ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void + testProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode() + throws Throwable { + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel = + new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .Builder() + .clientId("testString") + .clientSecret("testString") + .accessToken("testString") + .refreshToken("testString") + .authorizationCode("testString") + .build(); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel + .clientId(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel + .clientSecret(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel + .accessToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel + .refreshToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel + .authorizationCode(), + "testString"); + + String json = + TestUtilities.serialize( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModel); + + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew = + TestUtilities.deserialize( + json, + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode + .class); + assertTrue( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew + instanceof + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCode); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew + .clientId(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew + .clientSecret(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew + .accessToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew + .refreshToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2AuthorizationCodeModelNew + .authorizationCode(), + "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsTest.java new file mode 100644 index 00000000000..783e4f8655c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsTest.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + * model. + */ +public +class ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void + testProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials() + throws Throwable { + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModel = + new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + .Builder() + .clientId("testString") + .clientSecret("testString") + .accessToken("testString") + .refreshToken("testString") + .build(); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModel + .clientId(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModel + .clientSecret(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModel + .accessToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModel + .refreshToken(), + "testString"); + + String json = + TestUtilities.serialize( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModel); + + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModelNew = + TestUtilities.deserialize( + json, + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials + .class); + assertTrue( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModelNew + instanceof + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentials); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModelNew + .clientId(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModelNew + .clientSecret(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModelNew + .accessToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2ClientCredentialsModelNew + .refreshToken(), + "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordTest.java new file mode 100644 index 00000000000..a3ad088b995 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordTest.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** + * Unit test class for the + * ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password model. + */ +public +class ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void + testProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password() + throws Throwable { + ProviderPrivateAuthenticationOAuth2PasswordPassword + providerPrivateAuthenticationOAuth2PasswordPasswordModel = + new ProviderPrivateAuthenticationOAuth2PasswordPassword.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModel.type(), "value"); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModel.value(), "testString"); + + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel = + new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .Builder() + .clientId("testString") + .clientSecret("testString") + .accessToken("testString") + .refreshToken("testString") + .password(providerPrivateAuthenticationOAuth2PasswordPasswordModel) + .build(); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel + .clientId(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel + .clientSecret(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel + .accessToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel + .refreshToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel + .password(), + providerPrivateAuthenticationOAuth2PasswordPasswordModel); + + String json = + TestUtilities.serialize( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModel); + + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew = + TestUtilities.deserialize( + json, + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .class); + assertTrue( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew + instanceof + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew + .clientId(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew + .clientSecret(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew + .accessToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew + .refreshToken(), + "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2PasswordModelNew + .password() + .toString(), + providerPrivateAuthenticationOAuth2PasswordPasswordModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsTest.java new file mode 100644 index 00000000000..2e1eb99b3f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowFlowsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivateAuthenticationOAuth2FlowFlows model. */ +public class ProviderPrivateAuthenticationOAuth2FlowFlowsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testProviderPrivateAuthenticationOAuth2FlowFlows() throws Throwable { + ProviderPrivateAuthenticationOAuth2FlowFlows providerPrivateAuthenticationOAuth2FlowFlowsModel = + new ProviderPrivateAuthenticationOAuth2FlowFlows(); + assertNotNull(providerPrivateAuthenticationOAuth2FlowFlowsModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowTest.java new file mode 100644 index 00000000000..1d678e6da18 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2FlowTest.java @@ -0,0 +1,79 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivateAuthenticationOAuth2Flow model. */ +public class ProviderPrivateAuthenticationOAuth2FlowTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderPrivateAuthenticationOAuth2Flow() throws Throwable { + ProviderPrivateAuthenticationOAuth2PasswordPassword + providerPrivateAuthenticationOAuth2PasswordPasswordModel = + new ProviderPrivateAuthenticationOAuth2PasswordPassword.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModel.type(), "value"); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModel.value(), "testString"); + + ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + providerPrivateAuthenticationOAuth2FlowFlowsModel = + new ProviderPrivateAuthenticationOAuth2FlowFlowsProviderPrivateAuthenticationOAuth2Password + .Builder() + .clientId("testString") + .clientSecret("testString") + .accessToken("testString") + .refreshToken("testString") + .password(providerPrivateAuthenticationOAuth2PasswordPasswordModel) + .build(); + assertEquals(providerPrivateAuthenticationOAuth2FlowFlowsModel.clientId(), "testString"); + assertEquals(providerPrivateAuthenticationOAuth2FlowFlowsModel.clientSecret(), "testString"); + assertEquals(providerPrivateAuthenticationOAuth2FlowFlowsModel.accessToken(), "testString"); + assertEquals(providerPrivateAuthenticationOAuth2FlowFlowsModel.refreshToken(), "testString"); + assertEquals( + providerPrivateAuthenticationOAuth2FlowFlowsModel.password(), + providerPrivateAuthenticationOAuth2PasswordPasswordModel); + + ProviderPrivateAuthenticationOAuth2Flow providerPrivateAuthenticationOAuth2FlowModel = + new ProviderPrivateAuthenticationOAuth2Flow.Builder() + .flows(providerPrivateAuthenticationOAuth2FlowFlowsModel) + .build(); + assertEquals( + providerPrivateAuthenticationOAuth2FlowModel.flows(), + providerPrivateAuthenticationOAuth2FlowFlowsModel); + + String json = TestUtilities.serialize(providerPrivateAuthenticationOAuth2FlowModel); + + ProviderPrivateAuthenticationOAuth2Flow providerPrivateAuthenticationOAuth2FlowModelNew = + TestUtilities.deserialize(json, ProviderPrivateAuthenticationOAuth2Flow.class); + assertTrue( + providerPrivateAuthenticationOAuth2FlowModelNew + instanceof ProviderPrivateAuthenticationOAuth2Flow); + assertEquals( + providerPrivateAuthenticationOAuth2FlowModelNew.flows().toString(), + providerPrivateAuthenticationOAuth2FlowFlowsModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2PasswordPasswordTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2PasswordPasswordTest.java new file mode 100644 index 00000000000..1a955309be7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationOAuth2PasswordPasswordTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivateAuthenticationOAuth2PasswordPassword model. */ +public class ProviderPrivateAuthenticationOAuth2PasswordPasswordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderPrivateAuthenticationOAuth2PasswordPassword() throws Throwable { + ProviderPrivateAuthenticationOAuth2PasswordPassword + providerPrivateAuthenticationOAuth2PasswordPasswordModel = + new ProviderPrivateAuthenticationOAuth2PasswordPassword.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModel.type(), "value"); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModel.value(), "testString"); + + String json = TestUtilities.serialize(providerPrivateAuthenticationOAuth2PasswordPasswordModel); + + ProviderPrivateAuthenticationOAuth2PasswordPassword + providerPrivateAuthenticationOAuth2PasswordPasswordModelNew = + TestUtilities.deserialize( + json, ProviderPrivateAuthenticationOAuth2PasswordPassword.class); + assertTrue( + providerPrivateAuthenticationOAuth2PasswordPasswordModelNew + instanceof ProviderPrivateAuthenticationOAuth2PasswordPassword); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModelNew.type(), "value"); + assertEquals(providerPrivateAuthenticationOAuth2PasswordPasswordModelNew.value(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationTest.java new file mode 100644 index 00000000000..1c3084e369a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateAuthenticationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivateAuthentication model. */ +public class ProviderPrivateAuthenticationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testProviderPrivateAuthentication() throws Throwable { + ProviderPrivateAuthentication providerPrivateAuthenticationModel = + new ProviderPrivateAuthentication(); + assertNotNull(providerPrivateAuthenticationModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateTest.java new file mode 100644 index 00000000000..08a874f888c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderPrivateTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderPrivate model. */ +public class ProviderPrivateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderPrivate() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationModel = + new ProviderPrivateAuthenticationBearerFlow.Builder() + .token(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerPrivateAuthenticationModel.token(), providerAuthenticationTypeAndValueModel); + + ProviderPrivate providerPrivateModel = + new ProviderPrivate.Builder().authentication(providerPrivateAuthenticationModel).build(); + assertEquals(providerPrivateModel.authentication(), providerPrivateAuthenticationModel); + + String json = TestUtilities.serialize(providerPrivateModel); + + ProviderPrivate providerPrivateModelNew = + TestUtilities.deserialize(json, ProviderPrivate.class); + assertTrue(providerPrivateModelNew instanceof ProviderPrivate); + assertEquals( + providerPrivateModelNew.authentication().toString(), + providerPrivateAuthenticationModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testProviderPrivateError() throws Throwable { + new ProviderPrivate.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesBasicTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesBasicTest.java new file mode 100644 index 00000000000..a5a8acbe5e5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesBasicTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderResponseSpecificationComponentsSecuritySchemesBasic model. */ +public class ProviderResponseSpecificationComponentsSecuritySchemesBasicTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderResponseSpecificationComponentsSecuritySchemesBasic() throws Throwable { + ProviderResponseSpecificationComponentsSecuritySchemesBasic + providerResponseSpecificationComponentsSecuritySchemesBasicModel = + new ProviderResponseSpecificationComponentsSecuritySchemesBasic(); + assertNull(providerResponseSpecificationComponentsSecuritySchemesBasicModel.getUsername()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesTest.java new file mode 100644 index 00000000000..c9ef14807e6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsSecuritySchemesTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderResponseSpecificationComponentsSecuritySchemes model. */ +public class ProviderResponseSpecificationComponentsSecuritySchemesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderResponseSpecificationComponentsSecuritySchemes() throws Throwable { + ProviderResponseSpecificationComponentsSecuritySchemes + providerResponseSpecificationComponentsSecuritySchemesModel = + new ProviderResponseSpecificationComponentsSecuritySchemes(); + assertNull( + providerResponseSpecificationComponentsSecuritySchemesModel.getAuthenticationMethod()); + assertNull(providerResponseSpecificationComponentsSecuritySchemesModel.getBasic()); + assertNull(providerResponseSpecificationComponentsSecuritySchemesModel.getOauth2()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsTest.java new file mode 100644 index 00000000000..18c45260c8c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationComponentsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderResponseSpecificationComponents model. */ +public class ProviderResponseSpecificationComponentsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderResponseSpecificationComponents() throws Throwable { + ProviderResponseSpecificationComponents providerResponseSpecificationComponentsModel = + new ProviderResponseSpecificationComponents(); + assertNull(providerResponseSpecificationComponentsModel.getSecuritySchemes()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationServersItemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationServersItemTest.java new file mode 100644 index 00000000000..c790bd87e90 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationServersItemTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderResponseSpecificationServersItem model. */ +public class ProviderResponseSpecificationServersItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderResponseSpecificationServersItem() throws Throwable { + ProviderResponseSpecificationServersItem providerResponseSpecificationServersItemModel = + new ProviderResponseSpecificationServersItem(); + assertNull(providerResponseSpecificationServersItemModel.getUrl()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationTest.java new file mode 100644 index 00000000000..90f4f0b6e39 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseSpecificationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderResponseSpecification model. */ +public class ProviderResponseSpecificationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderResponseSpecification() throws Throwable { + ProviderResponseSpecification providerResponseSpecificationModel = + new ProviderResponseSpecification(); + assertNull(providerResponseSpecificationModel.getServers()); + assertNull(providerResponseSpecificationModel.getComponents()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseTest.java new file mode 100644 index 00000000000..e3d04c50b3d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderResponse model. */ +public class ProviderResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderResponse() throws Throwable { + ProviderResponse providerResponseModel = new ProviderResponse(); + assertNull(providerResponseModel.getProviderId()); + assertNull(providerResponseModel.getSpecification()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesBasicTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesBasicTest.java new file mode 100644 index 00000000000..76af442b234 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesBasicTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderSpecificationComponentsSecuritySchemesBasic model. */ +public class ProviderSpecificationComponentsSecuritySchemesBasicTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderSpecificationComponentsSecuritySchemesBasic() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModel.username(), + providerAuthenticationTypeAndValueModel); + + String json = TestUtilities.serialize(providerSpecificationComponentsSecuritySchemesBasicModel); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModelNew = + TestUtilities.deserialize( + json, ProviderSpecificationComponentsSecuritySchemesBasic.class); + assertTrue( + providerSpecificationComponentsSecuritySchemesBasicModelNew + instanceof ProviderSpecificationComponentsSecuritySchemesBasic); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModelNew.username().toString(), + providerAuthenticationTypeAndValueModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesTest.java new file mode 100644 index 00000000000..66ec8882305 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsSecuritySchemesTest.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderSpecificationComponentsSecuritySchemes model. */ +public class ProviderSpecificationComponentsSecuritySchemesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderSpecificationComponentsSecuritySchemes() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModel.username(), + providerAuthenticationTypeAndValueModel); + + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals(providerAuthenticationOAuth2FlowsModel.tokenUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.refreshUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.clientAuthType(), "Body"); + assertEquals(providerAuthenticationOAuth2FlowsModel.contentType(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.headerPrefix(), "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + assertEquals(providerAuthenticationOAuth2Model.preferredFlow(), "password"); + assertEquals(providerAuthenticationOAuth2Model.flows(), providerAuthenticationOAuth2FlowsModel); + + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.authenticationMethod(), "basic"); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.basic(), + providerSpecificationComponentsSecuritySchemesBasicModel); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.oauth2(), + providerAuthenticationOAuth2Model); + + String json = TestUtilities.serialize(providerSpecificationComponentsSecuritySchemesModel); + + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModelNew = + TestUtilities.deserialize(json, ProviderSpecificationComponentsSecuritySchemes.class); + assertTrue( + providerSpecificationComponentsSecuritySchemesModelNew + instanceof ProviderSpecificationComponentsSecuritySchemes); + assertEquals( + providerSpecificationComponentsSecuritySchemesModelNew.authenticationMethod(), "basic"); + assertEquals( + providerSpecificationComponentsSecuritySchemesModelNew.basic().toString(), + providerSpecificationComponentsSecuritySchemesBasicModel.toString()); + assertEquals( + providerSpecificationComponentsSecuritySchemesModelNew.oauth2().toString(), + providerAuthenticationOAuth2Model.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsTest.java new file mode 100644 index 00000000000..9aee2603a08 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationComponentsTest.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderSpecificationComponents model. */ +public class ProviderSpecificationComponentsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderSpecificationComponents() throws Throwable { + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModel.username(), + providerAuthenticationTypeAndValueModel); + + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals(providerAuthenticationOAuth2FlowsModel.tokenUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.refreshUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.clientAuthType(), "Body"); + assertEquals(providerAuthenticationOAuth2FlowsModel.contentType(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.headerPrefix(), "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + assertEquals(providerAuthenticationOAuth2Model.preferredFlow(), "password"); + assertEquals(providerAuthenticationOAuth2Model.flows(), providerAuthenticationOAuth2FlowsModel); + + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.authenticationMethod(), "basic"); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.basic(), + providerSpecificationComponentsSecuritySchemesBasicModel); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.oauth2(), + providerAuthenticationOAuth2Model); + + ProviderSpecificationComponents providerSpecificationComponentsModel = + new ProviderSpecificationComponents.Builder() + .securitySchemes(providerSpecificationComponentsSecuritySchemesModel) + .build(); + assertEquals( + providerSpecificationComponentsModel.securitySchemes(), + providerSpecificationComponentsSecuritySchemesModel); + + String json = TestUtilities.serialize(providerSpecificationComponentsModel); + + ProviderSpecificationComponents providerSpecificationComponentsModelNew = + TestUtilities.deserialize(json, ProviderSpecificationComponents.class); + assertTrue(providerSpecificationComponentsModelNew instanceof ProviderSpecificationComponents); + assertEquals( + providerSpecificationComponentsModelNew.securitySchemes().toString(), + providerSpecificationComponentsSecuritySchemesModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationServersItemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationServersItemTest.java new file mode 100644 index 00000000000..bd01d5005b8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationServersItemTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderSpecificationServersItem model. */ +public class ProviderSpecificationServersItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderSpecificationServersItem() throws Throwable { + ProviderSpecificationServersItem providerSpecificationServersItemModel = + new ProviderSpecificationServersItem.Builder().url("testString").build(); + assertEquals(providerSpecificationServersItemModel.url(), "testString"); + + String json = TestUtilities.serialize(providerSpecificationServersItemModel); + + ProviderSpecificationServersItem providerSpecificationServersItemModelNew = + TestUtilities.deserialize(json, ProviderSpecificationServersItem.class); + assertTrue( + providerSpecificationServersItemModelNew instanceof ProviderSpecificationServersItem); + assertEquals(providerSpecificationServersItemModelNew.url(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationTest.java new file mode 100644 index 00000000000..7a44ab74403 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ProviderSpecificationTest.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProviderSpecification model. */ +public class ProviderSpecificationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProviderSpecification() throws Throwable { + ProviderSpecificationServersItem providerSpecificationServersItemModel = + new ProviderSpecificationServersItem.Builder().url("testString").build(); + assertEquals(providerSpecificationServersItemModel.url(), "testString"); + + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModel.username(), + providerAuthenticationTypeAndValueModel); + + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals(providerAuthenticationOAuth2FlowsModel.tokenUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.refreshUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.clientAuthType(), "Body"); + assertEquals(providerAuthenticationOAuth2FlowsModel.contentType(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.headerPrefix(), "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + assertEquals(providerAuthenticationOAuth2Model.preferredFlow(), "password"); + assertEquals(providerAuthenticationOAuth2Model.flows(), providerAuthenticationOAuth2FlowsModel); + + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.authenticationMethod(), "basic"); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.basic(), + providerSpecificationComponentsSecuritySchemesBasicModel); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.oauth2(), + providerAuthenticationOAuth2Model); + + ProviderSpecificationComponents providerSpecificationComponentsModel = + new ProviderSpecificationComponents.Builder() + .securitySchemes(providerSpecificationComponentsSecuritySchemesModel) + .build(); + assertEquals( + providerSpecificationComponentsModel.securitySchemes(), + providerSpecificationComponentsSecuritySchemesModel); + + ProviderSpecification providerSpecificationModel = + new ProviderSpecification.Builder() + .servers(java.util.Arrays.asList(providerSpecificationServersItemModel)) + .components(providerSpecificationComponentsModel) + .build(); + assertEquals( + providerSpecificationModel.servers(), + java.util.Arrays.asList(providerSpecificationServersItemModel)); + assertEquals(providerSpecificationModel.components(), providerSpecificationComponentsModel); + + String json = TestUtilities.serialize(providerSpecificationModel); + + ProviderSpecification providerSpecificationModelNew = + TestUtilities.deserialize(json, ProviderSpecification.class); + assertTrue(providerSpecificationModelNew instanceof ProviderSpecification); + assertEquals( + providerSpecificationModelNew.components().toString(), + providerSpecificationComponentsModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testProviderSpecificationError() throws Throwable { + new ProviderSpecification.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseCollectionTest.java new file mode 100644 index 00000000000..9bd7babebf0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ReleaseCollection model. */ +public class ReleaseCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReleaseCollection() throws Throwable { + ReleaseCollection releaseCollectionModel = new ReleaseCollection(); + assertNull(releaseCollectionModel.getReleases()); + assertNull(releaseCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseContentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseContentTest.java new file mode 100644 index 00000000000..8eafea2ea23 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseContentTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ReleaseContent model. */ +public class ReleaseContentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReleaseContent() throws Throwable { + ReleaseContent releaseContentModel = new ReleaseContent.Builder().build(); + + String json = TestUtilities.serialize(releaseContentModel); + + ReleaseContent releaseContentModelNew = TestUtilities.deserialize(json, ReleaseContent.class); + assertTrue(releaseContentModelNew instanceof ReleaseContent); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseSkillReferenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseSkillReferenceTest.java new file mode 100644 index 00000000000..d6817d16271 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseSkillReferenceTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ReleaseSkillReference model. */ +public class ReleaseSkillReferenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReleaseSkillReference() throws Throwable { + ReleaseSkillReference releaseSkillReferenceModel = new ReleaseSkillReference(); + assertNull(releaseSkillReferenceModel.getSkillId()); + assertNull(releaseSkillReferenceModel.getType()); + assertNull(releaseSkillReferenceModel.getSnapshot()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseSkillTest.java new file mode 100644 index 00000000000..1e68f8b6a74 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseSkillTest.java @@ -0,0 +1,56 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ReleaseSkill model. */ +public class ReleaseSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReleaseSkill() throws Throwable { + ReleaseSkill releaseSkillModel = + new ReleaseSkill.Builder() + .skillId("testString") + .type("dialog") + .snapshot("testString") + .build(); + assertEquals(releaseSkillModel.skillId(), "testString"); + assertEquals(releaseSkillModel.type(), "dialog"); + assertEquals(releaseSkillModel.snapshot(), "testString"); + + String json = TestUtilities.serialize(releaseSkillModel); + + ReleaseSkill releaseSkillModelNew = TestUtilities.deserialize(json, ReleaseSkill.class); + assertTrue(releaseSkillModelNew instanceof ReleaseSkill); + assertEquals(releaseSkillModelNew.skillId(), "testString"); + assertEquals(releaseSkillModelNew.type(), "dialog"); + assertEquals(releaseSkillModelNew.snapshot(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReleaseSkillError() throws Throwable { + new ReleaseSkill.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseTest.java new file mode 100644 index 00000000000..e86f0c87875 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ReleaseTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Release model. */ +public class ReleaseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelease() throws Throwable { + Release releaseModel = new Release.Builder().description("testString").build(); + assertEquals(releaseModel.description(), "testString"); + + String json = TestUtilities.serialize(releaseModel); + + Release releaseModelNew = TestUtilities.deserialize(json, Release.class); + assertTrue(releaseModelNew instanceof Release); + assertEquals(releaseModelNew.description(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RequestAnalyticsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RequestAnalyticsTest.java new file mode 100644 index 00000000000..efc743db7dd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RequestAnalyticsTest.java @@ -0,0 +1,52 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RequestAnalytics model. */ +public class RequestAnalyticsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRequestAnalytics() throws Throwable { + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + String json = TestUtilities.serialize(requestAnalyticsModel); + + RequestAnalytics requestAnalyticsModelNew = + TestUtilities.deserialize(json, RequestAnalytics.class); + assertTrue(requestAnalyticsModelNew instanceof RequestAnalytics); + assertEquals(requestAnalyticsModelNew.browser(), "testString"); + assertEquals(requestAnalyticsModelNew.device(), "testString"); + assertEquals(requestAnalyticsModelNew.pageUrl(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericChannelTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericChannelTest.java new file mode 100644 index 00000000000..6380080a9ac --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericChannelTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResponseGenericChannel model. */ +public class ResponseGenericChannelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResponseGenericChannel() throws Throwable { + ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel(); + assertNull(responseGenericChannelModel.getChannel()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationRangesItemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationRangesItemTest.java new file mode 100644 index 00000000000..f1a05fe8348 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationRangesItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResponseGenericCitationRangesItem model. */ +public class ResponseGenericCitationRangesItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResponseGenericCitationRangesItem() throws Throwable { + ResponseGenericCitationRangesItem responseGenericCitationRangesItemModel = + new ResponseGenericCitationRangesItem(); + assertNull(responseGenericCitationRangesItemModel.getStart()); + assertNull(responseGenericCitationRangesItemModel.getEnd()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationTest.java new file mode 100644 index 00000000000..3aa758a41de --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericCitationTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResponseGenericCitation model. */ +public class ResponseGenericCitationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResponseGenericCitation() throws Throwable { + ResponseGenericCitation responseGenericCitationModel = new ResponseGenericCitation(); + assertNull(responseGenericCitationModel.getTitle()); + assertNull(responseGenericCitationModel.getText()); + assertNull(responseGenericCitationModel.getBody()); + assertNull(responseGenericCitationModel.getSearchResultIndex()); + assertNull(responseGenericCitationModel.getRanges()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericConfidenceScoresTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericConfidenceScoresTest.java new file mode 100644 index 00000000000..8a494ec5583 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ResponseGenericConfidenceScoresTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResponseGenericConfidenceScores model. */ +public class ResponseGenericConfidenceScoresTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResponseGenericConfidenceScores() throws Throwable { + ResponseGenericConfidenceScores responseGenericConfidenceScoresModel = + new ResponseGenericConfidenceScores(); + assertNull(responseGenericConfidenceScoresModel.getThreshold()); + assertNull(responseGenericConfidenceScoresModel.getPreGen()); + assertNull(responseGenericConfidenceScoresModel.getPostGen()); + assertNull(responseGenericConfidenceScoresModel.getExtractiveness()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternativeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternativeTest.java new file mode 100644 index 00000000000..ac0fad47a3c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternativeTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityAlternative model. */ +public class RuntimeEntityAlternativeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityAlternative() throws Throwable { + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeEntityAlternativeModel); + + RuntimeEntityAlternative runtimeEntityAlternativeModelNew = + TestUtilities.deserialize(json, RuntimeEntityAlternative.class); + assertTrue(runtimeEntityAlternativeModelNew instanceof RuntimeEntityAlternative); + assertEquals(runtimeEntityAlternativeModelNew.value(), "testString"); + assertEquals(runtimeEntityAlternativeModelNew.confidence(), Double.valueOf("72.5")); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretationTest.java new file mode 100644 index 00000000000..e4e7362b086 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretationTest.java @@ -0,0 +1,121 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityInterpretation model. */ +public class RuntimeEntityInterpretationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityInterpretation() throws Throwable { + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + String json = TestUtilities.serialize(runtimeEntityInterpretationModel); + + RuntimeEntityInterpretation runtimeEntityInterpretationModelNew = + TestUtilities.deserialize(json, RuntimeEntityInterpretation.class); + assertTrue(runtimeEntityInterpretationModelNew instanceof RuntimeEntityInterpretation); + assertEquals(runtimeEntityInterpretationModelNew.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModelNew.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.timezone(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRoleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRoleTest.java new file mode 100644 index 00000000000..960f230804c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRoleTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityRole model. */ +public class RuntimeEntityRoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityRole() throws Throwable { + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + String json = TestUtilities.serialize(runtimeEntityRoleModel); + + RuntimeEntityRole runtimeEntityRoleModelNew = + TestUtilities.deserialize(json, RuntimeEntityRole.class); + assertTrue(runtimeEntityRoleModelNew instanceof RuntimeEntityRole); + assertEquals(runtimeEntityRoleModelNew.type(), "date_from"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityTest.java new file mode 100644 index 00000000000..e68340c7818 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityTest.java @@ -0,0 +1,150 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntity model. */ +public class RuntimeEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntity() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + String json = TestUtilities.serialize(runtimeEntityModel); + + RuntimeEntity runtimeEntityModelNew = TestUtilities.deserialize(json, RuntimeEntity.class); + assertTrue(runtimeEntityModelNew instanceof RuntimeEntity); + assertEquals(runtimeEntityModelNew.entity(), "testString"); + assertEquals(runtimeEntityModelNew.value(), "testString"); + assertEquals(runtimeEntityModelNew.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModelNew.interpretation().toString(), + runtimeEntityInterpretationModel.toString()); + assertEquals(runtimeEntityModelNew.role().toString(), runtimeEntityRoleModel.toString()); + assertEquals(runtimeEntityModelNew.skill(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeEntityError() throws Throwable { + new RuntimeEntity.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeIntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeIntentTest.java new file mode 100644 index 00000000000..da6d374a5a6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeIntentTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeIntent model. */ +public class RuntimeIntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeIntent() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + String json = TestUtilities.serialize(runtimeIntentModel); + + RuntimeIntent runtimeIntentModelNew = TestUtilities.deserialize(json, RuntimeIntent.class); + assertTrue(runtimeIntentModelNew instanceof RuntimeIntent); + assertEquals(runtimeIntentModelNew.intent(), "testString"); + assertEquals(runtimeIntentModelNew.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModelNew.skill(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeIntentError() throws Throwable { + new RuntimeIntent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeAudioTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeAudioTest.java new file mode 100644 index 00000000000..5ae88e61478 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeAudioTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeAudio model. */ +public class RuntimeResponseGenericRuntimeResponseTypeAudioTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeAudio() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeAudio + runtimeResponseGenericRuntimeResponseTypeAudioModel = + new RuntimeResponseGenericRuntimeResponseTypeAudio(); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.source()); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.description()); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.channels()); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.channelOptions()); + assertNull(runtimeResponseGenericRuntimeResponseTypeAudioModel.altText()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest.java new file mode 100644 index 00000000000..7bb58aaa16e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeChannelTransfer model. */ +public class RuntimeResponseGenericRuntimeResponseTypeChannelTransferTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeChannelTransfer() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeChannelTransfer + runtimeResponseGenericRuntimeResponseTypeChannelTransferModel = + new RuntimeResponseGenericRuntimeResponseTypeChannelTransfer(); + assertNull(runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.messageToUser()); + assertNull(runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.transferInfo()); + assertNull(runtimeResponseGenericRuntimeResponseTypeChannelTransferModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java new file mode 100644 index 00000000000..167fdaaf7f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent model. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeConnectToAgent() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel = + new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.messageToHumanAgent()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentAvailable()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentUnavailable()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.transferInfo()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.topic()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConversationalSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConversationalSearchTest.java new file mode 100644 index 00000000000..9d65bbbb50c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConversationalSearchTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeConversationalSearch model. */ +public class RuntimeResponseGenericRuntimeResponseTypeConversationalSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeConversationalSearch() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeConversationalSearch + runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel = + new RuntimeResponseGenericRuntimeResponseTypeConversationalSearch(); + assertNull(runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.text()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.citationsTitle()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.citations()); + assertNull( + runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.confidenceScores()); + assertNull( + runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.responseLengthOption()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.searchResults()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConversationalSearchModel.disclaimer()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDateTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDateTest.java new file mode 100644 index 00000000000..8a9851bea1d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDateTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeDate model. */ +public class RuntimeResponseGenericRuntimeResponseTypeDateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeDate() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeDate + runtimeResponseGenericRuntimeResponseTypeDateModel = + new RuntimeResponseGenericRuntimeResponseTypeDate(); + assertNull(runtimeResponseGenericRuntimeResponseTypeDateModel.responseType()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmfTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmfTest.java new file mode 100644 index 00000000000..41dbff7793b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmfTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeDtmf model. */ +public class RuntimeResponseGenericRuntimeResponseTypeDtmfTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeDtmf() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeDtmf + runtimeResponseGenericRuntimeResponseTypeDtmfModel = + new RuntimeResponseGenericRuntimeResponseTypeDtmf(); + assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.commandInfo()); + assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSessionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSessionTest.java new file mode 100644 index 00000000000..e9e71df7ec7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSessionTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeEndSession model. */ +public class RuntimeResponseGenericRuntimeResponseTypeEndSessionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeEndSession() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeEndSession + runtimeResponseGenericRuntimeResponseTypeEndSessionModel = + new RuntimeResponseGenericRuntimeResponseTypeEndSession(); + assertNull(runtimeResponseGenericRuntimeResponseTypeEndSessionModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeEndSessionModel.channelOptions()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeIframeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeIframeTest.java new file mode 100644 index 00000000000..72aca8a4ff2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeIframeTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeIframe model. */ +public class RuntimeResponseGenericRuntimeResponseTypeIframeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeIframe() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeIframe + runtimeResponseGenericRuntimeResponseTypeIframeModel = + new RuntimeResponseGenericRuntimeResponseTypeIframe(); + assertNull(runtimeResponseGenericRuntimeResponseTypeIframeModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeIframeModel.source()); + assertNull(runtimeResponseGenericRuntimeResponseTypeIframeModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeIframeModel.description()); + assertNull(runtimeResponseGenericRuntimeResponseTypeIframeModel.imageUrl()); + assertNull(runtimeResponseGenericRuntimeResponseTypeIframeModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java new file mode 100644 index 00000000000..dae6291fe77 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeImage model. */ +public class RuntimeResponseGenericRuntimeResponseTypeImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeImage() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeImage + runtimeResponseGenericRuntimeResponseTypeImageModel = + new RuntimeResponseGenericRuntimeResponseTypeImage(); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.source()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.description()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.channels()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.altText()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java new file mode 100644 index 00000000000..cedf1c70af8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeOption model. */ +public class RuntimeResponseGenericRuntimeResponseTypeOptionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeOption() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeOption + runtimeResponseGenericRuntimeResponseTypeOptionModel = + new RuntimeResponseGenericRuntimeResponseTypeOption(); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.description()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.preference()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.options()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java new file mode 100644 index 00000000000..69ef4ef58a7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypePause model. */ +public class RuntimeResponseGenericRuntimeResponseTypePauseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypePause() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypePause + runtimeResponseGenericRuntimeResponseTypePauseModel = + new RuntimeResponseGenericRuntimeResponseTypePause(); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.time()); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.typing()); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearchTest.java new file mode 100644 index 00000000000..985faaca4d4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearchTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeSearch model. */ +public class RuntimeResponseGenericRuntimeResponseTypeSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeSearch() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeSearch + runtimeResponseGenericRuntimeResponseTypeSearchModel = + new RuntimeResponseGenericRuntimeResponseTypeSearch(); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.header()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.primaryResults()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.additionalResults()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java new file mode 100644 index 00000000000..68a6e876017 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeSuggestion model. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeSuggestion() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeSuggestion + runtimeResponseGenericRuntimeResponseTypeSuggestionModel = + new RuntimeResponseGenericRuntimeResponseTypeSuggestion(); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.suggestions()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java new file mode 100644 index 00000000000..d050d6b65b9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeText model. */ +public class RuntimeResponseGenericRuntimeResponseTypeTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeText() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeText + runtimeResponseGenericRuntimeResponseTypeTextModel = + new RuntimeResponseGenericRuntimeResponseTypeText(); + assertNull(runtimeResponseGenericRuntimeResponseTypeTextModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeTextModel.text()); + assertNull(runtimeResponseGenericRuntimeResponseTypeTextModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest.java new file mode 100644 index 00000000000..0c0608b5659 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeUserDefined model. */ +public class RuntimeResponseGenericRuntimeResponseTypeUserDefinedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeUserDefined() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeUserDefined + runtimeResponseGenericRuntimeResponseTypeUserDefinedModel = + new RuntimeResponseGenericRuntimeResponseTypeUserDefined(); + assertNull(runtimeResponseGenericRuntimeResponseTypeUserDefinedModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeUserDefinedModel.userDefined()); + assertNull(runtimeResponseGenericRuntimeResponseTypeUserDefinedModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeVideoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeVideoTest.java new file mode 100644 index 00000000000..abfdb7f4654 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeVideoTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeVideo model. */ +public class RuntimeResponseGenericRuntimeResponseTypeVideoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeVideo() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeVideo + runtimeResponseGenericRuntimeResponseTypeVideoModel = + new RuntimeResponseGenericRuntimeResponseTypeVideo(); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.source()); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.description()); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.channels()); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.channelOptions()); + assertNull(runtimeResponseGenericRuntimeResponseTypeVideoModel.altText()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericTest.java new file mode 100644 index 00000000000..2e1711cd7fd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGeneric model. */ +public class RuntimeResponseGenericTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testRuntimeResponseGeneric() throws Throwable { + RuntimeResponseGeneric runtimeResponseGenericModel = new RuntimeResponseGeneric(); + assertNotNull(runtimeResponseGenericModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultAnswerTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultAnswerTest.java new file mode 100644 index 00000000000..09fb517c59e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultAnswerTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResultAnswer model. */ +public class SearchResultAnswerTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResultAnswer() throws Throwable { + SearchResultAnswer searchResultAnswerModel = new SearchResultAnswer(); + assertNull(searchResultAnswerModel.getText()); + assertNull(searchResultAnswerModel.getConfidence()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultHighlightTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultHighlightTest.java new file mode 100644 index 00000000000..469b29e381c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultHighlightTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResultHighlight model. */ +public class SearchResultHighlightTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResultHighlight() throws Throwable { + SearchResultHighlight searchResultHighlightModel = new SearchResultHighlight(); + assertNull(searchResultHighlightModel.getBody()); + assertNull(searchResultHighlightModel.getTitle()); + assertNull(searchResultHighlightModel.getUrl()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultMetadataTest.java new file mode 100644 index 00000000000..1a5af1a37b9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultMetadataTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResultMetadata model. */ +public class SearchResultMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResultMetadata() throws Throwable { + SearchResultMetadata searchResultMetadataModel = new SearchResultMetadata(); + assertNull(searchResultMetadataModel.getConfidence()); + assertNull(searchResultMetadataModel.getScore()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultTest.java new file mode 100644 index 00000000000..dd307d79aa5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResult model. */ +public class SearchResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResult() throws Throwable { + SearchResult searchResultModel = new SearchResult(); + assertNull(searchResultModel.getId()); + assertNull(searchResultModel.getResultMetadata()); + assertNull(searchResultModel.getBody()); + assertNull(searchResultModel.getTitle()); + assertNull(searchResultModel.getUrl()); + assertNull(searchResultModel.getHighlight()); + assertNull(searchResultModel.getAnswers()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultsResultMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultsResultMetadataTest.java new file mode 100644 index 00000000000..8ffd9742a15 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultsResultMetadataTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResultsResultMetadata model. */ +public class SearchResultsResultMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResultsResultMetadata() throws Throwable { + SearchResultsResultMetadata searchResultsResultMetadataModel = + new SearchResultsResultMetadata(); + assertNull(searchResultsResultMetadataModel.getDocumentRetrievalSource()); + assertNull(searchResultsResultMetadataModel.getScore()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultsTest.java new file mode 100644 index 00000000000..8723aa25f39 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResults model. */ +public class SearchResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResults() throws Throwable { + SearchResults searchResultsModel = new SearchResults(); + assertNull(searchResultsModel.getResultMetadata()); + assertNull(searchResultsModel.getId()); + assertNull(searchResultsModel.getTitle()); + assertNull(searchResultsModel.getBody()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsClientSideSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsClientSideSearchTest.java new file mode 100644 index 00000000000..af4a0e180a0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsClientSideSearchTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsClientSideSearch model. */ +public class SearchSettingsClientSideSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsClientSideSearch() throws Throwable { + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(searchSettingsClientSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsClientSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(searchSettingsClientSideSearchModel); + + SearchSettingsClientSideSearch searchSettingsClientSideSearchModelNew = + TestUtilities.deserialize(json, SearchSettingsClientSideSearch.class); + assertTrue(searchSettingsClientSideSearchModelNew instanceof SearchSettingsClientSideSearch); + assertEquals(searchSettingsClientSideSearchModelNew.filter(), "testString"); + assertEquals( + searchSettingsClientSideSearchModelNew.metadata().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchResponseLengthTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchResponseLengthTest.java new file mode 100644 index 00000000000..ebbd2b2d433 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchResponseLengthTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsConversationalSearchResponseLength model. */ +public class SearchSettingsConversationalSearchResponseLengthTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsConversationalSearchResponseLength() throws Throwable { + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + assertEquals(searchSettingsConversationalSearchResponseLengthModel.option(), "moderate"); + + String json = TestUtilities.serialize(searchSettingsConversationalSearchResponseLengthModel); + + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModelNew = + TestUtilities.deserialize(json, SearchSettingsConversationalSearchResponseLength.class); + assertTrue( + searchSettingsConversationalSearchResponseLengthModelNew + instanceof SearchSettingsConversationalSearchResponseLength); + assertEquals(searchSettingsConversationalSearchResponseLengthModelNew.option(), "moderate"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchSearchConfidenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchSearchConfidenceTest.java new file mode 100644 index 00000000000..85008dc84f8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchSearchConfidenceTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsConversationalSearchSearchConfidence model. */ +public class SearchSettingsConversationalSearchSearchConfidenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsConversationalSearchSearchConfidence() throws Throwable { + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + assertEquals(searchSettingsConversationalSearchSearchConfidenceModel.threshold(), "less_often"); + + String json = TestUtilities.serialize(searchSettingsConversationalSearchSearchConfidenceModel); + + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModelNew = + TestUtilities.deserialize( + json, SearchSettingsConversationalSearchSearchConfidence.class); + assertTrue( + searchSettingsConversationalSearchSearchConfidenceModelNew + instanceof SearchSettingsConversationalSearchSearchConfidence); + assertEquals( + searchSettingsConversationalSearchSearchConfidenceModelNew.threshold(), "less_often"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchTest.java new file mode 100644 index 00000000000..39a0d270eca --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsConversationalSearchTest.java @@ -0,0 +1,80 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsConversationalSearch model. */ +public class SearchSettingsConversationalSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsConversationalSearch() throws Throwable { + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + assertEquals(searchSettingsConversationalSearchResponseLengthModel.option(), "moderate"); + + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + assertEquals(searchSettingsConversationalSearchSearchConfidenceModel.threshold(), "less_often"); + + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + assertEquals(searchSettingsConversationalSearchModel.enabled(), Boolean.valueOf(true)); + assertEquals( + searchSettingsConversationalSearchModel.responseLength(), + searchSettingsConversationalSearchResponseLengthModel); + assertEquals( + searchSettingsConversationalSearchModel.searchConfidence(), + searchSettingsConversationalSearchSearchConfidenceModel); + + String json = TestUtilities.serialize(searchSettingsConversationalSearchModel); + + SearchSettingsConversationalSearch searchSettingsConversationalSearchModelNew = + TestUtilities.deserialize(json, SearchSettingsConversationalSearch.class); + assertTrue( + searchSettingsConversationalSearchModelNew instanceof SearchSettingsConversationalSearch); + assertEquals(searchSettingsConversationalSearchModelNew.enabled(), Boolean.valueOf(true)); + assertEquals( + searchSettingsConversationalSearchModelNew.responseLength().toString(), + searchSettingsConversationalSearchResponseLengthModel.toString()); + assertEquals( + searchSettingsConversationalSearchModelNew.searchConfidence().toString(), + searchSettingsConversationalSearchSearchConfidenceModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsConversationalSearchError() throws Throwable { + new SearchSettingsConversationalSearch.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryAuthenticationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryAuthenticationTest.java new file mode 100644 index 00000000000..42b91b89368 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryAuthenticationTest.java @@ -0,0 +1,51 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsDiscoveryAuthentication model. */ +public class SearchSettingsDiscoveryAuthenticationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsDiscoveryAuthentication() throws Throwable { + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + assertEquals(searchSettingsDiscoveryAuthenticationModel.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModel.bearer(), "testString"); + + String json = TestUtilities.serialize(searchSettingsDiscoveryAuthenticationModel); + + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModelNew = + TestUtilities.deserialize(json, SearchSettingsDiscoveryAuthentication.class); + assertTrue( + searchSettingsDiscoveryAuthenticationModelNew + instanceof SearchSettingsDiscoveryAuthentication); + assertEquals(searchSettingsDiscoveryAuthenticationModelNew.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModelNew.bearer(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryTest.java new file mode 100644 index 00000000000..e99ded9a708 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsDiscoveryTest.java @@ -0,0 +1,86 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsDiscovery model. */ +public class SearchSettingsDiscoveryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsDiscovery() throws Throwable { + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + assertEquals(searchSettingsDiscoveryAuthenticationModel.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModel.bearer(), "testString"); + + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + assertEquals(searchSettingsDiscoveryModel.instanceId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.projectId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.url(), "testString"); + assertEquals(searchSettingsDiscoveryModel.maxPrimaryResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.maxTotalResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.confidenceThreshold(), Double.valueOf("0.0")); + assertEquals(searchSettingsDiscoveryModel.highlight(), Boolean.valueOf(true)); + assertEquals(searchSettingsDiscoveryModel.findAnswers(), Boolean.valueOf(true)); + assertEquals( + searchSettingsDiscoveryModel.authentication(), searchSettingsDiscoveryAuthenticationModel); + + String json = TestUtilities.serialize(searchSettingsDiscoveryModel); + + SearchSettingsDiscovery searchSettingsDiscoveryModelNew = + TestUtilities.deserialize(json, SearchSettingsDiscovery.class); + assertTrue(searchSettingsDiscoveryModelNew instanceof SearchSettingsDiscovery); + assertEquals(searchSettingsDiscoveryModelNew.instanceId(), "testString"); + assertEquals(searchSettingsDiscoveryModelNew.projectId(), "testString"); + assertEquals(searchSettingsDiscoveryModelNew.url(), "testString"); + assertEquals(searchSettingsDiscoveryModelNew.maxPrimaryResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModelNew.maxTotalResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModelNew.confidenceThreshold(), Double.valueOf("0.0")); + assertEquals(searchSettingsDiscoveryModelNew.highlight(), Boolean.valueOf(true)); + assertEquals(searchSettingsDiscoveryModelNew.findAnswers(), Boolean.valueOf(true)); + assertEquals( + searchSettingsDiscoveryModelNew.authentication().toString(), + searchSettingsDiscoveryAuthenticationModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsDiscoveryError() throws Throwable { + new SearchSettingsDiscovery.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsElasticSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsElasticSearchTest.java new file mode 100644 index 00000000000..a583f06e702 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsElasticSearchTest.java @@ -0,0 +1,78 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsElasticSearch model. */ +public class SearchSettingsElasticSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsElasticSearch() throws Throwable { + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + assertEquals(searchSettingsElasticSearchModel.url(), "testString"); + assertEquals(searchSettingsElasticSearchModel.port(), "testString"); + assertEquals(searchSettingsElasticSearchModel.username(), "testString"); + assertEquals(searchSettingsElasticSearchModel.password(), "testString"); + assertEquals(searchSettingsElasticSearchModel.index(), "testString"); + assertEquals(searchSettingsElasticSearchModel.filter(), java.util.Arrays.asList("testString")); + assertEquals( + searchSettingsElasticSearchModel.queryBody(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsElasticSearchModel.managedIndex(), "testString"); + assertEquals(searchSettingsElasticSearchModel.apikey(), "testString"); + + String json = TestUtilities.serialize(searchSettingsElasticSearchModel); + + SearchSettingsElasticSearch searchSettingsElasticSearchModelNew = + TestUtilities.deserialize(json, SearchSettingsElasticSearch.class); + assertTrue(searchSettingsElasticSearchModelNew instanceof SearchSettingsElasticSearch); + assertEquals(searchSettingsElasticSearchModelNew.url(), "testString"); + assertEquals(searchSettingsElasticSearchModelNew.port(), "testString"); + assertEquals(searchSettingsElasticSearchModelNew.username(), "testString"); + assertEquals(searchSettingsElasticSearchModelNew.password(), "testString"); + assertEquals(searchSettingsElasticSearchModelNew.index(), "testString"); + assertEquals( + searchSettingsElasticSearchModelNew.queryBody().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(searchSettingsElasticSearchModelNew.managedIndex(), "testString"); + assertEquals(searchSettingsElasticSearchModelNew.apikey(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsElasticSearchError() throws Throwable { + new SearchSettingsElasticSearch.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsMessagesTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsMessagesTest.java new file mode 100644 index 00000000000..8303a5d63da --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsMessagesTest.java @@ -0,0 +1,57 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsMessages model. */ +public class SearchSettingsMessagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsMessages() throws Throwable { + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + assertEquals(searchSettingsMessagesModel.success(), "testString"); + assertEquals(searchSettingsMessagesModel.error(), "testString"); + assertEquals(searchSettingsMessagesModel.noResult(), "testString"); + + String json = TestUtilities.serialize(searchSettingsMessagesModel); + + SearchSettingsMessages searchSettingsMessagesModelNew = + TestUtilities.deserialize(json, SearchSettingsMessages.class); + assertTrue(searchSettingsMessagesModelNew instanceof SearchSettingsMessages); + assertEquals(searchSettingsMessagesModelNew.success(), "testString"); + assertEquals(searchSettingsMessagesModelNew.error(), "testString"); + assertEquals(searchSettingsMessagesModelNew.noResult(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsMessagesError() throws Throwable { + new SearchSettingsMessages.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsSchemaMappingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsSchemaMappingTest.java new file mode 100644 index 00000000000..455e4502105 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsSchemaMappingTest.java @@ -0,0 +1,57 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsSchemaMapping model. */ +public class SearchSettingsSchemaMappingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsSchemaMapping() throws Throwable { + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + assertEquals(searchSettingsSchemaMappingModel.url(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.body(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.title(), "testString"); + + String json = TestUtilities.serialize(searchSettingsSchemaMappingModel); + + SearchSettingsSchemaMapping searchSettingsSchemaMappingModelNew = + TestUtilities.deserialize(json, SearchSettingsSchemaMapping.class); + assertTrue(searchSettingsSchemaMappingModelNew instanceof SearchSettingsSchemaMapping); + assertEquals(searchSettingsSchemaMappingModelNew.url(), "testString"); + assertEquals(searchSettingsSchemaMappingModelNew.body(), "testString"); + assertEquals(searchSettingsSchemaMappingModelNew.title(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsSchemaMappingError() throws Throwable { + new SearchSettingsSchemaMapping.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsServerSideSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsServerSideSearchTest.java new file mode 100644 index 00000000000..5863cd436c0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsServerSideSearchTest.java @@ -0,0 +1,79 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettingsServerSideSearch model. */ +public class SearchSettingsServerSideSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettingsServerSideSearch() throws Throwable { + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + assertEquals(searchSettingsServerSideSearchModel.url(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.port(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.username(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.password(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsServerSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsServerSideSearchModel.apikey(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.noAuth(), Boolean.valueOf(true)); + assertEquals(searchSettingsServerSideSearchModel.authType(), "basic"); + + String json = TestUtilities.serialize(searchSettingsServerSideSearchModel); + + SearchSettingsServerSideSearch searchSettingsServerSideSearchModelNew = + TestUtilities.deserialize(json, SearchSettingsServerSideSearch.class); + assertTrue(searchSettingsServerSideSearchModelNew instanceof SearchSettingsServerSideSearch); + assertEquals(searchSettingsServerSideSearchModelNew.url(), "testString"); + assertEquals(searchSettingsServerSideSearchModelNew.port(), "testString"); + assertEquals(searchSettingsServerSideSearchModelNew.username(), "testString"); + assertEquals(searchSettingsServerSideSearchModelNew.password(), "testString"); + assertEquals(searchSettingsServerSideSearchModelNew.filter(), "testString"); + assertEquals( + searchSettingsServerSideSearchModelNew.metadata().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(searchSettingsServerSideSearchModelNew.apikey(), "testString"); + assertEquals(searchSettingsServerSideSearchModelNew.noAuth(), Boolean.valueOf(true)); + assertEquals(searchSettingsServerSideSearchModelNew.authType(), "basic"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsServerSideSearchError() throws Throwable { + new SearchSettingsServerSideSearch.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsTest.java new file mode 100644 index 00000000000..f74c1dd992c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSettingsTest.java @@ -0,0 +1,218 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSettings model. */ +public class SearchSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSettings() throws Throwable { + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + assertEquals(searchSettingsDiscoveryAuthenticationModel.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModel.bearer(), "testString"); + + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + assertEquals(searchSettingsDiscoveryModel.instanceId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.projectId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.url(), "testString"); + assertEquals(searchSettingsDiscoveryModel.maxPrimaryResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.maxTotalResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.confidenceThreshold(), Double.valueOf("0.0")); + assertEquals(searchSettingsDiscoveryModel.highlight(), Boolean.valueOf(true)); + assertEquals(searchSettingsDiscoveryModel.findAnswers(), Boolean.valueOf(true)); + assertEquals( + searchSettingsDiscoveryModel.authentication(), searchSettingsDiscoveryAuthenticationModel); + + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + assertEquals(searchSettingsMessagesModel.success(), "testString"); + assertEquals(searchSettingsMessagesModel.error(), "testString"); + assertEquals(searchSettingsMessagesModel.noResult(), "testString"); + + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + assertEquals(searchSettingsSchemaMappingModel.url(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.body(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.title(), "testString"); + + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + assertEquals(searchSettingsElasticSearchModel.url(), "testString"); + assertEquals(searchSettingsElasticSearchModel.port(), "testString"); + assertEquals(searchSettingsElasticSearchModel.username(), "testString"); + assertEquals(searchSettingsElasticSearchModel.password(), "testString"); + assertEquals(searchSettingsElasticSearchModel.index(), "testString"); + assertEquals(searchSettingsElasticSearchModel.filter(), java.util.Arrays.asList("testString")); + assertEquals( + searchSettingsElasticSearchModel.queryBody(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsElasticSearchModel.managedIndex(), "testString"); + assertEquals(searchSettingsElasticSearchModel.apikey(), "testString"); + + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + assertEquals(searchSettingsConversationalSearchResponseLengthModel.option(), "moderate"); + + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + assertEquals(searchSettingsConversationalSearchSearchConfidenceModel.threshold(), "less_often"); + + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + assertEquals(searchSettingsConversationalSearchModel.enabled(), Boolean.valueOf(true)); + assertEquals( + searchSettingsConversationalSearchModel.responseLength(), + searchSettingsConversationalSearchResponseLengthModel); + assertEquals( + searchSettingsConversationalSearchModel.searchConfidence(), + searchSettingsConversationalSearchSearchConfidenceModel); + + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + assertEquals(searchSettingsServerSideSearchModel.url(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.port(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.username(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.password(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsServerSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsServerSideSearchModel.apikey(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.noAuth(), Boolean.valueOf(true)); + assertEquals(searchSettingsServerSideSearchModel.authType(), "basic"); + + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(searchSettingsClientSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsClientSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + SearchSettings searchSettingsModel = + new SearchSettings.Builder() + .discovery(searchSettingsDiscoveryModel) + .messages(searchSettingsMessagesModel) + .schemaMapping(searchSettingsSchemaMappingModel) + .elasticSearch(searchSettingsElasticSearchModel) + .conversationalSearch(searchSettingsConversationalSearchModel) + .serverSideSearch(searchSettingsServerSideSearchModel) + .clientSideSearch(searchSettingsClientSideSearchModel) + .build(); + assertEquals(searchSettingsModel.discovery(), searchSettingsDiscoveryModel); + assertEquals(searchSettingsModel.messages(), searchSettingsMessagesModel); + assertEquals(searchSettingsModel.schemaMapping(), searchSettingsSchemaMappingModel); + assertEquals(searchSettingsModel.elasticSearch(), searchSettingsElasticSearchModel); + assertEquals( + searchSettingsModel.conversationalSearch(), searchSettingsConversationalSearchModel); + assertEquals(searchSettingsModel.serverSideSearch(), searchSettingsServerSideSearchModel); + assertEquals(searchSettingsModel.clientSideSearch(), searchSettingsClientSideSearchModel); + + String json = TestUtilities.serialize(searchSettingsModel); + + SearchSettings searchSettingsModelNew = TestUtilities.deserialize(json, SearchSettings.class); + assertTrue(searchSettingsModelNew instanceof SearchSettings); + assertEquals( + searchSettingsModelNew.discovery().toString(), searchSettingsDiscoveryModel.toString()); + assertEquals( + searchSettingsModelNew.messages().toString(), searchSettingsMessagesModel.toString()); + assertEquals( + searchSettingsModelNew.schemaMapping().toString(), + searchSettingsSchemaMappingModel.toString()); + assertEquals( + searchSettingsModelNew.elasticSearch().toString(), + searchSettingsElasticSearchModel.toString()); + assertEquals( + searchSettingsModelNew.conversationalSearch().toString(), + searchSettingsConversationalSearchModel.toString()); + assertEquals( + searchSettingsModelNew.serverSideSearch().toString(), + searchSettingsServerSideSearchModel.toString()); + assertEquals( + searchSettingsModelNew.clientSideSearch().toString(), + searchSettingsClientSideSearchModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSearchSettingsError() throws Throwable { + new SearchSettings.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSkillWarningTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSkillWarningTest.java new file mode 100644 index 00000000000..f93bc92e5ed --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchSkillWarningTest.java @@ -0,0 +1,52 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchSkillWarning model. */ +public class SearchSkillWarningTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchSkillWarning() throws Throwable { + SearchSkillWarning searchSkillWarningModel = + new SearchSkillWarning.Builder() + .code("testString") + .path("testString") + .message("testString") + .build(); + assertEquals(searchSkillWarningModel.code(), "testString"); + assertEquals(searchSkillWarningModel.path(), "testString"); + assertEquals(searchSkillWarningModel.message(), "testString"); + + String json = TestUtilities.serialize(searchSkillWarningModel); + + SearchSkillWarning searchSkillWarningModelNew = + TestUtilities.deserialize(json, SearchSkillWarning.class); + assertTrue(searchSkillWarningModelNew instanceof SearchSkillWarning); + assertEquals(searchSkillWarningModelNew.code(), "testString"); + assertEquals(searchSkillWarningModelNew.path(), "testString"); + assertEquals(searchSkillWarningModelNew.message(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SessionResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SessionResponseTest.java new file mode 100644 index 00000000000..683365579ad --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SessionResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SessionResponse model. */ +public class SessionResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSessionResponse() throws Throwable { + SessionResponse sessionResponseModel = new SessionResponse(); + assertNull(sessionResponseModel.getSessionId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillImportTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillImportTest.java new file mode 100644 index 00000000000..6b1c12b14da --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillImportTest.java @@ -0,0 +1,231 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SkillImport model. */ +public class SkillImportTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSkillImport() throws Throwable { + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + assertEquals(searchSettingsDiscoveryAuthenticationModel.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModel.bearer(), "testString"); + + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + assertEquals(searchSettingsDiscoveryModel.instanceId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.projectId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.url(), "testString"); + assertEquals(searchSettingsDiscoveryModel.maxPrimaryResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.maxTotalResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.confidenceThreshold(), Double.valueOf("0.0")); + assertEquals(searchSettingsDiscoveryModel.highlight(), Boolean.valueOf(true)); + assertEquals(searchSettingsDiscoveryModel.findAnswers(), Boolean.valueOf(true)); + assertEquals( + searchSettingsDiscoveryModel.authentication(), searchSettingsDiscoveryAuthenticationModel); + + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + assertEquals(searchSettingsMessagesModel.success(), "testString"); + assertEquals(searchSettingsMessagesModel.error(), "testString"); + assertEquals(searchSettingsMessagesModel.noResult(), "testString"); + + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + assertEquals(searchSettingsSchemaMappingModel.url(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.body(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.title(), "testString"); + + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + assertEquals(searchSettingsElasticSearchModel.url(), "testString"); + assertEquals(searchSettingsElasticSearchModel.port(), "testString"); + assertEquals(searchSettingsElasticSearchModel.username(), "testString"); + assertEquals(searchSettingsElasticSearchModel.password(), "testString"); + assertEquals(searchSettingsElasticSearchModel.index(), "testString"); + assertEquals(searchSettingsElasticSearchModel.filter(), java.util.Arrays.asList("testString")); + assertEquals( + searchSettingsElasticSearchModel.queryBody(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsElasticSearchModel.managedIndex(), "testString"); + assertEquals(searchSettingsElasticSearchModel.apikey(), "testString"); + + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + assertEquals(searchSettingsConversationalSearchResponseLengthModel.option(), "moderate"); + + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + assertEquals(searchSettingsConversationalSearchSearchConfidenceModel.threshold(), "less_often"); + + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + assertEquals(searchSettingsConversationalSearchModel.enabled(), Boolean.valueOf(true)); + assertEquals( + searchSettingsConversationalSearchModel.responseLength(), + searchSettingsConversationalSearchResponseLengthModel); + assertEquals( + searchSettingsConversationalSearchModel.searchConfidence(), + searchSettingsConversationalSearchSearchConfidenceModel); + + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + assertEquals(searchSettingsServerSideSearchModel.url(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.port(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.username(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.password(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsServerSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsServerSideSearchModel.apikey(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.noAuth(), Boolean.valueOf(true)); + assertEquals(searchSettingsServerSideSearchModel.authType(), "basic"); + + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(searchSettingsClientSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsClientSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + SearchSettings searchSettingsModel = + new SearchSettings.Builder() + .discovery(searchSettingsDiscoveryModel) + .messages(searchSettingsMessagesModel) + .schemaMapping(searchSettingsSchemaMappingModel) + .elasticSearch(searchSettingsElasticSearchModel) + .conversationalSearch(searchSettingsConversationalSearchModel) + .serverSideSearch(searchSettingsServerSideSearchModel) + .clientSideSearch(searchSettingsClientSideSearchModel) + .build(); + assertEquals(searchSettingsModel.discovery(), searchSettingsDiscoveryModel); + assertEquals(searchSettingsModel.messages(), searchSettingsMessagesModel); + assertEquals(searchSettingsModel.schemaMapping(), searchSettingsSchemaMappingModel); + assertEquals(searchSettingsModel.elasticSearch(), searchSettingsElasticSearchModel); + assertEquals( + searchSettingsModel.conversationalSearch(), searchSettingsConversationalSearchModel); + assertEquals(searchSettingsModel.serverSideSearch(), searchSettingsServerSideSearchModel); + assertEquals(searchSettingsModel.clientSideSearch(), searchSettingsClientSideSearchModel); + + SkillImport skillImportModel = + new SkillImport.Builder() + .name("testString") + .description("testString") + .workspace(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogSettings(java.util.Collections.singletonMap("anyKey", "anyValue")) + .searchSettings(searchSettingsModel) + .language("testString") + .type("action") + .build(); + assertEquals(skillImportModel.name(), "testString"); + assertEquals(skillImportModel.description(), "testString"); + assertEquals( + skillImportModel.workspace(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + skillImportModel.dialogSettings(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(skillImportModel.searchSettings(), searchSettingsModel); + assertEquals(skillImportModel.language(), "testString"); + assertEquals(skillImportModel.type(), "action"); + + String json = TestUtilities.serialize(skillImportModel); + + SkillImport skillImportModelNew = TestUtilities.deserialize(json, SkillImport.class); + assertTrue(skillImportModelNew instanceof SkillImport); + assertEquals(skillImportModelNew.name(), "testString"); + assertEquals(skillImportModelNew.description(), "testString"); + assertEquals( + skillImportModelNew.workspace().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + skillImportModelNew.dialogSettings().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(skillImportModelNew.searchSettings().toString(), searchSettingsModel.toString()); + assertEquals(skillImportModelNew.language(), "testString"); + assertEquals(skillImportModelNew.type(), "action"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSkillImportError() throws Throwable { + new SkillImport.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillReferenceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillReferenceTest.java new file mode 100644 index 00000000000..0f6592177fe --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillReferenceTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SkillReference model. */ +public class SkillReferenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSkillReference() throws Throwable { + SkillReference skillReferenceModel = new SkillReference(); + assertNull(skillReferenceModel.getSkillId()); + assertNull(skillReferenceModel.getType()); + assertNull(skillReferenceModel.isDisabled()); + assertNull(skillReferenceModel.getSnapshot()); + assertNull(skillReferenceModel.getSkillReference()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillTest.java new file mode 100644 index 00000000000..b5eb19f8942 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Skill model. */ +public class SkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSkill() throws Throwable { + Skill skillModel = new Skill(); + assertNull(skillModel.getName()); + assertNull(skillModel.getDescription()); + assertNull(skillModel.getWorkspace()); + assertNull(skillModel.getDialogSettings()); + assertNull(skillModel.getSearchSettings()); + assertNull(skillModel.getLanguage()); + assertNull(skillModel.getType()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillsAsyncRequestStatusTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillsAsyncRequestStatusTest.java new file mode 100644 index 00000000000..834a905f6d2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillsAsyncRequestStatusTest.java @@ -0,0 +1,35 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SkillsAsyncRequestStatus model. */ +public class SkillsAsyncRequestStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSkillsAsyncRequestStatus() throws Throwable { + SkillsAsyncRequestStatus skillsAsyncRequestStatusModel = new SkillsAsyncRequestStatus(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillsExportTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillsExportTest.java new file mode 100644 index 00000000000..509f83d2e36 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SkillsExportTest.java @@ -0,0 +1,37 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SkillsExport model. */ +public class SkillsExportTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSkillsExport() throws Throwable { + SkillsExport skillsExportModel = new SkillsExport(); + assertNull(skillsExportModel.getAssistantSkills()); + assertNull(skillsExportModel.getAssistantState()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponseTest.java new file mode 100644 index 00000000000..e3daeb507bf --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatefulMessageResponse model. */ +public class StatefulMessageResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatefulMessageResponse() throws Throwable { + StatefulMessageResponse statefulMessageResponseModel = new StatefulMessageResponse(); + assertNull(statefulMessageResponseModel.getOutput()); + assertNull(statefulMessageResponseModel.getContext()); + assertNull(statefulMessageResponseModel.getUserId()); + assertNull(statefulMessageResponseModel.getMaskedOutput()); + assertNull(statefulMessageResponseModel.getMaskedInput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseOutputTest.java new file mode 100644 index 00000000000..3ff8c30168f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseOutputTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2024, 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessFinalResponseOutput model. */ +public class StatelessFinalResponseOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessFinalResponseOutput() throws Throwable { + StatelessFinalResponseOutput statelessFinalResponseOutputModel = + new StatelessFinalResponseOutput(); + assertNull(statelessFinalResponseOutputModel.getGeneric()); + assertNull(statelessFinalResponseOutputModel.getIntents()); + assertNull(statelessFinalResponseOutputModel.getEntities()); + assertNull(statelessFinalResponseOutputModel.getActions()); + assertNull(statelessFinalResponseOutputModel.getDebug()); + assertNull(statelessFinalResponseOutputModel.getUserDefined()); + assertNull(statelessFinalResponseOutputModel.getSpelling()); + assertNull(statelessFinalResponseOutputModel.getLlmMetadata()); + assertNull(statelessFinalResponseOutputModel.getStreamingMetadata()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseTest.java new file mode 100644 index 00000000000..beb4f048dd3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessFinalResponseTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessFinalResponse model. */ +public class StatelessFinalResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessFinalResponse() throws Throwable { + StatelessFinalResponse statelessFinalResponseModel = new StatelessFinalResponse(); + assertNull(statelessFinalResponseModel.getOutput()); + assertNull(statelessFinalResponseModel.getContext()); + assertNull(statelessFinalResponseModel.getUserId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobalTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobalTest.java new file mode 100644 index 00000000000..bdce29bc370 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobalTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContextGlobal model. */ +public class StatelessMessageContextGlobalTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContextGlobal() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(statelessMessageContextGlobalModel.system(), messageContextGlobalSystemModel); + assertEquals(statelessMessageContextGlobalModel.sessionId(), "testString"); + + String json = TestUtilities.serialize(statelessMessageContextGlobalModel); + + StatelessMessageContextGlobal statelessMessageContextGlobalModelNew = + TestUtilities.deserialize(json, StatelessMessageContextGlobal.class); + assertTrue(statelessMessageContextGlobalModelNew instanceof StatelessMessageContextGlobal); + assertEquals( + statelessMessageContextGlobalModelNew.system().toString(), + messageContextGlobalSystemModel.toString()); + assertEquals(statelessMessageContextGlobalModelNew.sessionId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkillTest.java new file mode 100644 index 00000000000..5fc3dc3e2e9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkillTest.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContextSkillsActionsSkill model. */ +public class StatelessMessageContextSkillsActionsSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContextSkillsActionsSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(statelessMessageContextSkillsActionsSkillModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModelNew = + TestUtilities.deserialize(json, StatelessMessageContextSkillsActionsSkill.class); + assertTrue( + statelessMessageContextSkillsActionsSkillModelNew + instanceof StatelessMessageContextSkillsActionsSkill); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.actionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.skillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.privateActionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.privateSkillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsTest.java new file mode 100644 index 00000000000..dae15c1607b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsTest.java @@ -0,0 +1,100 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContextSkills model. */ +public class StatelessMessageContextSkillsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContextSkills() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) + .build(); + assertEquals(statelessMessageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals( + statelessMessageContextSkillsModel.actionsSkill(), + statelessMessageContextSkillsActionsSkillModel); + + String json = TestUtilities.serialize(statelessMessageContextSkillsModel); + + StatelessMessageContextSkills statelessMessageContextSkillsModelNew = + TestUtilities.deserialize(json, StatelessMessageContextSkills.class); + assertTrue(statelessMessageContextSkillsModelNew instanceof StatelessMessageContextSkills); + assertEquals( + statelessMessageContextSkillsModelNew.mainSkill().toString(), + messageContextDialogSkillModel.toString()); + assertEquals( + statelessMessageContextSkillsModelNew.actionsSkill().toString(), + statelessMessageContextSkillsActionsSkillModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextTest.java new file mode 100644 index 00000000000..c62807dee76 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextTest.java @@ -0,0 +1,143 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContext model. */ +public class StatelessMessageContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContext() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(statelessMessageContextGlobalModel.system(), messageContextGlobalSystemModel); + assertEquals(statelessMessageContextGlobalModel.sessionId(), "testString"); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) + .build(); + assertEquals(statelessMessageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals( + statelessMessageContextSkillsModel.actionsSkill(), + statelessMessageContextSkillsActionsSkillModel); + + StatelessMessageContext statelessMessageContextModel = + new StatelessMessageContext.Builder() + .global(statelessMessageContextGlobalModel) + .skills(statelessMessageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(statelessMessageContextModel.global(), statelessMessageContextGlobalModel); + assertEquals(statelessMessageContextModel.skills(), statelessMessageContextSkillsModel); + assertEquals( + statelessMessageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(statelessMessageContextModel); + + StatelessMessageContext statelessMessageContextModelNew = + TestUtilities.deserialize(json, StatelessMessageContext.class); + assertTrue(statelessMessageContextModelNew instanceof StatelessMessageContext); + assertEquals( + statelessMessageContextModelNew.global().toString(), + statelessMessageContextGlobalModel.toString()); + assertEquals( + statelessMessageContextModelNew.skills().toString(), + statelessMessageContextSkillsModel.toString()); + assertEquals( + statelessMessageContextModelNew.integrations().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptionsTest.java new file mode 100644 index 00000000000..3e2890e2e5d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptionsTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageInputOptions model. */ +public class StatelessMessageInputOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageInputOptions() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .build(); + assertEquals(statelessMessageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(statelessMessageInputOptionsModel.debug(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(statelessMessageInputOptionsModel); + + StatelessMessageInputOptions statelessMessageInputOptionsModelNew = + TestUtilities.deserialize(json, StatelessMessageInputOptions.class); + assertTrue(statelessMessageInputOptionsModelNew instanceof StatelessMessageInputOptions); + assertEquals(statelessMessageInputOptionsModelNew.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModelNew.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModelNew.asyncCallout(), Boolean.valueOf(false)); + assertEquals( + statelessMessageInputOptionsModelNew.spelling().toString(), + messageInputOptionsSpellingModel.toString()); + assertEquals(statelessMessageInputOptionsModelNew.debug(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputTest.java new file mode 100644 index 00000000000..422b9e1d898 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputTest.java @@ -0,0 +1,213 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageInput model. */ +public class StatelessMessageInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageInput() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder() + .intent("testString") + .confidence(Double.valueOf("72.5")) + .skill("testString") + .build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeIntentModel.skill(), "testString"); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(java.util.Arrays.asList(Long.valueOf("26"))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .groups(java.util.Arrays.asList(captureGroupModel)) + .interpretation(runtimeEntityInterpretationModel) + .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) + .role(runtimeEntityRoleModel) + .skill("testString") + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + assertEquals(runtimeEntityModel.skill(), "testString"); + + MessageInputAttachment messageInputAttachmentModel = + new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); + assertEquals(messageInputAttachmentModel.url(), "testString"); + assertEquals(messageInputAttachmentModel.mediaType(), "testString"); + + RequestAnalytics requestAnalyticsModel = + new RequestAnalytics.Builder() + .browser("testString") + .device("testString") + .pageUrl("testString") + .build(); + assertEquals(requestAnalyticsModel.browser(), "testString"); + assertEquals(requestAnalyticsModel.device(), "testString"); + assertEquals(requestAnalyticsModel.pageUrl(), "testString"); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .build(); + assertEquals(statelessMessageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(statelessMessageInputOptionsModel.debug(), Boolean.valueOf(false)); + + StatelessMessageInput statelessMessageInputModel = + new StatelessMessageInput.Builder() + .messageType("text") + .text("testString") + .intents(java.util.Arrays.asList(runtimeIntentModel)) + .entities(java.util.Arrays.asList(runtimeEntityModel)) + .suggestionId("testString") + .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) + .analytics(requestAnalyticsModel) + .options(statelessMessageInputOptionsModel) + .build(); + assertEquals(statelessMessageInputModel.messageType(), "text"); + assertEquals(statelessMessageInputModel.text(), "testString"); + assertEquals(statelessMessageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals( + statelessMessageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(statelessMessageInputModel.suggestionId(), "testString"); + assertEquals( + statelessMessageInputModel.attachments(), + java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(statelessMessageInputModel.analytics(), requestAnalyticsModel); + assertEquals(statelessMessageInputModel.options(), statelessMessageInputOptionsModel); + + String json = TestUtilities.serialize(statelessMessageInputModel); + + StatelessMessageInput statelessMessageInputModelNew = + TestUtilities.deserialize(json, StatelessMessageInput.class); + assertTrue(statelessMessageInputModelNew instanceof StatelessMessageInput); + assertEquals(statelessMessageInputModelNew.messageType(), "text"); + assertEquals(statelessMessageInputModelNew.text(), "testString"); + assertEquals(statelessMessageInputModelNew.suggestionId(), "testString"); + assertEquals( + statelessMessageInputModelNew.analytics().toString(), requestAnalyticsModel.toString()); + assertEquals( + statelessMessageInputModelNew.options().toString(), + statelessMessageInputOptionsModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponseTest.java new file mode 100644 index 00000000000..42849b24ccd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageResponse model. */ +public class StatelessMessageResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageResponse() throws Throwable { + StatelessMessageResponse statelessMessageResponseModel = new StatelessMessageResponse(); + assertNull(statelessMessageResponseModel.getOutput()); + assertNull(statelessMessageResponseModel.getContext()); + assertNull(statelessMessageResponseModel.getMaskedOutput()); + assertNull(statelessMessageResponseModel.getMaskedInput()); + assertNull(statelessMessageResponseModel.getUserId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageStreamResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageStreamResponseTest.java new file mode 100644 index 00000000000..36ffe5c04ac --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageStreamResponseTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageStreamResponse model. */ +public class StatelessMessageStreamResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testStatelessMessageStreamResponse() throws Throwable { + StatelessMessageStreamResponse statelessMessageStreamResponseModel = + new StatelessMessageStreamResponse(); + assertNotNull(statelessMessageStreamResponseModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatusErrorTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatusErrorTest.java new file mode 100644 index 00000000000..333e93812ba --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatusErrorTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatusError model. */ +public class StatusErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatusError() throws Throwable { + StatusError statusErrorModel = new StatusError.Builder().message("testString").build(); + assertEquals(statusErrorModel.message(), "testString"); + + String json = TestUtilities.serialize(statusErrorModel); + + StatusError statusErrorModelNew = TestUtilities.deserialize(json, StatusError.class); + assertTrue(statusErrorModelNew instanceof StatusError); + assertEquals(statusErrorModelNew.message(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventActionSourceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventActionSourceTest.java new file mode 100644 index 00000000000..22872f01539 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventActionSourceTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventActionSource model. */ +public class TurnEventActionSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventActionSource() throws Throwable { + TurnEventActionSource turnEventActionSourceModel = new TurnEventActionSource(); + assertNull(turnEventActionSourceModel.getType()); + assertNull(turnEventActionSourceModel.getAction()); + assertNull(turnEventActionSourceModel.getActionTitle()); + assertNull(turnEventActionSourceModel.getCondition()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutRequestTest.java new file mode 100644 index 00000000000..75f2663beed --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutRequestTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventCalloutCalloutRequest model. */ +public class TurnEventCalloutCalloutRequestTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventCalloutCalloutRequest() throws Throwable { + TurnEventCalloutCalloutRequest turnEventCalloutCalloutRequestModel = + new TurnEventCalloutCalloutRequest(); + assertNull(turnEventCalloutCalloutRequestModel.getMethod()); + assertNull(turnEventCalloutCalloutRequestModel.getUrl()); + assertNull(turnEventCalloutCalloutRequestModel.getPath()); + assertNull(turnEventCalloutCalloutRequestModel.getQueryParameters()); + assertNull(turnEventCalloutCalloutRequestModel.getHeaders()); + assertNull(turnEventCalloutCalloutRequestModel.getBody()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutResponseTest.java new file mode 100644 index 00000000000..38a517e21eb --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutResponseTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventCalloutCalloutResponse model. */ +public class TurnEventCalloutCalloutResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventCalloutCalloutResponse() throws Throwable { + TurnEventCalloutCalloutResponse turnEventCalloutCalloutResponseModel = + new TurnEventCalloutCalloutResponse(); + assertNull(turnEventCalloutCalloutResponseModel.getBody()); + assertNull(turnEventCalloutCalloutResponseModel.getStatusCode()); + assertNull(turnEventCalloutCalloutResponseModel.getLastEvent()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutTest.java new file mode 100644 index 00000000000..647b33926ea --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutCalloutTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventCalloutCallout model. */ +public class TurnEventCalloutCalloutTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventCalloutCallout() throws Throwable { + TurnEventCalloutCallout turnEventCalloutCalloutModel = new TurnEventCalloutCallout(); + assertNull(turnEventCalloutCalloutModel.getType()); + assertNull(turnEventCalloutCalloutModel.getInternal()); + assertNull(turnEventCalloutCalloutModel.getResultVariable()); + assertNull(turnEventCalloutCalloutModel.getRequest()); + assertNull(turnEventCalloutCalloutModel.getResponse()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutErrorTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutErrorTest.java new file mode 100644 index 00000000000..82b21429316 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventCalloutErrorTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventCalloutError model. */ +public class TurnEventCalloutErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventCalloutError() throws Throwable { + TurnEventCalloutError turnEventCalloutErrorModel = new TurnEventCalloutError(); + assertNull(turnEventCalloutErrorModel.getMessage()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmResponseTest.java new file mode 100644 index 00000000000..306a90a8e37 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledCalloutLlmResponse model. */ +public class TurnEventGenerativeAICalledCalloutLlmResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledCalloutLlmResponse() throws Throwable { + TurnEventGenerativeAICalledCalloutLlmResponse + turnEventGenerativeAiCalledCalloutLlmResponseModel = + new TurnEventGenerativeAICalledCalloutLlmResponse(); + assertNull(turnEventGenerativeAiCalledCalloutLlmResponseModel.getText()); + assertNull(turnEventGenerativeAiCalledCalloutLlmResponseModel.getResponseType()); + assertNull(turnEventGenerativeAiCalledCalloutLlmResponseModel.isIsIdkResponse()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmTest.java new file mode 100644 index 00000000000..c61732e31b9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutLlmTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledCalloutLlm model. */ +public class TurnEventGenerativeAICalledCalloutLlmTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledCalloutLlm() throws Throwable { + TurnEventGenerativeAICalledCalloutLlm turnEventGenerativeAiCalledCalloutLlmModel = + new TurnEventGenerativeAICalledCalloutLlm(); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getType()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getModelId()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getModelClassId()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getGeneratedTokenCount()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getInputTokenCount()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.isSuccess()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getResponse()); + assertNull(turnEventGenerativeAiCalledCalloutLlmModel.getRequest()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutRequestTest.java new file mode 100644 index 00000000000..9ee92bf2dd3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutRequestTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledCalloutRequest model. */ +public class TurnEventGenerativeAICalledCalloutRequestTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledCalloutRequest() throws Throwable { + TurnEventGenerativeAICalledCalloutRequest turnEventGenerativeAiCalledCalloutRequestModel = + new TurnEventGenerativeAICalledCalloutRequest(); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getMethod()); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getUrl()); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getPort()); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getPath()); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getQueryParameters()); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getHeaders()); + assertNull(turnEventGenerativeAiCalledCalloutRequestModel.getBody()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutResponseTest.java new file mode 100644 index 00000000000..9104deb2454 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutResponseTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledCalloutResponse model. */ +public class TurnEventGenerativeAICalledCalloutResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledCalloutResponse() throws Throwable { + TurnEventGenerativeAICalledCalloutResponse turnEventGenerativeAiCalledCalloutResponseModel = + new TurnEventGenerativeAICalledCalloutResponse(); + assertNull(turnEventGenerativeAiCalledCalloutResponseModel.getBody()); + assertNull(turnEventGenerativeAiCalledCalloutResponseModel.getStatusCode()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutSearchTest.java new file mode 100644 index 00000000000..cc2f49b478a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutSearchTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledCalloutSearch model. */ +public class TurnEventGenerativeAICalledCalloutSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledCalloutSearch() throws Throwable { + TurnEventGenerativeAICalledCalloutSearch turnEventGenerativeAiCalledCalloutSearchModel = + new TurnEventGenerativeAICalledCalloutSearch(); + assertNull(turnEventGenerativeAiCalledCalloutSearchModel.getEngine()); + assertNull(turnEventGenerativeAiCalledCalloutSearchModel.getIndex()); + assertNull(turnEventGenerativeAiCalledCalloutSearchModel.getQuery()); + assertNull(turnEventGenerativeAiCalledCalloutSearchModel.getRequest()); + assertNull(turnEventGenerativeAiCalledCalloutSearchModel.getResponse()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutTest.java new file mode 100644 index 00000000000..977db8b13a0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledCalloutTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledCallout model. */ +public class TurnEventGenerativeAICalledCalloutTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledCallout() throws Throwable { + TurnEventGenerativeAICalledCallout turnEventGenerativeAiCalledCalloutModel = + new TurnEventGenerativeAICalledCallout(); + assertNull(turnEventGenerativeAiCalledCalloutModel.isSearchCalled()); + assertNull(turnEventGenerativeAiCalledCalloutModel.isLlmCalled()); + assertNull(turnEventGenerativeAiCalledCalloutModel.getSearch()); + assertNull(turnEventGenerativeAiCalledCalloutModel.getLlm()); + assertNull(turnEventGenerativeAiCalledCalloutModel.getIdkReasonCode()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledMetricsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledMetricsTest.java new file mode 100644 index 00000000000..338f770024c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventGenerativeAICalledMetricsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventGenerativeAICalledMetrics model. */ +public class TurnEventGenerativeAICalledMetricsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventGenerativeAICalledMetrics() throws Throwable { + TurnEventGenerativeAICalledMetrics turnEventGenerativeAiCalledMetricsModel = + new TurnEventGenerativeAICalledMetrics(); + assertNull(turnEventGenerativeAiCalledMetricsModel.getSearchTimeMs()); + assertNull(turnEventGenerativeAiCalledMetricsModel.getAnswerGenerationTimeMs()); + assertNull(turnEventGenerativeAiCalledMetricsModel.getTotalTimeMs()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventNodeSourceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventNodeSourceTest.java new file mode 100644 index 00000000000..d40562fc05e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventNodeSourceTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventNodeSource model. */ +public class TurnEventNodeSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventNodeSource() throws Throwable { + TurnEventNodeSource turnEventNodeSourceModel = new TurnEventNodeSource(); + assertNull(turnEventNodeSourceModel.getType()); + assertNull(turnEventNodeSourceModel.getDialogNode()); + assertNull(turnEventNodeSourceModel.getTitle()); + assertNull(turnEventNodeSourceModel.getCondition()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventSearchErrorTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventSearchErrorTest.java new file mode 100644 index 00000000000..abd47bf0052 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventSearchErrorTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventSearchError model. */ +public class TurnEventSearchErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventSearchError() throws Throwable { + TurnEventSearchError turnEventSearchErrorModel = new TurnEventSearchError(); + assertNull(turnEventSearchErrorModel.getMessage()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventStepSourceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventStepSourceTest.java new file mode 100644 index 00000000000..2a16316e37f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/TurnEventStepSourceTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TurnEventStepSource model. */ +public class TurnEventStepSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTurnEventStepSource() throws Throwable { + TurnEventStepSource turnEventStepSourceModel = new TurnEventStepSource(); + assertNull(turnEventStepSourceModel.getType()); + assertNull(turnEventStepSourceModel.getAction()); + assertNull(turnEventStepSourceModel.getActionTitle()); + assertNull(turnEventStepSourceModel.getStep()); + assertNull(turnEventStepSourceModel.isIsAiGuided()); + assertNull(turnEventStepSourceModel.isIsSkillBased()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOptionsTest.java new file mode 100644 index 00000000000..e7e8316e9bf --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOptionsTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEnvironmentOptions model. */ +public class UpdateEnvironmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEnvironmentOptions() throws Throwable { + UpdateEnvironmentOrchestration updateEnvironmentOrchestrationModel = + new UpdateEnvironmentOrchestration.Builder().searchSkillFallback(true).build(); + assertEquals(updateEnvironmentOrchestrationModel.searchSkillFallback(), Boolean.valueOf(true)); + + EnvironmentSkill environmentSkillModel = + new EnvironmentSkill.Builder() + .skillId("testString") + .type("dialog") + .disabled(true) + .snapshot("testString") + .skillReference("testString") + .build(); + assertEquals(environmentSkillModel.skillId(), "testString"); + assertEquals(environmentSkillModel.type(), "dialog"); + assertEquals(environmentSkillModel.disabled(), Boolean.valueOf(true)); + assertEquals(environmentSkillModel.snapshot(), "testString"); + assertEquals(environmentSkillModel.skillReference(), "testString"); + + UpdateEnvironmentOptions updateEnvironmentOptionsModel = + new UpdateEnvironmentOptions.Builder() + .assistantId("testString") + .environmentId("testString") + .name("testString") + .description("testString") + .orchestration(updateEnvironmentOrchestrationModel) + .sessionTimeout(Long.valueOf("10")) + .skillReferences(java.util.Arrays.asList(environmentSkillModel)) + .build(); + assertEquals(updateEnvironmentOptionsModel.assistantId(), "testString"); + assertEquals(updateEnvironmentOptionsModel.environmentId(), "testString"); + assertEquals(updateEnvironmentOptionsModel.name(), "testString"); + assertEquals(updateEnvironmentOptionsModel.description(), "testString"); + assertEquals( + updateEnvironmentOptionsModel.orchestration(), updateEnvironmentOrchestrationModel); + assertEquals(updateEnvironmentOptionsModel.sessionTimeout(), Long.valueOf("10")); + assertEquals( + updateEnvironmentOptionsModel.skillReferences(), + java.util.Arrays.asList(environmentSkillModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnvironmentOptionsError() throws Throwable { + new UpdateEnvironmentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOrchestrationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOrchestrationTest.java new file mode 100644 index 00000000000..d51e8c76e71 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateEnvironmentOrchestrationTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEnvironmentOrchestration model. */ +public class UpdateEnvironmentOrchestrationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEnvironmentOrchestration() throws Throwable { + UpdateEnvironmentOrchestration updateEnvironmentOrchestrationModel = + new UpdateEnvironmentOrchestration.Builder().searchSkillFallback(true).build(); + assertEquals(updateEnvironmentOrchestrationModel.searchSkillFallback(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(updateEnvironmentOrchestrationModel); + + UpdateEnvironmentOrchestration updateEnvironmentOrchestrationModelNew = + TestUtilities.deserialize(json, UpdateEnvironmentOrchestration.class); + assertTrue(updateEnvironmentOrchestrationModelNew instanceof UpdateEnvironmentOrchestration); + assertEquals( + updateEnvironmentOrchestrationModelNew.searchSkillFallback(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateProviderOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateProviderOptionsTest.java new file mode 100644 index 00000000000..f804b529c99 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateProviderOptionsTest.java @@ -0,0 +1,146 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateProviderOptions model. */ +public class UpdateProviderOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateProviderOptions() throws Throwable { + ProviderSpecificationServersItem providerSpecificationServersItemModel = + new ProviderSpecificationServersItem.Builder().url("testString").build(); + assertEquals(providerSpecificationServersItemModel.url(), "testString"); + + ProviderAuthenticationTypeAndValue providerAuthenticationTypeAndValueModel = + new ProviderAuthenticationTypeAndValue.Builder().type("value").value("testString").build(); + assertEquals(providerAuthenticationTypeAndValueModel.type(), "value"); + assertEquals(providerAuthenticationTypeAndValueModel.value(), "testString"); + + ProviderSpecificationComponentsSecuritySchemesBasic + providerSpecificationComponentsSecuritySchemesBasicModel = + new ProviderSpecificationComponentsSecuritySchemesBasic.Builder() + .username(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesBasicModel.username(), + providerAuthenticationTypeAndValueModel); + + ProviderAuthenticationOAuth2PasswordUsername providerAuthenticationOAuth2PasswordUsernameModel = + new ProviderAuthenticationOAuth2PasswordUsername.Builder() + .type("value") + .value("testString") + .build(); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.type(), "value"); + assertEquals(providerAuthenticationOAuth2PasswordUsernameModel.value(), "testString"); + + ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password + providerAuthenticationOAuth2FlowsModel = + new ProviderAuthenticationOAuth2FlowsProviderAuthenticationOAuth2Password.Builder() + .tokenUrl("testString") + .refreshUrl("testString") + .clientAuthType("Body") + .contentType("testString") + .headerPrefix("testString") + .username(providerAuthenticationOAuth2PasswordUsernameModel) + .build(); + assertEquals(providerAuthenticationOAuth2FlowsModel.tokenUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.refreshUrl(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.clientAuthType(), "Body"); + assertEquals(providerAuthenticationOAuth2FlowsModel.contentType(), "testString"); + assertEquals(providerAuthenticationOAuth2FlowsModel.headerPrefix(), "testString"); + assertEquals( + providerAuthenticationOAuth2FlowsModel.username(), + providerAuthenticationOAuth2PasswordUsernameModel); + + ProviderAuthenticationOAuth2 providerAuthenticationOAuth2Model = + new ProviderAuthenticationOAuth2.Builder() + .preferredFlow("password") + .flows(providerAuthenticationOAuth2FlowsModel) + .build(); + assertEquals(providerAuthenticationOAuth2Model.preferredFlow(), "password"); + assertEquals(providerAuthenticationOAuth2Model.flows(), providerAuthenticationOAuth2FlowsModel); + + ProviderSpecificationComponentsSecuritySchemes + providerSpecificationComponentsSecuritySchemesModel = + new ProviderSpecificationComponentsSecuritySchemes.Builder() + .authenticationMethod("basic") + .basic(providerSpecificationComponentsSecuritySchemesBasicModel) + .oauth2(providerAuthenticationOAuth2Model) + .build(); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.authenticationMethod(), "basic"); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.basic(), + providerSpecificationComponentsSecuritySchemesBasicModel); + assertEquals( + providerSpecificationComponentsSecuritySchemesModel.oauth2(), + providerAuthenticationOAuth2Model); + + ProviderSpecificationComponents providerSpecificationComponentsModel = + new ProviderSpecificationComponents.Builder() + .securitySchemes(providerSpecificationComponentsSecuritySchemesModel) + .build(); + assertEquals( + providerSpecificationComponentsModel.securitySchemes(), + providerSpecificationComponentsSecuritySchemesModel); + + ProviderSpecification providerSpecificationModel = + new ProviderSpecification.Builder() + .servers(java.util.Arrays.asList(providerSpecificationServersItemModel)) + .components(providerSpecificationComponentsModel) + .build(); + assertEquals( + providerSpecificationModel.servers(), + java.util.Arrays.asList(providerSpecificationServersItemModel)); + assertEquals(providerSpecificationModel.components(), providerSpecificationComponentsModel); + + ProviderPrivateAuthenticationBearerFlow providerPrivateAuthenticationModel = + new ProviderPrivateAuthenticationBearerFlow.Builder() + .token(providerAuthenticationTypeAndValueModel) + .build(); + assertEquals( + providerPrivateAuthenticationModel.token(), providerAuthenticationTypeAndValueModel); + + ProviderPrivate providerPrivateModel = + new ProviderPrivate.Builder().authentication(providerPrivateAuthenticationModel).build(); + assertEquals(providerPrivateModel.authentication(), providerPrivateAuthenticationModel); + + UpdateProviderOptions updateProviderOptionsModel = + new UpdateProviderOptions.Builder() + .providerId("testString") + .specification(providerSpecificationModel) + .xPrivate(providerPrivateModel) + .build(); + assertEquals(updateProviderOptionsModel.providerId(), "testString"); + assertEquals(updateProviderOptionsModel.specification(), providerSpecificationModel); + assertEquals(updateProviderOptionsModel.xPrivate(), providerPrivateModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateProviderOptionsError() throws Throwable { + new UpdateProviderOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateSkillOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateSkillOptionsTest.java new file mode 100644 index 00000000000..c2160d2bdcb --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/UpdateSkillOptionsTest.java @@ -0,0 +1,216 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateSkillOptions model. */ +public class UpdateSkillOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateSkillOptions() throws Throwable { + SearchSettingsDiscoveryAuthentication searchSettingsDiscoveryAuthenticationModel = + new SearchSettingsDiscoveryAuthentication.Builder() + .basic("testString") + .bearer("testString") + .build(); + assertEquals(searchSettingsDiscoveryAuthenticationModel.basic(), "testString"); + assertEquals(searchSettingsDiscoveryAuthenticationModel.bearer(), "testString"); + + SearchSettingsDiscovery searchSettingsDiscoveryModel = + new SearchSettingsDiscovery.Builder() + .instanceId("testString") + .projectId("testString") + .url("testString") + .maxPrimaryResults(Long.valueOf("10000")) + .maxTotalResults(Long.valueOf("10000")) + .confidenceThreshold(Double.valueOf("0.0")) + .highlight(true) + .findAnswers(true) + .authentication(searchSettingsDiscoveryAuthenticationModel) + .build(); + assertEquals(searchSettingsDiscoveryModel.instanceId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.projectId(), "testString"); + assertEquals(searchSettingsDiscoveryModel.url(), "testString"); + assertEquals(searchSettingsDiscoveryModel.maxPrimaryResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.maxTotalResults(), Long.valueOf("10000")); + assertEquals(searchSettingsDiscoveryModel.confidenceThreshold(), Double.valueOf("0.0")); + assertEquals(searchSettingsDiscoveryModel.highlight(), Boolean.valueOf(true)); + assertEquals(searchSettingsDiscoveryModel.findAnswers(), Boolean.valueOf(true)); + assertEquals( + searchSettingsDiscoveryModel.authentication(), searchSettingsDiscoveryAuthenticationModel); + + SearchSettingsMessages searchSettingsMessagesModel = + new SearchSettingsMessages.Builder() + .success("testString") + .error("testString") + .noResult("testString") + .build(); + assertEquals(searchSettingsMessagesModel.success(), "testString"); + assertEquals(searchSettingsMessagesModel.error(), "testString"); + assertEquals(searchSettingsMessagesModel.noResult(), "testString"); + + SearchSettingsSchemaMapping searchSettingsSchemaMappingModel = + new SearchSettingsSchemaMapping.Builder() + .url("testString") + .body("testString") + .title("testString") + .build(); + assertEquals(searchSettingsSchemaMappingModel.url(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.body(), "testString"); + assertEquals(searchSettingsSchemaMappingModel.title(), "testString"); + + SearchSettingsElasticSearch searchSettingsElasticSearchModel = + new SearchSettingsElasticSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .index("testString") + .filter(java.util.Arrays.asList("testString")) + .queryBody(java.util.Collections.singletonMap("anyKey", "anyValue")) + .managedIndex("testString") + .apikey("testString") + .build(); + assertEquals(searchSettingsElasticSearchModel.url(), "testString"); + assertEquals(searchSettingsElasticSearchModel.port(), "testString"); + assertEquals(searchSettingsElasticSearchModel.username(), "testString"); + assertEquals(searchSettingsElasticSearchModel.password(), "testString"); + assertEquals(searchSettingsElasticSearchModel.index(), "testString"); + assertEquals(searchSettingsElasticSearchModel.filter(), java.util.Arrays.asList("testString")); + assertEquals( + searchSettingsElasticSearchModel.queryBody(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsElasticSearchModel.managedIndex(), "testString"); + assertEquals(searchSettingsElasticSearchModel.apikey(), "testString"); + + SearchSettingsConversationalSearchResponseLength + searchSettingsConversationalSearchResponseLengthModel = + new SearchSettingsConversationalSearchResponseLength.Builder() + .option("moderate") + .build(); + assertEquals(searchSettingsConversationalSearchResponseLengthModel.option(), "moderate"); + + SearchSettingsConversationalSearchSearchConfidence + searchSettingsConversationalSearchSearchConfidenceModel = + new SearchSettingsConversationalSearchSearchConfidence.Builder() + .threshold("less_often") + .build(); + assertEquals(searchSettingsConversationalSearchSearchConfidenceModel.threshold(), "less_often"); + + SearchSettingsConversationalSearch searchSettingsConversationalSearchModel = + new SearchSettingsConversationalSearch.Builder() + .enabled(true) + .responseLength(searchSettingsConversationalSearchResponseLengthModel) + .searchConfidence(searchSettingsConversationalSearchSearchConfidenceModel) + .build(); + assertEquals(searchSettingsConversationalSearchModel.enabled(), Boolean.valueOf(true)); + assertEquals( + searchSettingsConversationalSearchModel.responseLength(), + searchSettingsConversationalSearchResponseLengthModel); + assertEquals( + searchSettingsConversationalSearchModel.searchConfidence(), + searchSettingsConversationalSearchSearchConfidenceModel); + + SearchSettingsServerSideSearch searchSettingsServerSideSearchModel = + new SearchSettingsServerSideSearch.Builder() + .url("testString") + .port("testString") + .username("testString") + .password("testString") + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .apikey("testString") + .noAuth(true) + .authType("basic") + .build(); + assertEquals(searchSettingsServerSideSearchModel.url(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.port(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.username(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.password(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsServerSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(searchSettingsServerSideSearchModel.apikey(), "testString"); + assertEquals(searchSettingsServerSideSearchModel.noAuth(), Boolean.valueOf(true)); + assertEquals(searchSettingsServerSideSearchModel.authType(), "basic"); + + SearchSettingsClientSideSearch searchSettingsClientSideSearchModel = + new SearchSettingsClientSideSearch.Builder() + .filter("testString") + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(searchSettingsClientSideSearchModel.filter(), "testString"); + assertEquals( + searchSettingsClientSideSearchModel.metadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + SearchSettings searchSettingsModel = + new SearchSettings.Builder() + .discovery(searchSettingsDiscoveryModel) + .messages(searchSettingsMessagesModel) + .schemaMapping(searchSettingsSchemaMappingModel) + .elasticSearch(searchSettingsElasticSearchModel) + .conversationalSearch(searchSettingsConversationalSearchModel) + .serverSideSearch(searchSettingsServerSideSearchModel) + .clientSideSearch(searchSettingsClientSideSearchModel) + .build(); + assertEquals(searchSettingsModel.discovery(), searchSettingsDiscoveryModel); + assertEquals(searchSettingsModel.messages(), searchSettingsMessagesModel); + assertEquals(searchSettingsModel.schemaMapping(), searchSettingsSchemaMappingModel); + assertEquals(searchSettingsModel.elasticSearch(), searchSettingsElasticSearchModel); + assertEquals( + searchSettingsModel.conversationalSearch(), searchSettingsConversationalSearchModel); + assertEquals(searchSettingsModel.serverSideSearch(), searchSettingsServerSideSearchModel); + assertEquals(searchSettingsModel.clientSideSearch(), searchSettingsClientSideSearchModel); + + UpdateSkillOptions updateSkillOptionsModel = + new UpdateSkillOptions.Builder() + .assistantId("testString") + .skillId("testString") + .name("testString") + .description("testString") + .workspace(java.util.Collections.singletonMap("anyKey", "anyValue")) + .dialogSettings(java.util.Collections.singletonMap("anyKey", "anyValue")) + .searchSettings(searchSettingsModel) + .build(); + assertEquals(updateSkillOptionsModel.assistantId(), "testString"); + assertEquals(updateSkillOptionsModel.skillId(), "testString"); + assertEquals(updateSkillOptionsModel.name(), "testString"); + assertEquals(updateSkillOptionsModel.description(), "testString"); + assertEquals( + updateSkillOptionsModel.workspace(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + updateSkillOptionsModel.dialogSettings(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateSkillOptionsModel.searchSettings(), searchSettingsModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSkillOptionsError() throws Throwable { + new UpdateSkillOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/testng.xml b/assistant/src/test/java/com/ibm/watson/assistant/v2/testng.xml new file mode 100644 index 00000000000..5b94611f4ea --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/utils/TestUtilities.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/utils/TestUtilities.java new file mode 100644 index 00000000000..e1ad03c5a14 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/utils/TestUtilities.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.assistant.v2.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index bb50181c17c..00000000000 --- a/build.gradle +++ /dev/null @@ -1,141 +0,0 @@ -buildscript { - repositories { - maven { url "https://plugins.gradle.org/m2/" } - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.3' - classpath "com.github.jengelman.gradle.plugins:shadow:1.2.4" - } -} - -apply from: 'utils.gradle' -apply plugin: 'java' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' -apply plugin: 'idea' - -archivesBaseName = 'ibm-watson' - -description = 'Client library to use the IBM Watson Services' - -javadoc { - source = 'src/main/java' -} - -checkstyle { - ignoreFailures = false -} - -checkstyleMain { - ignoreFailures = false -} - -checkstyleTest { - ignoreFailures = false -} - -task docs(type: Javadoc) { - destinationDir = file("$buildDir/docs/all") -} - -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } -} - -task copyJars(type: Copy) { - from subprojects.collect { it.tasks.withType(Jar) } - into "$buildDir/allJars" -} - -task signJars(type: Copy) { - from subprojects.collect { it.tasks.withType(Sign) } - into "$buildDir/allJars" -} - -allprojects { - apply plugin: 'java' // *Compatibility has no effect before the 'java' plug-in is applied - apply plugin: 'jacoco' - apply plugin: 'com.github.johnrengelman.shadow' - - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 - - repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } - } - - shadowJar { - classifier = 'jar-with-dependencies' - } -} - -subprojects { - dependencies { - testCompile group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '3.11.0' - testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - testCompile group: 'com.google.guava', name: 'guava', version: '27.1-android' - testCompile group: 'junit', name: 'junit', version: '4.12' - } - - checkstyleMain { - ignoreFailures = false - } - - checkstyleTest { - ignoreFailures = false - } - - test { - testLogging { - events "failed" - exceptionFormat "full" - } - } - - afterEvaluate { - if (plugins.hasPlugin(JavaPlugin)) { - rootProject.tasks.docs { - source += files(sourceSets.main.allJava) - classpath += files(sourceSets*.compileClasspath) - } - } - } -} - -task codeCoverageReport(type: JacocoReport) { - // Gather execution data from all sub projects - // (change this if you e.g. want to calculate unit test/integration test coverage separately) - executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") - - // Add all relevant source sets from the sub projects - subprojects.each { - sourceSets it.sourceSets.main - } - - reports { - xml.enabled true - xml.destination "${buildDir}/reports/jacoco/report.xml" - html.enabled true - html.destination "${buildDir}/reports/jacoco" - csv.enabled false - } -} - -// always run the tests before generating the report -codeCoverageReport.dependsOn { - subprojects*.test - testReport -} - -task testReport(type: TestReport) { - destinationDir = file("$buildDir/reports/allTests") - - // Include the results from the `test` task in all subprojects - reportOn subprojects*.test -} diff --git a/build/.travis.settings.xml b/build/.travis.settings.xml new file mode 100644 index 00000000000..7142f2a05ce --- /dev/null +++ b/build/.travis.settings.xml @@ -0,0 +1,11 @@ + + + + + central + ${env.CENTRAL_USERNAME} + ${env.CENTRAL_PASSWORD} + + + diff --git a/build/generateJavadocIndex.sh b/build/generateJavadocIndex.sh new file mode 100755 index 00000000000..4b276492b5f --- /dev/null +++ b/build/generateJavadocIndex.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# based on https://odoepner.wordpress.com/2012/02/17/shell-script-to-generate-simple-index-html/ + +echo ' + + + + + + IBM Watson Developer Cloud + + + +

+ + +

Info + | Documentation + | GitHub + | Maven +

+ +

Javadoc by branch/release:

+ +
+ +' diff --git a/build/publishCodeCoverage.sh b/build/publishCodeCoverage.sh new file mode 100755 index 00000000000..d20a5a70082 --- /dev/null +++ b/build/publishCodeCoverage.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script will publish code coverage info for a build of the main branch +# or a tagged release. + +if [[ -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "main" && "${TRAVIS_PULL_REQUEST}" == "false" ]]; then + printf ">>>>> Publishing code coverage info for branch: %s\n" ${TRAVIS_BRANCH} + $HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CODECOV_TOKEN +else + printf ">>>>> Bypassing code coverage publish step for feature branch/PR build.\n" +fi + diff --git a/build/publishJavadoc.sh b/build/publishJavadoc.sh new file mode 100755 index 00000000000..7a45aa3d2ad --- /dev/null +++ b/build/publishJavadoc.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# This script will publish the aggregated javadocs found in the project's "target" directory. +# The javadocs are committed and pushed to the git repository's gh-pages branch. +# Be sure to customize this file to reflect your SDK project's settings (git url, + +# Avoid publishing javadocs for a PR build +if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then + + printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} + + printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n" + rm -fr ./gh-pages + git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null + + printf "\n>>>>> Finished cloning...\n" + + + pushd gh-pages + + # Create a new directory for this branch/tag and copy the aggregated javadocs there. + printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${TRAVIS_BRANCH} + rm -rf docs/${TRAVIS_BRANCH} + mkdir -p docs/${TRAVIS_BRANCH} + cp -rf ../target/site/apidocs/* docs/${TRAVIS_BRANCH} + + printf "\n>>>>> Generating gh-pages index.html...\n" + ../build/generateJavadocIndex.sh > index.html + + # Update the 'latest' symlink to point to this branch if it's a tagged release. + if [ -n "$TRAVIS_TAG" ]; then + pushd docs + rm latest + ln -s ./${TRAVIS_TAG} latest + printf "\n>>>>> Updated 'docs/latest' symlink:\n" + ls -l latest + popd + fi + + printf "\n>>>>> Committing new javadoc...\n" + git add -f . + git commit -m "Javadoc for release ${TRAVIS_TAG} (${TRAVIS_COMMIT})" + git push -f origin gh-pages + + popd + + printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} + +else + + printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} + +fi diff --git a/build/publish_gha.sh b/build/publish_gha.sh new file mode 100755 index 00000000000..6aa5cf382a2 --- /dev/null +++ b/build/publish_gha.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# This script will publish the aggregated javadocs found in the project's "target" directory. +# The javadocs are committed and pushed to the git repository's gh-pages branch. +# Be sure to customize this file to reflect your SDK project's settings + +export GHA_TAG=${GHA_TAG##*/} # Get the last part for true tag name - "refs/heads/vx.x.x" +printf "\n>>>>> Publishing javadoc for release build: %s\n" ${GHA_TAG} + +printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n" +rm -fr ./gh-pages +git config --global user.email "watdevex@us.ibm.com" +git config --global user.name "watdevex" +git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null +printf "\n>>>>> Finished cloning...\n" + +pushd gh-pages + +# Create a new directory for this branch/tag and copy the aggregated javadocs there. +printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${GHA_TAG} +rm -rf docs/${GHA_TAG} +mkdir -p docs/${GHA_TAG} +cp -rf ../target/site/apidocs/* docs/${GHA_TAG} + +printf "\n>>>>> Generating gh-pages index.html...\n" +../build/generateJavadocIndex.sh > index.html + +# Update the 'latest' symlink to point to this branch if it's a tagged release. +pushd docs +rm latest +ln -s ./${GHA_TAG} latest +printf "\n>>>>> Updated 'docs/latest' symlink:\n" +ls -l latest +popd + +printf "\n>>>>> Committing new javadoc for commit: %s\n" ${GHA_COMMIT} +git add -f . +git commit -m "chore: Javadoc for release ${GHA_TAG} (${GHA_COMMIT})" +git push -f origin gh-pages + +popd diff --git a/build/setMavenVersion.sh b/build/setMavenVersion.sh new file mode 100755 index 00000000000..8b0f63995ae --- /dev/null +++ b/build/setMavenVersion.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script will check $TRAVIS_TAG to see if we need to run maven to +# set the artifact version #'s. + +if [[ -n "${TRAVIS_TAG}" ]]; then + printf "\n>>>>> Setting artifact version #'s to: %s\n" ${TRAVIS_TAG:1} + mvn versions:set -DnewVersion=${TRAVIS_TAG:1} -DgenerateBackupPoms=false +else + printf "\n>>>>> Bypassing artifact version setting for non-tagged build\n" +fi + \ No newline at end of file diff --git a/build/setMavenVersion_gha.sh b/build/setMavenVersion_gha.sh new file mode 100755 index 00000000000..69b6aceee1c --- /dev/null +++ b/build/setMavenVersion_gha.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This script will check $GHA_TAG to see if we need to run maven to +# set the artifact version #'s. +export GHA_TAG=${GHA_TAG##*/} # Get the last part for true tag name - "refs/heads/9260_gha" + +if [[ -n "${GHA_TAG}" ]]; then + printf "\n>>>>> Setting artifact version #'s to: %s\n" ${GHA_TAG} + mvn versions:set -DnewVersion=${GHA_TAG:1} -DgenerateBackupPoms=false +else + printf "\n>>>>> Bypassing artifact version setting for non-tagged build %s\n" ${GHA_TAG} +fi + \ No newline at end of file diff --git a/build/setupSigning.sh b/build/setupSigning.sh new file mode 100755 index 00000000000..c75c9f236a2 --- /dev/null +++ b/build/setupSigning.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -x + +# This script is responsible for decrypting your encrypted signing key file +# (build/signing.key.enc), and importing it into the gpg keystore. +# This is done so that your maven build will be able to properly sign your jars +# prior to publishing them on maven central. + +echo "Importing signing key..." + +# Modify the command below to use the correct environment variables +# that were added to your Travis build settings when you encrypted your signing.key file. +openssl aes-256-cbc -K $encrypted_6afd0fc9428e_key -iv $encrypted_6afd0fc9428e_iv -in build/signing.key.enc -out build/signing.key -d + +gpg --version +gpg --fast-import build/signing.key +rm build/signing.key + +echo "Signing key import finished!" diff --git a/build/setupSigning_gha.sh b/build/setupSigning_gha.sh new file mode 100755 index 00000000000..3b550f27cc4 --- /dev/null +++ b/build/setupSigning_gha.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# export GPG_TTY=$(tty) + +set -x + +# This script is responsible for decrypting your encrypted signing key file +# (build/signing.key.enc), and importing it into the gpg keystore. +# This is done so that your maven build will be able to properly sign your jars +# prior to publishing them on maven central. + +echo "Importing signing key..." + +# Modify the command below to use the correct environment variables +# that were added to your Travis build settings when you encrypted your signing.key file. +gpg --quiet --batch --yes --decrypt --passphrase="$SIGNING_PASSPHRASE" --output ./build/signing.key ./build/signing.key.gpg + +gpg --version +gpg --no-tty --batch --yes --import ./build/signing.key +rm ./build/signing.key + +echo "Signing key import finished!" diff --git a/build/signing.key.enc b/build/signing.key.enc new file mode 100644 index 00000000000..8cc16f2fa29 Binary files /dev/null and b/build/signing.key.enc differ diff --git a/build/signing.key.gpg b/build/signing.key.gpg new file mode 100644 index 00000000000..2685ce5e724 Binary files /dev/null and b/build/signing.key.gpg differ diff --git a/checkstyle.xml b/checkstyle.xml index 646f240b293..f33535703fe 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,21 +1,22 @@ + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> + + - - + - - - - - - @@ -32,12 +33,7 @@ - - - - - - + @@ -47,11 +43,13 @@ - - - + + + + @@ -66,10 +64,6 @@ - - - - @@ -78,22 +72,10 @@ - - - - - - - @@ -105,42 +87,32 @@ - - - - - - - - - - - - - - - - + + + + + + diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index b07307f58d2..00000000000 --- a/common/build.gradle +++ /dev/null @@ -1,72 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/common/gradle.properties b/common/gradle.properties deleted file mode 100644 index 2554f593815..00000000000 --- a/common/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:common -ARTIFACT_ID=common -NAME=IBM Watson Java SDK - Common -DESCRIPTION=Classes common to the rest of the wrapper libraries in the Watson Java SDK \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 00000000000..6642fc98ed2 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,105 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + + common + + + IBM Watson Java SDK - Common + jar + + + + com.ibm.cloud + sdk-core + + + org.testng + testng + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + com.squareup.okhttp3 + mockwebserver + 4.9.0 + test + + + ch.qos.logback + logback-classic + 1.2.3 + test + + + com.google.guava + guava + 27.1-android + test + + + junit + junit + 4.12 + test + + + + + + src/main/resources + true + + java-sdk-version.properties + + + + src/test/resources + true + + *.properties + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + + \ No newline at end of file diff --git a/common/src/main/java/com/ibm/watson/common/SdkCommon.java b/common/src/main/java/com/ibm/watson/common/SdkCommon.java index 17bbef95bd0..fe7aa1337e3 100644 --- a/common/src/main/java/com/ibm/watson/common/SdkCommon.java +++ b/common/src/main/java/com/ibm/watson/common/SdkCommon.java @@ -1,8 +1,19 @@ +/* + * (C) Copyright IBM Corp. 2019, 2020. + * + * 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.common; import com.ibm.cloud.sdk.core.http.HttpHeaders; import com.ibm.cloud.sdk.core.util.RequestUtils; - import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -10,12 +21,12 @@ import java.util.logging.Level; import java.util.logging.Logger; +/** The Class SdkCommon. */ public class SdkCommon { private static final Logger LOG = Logger.getLogger(SdkCommon.class.getName()); private static String userAgent; - private SdkCommon() { - } + private SdkCommon() {} private static String loadSdkVersion() { ClassLoader classLoader = SdkCommon.class.getClassLoader(); @@ -38,14 +49,22 @@ private static String getUserAgent() { return userAgent; } - public static Map getSdkHeaders(String serviceName, String serviceVersion, String operationId) { + /** + * Gets the sdk headers. + * + * @param serviceName the service name + * @param serviceVersion the service version + * @param operationId the operation id + * @return the sdk headers + */ + public static Map getSdkHeaders( + String serviceName, String serviceVersion, String operationId) { Map headers = new HashMap<>(); - String sdkAnalyticsHeaderValue = String.format( - "service_name=%s;service_version=%s;operation_id=%s", - serviceName, - serviceVersion, - operationId); + String sdkAnalyticsHeaderValue = + String.format( + "service_name=%s;service_version=%s;operation_id=%s", + serviceName, serviceVersion, operationId); headers.put(WatsonHttpHeaders.X_IBMCLOUD_SDK_ANALYTICS, sdkAnalyticsHeaderValue); headers.put(HttpHeaders.USER_AGENT, getUserAgent()); diff --git a/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java b/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java index 5c88b8c130b..352561f306e 100644 --- a/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java +++ b/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java @@ -1,5 +1,18 @@ +/* + * (C) Copyright IBM Corp. 2019, 2020. + * + * 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.common; +/** The Interface WatsonHttpHeaders. */ public interface WatsonHttpHeaders { /** Allow Watson to collect the payload. */ String X_WATSON_LEARNING_OPT_OUT = "X-Watson-Learning-Opt-Out"; diff --git a/common/src/test/java/com/ibm/watson/common/RetryRunner.java b/common/src/test/java/com/ibm/watson/common/RetryRunner.java index 8c336720a11..bb6e734a080 100644 --- a/common/src/test/java/com/ibm/watson/common/RetryRunner.java +++ b/common/src/test/java/com/ibm/watson/common/RetryRunner.java @@ -1,7 +1,21 @@ +/* + * (C) Copyright IBM Corp. 2019, 2024. + * + * 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.common; import com.ibm.cloud.sdk.core.service.exception.TooManyRequestsException; import com.ibm.cloud.sdk.core.service.exception.UnauthorizedException; +import java.util.logging.Level; +import java.util.logging.Logger; import org.junit.Ignore; import org.junit.internal.AssumptionViolatedException; import org.junit.internal.runners.model.EachTestNotifier; @@ -13,20 +27,13 @@ import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Junit Runner that retry tests. Useful when tests could fail due to network issues. - */ +/** Junit Runner that retry tests. Useful when tests could fail due to network issues. */ public class RetryRunner extends BlockJUnit4ClassRunner { private static final Logger LOG = Logger.getLogger(RetryRunner.class.getName()); - private static final int RETRY_COUNT = 3; + private static final int RETRY_COUNT = 0; - /** - * Delay factor when tests are failing. - */ + /** Delay factor when tests are failing. */ private static final int RETRY_DELAY_FACTOR = 2000; /** @@ -89,7 +96,11 @@ private void runTest(Statement statement, Description description, RunNotifier n } } - private void retry(EachTestNotifier notifier, Statement statement, Throwable currentThrowable, Description info) { + private void retry( + EachTestNotifier notifier, + Statement statement, + Throwable currentThrowable, + Description info) { int failedAttempts = 0; Throwable caughtThrowable = currentThrowable; while (RETRY_COUNT > failedAttempts) { diff --git a/common/src/test/java/com/ibm/watson/common/SdkCommonTest.java b/common/src/test/java/com/ibm/watson/common/SdkCommonTest.java index b07b8a21296..e328ebf9758 100644 --- a/common/src/test/java/com/ibm/watson/common/SdkCommonTest.java +++ b/common/src/test/java/com/ibm/watson/common/SdkCommonTest.java @@ -1,19 +1,34 @@ +/* + * (C) Copyright IBM Corp. 2019, 2020. + * + * 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.common; -import com.ibm.cloud.sdk.core.http.HttpHeaders; -import org.junit.Test; +import static org.junit.Assert.assertTrue; +import com.ibm.cloud.sdk.core.http.HttpHeaders; import java.util.Map; +import org.junit.Test; -import static org.junit.Assert.assertTrue; - +/** The Class SdkCommonTest. */ public class SdkCommonTest { + + /** Test get sdk headers. */ @Test public void testGetSdkHeaders() { String serviceName = "test_name"; String serviceVersion = "v1"; String operationId = "test_method"; - Map defaultHeaders = SdkCommon.getSdkHeaders(serviceName, serviceVersion, operationId); + Map defaultHeaders = + SdkCommon.getSdkHeaders(serviceName, serviceVersion, operationId); assertTrue(defaultHeaders.containsKey(WatsonHttpHeaders.X_IBMCLOUD_SDK_ANALYTICS)); String analyticsHeaderValue = defaultHeaders.get(WatsonHttpHeaders.X_IBMCLOUD_SDK_ANALYTICS); diff --git a/common/src/test/java/com/ibm/watson/common/TestUtils.java b/common/src/test/java/com/ibm/watson/common/TestUtils.java index 1baf8e58d4f..493b0b014da 100644 --- a/common/src/test/java/com/ibm/watson/common/TestUtils.java +++ b/common/src/test/java/com/ibm/watson/common/TestUtils.java @@ -1,8 +1,17 @@ +/* + * (C) Copyright IBM Corp. 2019, 2020. + * + * 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.common; -import junit.framework.AssertionFailedError; -import org.junit.Ignore; - import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -11,17 +20,14 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; +import junit.framework.AssertionFailedError; +import org.junit.Ignore; -/** - * The Class TestUtils. - */ +/** The Class TestUtils. */ @Ignore public final class TestUtils { - /** - * Private constructor. - */ - private TestUtils() { - } + /** Private constructor. */ + private TestUtils() {} /** * Test that a collection is not null or empty. @@ -43,7 +49,8 @@ public static void assertIsEmpty(final Collection objs) throws Exception { * @throws Exception any exception */ @SuppressWarnings("rawtypes") - public static void assertNoExceptionsOnCollectionIteration(final Collection objs) throws Exception { + public static void assertNoExceptionsOnCollectionIteration(final Collection objs) + throws Exception { for (final Object obj : objs) { assertNoExceptionsOnGetters(obj); } @@ -76,7 +83,6 @@ public static void assertNoExceptionsOnGetters(final Object obj) throws Exceptio } } } - } /** @@ -85,7 +91,7 @@ public static void assertNoExceptionsOnGetters(final Object obj) throws Exceptio * @param objs the collection of objects * @throws Exception any exception */ - @SuppressWarnings({ "rawtypes" }) + @SuppressWarnings({"rawtypes"}) public static void assertNotEmpty(final Collection objs) throws Exception { if (objs == null) { throw new AssertionFailedError("Collection is null"); @@ -96,7 +102,8 @@ public static void assertNotEmpty(final Collection objs) throws Exception { } /** - * Checks if both InputStreams have the same content and length. The streams are closed after reading. + * Checks if both InputStreams have the same content and length. The streams are closed after + * reading. * * @param s1 the s1 * @param s2 the s2 diff --git a/common/src/test/java/com/ibm/watson/common/WaitFor.java b/common/src/test/java/com/ibm/watson/common/WaitFor.java index c4dccc1ad94..c2b3db5eab5 100644 --- a/common/src/test/java/com/ibm/watson/common/WaitFor.java +++ b/common/src/test/java/com/ibm/watson/common/WaitFor.java @@ -1,17 +1,23 @@ +/* + * (C) Copyright IBM Corp. 2019, 2020. + * + * 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.common; import java.util.concurrent.TimeUnit; -/** - * Wait for a certain condition to be true or for a timeout to expire. - * - */ - +/** Wait for a certain condition to be true or for a timeout to expire. */ public class WaitFor { - private WaitFor() { - - } + private WaitFor() {} /** * Static method used to wait for a specific condition to be satisfied. @@ -20,7 +26,6 @@ private WaitFor() { * @param time The maximum time to wait for the condition to become true * @param unit The time unit of the {@code time} argument * @param sleepMs The time to wait between checks - * * @return true if the condition was true before the timeout, false if it wasn't. */ public static boolean waitFor(Condition condition, long time, TimeUnit unit, long sleepMs) { @@ -39,11 +44,12 @@ public static boolean waitFor(Condition condition, long time, TimeUnit unit, lon return false; } - /** - * The Interface Condition. - */ + /** The Interface Condition. */ public interface Condition { + /** + * Checks if is satisfied. + * * @return true/false indicating whether or not the condition has been met. */ boolean isSatisfied(); diff --git a/common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java b/common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java index 02ba0c8ccf5..dede080d3f5 100644 --- a/common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java +++ b/common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java @@ -1,8 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2019, 2020. + * + * 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.common; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import org.slf4j.LoggerFactory; +import static org.junit.Assert.fail; +import com.ibm.cloud.sdk.core.util.GsonSingleton; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -19,12 +31,9 @@ import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.Logger; +import org.slf4j.LoggerFactory; -import static org.junit.Assert.fail; - -/** - * Utility class to test the Watson Services. - */ +/** Utility class to test the Watson Services. */ public abstract class WatsonServiceTest { private static final String DEFAULT_PROPERTIES = "config.properties"; @@ -35,9 +44,7 @@ public abstract class WatsonServiceTest { /** The Constant CONTENT_TYPE. */ protected static final String CONTENT_TYPE = "Content-Type"; - /** - * Instantiates a new watson service test. - */ + /** Instantiates a new watson service test. */ public WatsonServiceTest() { if (properties == null) { loadProperties(); @@ -88,7 +95,6 @@ public static String getStringFromInputStream(InputStream is) { } return sb.toString(); - } /** The prop. */ @@ -107,9 +113,11 @@ public String getProperty(String property) { private void loadProperties() { properties = new Properties(); - InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(LOCAL_PROPERTIES); + InputStream input = + Thread.currentThread().getContextClassLoader().getResourceAsStream(LOCAL_PROPERTIES); if (input == null) { - input = Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_PROPERTIES); + input = + Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_PROPERTIES); } else { LOG.info("Using " + LOCAL_PROPERTIES); } @@ -123,15 +131,12 @@ private void loadProperties() { } catch (IOException e) { LOG.log(Level.SEVERE, "Error loading the config.properties"); } - } - /** - * Setup logging. - */ + /** Setup logging. */ private void setupLogging() { - ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger( - org.slf4j.Logger.ROOT_LOGGER_NAME); + ch.qos.logback.classic.Logger root = + (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); root.setLevel(ch.qos.logback.classic.Level.OFF); try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); @@ -180,33 +185,41 @@ public static void writeInputStreamToFile(InputStream inputStream, File file) { * @return the t * @throws FileNotFoundException the file not found exception */ - public static T loadFixture(String filename, Class returnType) throws FileNotFoundException { + public static T loadFixture(String filename, Class returnType) + throws FileNotFoundException { String jsonString = getStringFromInputStream(new FileInputStream(filename)); return GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(jsonString, returnType); } /** - * Sets the up. + * Sets up the tests. * * @throws Exception the exception */ - public void setUp() throws Exception { - } - - /** - * Fuzzy date checking. - */ + public void setUp() throws Exception {} + /** Fuzzy date checking. */ private long tolerance = 5000; // 5 secs in ms - /** return `true` if ldate before rdate within tolerance. */ + /** + * return `true` if ldate before rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful + */ public boolean fuzzyBefore(Date ldate, Date rdate) { return (ldate.getTime() - rdate.getTime()) < tolerance; } - /** return `true` if ldate after rdate within tolerance. */ + /** + * return `true` if ldate after rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful + */ public boolean fuzzyAfter(Date ldate, Date rdate) { return (rdate.getTime() - ldate.getTime()) < tolerance; } - } diff --git a/common/src/test/java/com/ibm/watson/common/WatsonServiceUnitTest.java b/common/src/test/java/com/ibm/watson/common/WatsonServiceUnitTest.java index c95e4a8a003..74514906a26 100644 --- a/common/src/test/java/com/ibm/watson/common/WatsonServiceUnitTest.java +++ b/common/src/test/java/com/ibm/watson/common/WatsonServiceUnitTest.java @@ -1,15 +1,30 @@ +/* + * (C) Copyright IBM Corp. 2019, 2024. + * + * 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.common; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.HashMap; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import org.apache.commons.lang3.StringUtils; import org.junit.After; -import java.io.IOException; - +/** The Class WatsonServiceUnitTest. */ public class WatsonServiceUnitTest extends WatsonServiceTest { /** The Constant DELETE. */ protected static final String DELETE = "DELETE"; @@ -65,6 +80,22 @@ protected String getMockWebServerUrl() { * @return the mock response */ protected static MockResponse jsonResponse(Object body) { - return new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(body)); + return new MockResponse() + .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) + .setBody(GSON.toJson(body)); + } + + /** + * Create a MockResponse with JSON content type and the object serialized to JSON as body. For + * HashMaps + * + * @param body the body + * @return the mock response + */ + protected static MockResponse hashmapToJsonResponse(Object body) { + Type typeObject = new TypeToken() {}.getType(); + return new MockResponse() + .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) + .setBody(GSON.toJson(body, typeObject)); } } diff --git a/common/src/test/resources/logging.properties b/common/src/test/resources/logging.properties index 343c92b98a8..602e1a4e93d 100644 --- a/common/src/test/resources/logging.properties +++ b/common/src/test/resources/logging.properties @@ -3,7 +3,7 @@ java.util.logging.ConsoleHandler.level=FINE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter java.util.logging.SimpleFormatter.format=%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s %4$s: %5$s%n .level=SEVERE -okhttp3.level=FINE +okhttp3.level=SEVERE okhttp3.mockwebserver.level=WARNING com.ibm.watson.level=FINE -com.ibm.watson.developer_cloud.util.level=WARNING \ No newline at end of file +com.ibm.watson.common.util.level=WARNING \ No newline at end of file diff --git a/compare-comply/README.md b/compare-comply/README.md deleted file mode 100644 index 30edd3b4a4a..00000000000 --- a/compare-comply/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Compare and Comply - -## Installation - -##### Maven - -```xml - - com.ibm.watson - compare-comply - 8.3.1 - -``` - -##### Gradle - -```gradle -'com.ibm.watson.developer_cloud:compare-comply:8.3.1' -``` - -## Usage - -Use the [Compare and Comply](https://cloud.ibm.com/docs/compare-comply/index.html#about) service to enable better and faster document understanding. Below is an example of converting a PDF file into HTML: - -```java -Authenticator authenticator = new IamAuthenticator(""); -CompareComply service = new CompareComply("2018-10-15", authenticator); - -ConvertToHtmlOptions convertToHtmlOptions = new ConvertToHtmlOptions.Builder() - .file("~/path/to/file.pdf") - .fileContentType(HttpMediaType.APPLICATION_PDF) - .build(); - -// Response body with converted HTML -HTMLReturn response = service.convertToHtml(convertToHtmlOptions).execute().getResult(); -``` diff --git a/compare-comply/build.gradle b/compare-comply/build.gradle deleted file mode 100644 index ec219455832..00000000000 --- a/compare-comply/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/compare-comply/gradle.properties b/compare-comply/gradle.properties deleted file mode 100644 index 61764eaf267..00000000000 --- a/compare-comply/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:compare-comply -ARTIFACT_ID=compare-comply -NAME=IBM Watson Java SDK - Compare and Comply -DESCRIPTION=Java client library to use the IBM Compare and Comply API \ No newline at end of file diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java deleted file mode 100644 index bd86c58fb8b..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java +++ /dev/null @@ -1,589 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.compare_comply.v1.model.AddFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.BatchStatus; -import com.ibm.watson.compare_comply.v1.model.Batches; -import com.ibm.watson.compare_comply.v1.model.ClassifyElementsOptions; -import com.ibm.watson.compare_comply.v1.model.ClassifyReturn; -import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions; -import com.ibm.watson.compare_comply.v1.model.CompareReturn; -import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions; -import com.ibm.watson.compare_comply.v1.model.CreateBatchOptions; -import com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.ExtractTablesOptions; -import com.ibm.watson.compare_comply.v1.model.FeedbackDeleted; -import com.ibm.watson.compare_comply.v1.model.FeedbackList; -import com.ibm.watson.compare_comply.v1.model.FeedbackReturn; -import com.ibm.watson.compare_comply.v1.model.GetBatchOptions; -import com.ibm.watson.compare_comply.v1.model.GetFeedback; -import com.ibm.watson.compare_comply.v1.model.GetFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.HTMLReturn; -import com.ibm.watson.compare_comply.v1.model.ListBatchesOptions; -import com.ibm.watson.compare_comply.v1.model.ListFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.TableReturn; -import com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions; -import java.util.Map; -import java.util.Map.Entry; -import okhttp3.MultipartBody; - -/** - * IBM Watson™ Compare and Comply analyzes governing documents to provide details about critical aspects of the - * documents. - * - * @version v1 - * @see Compare Comply - */ -public class CompareComply extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "compare_comply"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/compare-comply/api"; - - private String versionDate; - - /** - * Constructs a new `CompareComply` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public CompareComply(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `CompareComply` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public CompareComply(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `CompareComply` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public CompareComply(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `CompareComply` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public CompareComply(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Convert document to HTML. - * - * Converts a document to HTML. - * - * @param convertToHtmlOptions the {@link ConvertToHtmlOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link HTMLReturn} - */ - public ServiceCall convertToHtml(ConvertToHtmlOptions convertToHtmlOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(convertToHtmlOptions, - "convertToHtmlOptions cannot be null"); - String[] pathSegments = { "v1/html_conversion" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "convertToHtml"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (convertToHtmlOptions.model() != null) { - builder.query("model", convertToHtmlOptions.model()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(convertToHtmlOptions.file(), convertToHtmlOptions - .fileContentType()); - multipartBuilder.addFormDataPart("file", "filename", fileBody); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Classify the elements of a document. - * - * Analyzes the structural and semantic elements of a document. - * - * @param classifyElementsOptions the {@link ClassifyElementsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ClassifyReturn} - */ - public ServiceCall classifyElements(ClassifyElementsOptions classifyElementsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classifyElementsOptions, - "classifyElementsOptions cannot be null"); - String[] pathSegments = { "v1/element_classification" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "classifyElements"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (classifyElementsOptions.model() != null) { - builder.query("model", classifyElementsOptions.model()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(classifyElementsOptions.file(), classifyElementsOptions - .fileContentType()); - multipartBuilder.addFormDataPart("file", "filename", fileBody); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Extract a document's tables. - * - * Analyzes the tables in a document. - * - * @param extractTablesOptions the {@link ExtractTablesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TableReturn} - */ - public ServiceCall extractTables(ExtractTablesOptions extractTablesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(extractTablesOptions, - "extractTablesOptions cannot be null"); - String[] pathSegments = { "v1/tables" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "extractTables"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (extractTablesOptions.model() != null) { - builder.query("model", extractTablesOptions.model()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(extractTablesOptions.file(), extractTablesOptions - .fileContentType()); - multipartBuilder.addFormDataPart("file", "filename", fileBody); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Compare two documents. - * - * Compares two input documents. Documents must be in the same format. - * - * @param compareDocumentsOptions the {@link CompareDocumentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link CompareReturn} - */ - public ServiceCall compareDocuments(CompareDocumentsOptions compareDocumentsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(compareDocumentsOptions, - "compareDocumentsOptions cannot be null"); - String[] pathSegments = { "v1/comparison" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "compareDocuments"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (compareDocumentsOptions.file1Label() != null) { - builder.query("file_1_label", compareDocumentsOptions.file1Label()); - } - if (compareDocumentsOptions.file2Label() != null) { - builder.query("file_2_label", compareDocumentsOptions.file2Label()); - } - if (compareDocumentsOptions.model() != null) { - builder.query("model", compareDocumentsOptions.model()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody file1Body = RequestUtils.inputStreamBody(compareDocumentsOptions.file1(), - compareDocumentsOptions.file1ContentType()); - multipartBuilder.addFormDataPart("file_1", "filename", file1Body); - okhttp3.RequestBody file2Body = RequestUtils.inputStreamBody(compareDocumentsOptions.file2(), - compareDocumentsOptions.file2ContentType()); - multipartBuilder.addFormDataPart("file_2", "filename", file2Body); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add feedback. - * - * Adds feedback in the form of _labels_ from a subject-matter expert (SME) to a governing document. - * **Important:** Feedback is not immediately incorporated into the training model, nor is it guaranteed to be - * incorporated at a later date. Instead, submitted feedback is used to suggest future updates to the training model. - * - * @param addFeedbackOptions the {@link AddFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link FeedbackReturn} - */ - public ServiceCall addFeedback(AddFeedbackOptions addFeedbackOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addFeedbackOptions, - "addFeedbackOptions cannot be null"); - String[] pathSegments = { "v1/feedback" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "addFeedback"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.add("feedback_data", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addFeedbackOptions - .feedbackData())); - if (addFeedbackOptions.userId() != null) { - contentJson.addProperty("user_id", addFeedbackOptions.userId()); - } - if (addFeedbackOptions.comment() != null) { - contentJson.addProperty("comment", addFeedbackOptions.comment()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List the feedback in a document. - * - * Lists the feedback in a document. - * - * @param listFeedbackOptions the {@link ListFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link FeedbackList} - */ - public ServiceCall listFeedback(ListFeedbackOptions listFeedbackOptions) { - String[] pathSegments = { "v1/feedback" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "listFeedback"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listFeedbackOptions != null) { - if (listFeedbackOptions.feedbackType() != null) { - builder.query("feedback_type", listFeedbackOptions.feedbackType()); - } - if (listFeedbackOptions.before() != null) { - builder.query("before", String.valueOf(listFeedbackOptions.before())); - } - if (listFeedbackOptions.after() != null) { - builder.query("after", String.valueOf(listFeedbackOptions.after())); - } - if (listFeedbackOptions.documentTitle() != null) { - builder.query("document_title", listFeedbackOptions.documentTitle()); - } - if (listFeedbackOptions.modelId() != null) { - builder.query("model_id", listFeedbackOptions.modelId()); - } - if (listFeedbackOptions.modelVersion() != null) { - builder.query("model_version", listFeedbackOptions.modelVersion()); - } - if (listFeedbackOptions.categoryRemoved() != null) { - builder.query("category_removed", listFeedbackOptions.categoryRemoved()); - } - if (listFeedbackOptions.categoryAdded() != null) { - builder.query("category_added", listFeedbackOptions.categoryAdded()); - } - if (listFeedbackOptions.categoryNotChanged() != null) { - builder.query("category_not_changed", listFeedbackOptions.categoryNotChanged()); - } - if (listFeedbackOptions.typeRemoved() != null) { - builder.query("type_removed", listFeedbackOptions.typeRemoved()); - } - if (listFeedbackOptions.typeAdded() != null) { - builder.query("type_added", listFeedbackOptions.typeAdded()); - } - if (listFeedbackOptions.typeNotChanged() != null) { - builder.query("type_not_changed", listFeedbackOptions.typeNotChanged()); - } - if (listFeedbackOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listFeedbackOptions.pageLimit())); - } - if (listFeedbackOptions.cursor() != null) { - builder.query("cursor", listFeedbackOptions.cursor()); - } - if (listFeedbackOptions.sort() != null) { - builder.query("sort", listFeedbackOptions.sort()); - } - if (listFeedbackOptions.includeTotal() != null) { - builder.query("include_total", String.valueOf(listFeedbackOptions.includeTotal())); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List the feedback in a document. - * - * Lists the feedback in a document. - * - * @return a {@link ServiceCall} with a response type of {@link FeedbackList} - */ - public ServiceCall listFeedback() { - return listFeedback(null); - } - - /** - * Get a specified feedback entry. - * - * Gets a feedback entry with a specified `feedback_id`. - * - * @param getFeedbackOptions the {@link GetFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link GetFeedback} - */ - public ServiceCall getFeedback(GetFeedbackOptions getFeedbackOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getFeedbackOptions, - "getFeedbackOptions cannot be null"); - String[] pathSegments = { "v1/feedback" }; - String[] pathParameters = { getFeedbackOptions.feedbackId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getFeedback"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getFeedbackOptions.model() != null) { - builder.query("model", getFeedbackOptions.model()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a specified feedback entry. - * - * Deletes a feedback entry with a specified `feedback_id`. - * - * @param deleteFeedbackOptions the {@link DeleteFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link FeedbackDeleted} - */ - public ServiceCall deleteFeedback(DeleteFeedbackOptions deleteFeedbackOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteFeedbackOptions, - "deleteFeedbackOptions cannot be null"); - String[] pathSegments = { "v1/feedback" }; - String[] pathParameters = { deleteFeedbackOptions.feedbackId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "deleteFeedback"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (deleteFeedbackOptions.model() != null) { - builder.query("model", deleteFeedbackOptions.model()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Submit a batch-processing request. - * - * Run Compare and Comply methods over a collection of input documents. - * - * **Important:** Batch processing requires the use of the [IBM Cloud Object Storage - * service] - * (https://cloud.ibm.com/docs/cloud-object-storage? - * topic=cloud-object-storage-about#about-ibm-cloud-object-storage). - * The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using batch - * processing](https://cloud.ibm.com/docs/compare-comply?topic=compare-comply-batching#before-you-batch). - * - * @param createBatchOptions the {@link CreateBatchOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link BatchStatus} - */ - public ServiceCall createBatch(CreateBatchOptions createBatchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createBatchOptions, - "createBatchOptions cannot be null"); - String[] pathSegments = { "v1/batches" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "createBatch"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("function", createBatchOptions.function()); - if (createBatchOptions.model() != null) { - builder.query("model", createBatchOptions.model()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody inputCredentialsFileBody = RequestUtils.inputStreamBody(createBatchOptions - .inputCredentialsFile(), "application/json"); - multipartBuilder.addFormDataPart("input_credentials_file", "filename", inputCredentialsFileBody); - multipartBuilder.addFormDataPart("input_bucket_location", createBatchOptions.inputBucketLocation()); - multipartBuilder.addFormDataPart("input_bucket_name", createBatchOptions.inputBucketName()); - okhttp3.RequestBody outputCredentialsFileBody = RequestUtils.inputStreamBody(createBatchOptions - .outputCredentialsFile(), "application/json"); - multipartBuilder.addFormDataPart("output_credentials_file", "filename", outputCredentialsFileBody); - multipartBuilder.addFormDataPart("output_bucket_location", createBatchOptions.outputBucketLocation()); - multipartBuilder.addFormDataPart("output_bucket_name", createBatchOptions.outputBucketName()); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List submitted batch-processing jobs. - * - * Lists batch-processing jobs submitted by users. - * - * @param listBatchesOptions the {@link ListBatchesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Batches} - */ - public ServiceCall listBatches(ListBatchesOptions listBatchesOptions) { - String[] pathSegments = { "v1/batches" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "listBatches"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listBatchesOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List submitted batch-processing jobs. - * - * Lists batch-processing jobs submitted by users. - * - * @return a {@link ServiceCall} with a response type of {@link Batches} - */ - public ServiceCall listBatches() { - return listBatches(null); - } - - /** - * Get information about a specific batch-processing job. - * - * Gets information about a batch-processing job with a specified ID. - * - * @param getBatchOptions the {@link GetBatchOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link BatchStatus} - */ - public ServiceCall getBatch(GetBatchOptions getBatchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getBatchOptions, - "getBatchOptions cannot be null"); - String[] pathSegments = { "v1/batches" }; - String[] pathParameters = { getBatchOptions.batchId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getBatch"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update a pending or active batch-processing job. - * - * Updates a pending or active batch-processing job. You can rescan the input bucket to check for new documents or - * cancel a job. - * - * @param updateBatchOptions the {@link UpdateBatchOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link BatchStatus} - */ - public ServiceCall updateBatch(UpdateBatchOptions updateBatchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateBatchOptions, - "updateBatchOptions cannot be null"); - String[] pathSegments = { "v1/batches" }; - String[] pathParameters = { updateBatchOptions.batchId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "updateBatch"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("action", updateBatchOptions.action()); - if (updateBatchOptions.model() != null) { - builder.query("model", updateBatchOptions.model()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java deleted file mode 100644 index 277586484f2..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addFeedback options. - */ -public class AddFeedbackOptions extends GenericModel { - - protected FeedbackDataInput feedbackData; - protected String userId; - protected String comment; - - /** - * Builder. - */ - public static class Builder { - private FeedbackDataInput feedbackData; - private String userId; - private String comment; - - private Builder(AddFeedbackOptions addFeedbackOptions) { - this.feedbackData = addFeedbackOptions.feedbackData; - this.userId = addFeedbackOptions.userId; - this.comment = addFeedbackOptions.comment; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param feedbackData the feedbackData - */ - public Builder(FeedbackDataInput feedbackData) { - this.feedbackData = feedbackData; - } - - /** - * Builds a AddFeedbackOptions. - * - * @return the addFeedbackOptions - */ - public AddFeedbackOptions build() { - return new AddFeedbackOptions(this); - } - - /** - * Set the feedbackData. - * - * @param feedbackData the feedbackData - * @return the AddFeedbackOptions builder - */ - public Builder feedbackData(FeedbackDataInput feedbackData) { - this.feedbackData = feedbackData; - return this; - } - - /** - * Set the userId. - * - * @param userId the userId - * @return the AddFeedbackOptions builder - */ - public Builder userId(String userId) { - this.userId = userId; - return this; - } - - /** - * Set the comment. - * - * @param comment the comment - * @return the AddFeedbackOptions builder - */ - public Builder comment(String comment) { - this.comment = comment; - return this; - } - } - - protected AddFeedbackOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.feedbackData, - "feedbackData cannot be null"); - feedbackData = builder.feedbackData; - userId = builder.userId; - comment = builder.comment; - } - - /** - * New builder. - * - * @return a AddFeedbackOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the feedbackData. - * - * Feedback data for submission. - * - * @return the feedbackData - */ - public FeedbackDataInput feedbackData() { - return feedbackData; - } - - /** - * Gets the userId. - * - * An optional string identifying the user. - * - * @return the userId - */ - public String userId() { - return userId; - } - - /** - * Gets the comment. - * - * An optional comment on or description of the feedback. - * - * @return the comment - */ - public String comment() { - return comment; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java deleted file mode 100644 index ee21e0d3caf..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A party's address. - */ -public class Address extends GenericModel { - - protected String text; - protected Location location; - - /** - * Gets the text. - * - * A string listing the address. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java deleted file mode 100644 index d5b90e0537e..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * AlignedElement. - */ -public class AlignedElement extends GenericModel { - - @SerializedName("element_pair") - protected List elementPair; - @SerializedName("identical_text") - protected Boolean identicalText; - @SerializedName("provenance_ids") - protected List provenanceIds; - @SerializedName("significant_elements") - protected Boolean significantElements; - - /** - * Gets the elementPair. - * - * Identifies two elements that semantically align between the compared documents. - * - * @return the elementPair - */ - public List getElementPair() { - return elementPair; - } - - /** - * Gets the identicalText. - * - * Specifies whether the aligned element is identical. Elements are considered identical despite minor differences - * such as leading punctuation, end-of-sentence punctuation, whitespace, the presence or absence of definite or - * indefinite articles, and others. - * - * @return the identicalText - */ - public Boolean isIdenticalText() { - return identicalText; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the significantElements. - * - * Indicates that the elements aligned are contractual clauses of significance. - * - * @return the significantElements - */ - public Boolean isSignificantElements() { - return significantElements; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java deleted file mode 100644 index 6af5bd47c39..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * List of document attributes. - */ -public class Attribute extends GenericModel { - - /** - * The type of attribute. - */ - public interface Type { - /** Currency. */ - String CURRENCY = "Currency"; - /** DateTime. */ - String DATETIME = "DateTime"; - /** DefinedTerm. */ - String DEFINEDTERM = "DefinedTerm"; - /** Duration. */ - String DURATION = "Duration"; - /** Location. */ - String LOCATION = "Location"; - /** Number. */ - String NUMBER = "Number"; - /** Organization. */ - String ORGANIZATION = "Organization"; - /** Percentage. */ - String PERCENTAGE = "Percentage"; - /** Person. */ - String PERSON = "Person"; - } - - protected String type; - protected String text; - protected Location location; - - /** - * Gets the type. - * - * The type of attribute. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the text. - * - * The text associated with the attribute. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java deleted file mode 100644 index 4211ed4e02d..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The batch-request status. - */ -public class BatchStatus extends GenericModel { - - /** - * The method to be run against the documents. Possible values are `html_conversion`, `element_classification`, and - * `tables`. - */ - public interface Function { - /** element_classification. */ - String ELEMENT_CLASSIFICATION = "element_classification"; - /** html_conversion. */ - String HTML_CONVERSION = "html_conversion"; - /** tables. */ - String TABLES = "tables"; - } - - protected String function; - @SerializedName("input_bucket_location") - protected String inputBucketLocation; - @SerializedName("input_bucket_name") - protected String inputBucketName; - @SerializedName("output_bucket_location") - protected String outputBucketLocation; - @SerializedName("output_bucket_name") - protected String outputBucketName; - @SerializedName("batch_id") - protected String batchId; - @SerializedName("document_counts") - protected DocCounts documentCounts; - protected String status; - protected Date created; - protected Date updated; - - /** - * Gets the function. - * - * The method to be run against the documents. Possible values are `html_conversion`, `element_classification`, and - * `tables`. - * - * @return the function - */ - public String getFunction() { - return function; - } - - /** - * Gets the inputBucketLocation. - * - * The geographical location of the Cloud Object Storage input bucket as listed on the **Endpoint** tab of your COS - * instance; for example, `us-geo`, `eu-geo`, or `ap-geo`. - * - * @return the inputBucketLocation - */ - public String getInputBucketLocation() { - return inputBucketLocation; - } - - /** - * Gets the inputBucketName. - * - * The name of the Cloud Object Storage input bucket. - * - * @return the inputBucketName - */ - public String getInputBucketName() { - return inputBucketName; - } - - /** - * Gets the outputBucketLocation. - * - * The geographical location of the Cloud Object Storage output bucket as listed on the **Endpoint** tab of your COS - * instance; for example, `us-geo`, `eu-geo`, or `ap-geo`. - * - * @return the outputBucketLocation - */ - public String getOutputBucketLocation() { - return outputBucketLocation; - } - - /** - * Gets the outputBucketName. - * - * The name of the Cloud Object Storage output bucket. - * - * @return the outputBucketName - */ - public String getOutputBucketName() { - return outputBucketName; - } - - /** - * Gets the batchId. - * - * The unique identifier for the batch request. - * - * @return the batchId - */ - public String getBatchId() { - return batchId; - } - - /** - * Gets the documentCounts. - * - * Document counts. - * - * @return the documentCounts - */ - public DocCounts getDocumentCounts() { - return documentCounts; - } - - /** - * Gets the status. - * - * The status of the batch request. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the created. - * - * The creation time of the batch request. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The time of the most recent update to the batch request. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java deleted file mode 100644 index 0dd0ff6b13d..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of a successful **List Batches** request. - */ -public class Batches extends GenericModel { - - protected List batches; - - /** - * Gets the batches. - * - * A list of the status of all batch requests. - * - * @return the batches - */ - public List getBatches() { - return batches; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java deleted file mode 100644 index fca73bbd558..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Cells that are not table header, column header, or row header cells. - */ -public class BodyCells extends GenericModel { - - @SerializedName("cell_id") - protected String cellId; - protected Location location; - protected String text; - @SerializedName("row_index_begin") - protected Long rowIndexBegin; - @SerializedName("row_index_end") - protected Long rowIndexEnd; - @SerializedName("column_index_begin") - protected Long columnIndexBegin; - @SerializedName("column_index_end") - protected Long columnIndexEnd; - @SerializedName("row_header_ids") - protected List rowHeaderIds; - @SerializedName("row_header_texts") - protected List rowHeaderTexts; - @SerializedName("row_header_texts_normalized") - protected List rowHeaderTextsNormalized; - @SerializedName("column_header_ids") - protected List columnHeaderIds; - @SerializedName("column_header_texts") - protected List columnHeaderTexts; - @SerializedName("column_header_texts_normalized") - protected List columnHeaderTextsNormalized; - protected List attributes; - - /** - * Gets the cellId. - * - * The unique ID of the cell in the current table. - * - * @return the cellId - */ - public String getCellId() { - return cellId; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The textual contents of this cell from the input document without associated markup content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the rowIndexBegin. - * - * The `begin` index of this cell's `row` location in the current table. - * - * @return the rowIndexBegin - */ - public Long getRowIndexBegin() { - return rowIndexBegin; - } - - /** - * Gets the rowIndexEnd. - * - * The `end` index of this cell's `row` location in the current table. - * - * @return the rowIndexEnd - */ - public Long getRowIndexEnd() { - return rowIndexEnd; - } - - /** - * Gets the columnIndexBegin. - * - * The `begin` index of this cell's `column` location in the current table. - * - * @return the columnIndexBegin - */ - public Long getColumnIndexBegin() { - return columnIndexBegin; - } - - /** - * Gets the columnIndexEnd. - * - * The `end` index of this cell's `column` location in the current table. - * - * @return the columnIndexEnd - */ - public Long getColumnIndexEnd() { - return columnIndexEnd; - } - - /** - * Gets the rowHeaderIds. - * - * An array that contains the `id` value of a row header that is applicable to this body cell. - * - * @return the rowHeaderIds - */ - public List getRowHeaderIds() { - return rowHeaderIds; - } - - /** - * Gets the rowHeaderTexts. - * - * An array that contains the `text` value of a row header that is applicable to this body cell. - * - * @return the rowHeaderTexts - */ - public List getRowHeaderTexts() { - return rowHeaderTexts; - } - - /** - * Gets the rowHeaderTextsNormalized. - * - * If you provide customization input, the normalized version of the row header texts according to the customization; - * otherwise, the same value as `row_header_texts`. - * - * @return the rowHeaderTextsNormalized - */ - public List getRowHeaderTextsNormalized() { - return rowHeaderTextsNormalized; - } - - /** - * Gets the columnHeaderIds. - * - * An array that contains the `id` value of a column header that is applicable to the current cell. - * - * @return the columnHeaderIds - */ - public List getColumnHeaderIds() { - return columnHeaderIds; - } - - /** - * Gets the columnHeaderTexts. - * - * An array that contains the `text` value of a column header that is applicable to the current cell. - * - * @return the columnHeaderTexts - */ - public List getColumnHeaderTexts() { - return columnHeaderTexts; - } - - /** - * Gets the columnHeaderTextsNormalized. - * - * If you provide customization input, the normalized version of the column header texts according to the - * customization; otherwise, the same value as `column_header_texts`. - * - * @return the columnHeaderTextsNormalized - */ - public List getColumnHeaderTextsNormalized() { - return columnHeaderTextsNormalized; - } - - /** - * Gets the attributes. - * - * @return the attributes - */ - public List getAttributes() { - return attributes; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java deleted file mode 100644 index 95a1872aa4a..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information defining an element's subject matter. - */ -public class Category extends GenericModel { - - /** - * The category of the associated element. - */ - public interface Label { - /** Amendments. */ - String AMENDMENTS = "Amendments"; - /** Asset Use. */ - String ASSET_USE = "Asset Use"; - /** Assignments. */ - String ASSIGNMENTS = "Assignments"; - /** Audits. */ - String AUDITS = "Audits"; - /** Business Continuity. */ - String BUSINESS_CONTINUITY = "Business Continuity"; - /** Communication. */ - String COMMUNICATION = "Communication"; - /** Confidentiality. */ - String CONFIDENTIALITY = "Confidentiality"; - /** Deliverables. */ - String DELIVERABLES = "Deliverables"; - /** Delivery. */ - String DELIVERY = "Delivery"; - /** Dispute Resolution. */ - String DISPUTE_RESOLUTION = "Dispute Resolution"; - /** Force Majeure. */ - String FORCE_MAJEURE = "Force Majeure"; - /** Indemnification. */ - String INDEMNIFICATION = "Indemnification"; - /** Insurance. */ - String INSURANCE = "Insurance"; - /** Intellectual Property. */ - String INTELLECTUAL_PROPERTY = "Intellectual Property"; - /** Liability. */ - String LIABILITY = "Liability"; - /** Order of Precedence. */ - String ORDER_OF_PRECEDENCE = "Order of Precedence"; - /** Payment Terms & Billing. */ - String PAYMENT_TERMS_BILLING = "Payment Terms & Billing"; - /** Pricing & Taxes. */ - String PRICING_TAXES = "Pricing & Taxes"; - /** Privacy. */ - String PRIVACY = "Privacy"; - /** Responsibilities. */ - String RESPONSIBILITIES = "Responsibilities"; - /** Safety and Security. */ - String SAFETY_AND_SECURITY = "Safety and Security"; - /** Scope of Work. */ - String SCOPE_OF_WORK = "Scope of Work"; - /** Subcontracts. */ - String SUBCONTRACTS = "Subcontracts"; - /** Term & Termination. */ - String TERM_TERMINATION = "Term & Termination"; - /** Warranties. */ - String WARRANTIES = "Warranties"; - } - - protected String label; - @SerializedName("provenance_ids") - protected List provenanceIds; - - /** - * Builder. - */ - public static class Builder { - private String label; - private List provenanceIds; - - private Builder(Category category) { - this.label = category.label; - this.provenanceIds = category.provenanceIds; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a Category. - * - * @return the category - */ - public Category build() { - return new Category(this); - } - - /** - * Adds an provenanceIds to provenanceIds. - * - * @param provenanceIds the new provenanceIds - * @return the Category builder - */ - public Builder addProvenanceIds(String provenanceIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(provenanceIds, - "provenanceIds cannot be null"); - if (this.provenanceIds == null) { - this.provenanceIds = new ArrayList(); - } - this.provenanceIds.add(provenanceIds); - return this; - } - - /** - * Set the label. - * - * @param label the label - * @return the Category builder - */ - public Builder label(String label) { - this.label = label; - return this; - } - - /** - * Set the provenanceIds. - * Existing provenanceIds will be replaced. - * - * @param provenanceIds the provenanceIds - * @return the Category builder - */ - public Builder provenanceIds(List provenanceIds) { - this.provenanceIds = provenanceIds; - return this; - } - } - - protected Category(Builder builder) { - label = builder.label; - provenanceIds = builder.provenanceIds; - } - - /** - * New builder. - * - * @return a Category builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the label. - * - * The category of the associated element. - * - * @return the label - */ - public String label() { - return label; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List provenanceIds() { - return provenanceIds; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java deleted file mode 100644 index dc4cae6b201..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information defining an element's subject matter. - */ -public class CategoryComparison extends GenericModel { - - /** - * The category of the associated element. - */ - public interface Label { - /** Amendments. */ - String AMENDMENTS = "Amendments"; - /** Asset Use. */ - String ASSET_USE = "Asset Use"; - /** Assignments. */ - String ASSIGNMENTS = "Assignments"; - /** Audits. */ - String AUDITS = "Audits"; - /** Business Continuity. */ - String BUSINESS_CONTINUITY = "Business Continuity"; - /** Communication. */ - String COMMUNICATION = "Communication"; - /** Confidentiality. */ - String CONFIDENTIALITY = "Confidentiality"; - /** Deliverables. */ - String DELIVERABLES = "Deliverables"; - /** Delivery. */ - String DELIVERY = "Delivery"; - /** Dispute Resolution. */ - String DISPUTE_RESOLUTION = "Dispute Resolution"; - /** Force Majeure. */ - String FORCE_MAJEURE = "Force Majeure"; - /** Indemnification. */ - String INDEMNIFICATION = "Indemnification"; - /** Insurance. */ - String INSURANCE = "Insurance"; - /** Intellectual Property. */ - String INTELLECTUAL_PROPERTY = "Intellectual Property"; - /** Liability. */ - String LIABILITY = "Liability"; - /** Order of Precedence. */ - String ORDER_OF_PRECEDENCE = "Order of Precedence"; - /** Payment Terms & Billing. */ - String PAYMENT_TERMS_BILLING = "Payment Terms & Billing"; - /** Pricing & Taxes. */ - String PRICING_TAXES = "Pricing & Taxes"; - /** Privacy. */ - String PRIVACY = "Privacy"; - /** Responsibilities. */ - String RESPONSIBILITIES = "Responsibilities"; - /** Safety and Security. */ - String SAFETY_AND_SECURITY = "Safety and Security"; - /** Scope of Work. */ - String SCOPE_OF_WORK = "Scope of Work"; - /** Subcontracts. */ - String SUBCONTRACTS = "Subcontracts"; - /** Term & Termination. */ - String TERM_TERMINATION = "Term & Termination"; - /** Warranties. */ - String WARRANTIES = "Warranties"; - } - - protected String label; - - /** - * Gets the label. - * - * The category of the associated element. - * - * @return the label - */ - public String getLabel() { - return label; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java deleted file mode 100644 index 7eba34cfc13..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.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 classifyElements options. - */ -public class ClassifyElementsOptions extends GenericModel { - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected InputStream file; - protected String fileContentType; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private InputStream file; - private String fileContentType; - private String model; - - private Builder(ClassifyElementsOptions classifyElementsOptions) { - this.file = classifyElementsOptions.file; - this.fileContentType = classifyElementsOptions.fileContentType; - this.model = classifyElementsOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param file the file - */ - public Builder(InputStream file) { - this.file = file; - } - - /** - * Builds a ClassifyElementsOptions. - * - * @return the classifyElementsOptions - */ - public ClassifyElementsOptions build() { - return new ClassifyElementsOptions(this); - } - - /** - * Set the file. - * - * @param file the file - * @return the ClassifyElementsOptions builder - */ - public Builder file(InputStream file) { - this.file = file; - return this; - } - - /** - * Set the fileContentType. - * - * @param fileContentType the fileContentType - * @return the ClassifyElementsOptions builder - */ - public Builder fileContentType(String fileContentType) { - this.fileContentType = fileContentType; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the ClassifyElementsOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the ClassifyElementsOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file(File file) throws FileNotFoundException { - this.file = new FileInputStream(file); - return this; - } - } - - protected ClassifyElementsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file, - "file cannot be null"); - file = builder.file; - fileContentType = builder.fileContentType; - model = builder.model; - } - - /** - * New builder. - * - * @return a ClassifyElementsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the file. - * - * The document to classify. - * - * @return the file - */ - public InputStream file() { - return file; - } - - /** - * 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 model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java deleted file mode 100644 index 92a655b4622..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The analysis of objects returned by the **Element classification** method. - */ -public class ClassifyReturn extends GenericModel { - - protected Document document; - @SerializedName("model_id") - protected String modelId; - @SerializedName("model_version") - protected String modelVersion; - protected List elements; - @SerializedName("effective_dates") - protected List effectiveDates; - @SerializedName("contract_amounts") - protected List contractAmounts; - @SerializedName("termination_dates") - protected List terminationDates; - @SerializedName("contract_types") - protected List contractTypes; - @SerializedName("contract_terms") - protected List contractTerms; - @SerializedName("payment_terms") - protected List paymentTerms; - @SerializedName("contract_currencies") - protected List contractCurrencies; - protected List tables; - @SerializedName("document_structure") - protected DocStructure documentStructure; - protected List parties; - - /** - * Gets the document. - * - * Basic information about the input document. - * - * @return the document - */ - public Document getDocument() { - return document; - } - - /** - * Gets the modelId. - * - * The analysis model used to classify the input document. For the **Element classification** method, the only valid - * value is `contracts`. - * - * @return the modelId - */ - public String getModelId() { - return modelId; - } - - /** - * Gets the modelVersion. - * - * The version of the analysis model identified by the value of the `model_id` key. - * - * @return the modelVersion - */ - public String getModelVersion() { - return modelVersion; - } - - /** - * Gets the elements. - * - * Document elements identified by the service. - * - * @return the elements - */ - public List getElements() { - return elements; - } - - /** - * Gets the effectiveDates. - * - * The date or dates on which the document becomes effective. - * - * @return the effectiveDates - */ - public List getEffectiveDates() { - return effectiveDates; - } - - /** - * Gets the contractAmounts. - * - * The monetary amounts that identify the total amount of the contract that needs to be paid from one party to - * another. - * - * @return the contractAmounts - */ - public List getContractAmounts() { - return contractAmounts; - } - - /** - * Gets the terminationDates. - * - * The dates on which the document is to be terminated. - * - * @return the terminationDates - */ - public List getTerminationDates() { - return terminationDates; - } - - /** - * Gets the contractTypes. - * - * The contract type as declared in the document. - * - * @return the contractTypes - */ - public List getContractTypes() { - return contractTypes; - } - - /** - * Gets the contractTerms. - * - * The durations of the contract. - * - * @return the contractTerms - */ - public List getContractTerms() { - return contractTerms; - } - - /** - * Gets the paymentTerms. - * - * The document's payment durations. - * - * @return the paymentTerms - */ - public List getPaymentTerms() { - return paymentTerms; - } - - /** - * Gets the contractCurrencies. - * - * The contract currencies as declared in the document. - * - * @return the contractCurrencies - */ - public List getContractCurrencies() { - return contractCurrencies; - } - - /** - * Gets the tables. - * - * Definition of tables identified in the input document. - * - * @return the tables - */ - public List getTables() { - return tables; - } - - /** - * Gets the documentStructure. - * - * The structure of the input document. - * - * @return the documentStructure - */ - public DocStructure getDocumentStructure() { - return documentStructure; - } - - /** - * Gets the parties. - * - * Definitions of the parties identified in the input document. - * - * @return the parties - */ - public List getParties() { - return parties; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java deleted file mode 100644 index 7f90c3f676d..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Column-level cells, each applicable as a header to other cells in the same column as itself, of the current table. - */ -public class ColumnHeaders extends GenericModel { - - @SerializedName("cell_id") - protected String cellId; - protected Map location; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - @SerializedName("row_index_begin") - protected Long rowIndexBegin; - @SerializedName("row_index_end") - protected Long rowIndexEnd; - @SerializedName("column_index_begin") - protected Long columnIndexBegin; - @SerializedName("column_index_end") - protected Long columnIndexEnd; - - /** - * Gets the cellId. - * - * The unique ID of the cell in the current table. - * - * @return the cellId - */ - public String getCellId() { - return cellId; - } - - /** - * Gets the location. - * - * The location of the column header cell in the current table as defined by its `begin` and `end` offsets, - * respectfully, in the input document. - * - * @return the location - */ - public Map getLocation() { - return location; - } - - /** - * Gets the text. - * - * The textual contents of this cell from the input document without associated markup content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * If you provide customization input, the normalized version of the cell text according to the customization; - * otherwise, the same value as `text`. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the rowIndexBegin. - * - * The `begin` index of this cell's `row` location in the current table. - * - * @return the rowIndexBegin - */ - public Long getRowIndexBegin() { - return rowIndexBegin; - } - - /** - * Gets the rowIndexEnd. - * - * The `end` index of this cell's `row` location in the current table. - * - * @return the rowIndexEnd - */ - public Long getRowIndexEnd() { - return rowIndexEnd; - } - - /** - * Gets the columnIndexBegin. - * - * The `begin` index of this cell's `column` location in the current table. - * - * @return the columnIndexBegin - */ - public Long getColumnIndexBegin() { - return columnIndexBegin; - } - - /** - * Gets the columnIndexEnd. - * - * The `end` index of this cell's `column` location in the current table. - * - * @return the columnIndexEnd - */ - public Long getColumnIndexEnd() { - return columnIndexEnd; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java deleted file mode 100644 index 9db1e0b5757..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.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 compareDocuments options. - */ -public class CompareDocumentsOptions extends GenericModel { - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected InputStream file1; - protected InputStream file2; - protected String file1ContentType; - protected String file2ContentType; - protected String file1Label; - protected String file2Label; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private InputStream file1; - private InputStream file2; - private String file1ContentType; - private String file2ContentType; - private String file1Label; - private String file2Label; - private String model; - - private Builder(CompareDocumentsOptions compareDocumentsOptions) { - this.file1 = compareDocumentsOptions.file1; - this.file2 = compareDocumentsOptions.file2; - this.file1ContentType = compareDocumentsOptions.file1ContentType; - this.file2ContentType = compareDocumentsOptions.file2ContentType; - this.file1Label = compareDocumentsOptions.file1Label; - this.file2Label = compareDocumentsOptions.file2Label; - this.model = compareDocumentsOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param file1 the file1 - * @param file2 the file2 - */ - public Builder(InputStream file1, InputStream file2) { - this.file1 = file1; - this.file2 = file2; - } - - /** - * Builds a CompareDocumentsOptions. - * - * @return the compareDocumentsOptions - */ - public CompareDocumentsOptions build() { - return new CompareDocumentsOptions(this); - } - - /** - * Set the file1. - * - * @param file1 the file1 - * @return the CompareDocumentsOptions builder - */ - public Builder file1(InputStream file1) { - this.file1 = file1; - return this; - } - - /** - * Set the file2. - * - * @param file2 the file2 - * @return the CompareDocumentsOptions builder - */ - public Builder file2(InputStream file2) { - this.file2 = file2; - return this; - } - - /** - * Set the file1ContentType. - * - * @param file1ContentType the file1ContentType - * @return the CompareDocumentsOptions builder - */ - public Builder file1ContentType(String file1ContentType) { - this.file1ContentType = file1ContentType; - return this; - } - - /** - * Set the file2ContentType. - * - * @param file2ContentType the file2ContentType - * @return the CompareDocumentsOptions builder - */ - public Builder file2ContentType(String file2ContentType) { - this.file2ContentType = file2ContentType; - return this; - } - - /** - * Set the file1Label. - * - * @param file1Label the file1Label - * @return the CompareDocumentsOptions builder - */ - public Builder file1Label(String file1Label) { - this.file1Label = file1Label; - return this; - } - - /** - * Set the file2Label. - * - * @param file2Label the file2Label - * @return the CompareDocumentsOptions builder - */ - public Builder file2Label(String file2Label) { - this.file2Label = file2Label; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the CompareDocumentsOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the file1. - * - * @param file1 the file1 - * @return the CompareDocumentsOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file1(File file1) throws FileNotFoundException { - this.file1 = new FileInputStream(file1); - return this; - } - - /** - * Set the file2. - * - * @param file2 the file2 - * @return the CompareDocumentsOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file2(File file2) throws FileNotFoundException { - this.file2 = new FileInputStream(file2); - return this; - } - } - - protected CompareDocumentsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file1, - "file1 cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file2, - "file2 cannot be null"); - file1 = builder.file1; - file2 = builder.file2; - file1ContentType = builder.file1ContentType; - file2ContentType = builder.file2ContentType; - file1Label = builder.file1Label; - file2Label = builder.file2Label; - model = builder.model; - } - - /** - * New builder. - * - * @return a CompareDocumentsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the file1. - * - * The first document to compare. - * - * @return the file1 - */ - public InputStream file1() { - return file1; - } - - /** - * Gets the file2. - * - * The second document to compare. - * - * @return the file2 - */ - public InputStream file2() { - return file2; - } - - /** - * Gets the file1ContentType. - * - * The content type of file1. Values for this parameter can be obtained from the HttpMediaType class. - * - * @return the file1ContentType - */ - public String file1ContentType() { - return file1ContentType; - } - - /** - * Gets the file2ContentType. - * - * The content type of file2. Values for this parameter can be obtained from the HttpMediaType class. - * - * @return the file2ContentType - */ - public String file2ContentType() { - return file2ContentType; - } - - /** - * Gets the file1Label. - * - * A text label for the first document. - * - * @return the file1Label - */ - public String file1Label() { - return file1Label; - } - - /** - * Gets the file2Label. - * - * A text label for the second document. - * - * @return the file2Label - */ - public String file2Label() { - return file2Label; - } - - /** - * Gets the model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java deleted file mode 100644 index fba4828b081..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The comparison of the two submitted documents. - */ -public class CompareReturn extends GenericModel { - - @SerializedName("model_id") - protected String modelId; - @SerializedName("model_version") - protected String modelVersion; - protected List documents; - @SerializedName("aligned_elements") - protected List alignedElements; - @SerializedName("unaligned_elements") - protected List unalignedElements; - - /** - * Gets the modelId. - * - * The analysis model used to compare the input documents. For the **Compare two documents** method, the only valid - * value is `contracts`. - * - * @return the modelId - */ - public String getModelId() { - return modelId; - } - - /** - * Gets the modelVersion. - * - * The version of the analysis model identified by the value of the `model_id` key. - * - * @return the modelVersion - */ - public String getModelVersion() { - return modelVersion; - } - - /** - * Gets the documents. - * - * Information about the documents being compared. - * - * @return the documents - */ - public List getDocuments() { - return documents; - } - - /** - * Gets the alignedElements. - * - * A list of pairs of elements that semantically align between the compared documents. - * - * @return the alignedElements - */ - public List getAlignedElements() { - return alignedElements; - } - - /** - * Gets the unalignedElements. - * - * A list of elements that do not semantically align between the compared documents. - * - * @return the unalignedElements - */ - public List getUnalignedElements() { - return unalignedElements; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java deleted file mode 100644 index 157aa3fb048..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A contact. - */ -public class Contact extends GenericModel { - - protected String name; - protected String role; - - /** - * Gets the name. - * - * A string listing the name of the contact. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the role. - * - * A string listing the role of the contact. - * - * @return the role - */ - public String getRole() { - return role; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java deleted file mode 100644 index 240f398c2d9..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Text that is related to the contents of the table and that precedes or follows the current table. - */ -public class Contexts extends GenericModel { - - protected String text; - protected Location location; - - /** - * Gets the text. - * - * The related text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java deleted file mode 100644 index 182d7202df0..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A monetary amount identified in the input document. - */ -public class ContractAmts extends GenericModel { - - /** - * The confidence level in the identification of the contract amount. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - protected Interpretation interpretation; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the contract amount. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The monetary amount. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * The normalized form of the amount, which is listed as a string. This element is optional; it is returned only if - * normalized text exists. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the interpretation. - * - * The details of the normalized text, if applicable. This element is optional; it is returned only if normalized text - * exists. - * - * @return the interpretation - */ - public Interpretation getInterpretation() { - return interpretation; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java deleted file mode 100644 index a9598f0e83c..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The contract currencies that are declared in the document. - */ -public class ContractCurrencies extends GenericModel { - - /** - * The confidence level in the identification of the contract currency. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the contract currency. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The contract currency. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * The normalized form of the contract currency, which is listed as a string in - * [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) format. This element is optional; it is returned only - * if normalized text exists. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java deleted file mode 100644 index 6d0dd8ab1c4..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The duration or durations of the contract. - */ -public class ContractTerms extends GenericModel { - - /** - * The confidence level in the identification of the contract term. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - protected Interpretation interpretation; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the contract term. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The contract term (duration). - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * The normalized form of the contract term, which is listed as a string. This element is optional; it is returned - * only if normalized text exists. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the interpretation. - * - * The details of the normalized text, if applicable. This element is optional; it is returned only if normalized text - * exists. - * - * @return the interpretation - */ - public Interpretation getInterpretation() { - return interpretation; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java deleted file mode 100644 index 59a98bb14e2..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The contract type identified in the input document. - */ -public class ContractTypes extends GenericModel { - - /** - * The confidence level in the identification of the contract type. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the contract type. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The contract type. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java deleted file mode 100644 index f7af848a5e3..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.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 convertToHtml options. - */ -public class ConvertToHtmlOptions extends GenericModel { - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected InputStream file; - protected String fileContentType; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private InputStream file; - private String fileContentType; - private String model; - - private Builder(ConvertToHtmlOptions convertToHtmlOptions) { - this.file = convertToHtmlOptions.file; - this.fileContentType = convertToHtmlOptions.fileContentType; - this.model = convertToHtmlOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param file the file - */ - public Builder(InputStream file) { - this.file = file; - } - - /** - * Builds a ConvertToHtmlOptions. - * - * @return the convertToHtmlOptions - */ - public ConvertToHtmlOptions build() { - return new ConvertToHtmlOptions(this); - } - - /** - * Set the file. - * - * @param file the file - * @return the ConvertToHtmlOptions builder - */ - public Builder file(InputStream file) { - this.file = file; - return this; - } - - /** - * Set the fileContentType. - * - * @param fileContentType the fileContentType - * @return the ConvertToHtmlOptions builder - */ - public Builder fileContentType(String fileContentType) { - this.fileContentType = fileContentType; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the ConvertToHtmlOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the ConvertToHtmlOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file(File file) throws FileNotFoundException { - this.file = new FileInputStream(file); - return this; - } - } - - protected ConvertToHtmlOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file, - "file cannot be null"); - file = builder.file; - fileContentType = builder.fileContentType; - model = builder.model; - } - - /** - * New builder. - * - * @return a ConvertToHtmlOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the file. - * - * The document to convert. - * - * @return the file - */ - public InputStream file() { - return file; - } - - /** - * 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 model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java deleted file mode 100644 index 3a81a34ee50..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.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 createBatch options. - */ -public class CreateBatchOptions extends GenericModel { - - /** - * The Compare and Comply method to run across the submitted input documents. - */ - public interface Function { - /** html_conversion. */ - String HTML_CONVERSION = "html_conversion"; - /** element_classification. */ - String ELEMENT_CLASSIFICATION = "element_classification"; - /** tables. */ - String TABLES = "tables"; - } - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected String function; - protected InputStream inputCredentialsFile; - protected String inputBucketLocation; - protected String inputBucketName; - protected InputStream outputCredentialsFile; - protected String outputBucketLocation; - protected String outputBucketName; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private String function; - private InputStream inputCredentialsFile; - private String inputBucketLocation; - private String inputBucketName; - private InputStream outputCredentialsFile; - private String outputBucketLocation; - private String outputBucketName; - private String model; - - private Builder(CreateBatchOptions createBatchOptions) { - this.function = createBatchOptions.function; - this.inputCredentialsFile = createBatchOptions.inputCredentialsFile; - this.inputBucketLocation = createBatchOptions.inputBucketLocation; - this.inputBucketName = createBatchOptions.inputBucketName; - this.outputCredentialsFile = createBatchOptions.outputCredentialsFile; - this.outputBucketLocation = createBatchOptions.outputBucketLocation; - this.outputBucketName = createBatchOptions.outputBucketName; - this.model = createBatchOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param function the function - * @param inputCredentialsFile the inputCredentialsFile - * @param inputBucketLocation the inputBucketLocation - * @param inputBucketName the inputBucketName - * @param outputCredentialsFile the outputCredentialsFile - * @param outputBucketLocation the outputBucketLocation - * @param outputBucketName the outputBucketName - */ - public Builder(String function, InputStream inputCredentialsFile, String inputBucketLocation, - String inputBucketName, InputStream outputCredentialsFile, String outputBucketLocation, - String outputBucketName) { - this.function = function; - this.inputCredentialsFile = inputCredentialsFile; - this.inputBucketLocation = inputBucketLocation; - this.inputBucketName = inputBucketName; - this.outputCredentialsFile = outputCredentialsFile; - this.outputBucketLocation = outputBucketLocation; - this.outputBucketName = outputBucketName; - } - - /** - * Builds a CreateBatchOptions. - * - * @return the createBatchOptions - */ - public CreateBatchOptions build() { - return new CreateBatchOptions(this); - } - - /** - * Set the function. - * - * @param function the function - * @return the CreateBatchOptions builder - */ - public Builder function(String function) { - this.function = function; - return this; - } - - /** - * Set the inputCredentialsFile. - * - * @param inputCredentialsFile the inputCredentialsFile - * @return the CreateBatchOptions builder - */ - public Builder inputCredentialsFile(InputStream inputCredentialsFile) { - this.inputCredentialsFile = inputCredentialsFile; - return this; - } - - /** - * Set the inputBucketLocation. - * - * @param inputBucketLocation the inputBucketLocation - * @return the CreateBatchOptions builder - */ - public Builder inputBucketLocation(String inputBucketLocation) { - this.inputBucketLocation = inputBucketLocation; - return this; - } - - /** - * Set the inputBucketName. - * - * @param inputBucketName the inputBucketName - * @return the CreateBatchOptions builder - */ - public Builder inputBucketName(String inputBucketName) { - this.inputBucketName = inputBucketName; - return this; - } - - /** - * Set the outputCredentialsFile. - * - * @param outputCredentialsFile the outputCredentialsFile - * @return the CreateBatchOptions builder - */ - public Builder outputCredentialsFile(InputStream outputCredentialsFile) { - this.outputCredentialsFile = outputCredentialsFile; - return this; - } - - /** - * Set the outputBucketLocation. - * - * @param outputBucketLocation the outputBucketLocation - * @return the CreateBatchOptions builder - */ - public Builder outputBucketLocation(String outputBucketLocation) { - this.outputBucketLocation = outputBucketLocation; - return this; - } - - /** - * Set the outputBucketName. - * - * @param outputBucketName the outputBucketName - * @return the CreateBatchOptions builder - */ - public Builder outputBucketName(String outputBucketName) { - this.outputBucketName = outputBucketName; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the CreateBatchOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the inputCredentialsFile. - * - * @param inputCredentialsFile the inputCredentialsFile - * @return the CreateBatchOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder inputCredentialsFile(File inputCredentialsFile) throws FileNotFoundException { - this.inputCredentialsFile = new FileInputStream(inputCredentialsFile); - return this; - } - - /** - * Set the outputCredentialsFile. - * - * @param outputCredentialsFile the outputCredentialsFile - * @return the CreateBatchOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder outputCredentialsFile(File outputCredentialsFile) throws FileNotFoundException { - this.outputCredentialsFile = new FileInputStream(outputCredentialsFile); - return this; - } - } - - protected CreateBatchOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.function, - "function cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.inputCredentialsFile, - "inputCredentialsFile cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.inputBucketLocation, - "inputBucketLocation cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.inputBucketName, - "inputBucketName cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.outputCredentialsFile, - "outputCredentialsFile cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.outputBucketLocation, - "outputBucketLocation cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.outputBucketName, - "outputBucketName cannot be null"); - function = builder.function; - inputCredentialsFile = builder.inputCredentialsFile; - inputBucketLocation = builder.inputBucketLocation; - inputBucketName = builder.inputBucketName; - outputCredentialsFile = builder.outputCredentialsFile; - outputBucketLocation = builder.outputBucketLocation; - outputBucketName = builder.outputBucketName; - model = builder.model; - } - - /** - * New builder. - * - * @return a CreateBatchOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the function. - * - * The Compare and Comply method to run across the submitted input documents. - * - * @return the function - */ - public String function() { - return function; - } - - /** - * Gets the inputCredentialsFile. - * - * A JSON file containing the input Cloud Object Storage credentials. At a minimum, the credentials must enable `READ` - * permissions on the bucket defined by the `input_bucket_name` parameter. - * - * @return the inputCredentialsFile - */ - public InputStream inputCredentialsFile() { - return inputCredentialsFile; - } - - /** - * Gets the inputBucketLocation. - * - * The geographical location of the Cloud Object Storage input bucket as listed on the **Endpoint** tab of your Cloud - * Object Storage instance; for example, `us-geo`, `eu-geo`, or `ap-geo`. - * - * @return the inputBucketLocation - */ - public String inputBucketLocation() { - return inputBucketLocation; - } - - /** - * Gets the inputBucketName. - * - * The name of the Cloud Object Storage input bucket. - * - * @return the inputBucketName - */ - public String inputBucketName() { - return inputBucketName; - } - - /** - * Gets the outputCredentialsFile. - * - * A JSON file that lists the Cloud Object Storage output credentials. At a minimum, the credentials must enable - * `READ` and `WRITE` permissions on the bucket defined by the `output_bucket_name` parameter. - * - * @return the outputCredentialsFile - */ - public InputStream outputCredentialsFile() { - return outputCredentialsFile; - } - - /** - * Gets the outputBucketLocation. - * - * The geographical location of the Cloud Object Storage output bucket as listed on the **Endpoint** tab of your Cloud - * Object Storage instance; for example, `us-geo`, `eu-geo`, or `ap-geo`. - * - * @return the outputBucketLocation - */ - public String outputBucketLocation() { - return outputBucketLocation; - } - - /** - * Gets the outputBucketName. - * - * The name of the Cloud Object Storage output bucket. - * - * @return the outputBucketName - */ - public String outputBucketName() { - return outputBucketName; - } - - /** - * Gets the model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java deleted file mode 100644 index e0c9b4f39ef..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteFeedback options. - */ -public class DeleteFeedbackOptions extends GenericModel { - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected String feedbackId; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private String feedbackId; - private String model; - - private Builder(DeleteFeedbackOptions deleteFeedbackOptions) { - this.feedbackId = deleteFeedbackOptions.feedbackId; - this.model = deleteFeedbackOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param feedbackId the feedbackId - */ - public Builder(String feedbackId) { - this.feedbackId = feedbackId; - } - - /** - * Builds a DeleteFeedbackOptions. - * - * @return the deleteFeedbackOptions - */ - public DeleteFeedbackOptions build() { - return new DeleteFeedbackOptions(this); - } - - /** - * Set the feedbackId. - * - * @param feedbackId the feedbackId - * @return the DeleteFeedbackOptions builder - */ - public Builder feedbackId(String feedbackId) { - this.feedbackId = feedbackId; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the DeleteFeedbackOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - protected DeleteFeedbackOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.feedbackId, - "feedbackId cannot be empty"); - feedbackId = builder.feedbackId; - model = builder.model; - } - - /** - * New builder. - * - * @return a DeleteFeedbackOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the feedbackId. - * - * A string that specifies the feedback entry to be deleted from the document. - * - * @return the feedbackId - */ - public String feedbackId() { - return feedbackId; - } - - /** - * Gets the model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java deleted file mode 100644 index 1b8e613c9e3..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Document counts. - */ -public class DocCounts extends GenericModel { - - protected Long total; - protected Long pending; - protected Long successful; - protected Long failed; - - /** - * Gets the total. - * - * Total number of documents. - * - * @return the total - */ - public Long getTotal() { - return total; - } - - /** - * Gets the pending. - * - * Number of pending documents. - * - * @return the pending - */ - public Long getPending() { - return pending; - } - - /** - * Gets the successful. - * - * Number of documents successfully processed. - * - * @return the successful - */ - public Long getSuccessful() { - return successful; - } - - /** - * Gets the failed. - * - * Number of documents not successfully processed. - * - * @return the failed - */ - public Long getFailed() { - return failed; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java deleted file mode 100644 index 3903e0b1857..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about the parsed input document. - */ -public class DocInfo extends GenericModel { - - protected String html; - protected String title; - protected String hash; - - /** - * Gets the html. - * - * The full text of the parsed document in HTML format. - * - * @return the html - */ - public String getHtml() { - return html; - } - - /** - * Gets the title. - * - * The title of the parsed document. If the service did not detect a title, the value of this element is `null`. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the hash. - * - * The MD5 hash of the input document. - * - * @return the hash - */ - public String getHash() { - return hash; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java deleted file mode 100644 index 4570f10666c..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The structure of the input document. - */ -public class DocStructure extends GenericModel { - - @SerializedName("section_titles") - protected List sectionTitles; - @SerializedName("leading_sentences") - protected List leadingSentences; - protected List paragraphs; - - /** - * Gets the sectionTitles. - * - * An array containing one object per section or subsection identified in the input document. - * - * @return the sectionTitles - */ - public List getSectionTitles() { - return sectionTitles; - } - - /** - * Gets the leadingSentences. - * - * An array containing one object per section or subsection, in parallel with the `section_titles` array, that details - * the leading sentences in the corresponding section or subsection. - * - * @return the leadingSentences - */ - public List getLeadingSentences() { - return leadingSentences; - } - - /** - * Gets the paragraphs. - * - * An array containing one object per paragraph, in parallel with the `section_titles` and `leading_sentences` arrays. - * - * @return the paragraphs - */ - public List getParagraphs() { - return paragraphs; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java deleted file mode 100644 index a8486f316cf..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Basic information about the input document. - */ -public class Document extends GenericModel { - - protected String title; - protected String html; - protected String hash; - protected String label; - - /** - * Gets the title. - * - * Document title, if detected. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the html. - * - * The input document converted into HTML format. - * - * @return the html - */ - public String getHtml() { - return html; - } - - /** - * Gets the hash. - * - * The MD5 hash value of the input document. - * - * @return the hash - */ - public String getHash() { - return hash; - } - - /** - * Gets the label. - * - * The label applied to the input document with the calling method's `file_1_label` or `file_2_label` value. This - * field is specified only in the output of the **Comparing two documents** method. - * - * @return the label - */ - public String getLabel() { - return label; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java deleted file mode 100644 index 64a4a305a09..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An effective date. - */ -public class EffectiveDates extends GenericModel { - - /** - * The confidence level in the identification of the effective date. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the effective date. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The effective date, listed as a string. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * The normalized form of the effective date, which is listed as a string. This element is optional; it is returned - * only if normalized text exists. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java deleted file mode 100644 index 8b925db67b1..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A component part of the document. - */ -public class Element extends GenericModel { - - protected Location location; - protected String text; - protected List types; - protected List categories; - protected List attributes; - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The text of the element. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List getTypes() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List getCategories() { - return categories; - } - - /** - * Gets the attributes. - * - * List of document attributes. - * - * @return the attributes - */ - public List getAttributes() { - return attributes; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java deleted file mode 100644 index 885864ebf45..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A list of `begin` and `end` indexes that indicate the locations of the elements in the input document. - */ -public class ElementLocations extends GenericModel { - - protected Long begin; - protected Long end; - - /** - * Gets the begin. - * - * An integer that indicates the starting position of the element in the input document. - * - * @return the begin - */ - public Long getBegin() { - return begin; - } - - /** - * Gets the end. - * - * An integer that indicates the ending position of the element in the input document. - * - * @return the end - */ - public Long getEnd() { - return end; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java deleted file mode 100644 index 46b02ae318c..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details of semantically aligned elements. - */ -public class ElementPair extends GenericModel { - - @SerializedName("document_label") - protected String documentLabel; - protected String text; - protected Location location; - protected List types; - protected List categories; - protected List attributes; - - /** - * Gets the documentLabel. - * - * The label of the document (that is, the value of either the `file_1_label` or `file_2_label` parameters) in which - * the element occurs. - * - * @return the documentLabel - */ - public String getDocumentLabel() { - return documentLabel; - } - - /** - * Gets the text. - * - * The contents of the element. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List getTypes() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List getCategories() { - return categories; - } - - /** - * Gets the attributes. - * - * List of document attributes. - * - * @return the attributes - */ - public List getAttributes() { - return attributes; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java deleted file mode 100644 index e95a85663a6..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.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 extractTables options. - */ -public class ExtractTablesOptions extends GenericModel { - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected InputStream file; - protected String fileContentType; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private InputStream file; - private String fileContentType; - private String model; - - private Builder(ExtractTablesOptions extractTablesOptions) { - this.file = extractTablesOptions.file; - this.fileContentType = extractTablesOptions.fileContentType; - this.model = extractTablesOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param file the file - */ - public Builder(InputStream file) { - this.file = file; - } - - /** - * Builds a ExtractTablesOptions. - * - * @return the extractTablesOptions - */ - public ExtractTablesOptions build() { - return new ExtractTablesOptions(this); - } - - /** - * Set the file. - * - * @param file the file - * @return the ExtractTablesOptions builder - */ - public Builder file(InputStream file) { - this.file = file; - return this; - } - - /** - * Set the fileContentType. - * - * @param fileContentType the fileContentType - * @return the ExtractTablesOptions builder - */ - public Builder fileContentType(String fileContentType) { - this.fileContentType = fileContentType; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the ExtractTablesOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the ExtractTablesOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file(File file) throws FileNotFoundException { - this.file = new FileInputStream(file); - return this; - } - } - - protected ExtractTablesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file, - "file cannot be null"); - file = builder.file; - fileContentType = builder.fileContentType; - model = builder.model; - } - - /** - * New builder. - * - * @return a ExtractTablesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the file. - * - * The document on which to run table extraction. - * - * @return the file - */ - public InputStream file() { - return file; - } - - /** - * 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 model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java deleted file mode 100644 index 84ebae1586d..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Feedback data for submission. - */ -public class FeedbackDataInput extends GenericModel { - - @SerializedName("feedback_type") - protected String feedbackType; - protected ShortDoc document; - @SerializedName("model_id") - protected String modelId; - @SerializedName("model_version") - protected String modelVersion; - protected Location location; - protected String text; - @SerializedName("original_labels") - protected OriginalLabelsIn originalLabels; - @SerializedName("updated_labels") - protected UpdatedLabelsIn updatedLabels; - - /** - * Builder. - */ - public static class Builder { - private String feedbackType; - private ShortDoc document; - private String modelId; - private String modelVersion; - private Location location; - private String text; - private OriginalLabelsIn originalLabels; - private UpdatedLabelsIn updatedLabels; - - private Builder(FeedbackDataInput feedbackDataInput) { - this.feedbackType = feedbackDataInput.feedbackType; - this.document = feedbackDataInput.document; - this.modelId = feedbackDataInput.modelId; - this.modelVersion = feedbackDataInput.modelVersion; - this.location = feedbackDataInput.location; - this.text = feedbackDataInput.text; - this.originalLabels = feedbackDataInput.originalLabels; - this.updatedLabels = feedbackDataInput.updatedLabels; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param feedbackType the feedbackType - * @param location the location - * @param text the text - * @param originalLabels the originalLabels - * @param updatedLabels the updatedLabels - */ - public Builder(String feedbackType, Location location, String text, OriginalLabelsIn originalLabels, - UpdatedLabelsIn updatedLabels) { - this.feedbackType = feedbackType; - this.location = location; - this.text = text; - this.originalLabels = originalLabels; - this.updatedLabels = updatedLabels; - } - - /** - * Builds a FeedbackDataInput. - * - * @return the feedbackDataInput - */ - public FeedbackDataInput build() { - return new FeedbackDataInput(this); - } - - /** - * Set the feedbackType. - * - * @param feedbackType the feedbackType - * @return the FeedbackDataInput builder - */ - public Builder feedbackType(String feedbackType) { - this.feedbackType = feedbackType; - return this; - } - - /** - * Set the document. - * - * @param document the document - * @return the FeedbackDataInput builder - */ - public Builder document(ShortDoc document) { - this.document = document; - return this; - } - - /** - * Set the modelId. - * - * @param modelId the modelId - * @return the FeedbackDataInput builder - */ - public Builder modelId(String modelId) { - this.modelId = modelId; - return this; - } - - /** - * Set the modelVersion. - * - * @param modelVersion the modelVersion - * @return the FeedbackDataInput builder - */ - public Builder modelVersion(String modelVersion) { - this.modelVersion = modelVersion; - return this; - } - - /** - * Set the location. - * - * @param location the location - * @return the FeedbackDataInput builder - */ - public Builder location(Location location) { - this.location = location; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the FeedbackDataInput builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the originalLabels. - * - * @param originalLabels the originalLabels - * @return the FeedbackDataInput builder - */ - public Builder originalLabels(OriginalLabelsIn originalLabels) { - this.originalLabels = originalLabels; - return this; - } - - /** - * Set the updatedLabels. - * - * @param updatedLabels the updatedLabels - * @return the FeedbackDataInput builder - */ - public Builder updatedLabels(UpdatedLabelsIn updatedLabels) { - this.updatedLabels = updatedLabels; - return this; - } - } - - protected FeedbackDataInput(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.feedbackType, - "feedbackType cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.location, - "location cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.originalLabels, - "originalLabels cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.updatedLabels, - "updatedLabels cannot be null"); - feedbackType = builder.feedbackType; - document = builder.document; - modelId = builder.modelId; - modelVersion = builder.modelVersion; - location = builder.location; - text = builder.text; - originalLabels = builder.originalLabels; - updatedLabels = builder.updatedLabels; - } - - /** - * New builder. - * - * @return a FeedbackDataInput builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the feedbackType. - * - * The type of feedback. The only permitted value is `element_classification`. - * - * @return the feedbackType - */ - public String feedbackType() { - return feedbackType; - } - - /** - * Gets the document. - * - * Brief information about the input document. - * - * @return the document - */ - public ShortDoc document() { - return document; - } - - /** - * Gets the modelId. - * - * An optional string identifying the model ID. The only permitted value is `contracts`. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } - - /** - * Gets the modelVersion. - * - * An optional string identifying the version of the model used. - * - * @return the modelVersion - */ - public String modelVersion() { - return modelVersion; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location location() { - return location; - } - - /** - * Gets the text. - * - * The text on which to submit feedback. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the originalLabels. - * - * The original labeling from the input document, without the submitted feedback. - * - * @return the originalLabels - */ - public OriginalLabelsIn originalLabels() { - return originalLabels; - } - - /** - * Gets the updatedLabels. - * - * The updated labeling from the input document, accounting for the submitted feedback. - * - * @return the updatedLabels - */ - public UpdatedLabelsIn updatedLabels() { - return updatedLabels; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java deleted file mode 100644 index 82a3b9e276f..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information returned from the **Add Feedback** method. - */ -public class FeedbackDataOutput extends GenericModel { - - @SerializedName("feedback_type") - protected String feedbackType; - protected ShortDoc document; - @SerializedName("model_id") - protected String modelId; - @SerializedName("model_version") - protected String modelVersion; - protected Location location; - protected String text; - @SerializedName("original_labels") - protected OriginalLabelsOut originalLabels; - @SerializedName("updated_labels") - protected UpdatedLabelsOut updatedLabels; - protected Pagination pagination; - - /** - * Gets the feedbackType. - * - * A string identifying the user adding the feedback. The only permitted value is `element_classification`. - * - * @return the feedbackType - */ - public String getFeedbackType() { - return feedbackType; - } - - /** - * Gets the document. - * - * Brief information about the input document. - * - * @return the document - */ - public ShortDoc getDocument() { - return document; - } - - /** - * Gets the modelId. - * - * An optional string identifying the model ID. The only permitted value is `contracts`. - * - * @return the modelId - */ - public String getModelId() { - return modelId; - } - - /** - * Gets the modelVersion. - * - * An optional string identifying the version of the model used. - * - * @return the modelVersion - */ - public String getModelVersion() { - return modelVersion; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The text to which the feedback applies. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the originalLabels. - * - * The original labeling from the input document, without the submitted feedback. - * - * @return the originalLabels - */ - public OriginalLabelsOut getOriginalLabels() { - return originalLabels; - } - - /** - * Gets the updatedLabels. - * - * The updated labeling from the input document, accounting for the submitted feedback. - * - * @return the updatedLabels - */ - public UpdatedLabelsOut getUpdatedLabels() { - return updatedLabels; - } - - /** - * Gets the pagination. - * - * Pagination details, if required by the length of the output. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java deleted file mode 100644 index a6854dc4927..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The status and message of the deletion request. - */ -public class FeedbackDeleted extends GenericModel { - - protected Long status; - protected String message; - - /** - * Gets the status. - * - * HTTP return code. - * - * @return the status - */ - public Long getStatus() { - return status; - } - - /** - * Gets the message. - * - * Status message returned from the service. - * - * @return the message - */ - public String getMessage() { - return message; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java deleted file mode 100644 index 9b34a7d396e..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of a successful **List Feedback** request for all feedback. - */ -public class FeedbackList extends GenericModel { - - protected List feedback; - - /** - * Gets the feedback. - * - * A list of all feedback for the document. - * - * @return the feedback - */ - public List getFeedback() { - return feedback; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java deleted file mode 100644 index 89a19b96ef5..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about the document and the submitted feedback. - */ -public class FeedbackReturn extends GenericModel { - - @SerializedName("feedback_id") - protected String feedbackId; - @SerializedName("user_id") - protected String userId; - protected String comment; - protected Date created; - @SerializedName("feedback_data") - protected FeedbackDataOutput feedbackData; - - /** - * Gets the feedbackId. - * - * The unique ID of the feedback object. - * - * @return the feedbackId - */ - public String getFeedbackId() { - return feedbackId; - } - - /** - * Gets the userId. - * - * An optional string identifying the person submitting feedback. - * - * @return the userId - */ - public String getUserId() { - return userId; - } - - /** - * Gets the comment. - * - * An optional comment from the person submitting the feedback. - * - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * Gets the created. - * - * Timestamp listing the creation time of the feedback submission. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the feedbackData. - * - * Information returned from the **Add Feedback** method. - * - * @return the feedbackData - */ - public FeedbackDataOutput getFeedbackData() { - return feedbackData; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java deleted file mode 100644 index efd1e1fead8..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getBatch options. - */ -public class GetBatchOptions extends GenericModel { - - protected String batchId; - - /** - * Builder. - */ - public static class Builder { - private String batchId; - - private Builder(GetBatchOptions getBatchOptions) { - this.batchId = getBatchOptions.batchId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param batchId the batchId - */ - public Builder(String batchId) { - this.batchId = batchId; - } - - /** - * Builds a GetBatchOptions. - * - * @return the getBatchOptions - */ - public GetBatchOptions build() { - return new GetBatchOptions(this); - } - - /** - * Set the batchId. - * - * @param batchId the batchId - * @return the GetBatchOptions builder - */ - public Builder batchId(String batchId) { - this.batchId = batchId; - return this; - } - } - - protected GetBatchOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.batchId, - "batchId cannot be empty"); - batchId = builder.batchId; - } - - /** - * New builder. - * - * @return a GetBatchOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the batchId. - * - * The ID of the batch-processing job whose information you want to retrieve. - * - * @return the batchId - */ - public String batchId() { - return batchId; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java deleted file mode 100644 index 8e795ebfffe..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of a successful **Get Feedback** request for a single feedback entry. - */ -public class GetFeedback extends GenericModel { - - @SerializedName("feedback_id") - protected String feedbackId; - protected Date created; - protected String comment; - @SerializedName("feedback_data") - protected FeedbackDataOutput feedbackData; - - /** - * Gets the feedbackId. - * - * A string uniquely identifying the feedback entry. - * - * @return the feedbackId - */ - public String getFeedbackId() { - return feedbackId; - } - - /** - * Gets the created. - * - * A timestamp identifying the creation time of the feedback entry. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the comment. - * - * A string containing the user's comment about the feedback entry. - * - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * Gets the feedbackData. - * - * Information returned from the **Add Feedback** method. - * - * @return the feedbackData - */ - public FeedbackDataOutput getFeedbackData() { - return feedbackData; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java deleted file mode 100644 index 943de3981f3..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getFeedback options. - */ -public class GetFeedbackOptions extends GenericModel { - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected String feedbackId; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private String feedbackId; - private String model; - - private Builder(GetFeedbackOptions getFeedbackOptions) { - this.feedbackId = getFeedbackOptions.feedbackId; - this.model = getFeedbackOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param feedbackId the feedbackId - */ - public Builder(String feedbackId) { - this.feedbackId = feedbackId; - } - - /** - * Builds a GetFeedbackOptions. - * - * @return the getFeedbackOptions - */ - public GetFeedbackOptions build() { - return new GetFeedbackOptions(this); - } - - /** - * Set the feedbackId. - * - * @param feedbackId the feedbackId - * @return the GetFeedbackOptions builder - */ - public Builder feedbackId(String feedbackId) { - this.feedbackId = feedbackId; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the GetFeedbackOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - protected GetFeedbackOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.feedbackId, - "feedbackId cannot be empty"); - feedbackId = builder.feedbackId; - model = builder.model; - } - - /** - * New builder. - * - * @return a GetFeedbackOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the feedbackId. - * - * A string that specifies the feedback entry to be included in the output. - * - * @return the feedbackId - */ - public String feedbackId() { - return feedbackId; - } - - /** - * Gets the model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java deleted file mode 100644 index 5650bfafd49..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The HTML converted from an input document. - */ -public class HTMLReturn extends GenericModel { - - @SerializedName("num_pages") - protected String numPages; - protected String author; - @SerializedName("publication_date") - protected String publicationDate; - protected String title; - protected String html; - - /** - * Gets the numPages. - * - * The number of pages in the input document. - * - * @return the numPages - */ - public String getNumPages() { - return numPages; - } - - /** - * Gets the author. - * - * The author of the input document, if identified. - * - * @return the author - */ - public String getAuthor() { - return author; - } - - /** - * Gets the publicationDate. - * - * The publication date of the input document, if identified. - * - * @return the publicationDate - */ - public String getPublicationDate() { - return publicationDate; - } - - /** - * Gets the title. - * - * The title of the input document, if identified. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the html. - * - * The HTML version of the input document. - * - * @return the html - */ - public String getHtml() { - return html; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java deleted file mode 100644 index d8501c148ed..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The details of the normalized text, if applicable. This element is optional; it is returned only if normalized text - * exists. - */ -public class Interpretation extends GenericModel { - - protected String value; - @SerializedName("numeric_value") - protected Double numericValue; - protected String unit; - - /** - * Gets the value. - * - * The value that was located in the normalized text. - * - * @return the value - */ - public String getValue() { - return value; - } - - /** - * Gets the numericValue. - * - * An integer or float expressing the numeric value of the `value` key. - * - * @return the numericValue - */ - public Double getNumericValue() { - return numericValue; - } - - /** - * Gets the unit. - * - * A string listing the unit of the value that was found in the normalized text. - * - * **Note:** The value of `unit` is the [ISO-4217 currency code](https://www.iso.org/iso-4217-currency-codes.html) - * identified for the currency amount (for example, `USD` or `EUR`). If the service cannot disambiguate a currency - * symbol (for example, `$` or `£`), the value of `unit` contains the ambiguous symbol as-is. - * - * @return the unit - */ - public String getUnit() { - return unit; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java deleted file mode 100644 index ab8a4da847d..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A key in a key-value pair. - */ -public class Key extends GenericModel { - - @SerializedName("cell_id") - protected String cellId; - protected Location location; - protected String text; - - /** - * Gets the cellId. - * - * The unique ID of the key in the table. - * - * @return the cellId - */ - public String getCellId() { - return cellId; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The text content of the table cell without HTML markup. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java deleted file mode 100644 index 45aeadb64e2..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Key-value pairs detected across cell boundaries. - */ -public class KeyValuePair extends GenericModel { - - protected Key key; - protected List value; - - /** - * Gets the key. - * - * A key in a key-value pair. - * - * @return the key - */ - public Key getKey() { - return key; - } - - /** - * Gets the value. - * - * A list of values in a key-value pair. - * - * @return the value - */ - public List getValue() { - return value; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java deleted file mode 100644 index 7aae6339b8a..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A pair of `nature` and `party` objects. The `nature` object identifies the effect of the element on the identified - * `party`, and the `party` object identifies the affected party. - */ -public class Label extends GenericModel { - - protected String nature; - protected String party; - - /** - * Builder. - */ - public static class Builder { - private String nature; - private String party; - - private Builder(Label label) { - this.nature = label.nature; - this.party = label.party; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param nature the nature - * @param party the party - */ - public Builder(String nature, String party) { - this.nature = nature; - this.party = party; - } - - /** - * Builds a Label. - * - * @return the label - */ - public Label build() { - return new Label(this); - } - - /** - * Set the nature. - * - * @param nature the nature - * @return the Label builder - */ - public Builder nature(String nature) { - this.nature = nature; - return this; - } - - /** - * Set the party. - * - * @param party the party - * @return the Label builder - */ - public Builder party(String party) { - this.party = party; - return this; - } - } - - protected Label(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.nature, - "nature cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.party, - "party cannot be null"); - nature = builder.nature; - party = builder.party; - } - - /** - * New builder. - * - * @return a Label builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the nature. - * - * The identified `nature` of the element. - * - * @return the nature - */ - public String nature() { - return nature; - } - - /** - * Gets the party. - * - * The identified `party` of the element. - * - * @return the party - */ - public String party() { - return party; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java deleted file mode 100644 index 0d8210616be..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The leading sentences in a section or subsection of the input document. - */ -public class LeadingSentence extends GenericModel { - - protected String text; - protected Location location; - @SerializedName("element_locations") - protected List elementLocations; - - /** - * Gets the text. - * - * The text of the leading sentence. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the elementLocations. - * - * An array of `location` objects that lists the locations of detected leading sentences. - * - * @return the elementLocations - */ - public List getElementLocations() { - return elementLocations; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java deleted file mode 100644 index d58582e963a..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listBatches options. - */ -public class ListBatchesOptions extends GenericModel { - - /** - * Builder. - */ - public static class Builder { - - private Builder(ListBatchesOptions listBatchesOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListBatchesOptions. - * - * @return the listBatchesOptions - */ - public ListBatchesOptions build() { - return new ListBatchesOptions(this); - } - } - - private ListBatchesOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListBatchesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java deleted file mode 100644 index 3f71b90acfa..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.Date; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listFeedback options. - */ -public class ListFeedbackOptions extends GenericModel { - - protected String feedbackType; - protected Date before; - protected Date after; - protected String documentTitle; - protected String modelId; - protected String modelVersion; - protected String categoryRemoved; - protected String categoryAdded; - protected String categoryNotChanged; - protected String typeRemoved; - protected String typeAdded; - protected String typeNotChanged; - protected Long pageLimit; - protected String cursor; - protected String sort; - protected Boolean includeTotal; - - /** - * Builder. - */ - public static class Builder { - private String feedbackType; - private Date before; - private Date after; - private String documentTitle; - private String modelId; - private String modelVersion; - private String categoryRemoved; - private String categoryAdded; - private String categoryNotChanged; - private String typeRemoved; - private String typeAdded; - private String typeNotChanged; - private Long pageLimit; - private String cursor; - private String sort; - private Boolean includeTotal; - - private Builder(ListFeedbackOptions listFeedbackOptions) { - this.feedbackType = listFeedbackOptions.feedbackType; - this.before = listFeedbackOptions.before; - this.after = listFeedbackOptions.after; - this.documentTitle = listFeedbackOptions.documentTitle; - this.modelId = listFeedbackOptions.modelId; - this.modelVersion = listFeedbackOptions.modelVersion; - this.categoryRemoved = listFeedbackOptions.categoryRemoved; - this.categoryAdded = listFeedbackOptions.categoryAdded; - this.categoryNotChanged = listFeedbackOptions.categoryNotChanged; - this.typeRemoved = listFeedbackOptions.typeRemoved; - this.typeAdded = listFeedbackOptions.typeAdded; - this.typeNotChanged = listFeedbackOptions.typeNotChanged; - this.pageLimit = listFeedbackOptions.pageLimit; - this.cursor = listFeedbackOptions.cursor; - this.sort = listFeedbackOptions.sort; - this.includeTotal = listFeedbackOptions.includeTotal; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListFeedbackOptions. - * - * @return the listFeedbackOptions - */ - public ListFeedbackOptions build() { - return new ListFeedbackOptions(this); - } - - /** - * Set the feedbackType. - * - * @param feedbackType the feedbackType - * @return the ListFeedbackOptions builder - */ - public Builder feedbackType(String feedbackType) { - this.feedbackType = feedbackType; - return this; - } - - /** - * Set the before. - * - * @param before the before - * @return the ListFeedbackOptions builder - */ - public Builder before(Date before) { - this.before = before; - return this; - } - - /** - * Set the after. - * - * @param after the after - * @return the ListFeedbackOptions builder - */ - public Builder after(Date after) { - this.after = after; - return this; - } - - /** - * Set the documentTitle. - * - * @param documentTitle the documentTitle - * @return the ListFeedbackOptions builder - */ - public Builder documentTitle(String documentTitle) { - this.documentTitle = documentTitle; - return this; - } - - /** - * Set the modelId. - * - * @param modelId the modelId - * @return the ListFeedbackOptions builder - */ - public Builder modelId(String modelId) { - this.modelId = modelId; - return this; - } - - /** - * Set the modelVersion. - * - * @param modelVersion the modelVersion - * @return the ListFeedbackOptions builder - */ - public Builder modelVersion(String modelVersion) { - this.modelVersion = modelVersion; - return this; - } - - /** - * Set the categoryRemoved. - * - * @param categoryRemoved the categoryRemoved - * @return the ListFeedbackOptions builder - */ - public Builder categoryRemoved(String categoryRemoved) { - this.categoryRemoved = categoryRemoved; - return this; - } - - /** - * Set the categoryAdded. - * - * @param categoryAdded the categoryAdded - * @return the ListFeedbackOptions builder - */ - public Builder categoryAdded(String categoryAdded) { - this.categoryAdded = categoryAdded; - return this; - } - - /** - * Set the categoryNotChanged. - * - * @param categoryNotChanged the categoryNotChanged - * @return the ListFeedbackOptions builder - */ - public Builder categoryNotChanged(String categoryNotChanged) { - this.categoryNotChanged = categoryNotChanged; - return this; - } - - /** - * Set the typeRemoved. - * - * @param typeRemoved the typeRemoved - * @return the ListFeedbackOptions builder - */ - public Builder typeRemoved(String typeRemoved) { - this.typeRemoved = typeRemoved; - return this; - } - - /** - * Set the typeAdded. - * - * @param typeAdded the typeAdded - * @return the ListFeedbackOptions builder - */ - public Builder typeAdded(String typeAdded) { - this.typeAdded = typeAdded; - return this; - } - - /** - * Set the typeNotChanged. - * - * @param typeNotChanged the typeNotChanged - * @return the ListFeedbackOptions builder - */ - public Builder typeNotChanged(String typeNotChanged) { - this.typeNotChanged = typeNotChanged; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListFeedbackOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = pageLimit; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListFeedbackOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the ListFeedbackOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the includeTotal. - * - * @param includeTotal the includeTotal - * @return the ListFeedbackOptions builder - */ - public Builder includeTotal(Boolean includeTotal) { - this.includeTotal = includeTotal; - return this; - } - } - - protected ListFeedbackOptions(Builder builder) { - feedbackType = builder.feedbackType; - before = builder.before; - after = builder.after; - documentTitle = builder.documentTitle; - modelId = builder.modelId; - modelVersion = builder.modelVersion; - categoryRemoved = builder.categoryRemoved; - categoryAdded = builder.categoryAdded; - categoryNotChanged = builder.categoryNotChanged; - typeRemoved = builder.typeRemoved; - typeAdded = builder.typeAdded; - typeNotChanged = builder.typeNotChanged; - pageLimit = builder.pageLimit; - cursor = builder.cursor; - sort = builder.sort; - includeTotal = builder.includeTotal; - } - - /** - * New builder. - * - * @return a ListFeedbackOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the feedbackType. - * - * An optional string that filters the output to include only feedback with the specified feedback type. The only - * permitted value is `element_classification`. - * - * @return the feedbackType - */ - public String feedbackType() { - return feedbackType; - } - - /** - * Gets the before. - * - * An optional string in the format `YYYY-MM-DD` that filters the output to include only feedback that was added - * before the specified date. - * - * @return the before - */ - public Date before() { - return before; - } - - /** - * Gets the after. - * - * An optional string in the format `YYYY-MM-DD` that filters the output to include only feedback that was added after - * the specified date. - * - * @return the after - */ - public Date after() { - return after; - } - - /** - * Gets the documentTitle. - * - * An optional string that filters the output to include only feedback from the document with the specified - * `document_title`. - * - * @return the documentTitle - */ - public String documentTitle() { - return documentTitle; - } - - /** - * Gets the modelId. - * - * An optional string that filters the output to include only feedback with the specified `model_id`. The only - * permitted value is `contracts`. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } - - /** - * Gets the modelVersion. - * - * An optional string that filters the output to include only feedback with the specified `model_version`. - * - * @return the modelVersion - */ - public String modelVersion() { - return modelVersion; - } - - /** - * Gets the categoryRemoved. - * - * An optional string in the form of a comma-separated list of categories. If it is specified, the service filters the - * output to include only feedback that has at least one category from the list removed. - * - * @return the categoryRemoved - */ - public String categoryRemoved() { - return categoryRemoved; - } - - /** - * Gets the categoryAdded. - * - * An optional string in the form of a comma-separated list of categories. If this is specified, the service filters - * the output to include only feedback that has at least one category from the list added. - * - * @return the categoryAdded - */ - public String categoryAdded() { - return categoryAdded; - } - - /** - * Gets the categoryNotChanged. - * - * An optional string in the form of a comma-separated list of categories. If this is specified, the service filters - * the output to include only feedback that has at least one category from the list unchanged. - * - * @return the categoryNotChanged - */ - public String categoryNotChanged() { - return categoryNotChanged; - } - - /** - * Gets the typeRemoved. - * - * An optional string of comma-separated `nature`:`party` pairs. If this is specified, the service filters the output - * to include only feedback that has at least one `nature`:`party` pair from the list removed. - * - * @return the typeRemoved - */ - public String typeRemoved() { - return typeRemoved; - } - - /** - * Gets the typeAdded. - * - * An optional string of comma-separated `nature`:`party` pairs. If this is specified, the service filters the output - * to include only feedback that has at least one `nature`:`party` pair from the list removed. - * - * @return the typeAdded - */ - public String typeAdded() { - return typeAdded; - } - - /** - * Gets the typeNotChanged. - * - * An optional string of comma-separated `nature`:`party` pairs. If this is specified, the service filters the output - * to include only feedback that has at least one `nature`:`party` pair from the list unchanged. - * - * @return the typeNotChanged - */ - public String typeNotChanged() { - return typeNotChanged; - } - - /** - * Gets the pageLimit. - * - * An optional integer specifying the number of documents that you want the service to return. - * - * @return the pageLimit - */ - public Long pageLimit() { - return pageLimit; - } - - /** - * Gets the cursor. - * - * An optional string that returns the set of documents after the previous set. Use this parameter with the - * `page_limit` parameter. - * - * @return the cursor - */ - public String cursor() { - return cursor; - } - - /** - * Gets the sort. - * - * An optional comma-separated list of fields in the document to sort on. You can optionally specify the sort - * direction by prefixing the value of the field with `-` for descending order or `+` for ascending order (the - * default). Currently permitted sorting fields are `created`, `user_id`, and `document_title`. - * - * @return the sort - */ - public String sort() { - return sort; - } - - /** - * Gets the includeTotal. - * - * An optional boolean value. If specified as `true`, the `pagination` object in the output includes a value called - * `total` that gives the total count of feedback created. - * - * @return the includeTotal - */ - public Boolean includeTotal() { - return includeTotal; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java deleted file mode 100644 index bcb5f70ac6d..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - */ -public class Location extends GenericModel { - - protected Long begin; - protected Long end; - - /** - * Builder. - */ - public static class Builder { - private Long begin; - private Long end; - - private Builder(Location location) { - this.begin = location.begin; - this.end = location.end; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param begin the begin - * @param end the end - */ - public Builder(Long begin, Long end) { - this.begin = begin; - this.end = end; - } - - /** - * Builds a Location. - * - * @return the location - */ - public Location build() { - return new Location(this); - } - - /** - * Set the begin. - * - * @param begin the begin - * @return the Location builder - */ - public Builder begin(long begin) { - this.begin = begin; - return this; - } - - /** - * Set the end. - * - * @param end the end - * @return the Location builder - */ - public Builder end(long end) { - this.end = end; - return this; - } - } - - protected Location(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.begin, - "begin cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.end, - "end cannot be null"); - begin = builder.begin; - end = builder.end; - } - - /** - * New builder. - * - * @return a Location builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the begin. - * - * The element's `begin` index. - * - * @return the begin - */ - public Long begin() { - return begin; - } - - /** - * Gets the end. - * - * The element's `end` index. - * - * @return the end - */ - public Long end() { - return end; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java deleted file mode 100644 index c044628a7ef..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A mention of a party. - */ -public class Mention extends GenericModel { - - protected String text; - protected Location location; - - /** - * Gets the text. - * - * The name of the party. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java deleted file mode 100644 index 7ed00b9517f..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The original labeling from the input document, without the submitted feedback. - */ -public class OriginalLabelsIn extends GenericModel { - - protected List types; - protected List categories; - - /** - * Builder. - */ - public static class Builder { - private List types; - private List categories; - - private Builder(OriginalLabelsIn originalLabelsIn) { - this.types = originalLabelsIn.types; - this.categories = originalLabelsIn.categories; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param types the types - * @param categories the categories - */ - public Builder(List types, List categories) { - this.types = types; - this.categories = categories; - } - - /** - * Builds a OriginalLabelsIn. - * - * @return the originalLabelsIn - */ - public OriginalLabelsIn build() { - return new OriginalLabelsIn(this); - } - - /** - * Adds an types to types. - * - * @param types the new types - * @return the OriginalLabelsIn builder - */ - public Builder addTypes(TypeLabel types) { - com.ibm.cloud.sdk.core.util.Validator.notNull(types, - "types cannot be null"); - if (this.types == null) { - this.types = new ArrayList(); - } - this.types.add(types); - return this; - } - - /** - * Adds an categories to categories. - * - * @param categories the new categories - * @return the OriginalLabelsIn builder - */ - public Builder addCategories(Category categories) { - com.ibm.cloud.sdk.core.util.Validator.notNull(categories, - "categories cannot be null"); - if (this.categories == null) { - this.categories = new ArrayList(); - } - this.categories.add(categories); - return this; - } - - /** - * Set the types. - * Existing types will be replaced. - * - * @param types the types - * @return the OriginalLabelsIn builder - */ - public Builder types(List types) { - this.types = types; - return this; - } - - /** - * Set the categories. - * Existing categories will be replaced. - * - * @param categories the categories - * @return the OriginalLabelsIn builder - */ - public Builder categories(List categories) { - this.categories = categories; - return this; - } - } - - protected OriginalLabelsIn(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.types, - "types cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.categories, - "categories cannot be null"); - types = builder.types; - categories = builder.categories; - } - - /** - * New builder. - * - * @return a OriginalLabelsIn builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List types() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List categories() { - return categories; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java deleted file mode 100644 index dc635390157..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The original labeling from the input document, without the submitted feedback. - */ -public class OriginalLabelsOut extends GenericModel { - - /** - * A string identifying the type of modification the feedback entry in the `updated_labels` array. Possible values are - * `added`, `not_changed`, and `removed`. - */ - public interface Modification { - /** added. */ - String ADDED = "added"; - /** not_changed. */ - String NOT_CHANGED = "not_changed"; - /** removed. */ - String REMOVED = "removed"; - } - - protected List types; - protected List categories; - protected String modification; - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List getTypes() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List getCategories() { - return categories; - } - - /** - * Gets the modification. - * - * A string identifying the type of modification the feedback entry in the `updated_labels` array. Possible values are - * `added`, `not_changed`, and `removed`. - * - * @return the modification - */ - public String getModification() { - return modification; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java deleted file mode 100644 index 58669611ca6..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Pagination details, if required by the length of the output. - */ -public class Pagination extends GenericModel { - - @SerializedName("refresh_cursor") - protected String refreshCursor; - @SerializedName("next_cursor") - protected String nextCursor; - @SerializedName("refresh_url") - protected String refreshUrl; - @SerializedName("next_url") - protected String nextUrl; - protected Long total; - - /** - * Gets the refreshCursor. - * - * A token identifying the current page of results. - * - * @return the refreshCursor - */ - public String getRefreshCursor() { - return refreshCursor; - } - - /** - * Gets the nextCursor. - * - * A token identifying the next page of results. - * - * @return the nextCursor - */ - public String getNextCursor() { - return nextCursor; - } - - /** - * Gets the refreshUrl. - * - * The URL that returns the current page of results. - * - * @return the refreshUrl - */ - public String getRefreshUrl() { - return refreshUrl; - } - - /** - * Gets the nextUrl. - * - * The URL that returns the next page of results. - * - * @return the nextUrl - */ - public String getNextUrl() { - return nextUrl; - } - - /** - * Gets the total. - * - * Reserved for future use. - * - * @return the total - */ - public Long getTotal() { - return total; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java deleted file mode 100644 index 38c5ac085b4..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The locations of each paragraph in the input document. - */ -public class Paragraphs extends GenericModel { - - protected Location location; - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java deleted file mode 100644 index 29100779133..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A party and its corresponding role, including address and contact information if identified. - */ -public class Parties extends GenericModel { - - /** - * A string that identifies the importance of the party. - */ - public interface Importance { - /** Primary. */ - String PRIMARY = "Primary"; - /** Unknown. */ - String UNKNOWN = "Unknown"; - } - - protected String party; - protected String role; - protected String importance; - protected List
addresses; - protected List contacts; - protected List mentions; - - /** - * Gets the party. - * - * The normalized form of the party's name. - * - * @return the party - */ - public String getParty() { - return party; - } - - /** - * Gets the role. - * - * A string identifying the party's role. - * - * @return the role - */ - public String getRole() { - return role; - } - - /** - * Gets the importance. - * - * A string that identifies the importance of the party. - * - * @return the importance - */ - public String getImportance() { - return importance; - } - - /** - * Gets the addresses. - * - * A list of the party's address or addresses. - * - * @return the addresses - */ - public List
getAddresses() { - return addresses; - } - - /** - * Gets the contacts. - * - * A list of the names and roles of contacts identified in the input document. - * - * @return the contacts - */ - public List getContacts() { - return contacts; - } - - /** - * Gets the mentions. - * - * A list of the party's mentions in the input document. - * - * @return the mentions - */ - public List getMentions() { - return mentions; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java deleted file mode 100644 index db2b8e1aaa2..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The document's payment duration or durations. - */ -public class PaymentTerms extends GenericModel { - - /** - * The confidence level in the identification of the payment term. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - protected Interpretation interpretation; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the payment term. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The payment term (duration). - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * The normalized form of the payment term, which is listed as a string. This element is optional; it is returned only - * if normalized text exists. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the interpretation. - * - * The details of the normalized text, if applicable. This element is optional; it is returned only if normalized text - * exists. - * - * @return the interpretation - */ - public Interpretation getInterpretation() { - return interpretation; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java deleted file mode 100644 index 1464cc5ef8c..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Row-level cells, each applicable as a header to other cells in the same row as itself, of the current table. - */ -public class RowHeaders extends GenericModel { - - @SerializedName("cell_id") - protected String cellId; - protected Location location; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - @SerializedName("row_index_begin") - protected Long rowIndexBegin; - @SerializedName("row_index_end") - protected Long rowIndexEnd; - @SerializedName("column_index_begin") - protected Long columnIndexBegin; - @SerializedName("column_index_end") - protected Long columnIndexEnd; - - /** - * Gets the cellId. - * - * The unique ID of the cell in the current table. - * - * @return the cellId - */ - public String getCellId() { - return cellId; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The textual contents of this cell from the input document without associated markup content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * If you provide customization input, the normalized version of the cell text according to the customization; - * otherwise, the same value as `text`. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the rowIndexBegin. - * - * The `begin` index of this cell's `row` location in the current table. - * - * @return the rowIndexBegin - */ - public Long getRowIndexBegin() { - return rowIndexBegin; - } - - /** - * Gets the rowIndexEnd. - * - * The `end` index of this cell's `row` location in the current table. - * - * @return the rowIndexEnd - */ - public Long getRowIndexEnd() { - return rowIndexEnd; - } - - /** - * Gets the columnIndexBegin. - * - * The `begin` index of this cell's `column` location in the current table. - * - * @return the columnIndexBegin - */ - public Long getColumnIndexBegin() { - return columnIndexBegin; - } - - /** - * Gets the columnIndexEnd. - * - * The `end` index of this cell's `column` location in the current table. - * - * @return the columnIndexEnd - */ - public Long getColumnIndexEnd() { - return columnIndexEnd; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java deleted file mode 100644 index 36a4b5be950..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The table's section title, if identified. - */ -public class SectionTitle extends GenericModel { - - protected String text; - protected Location location; - - /** - * Gets the text. - * - * The text of the section title, if identified. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java deleted file mode 100644 index 72f61353390..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An array containing one object per section or subsection detected in the input document. Sections and subsections are - * not nested; instead, they are flattened out and can be placed back in order by using the `begin` and `end` values of - * the element and the `level` value of the section. - */ -public class SectionTitles extends GenericModel { - - protected String text; - protected Location location; - protected Long level; - @SerializedName("element_locations") - protected List elementLocations; - - /** - * Gets the text. - * - * The text of the section title, if identified. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the level. - * - * An integer indicating the level at which the section is located in the input document. For example, `1` represents - * a top-level section, `2` represents a subsection within the level `1` section, and so forth. - * - * @return the level - */ - public Long getLevel() { - return level; - } - - /** - * Gets the elementLocations. - * - * An array of `location` objects that lists the locations of detected section titles. - * - * @return the elementLocations - */ - public List getElementLocations() { - return elementLocations; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java deleted file mode 100644 index d32cf3067d9..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Brief information about the input document. - */ -public class ShortDoc extends GenericModel { - - protected String title; - protected String hash; - - /** - * Builder. - */ - public static class Builder { - private String title; - private String hash; - - private Builder(ShortDoc shortDoc) { - this.title = shortDoc.title; - this.hash = shortDoc.hash; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ShortDoc. - * - * @return the shortDoc - */ - public ShortDoc build() { - return new ShortDoc(this); - } - - /** - * Set the title. - * - * @param title the title - * @return the ShortDoc builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the hash. - * - * @param hash the hash - * @return the ShortDoc builder - */ - public Builder hash(String hash) { - this.hash = hash; - return this; - } - } - - protected ShortDoc(Builder builder) { - title = builder.title; - hash = builder.hash; - } - - /** - * New builder. - * - * @return a ShortDoc builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the title. - * - * The title of the input document, if identified. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the hash. - * - * The MD5 hash of the input document. - * - * @return the hash - */ - public String hash() { - return hash; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java deleted file mode 100644 index cc744f27132..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The contents of the current table's header. - */ -public class TableHeaders extends GenericModel { - - @SerializedName("cell_id") - protected String cellId; - protected Map location; - protected String text; - @SerializedName("row_index_begin") - protected Long rowIndexBegin; - @SerializedName("row_index_end") - protected Long rowIndexEnd; - @SerializedName("column_index_begin") - protected Long columnIndexBegin; - @SerializedName("column_index_end") - protected Long columnIndexEnd; - - /** - * Gets the cellId. - * - * The unique ID of the cell in the current table. - * - * @return the cellId - */ - public String getCellId() { - return cellId; - } - - /** - * Gets the location. - * - * The location of the table header cell in the current table as defined by its `begin` and `end` offsets, - * respectfully, in the input document. - * - * @return the location - */ - public Map getLocation() { - return location; - } - - /** - * Gets the text. - * - * The textual contents of the cell from the input document without associated markup content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the rowIndexBegin. - * - * The `begin` index of this cell's `row` location in the current table. - * - * @return the rowIndexBegin - */ - public Long getRowIndexBegin() { - return rowIndexBegin; - } - - /** - * Gets the rowIndexEnd. - * - * The `end` index of this cell's `row` location in the current table. - * - * @return the rowIndexEnd - */ - public Long getRowIndexEnd() { - return rowIndexEnd; - } - - /** - * Gets the columnIndexBegin. - * - * The `begin` index of this cell's `column` location in the current table. - * - * @return the columnIndexBegin - */ - public Long getColumnIndexBegin() { - return columnIndexBegin; - } - - /** - * Gets the columnIndexEnd. - * - * The `end` index of this cell's `column` location in the current table. - * - * @return the columnIndexEnd - */ - public Long getColumnIndexEnd() { - return columnIndexEnd; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java deleted file mode 100644 index 050c4d08693..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The analysis of the document's tables. - */ -public class TableReturn extends GenericModel { - - protected DocInfo document; - @SerializedName("model_id") - protected String modelId; - @SerializedName("model_version") - protected String modelVersion; - protected List tables; - - /** - * Gets the document. - * - * Information about the parsed input document. - * - * @return the document - */ - public DocInfo getDocument() { - return document; - } - - /** - * Gets the modelId. - * - * The ID of the model used to extract the table contents. The value for table extraction is `tables`. - * - * @return the modelId - */ - public String getModelId() { - return modelId; - } - - /** - * Gets the modelVersion. - * - * The version of the `tables` model ID. - * - * @return the modelVersion - */ - public String getModelVersion() { - return modelVersion; - } - - /** - * Gets the tables. - * - * Definitions of the tables identified in the input document. - * - * @return the tables - */ - public List getTables() { - return tables; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java deleted file mode 100644 index 91a129e915f..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * If identified, the title or caption of the current table of the form `Table x.: ...`. Empty when no title is - * identified. When exposed, the `title` is also excluded from the `contexts` array of the same table. - */ -public class TableTitle extends GenericModel { - - protected Location location; - protected String text; - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The text of the identified table title or caption. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java deleted file mode 100644 index f9449bd6afd..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The contents of the tables extracted from a document. - */ -public class Tables extends GenericModel { - - protected Location location; - protected String text; - @SerializedName("section_title") - protected SectionTitle sectionTitle; - protected TableTitle title; - @SerializedName("table_headers") - protected List tableHeaders; - @SerializedName("row_headers") - protected List rowHeaders; - @SerializedName("column_headers") - protected List columnHeaders; - @SerializedName("body_cells") - protected List bodyCells; - protected List contexts; - @SerializedName("key_value_pairs") - protected List keyValuePairs; - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The textual contents of the current table from the input document without associated markup content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the sectionTitle. - * - * The table's section title, if identified. - * - * @return the sectionTitle - */ - public SectionTitle getSectionTitle() { - return sectionTitle; - } - - /** - * Gets the title. - * - * If identified, the title or caption of the current table of the form `Table x.: ...`. Empty when no title is - * identified. When exposed, the `title` is also excluded from the `contexts` array of the same table. - * - * @return the title - */ - public TableTitle getTitle() { - return title; - } - - /** - * Gets the tableHeaders. - * - * An array of table-level cells that apply as headers to all the other cells in the current table. - * - * @return the tableHeaders - */ - public List getTableHeaders() { - return tableHeaders; - } - - /** - * Gets the rowHeaders. - * - * An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current - * table. - * - * @return the rowHeaders - */ - public List getRowHeaders() { - return rowHeaders; - } - - /** - * Gets the columnHeaders. - * - * An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the - * current table. - * - * @return the columnHeaders - */ - public List getColumnHeaders() { - return columnHeaders; - } - - /** - * Gets the bodyCells. - * - * An array of cells that are neither table header nor column header nor row header cells, of the current table with - * corresponding row and column header associations. - * - * @return the bodyCells - */ - public List getBodyCells() { - return bodyCells; - } - - /** - * Gets the contexts. - * - * An array of objects that list text that is related to the table contents and that precedes or follows the current - * table. - * - * @return the contexts - */ - public List getContexts() { - return contexts; - } - - /** - * Gets the keyValuePairs. - * - * An array of key-value pairs identified in the current table. - * - * @return the keyValuePairs - */ - public List getKeyValuePairs() { - return keyValuePairs; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java deleted file mode 100644 index 2a50e500a30..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Termination dates identified in the input document. - */ -public class TerminationDates extends GenericModel { - - /** - * The confidence level in the identification of the termination date. - */ - public interface ConfidenceLevel { - /** High. */ - String HIGH = "High"; - /** Medium. */ - String MEDIUM = "Medium"; - /** Low. */ - String LOW = "Low"; - } - - @SerializedName("confidence_level") - protected String confidenceLevel; - protected String text; - @SerializedName("text_normalized") - protected String textNormalized; - @SerializedName("provenance_ids") - protected List provenanceIds; - protected Location location; - - /** - * Gets the confidenceLevel. - * - * The confidence level in the identification of the termination date. - * - * @return the confidenceLevel - */ - public String getConfidenceLevel() { - return confidenceLevel; - } - - /** - * Gets the text. - * - * The termination date. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the textNormalized. - * - * The normalized form of the termination date, which is listed as a string. This element is optional; it is returned - * only if normalized text exists. - * - * @return the textNormalized - */ - public String getTextNormalized() { - return textNormalized; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List getProvenanceIds() { - return provenanceIds; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java deleted file mode 100644 index 408dd7a2174..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Identification of a specific type. - */ -public class TypeLabel extends GenericModel { - - protected Label label; - @SerializedName("provenance_ids") - protected List provenanceIds; - - /** - * Builder. - */ - public static class Builder { - private Label label; - private List provenanceIds; - - private Builder(TypeLabel typeLabel) { - this.label = typeLabel.label; - this.provenanceIds = typeLabel.provenanceIds; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a TypeLabel. - * - * @return the typeLabel - */ - public TypeLabel build() { - return new TypeLabel(this); - } - - /** - * Adds an provenanceIds to provenanceIds. - * - * @param provenanceIds the new provenanceIds - * @return the TypeLabel builder - */ - public Builder addProvenanceIds(String provenanceIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(provenanceIds, - "provenanceIds cannot be null"); - if (this.provenanceIds == null) { - this.provenanceIds = new ArrayList(); - } - this.provenanceIds.add(provenanceIds); - return this; - } - - /** - * Set the label. - * - * @param label the label - * @return the TypeLabel builder - */ - public Builder label(Label label) { - this.label = label; - return this; - } - - /** - * Set the provenanceIds. - * Existing provenanceIds will be replaced. - * - * @param provenanceIds the provenanceIds - * @return the TypeLabel builder - */ - public Builder provenanceIds(List provenanceIds) { - this.provenanceIds = provenanceIds; - return this; - } - } - - protected TypeLabel(Builder builder) { - label = builder.label; - provenanceIds = builder.provenanceIds; - } - - /** - * New builder. - * - * @return a TypeLabel builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the label. - * - * A pair of `nature` and `party` objects. The `nature` object identifies the effect of the element on the identified - * `party`, and the `party` object identifies the affected party. - * - * @return the label - */ - public Label label() { - return label; - } - - /** - * Gets the provenanceIds. - * - * Hashed values that you can send to IBM to provide feedback or receive support. - * - * @return the provenanceIds - */ - public List provenanceIds() { - return provenanceIds; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java deleted file mode 100644 index f53b9786401..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Identification of a specific type. - */ -public class TypeLabelComparison extends GenericModel { - - protected Label label; - - /** - * Gets the label. - * - * A pair of `nature` and `party` objects. The `nature` object identifies the effect of the element on the identified - * `party`, and the `party` object identifies the affected party. - * - * @return the label - */ - public Label getLabel() { - return label; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java deleted file mode 100644 index 1f07ed93554..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Element that does not align semantically between two compared documents. - */ -public class UnalignedElement extends GenericModel { - - @SerializedName("document_label") - protected String documentLabel; - protected Location location; - protected String text; - protected List types; - protected List categories; - protected List attributes; - - /** - * Gets the documentLabel. - * - * The label assigned to the document by the value of the `file_1_label` or `file_2_label` parameters on the **Compare - * two documents** method. - * - * @return the documentLabel - */ - public String getDocumentLabel() { - return documentLabel; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The text of the element. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List getTypes() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List getCategories() { - return categories; - } - - /** - * Gets the attributes. - * - * List of document attributes. - * - * @return the attributes - */ - public List getAttributes() { - return attributes; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java deleted file mode 100644 index 7623f0d2b59..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateBatch options. - */ -public class UpdateBatchOptions extends GenericModel { - - /** - * The action you want to perform on the specified batch-processing job. - */ - public interface Action { - /** rescan. */ - String RESCAN = "rescan"; - /** cancel. */ - String CANCEL = "cancel"; - } - - /** - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - */ - public interface Model { - /** contracts. */ - String CONTRACTS = "contracts"; - /** tables. */ - String TABLES = "tables"; - } - - protected String batchId; - protected String action; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private String batchId; - private String action; - private String model; - - private Builder(UpdateBatchOptions updateBatchOptions) { - this.batchId = updateBatchOptions.batchId; - this.action = updateBatchOptions.action; - this.model = updateBatchOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param batchId the batchId - * @param action the action - */ - public Builder(String batchId, String action) { - this.batchId = batchId; - this.action = action; - } - - /** - * Builds a UpdateBatchOptions. - * - * @return the updateBatchOptions - */ - public UpdateBatchOptions build() { - return new UpdateBatchOptions(this); - } - - /** - * Set the batchId. - * - * @param batchId the batchId - * @return the UpdateBatchOptions builder - */ - public Builder batchId(String batchId) { - this.batchId = batchId; - return this; - } - - /** - * Set the action. - * - * @param action the action - * @return the UpdateBatchOptions builder - */ - public Builder action(String action) { - this.action = action; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the UpdateBatchOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - protected UpdateBatchOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.batchId, - "batchId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.action, - "action cannot be null"); - batchId = builder.batchId; - action = builder.action; - model = builder.model; - } - - /** - * New builder. - * - * @return a UpdateBatchOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the batchId. - * - * The ID of the batch-processing job you want to update. - * - * @return the batchId - */ - public String batchId() { - return batchId; - } - - /** - * Gets the action. - * - * The action you want to perform on the specified batch-processing job. - * - * @return the action - */ - public String action() { - return action; - } - - /** - * Gets the model. - * - * The analysis model to be used by the service. For the **Element classification** and **Compare two documents** - * methods, the default is `contracts`. For the **Extract tables** method, the default is `tables`. These defaults - * apply to the standalone methods as well as to the methods' use in batch-processing requests. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java deleted file mode 100644 index cfd9feb8e58..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updated labeling from the input document, accounting for the submitted feedback. - */ -public class UpdatedLabelsIn extends GenericModel { - - protected List types; - protected List categories; - - /** - * Builder. - */ - public static class Builder { - private List types; - private List categories; - - private Builder(UpdatedLabelsIn updatedLabelsIn) { - this.types = updatedLabelsIn.types; - this.categories = updatedLabelsIn.categories; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param types the types - * @param categories the categories - */ - public Builder(List types, List categories) { - this.types = types; - this.categories = categories; - } - - /** - * Builds a UpdatedLabelsIn. - * - * @return the updatedLabelsIn - */ - public UpdatedLabelsIn build() { - return new UpdatedLabelsIn(this); - } - - /** - * Adds an types to types. - * - * @param types the new types - * @return the UpdatedLabelsIn builder - */ - public Builder addTypes(TypeLabel types) { - com.ibm.cloud.sdk.core.util.Validator.notNull(types, - "types cannot be null"); - if (this.types == null) { - this.types = new ArrayList(); - } - this.types.add(types); - return this; - } - - /** - * Adds an categories to categories. - * - * @param categories the new categories - * @return the UpdatedLabelsIn builder - */ - public Builder addCategories(Category categories) { - com.ibm.cloud.sdk.core.util.Validator.notNull(categories, - "categories cannot be null"); - if (this.categories == null) { - this.categories = new ArrayList(); - } - this.categories.add(categories); - return this; - } - - /** - * Set the types. - * Existing types will be replaced. - * - * @param types the types - * @return the UpdatedLabelsIn builder - */ - public Builder types(List types) { - this.types = types; - return this; - } - - /** - * Set the categories. - * Existing categories will be replaced. - * - * @param categories the categories - * @return the UpdatedLabelsIn builder - */ - public Builder categories(List categories) { - this.categories = categories; - return this; - } - } - - protected UpdatedLabelsIn(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.types, - "types cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.categories, - "categories cannot be null"); - types = builder.types; - categories = builder.categories; - } - - /** - * New builder. - * - * @return a UpdatedLabelsIn builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List types() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List categories() { - return categories; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java deleted file mode 100644 index 9c739152c5e..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updated labeling from the input document, accounting for the submitted feedback. - */ -public class UpdatedLabelsOut extends GenericModel { - - /** - * The type of modification the feedback entry in the `updated_labels` array. Possible values are `added`, - * `not_changed`, and `removed`. - */ - public interface Modification { - /** added. */ - String ADDED = "added"; - /** not_changed. */ - String NOT_CHANGED = "not_changed"; - /** removed. */ - String REMOVED = "removed"; - } - - protected List types; - protected List categories; - protected String modification; - - /** - * Gets the types. - * - * Description of the action specified by the element and whom it affects. - * - * @return the types - */ - public List getTypes() { - return types; - } - - /** - * Gets the categories. - * - * List of functional categories into which the element falls; in other words, the subject matter of the element. - * - * @return the categories - */ - public List getCategories() { - return categories; - } - - /** - * Gets the modification. - * - * The type of modification the feedback entry in the `updated_labels` array. Possible values are `added`, - * `not_changed`, and `removed`. - * - * @return the modification - */ - public String getModification() { - return modification; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java deleted file mode 100644 index c7c67062f98..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.compare_comply.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A value in a key-value pair. - */ -public class Value extends GenericModel { - - @SerializedName("cell_id") - protected String cellId; - protected Location location; - protected String text; - - /** - * Gets the cellId. - * - * The unique ID of the value in the table. - * - * @return the cellId - */ - public String getCellId() { - return cellId; - } - - /** - * Gets the location. - * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the text. - * - * The text content of the table cell without HTML markup. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java deleted file mode 100644 index 0fad0e32c58..00000000000 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Compare and Comply v1. - */ -package com.ibm.watson.compare_comply.v1; diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceIT.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceIT.java deleted file mode 100644 index de94cfd9687..00000000000 --- a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceIT.java +++ /dev/null @@ -1,258 +0,0 @@ -package com.ibm.watson.compare_comply.v1; - -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.watson.common.RetryRunner; -import com.ibm.watson.compare_comply.v1.model.AddFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.BatchStatus; -import com.ibm.watson.compare_comply.v1.model.Batches; -import com.ibm.watson.compare_comply.v1.model.Category; -import com.ibm.watson.compare_comply.v1.model.ClassifyElementsOptions; -import com.ibm.watson.compare_comply.v1.model.ClassifyReturn; -import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions; -import com.ibm.watson.compare_comply.v1.model.CompareReturn; -import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions; -import com.ibm.watson.compare_comply.v1.model.CreateBatchOptions; -import com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.ExtractTablesOptions; -import com.ibm.watson.compare_comply.v1.model.FeedbackDataInput; -import com.ibm.watson.compare_comply.v1.model.FeedbackList; -import com.ibm.watson.compare_comply.v1.model.FeedbackReturn; -import com.ibm.watson.compare_comply.v1.model.GetBatchOptions; -import com.ibm.watson.compare_comply.v1.model.GetFeedback; -import com.ibm.watson.compare_comply.v1.model.GetFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.HTMLReturn; -import com.ibm.watson.compare_comply.v1.model.Label; -import com.ibm.watson.compare_comply.v1.model.Location; -import com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn; -import com.ibm.watson.compare_comply.v1.model.ShortDoc; -import com.ibm.watson.compare_comply.v1.model.TableReturn; -import com.ibm.watson.compare_comply.v1.model.TypeLabel; -import com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions; -import com.ibm.watson.compare_comply.v1.model.UpdatedLabelsIn; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Integration tests for Compare and Comply. - */ -@RunWith(RetryRunner.class) -public class CompareComplyServiceIT extends CompareComplyServiceTest { - private static final String RESOURCE = "src/test/resources/compare_comply/"; - private static final File CONTRACT_A = new File(RESOURCE + "contract-a.pdf"); - private static final File CONTRACT_B = new File(RESOURCE + "contract-b.pdf"); - private static final File TABLE_FILE = new File(RESOURCE + "test-table.png"); - private static final File INPUT_CREDENTIALS_FILE = new File(RESOURCE + "cloud-object-storage-credentials-input.json"); - private static final File OUTPUT_CREDENTIALS_FILE = new File(RESOURCE - + "cloud-object-storage-credentials-output.json"); - - private CompareComply service; - - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - this.service = getService(); - } - - @Test - public void testConvertToHtml() throws FileNotFoundException { - ConvertToHtmlOptions convertToHtmlOptions = new ConvertToHtmlOptions.Builder() - .file(CONTRACT_A) - .fileContentType(HttpMediaType.APPLICATION_PDF) - .build(); - HTMLReturn response = service.convertToHtml(convertToHtmlOptions).execute().getResult(); - - System.out.println(response); - } - - @Test - public void testClassifyElements() throws FileNotFoundException { - ClassifyElementsOptions classifyElementsOptions = new ClassifyElementsOptions.Builder() - .file(CONTRACT_A) - .fileContentType(HttpMediaType.APPLICATION_PDF) - .build(); - ClassifyReturn response = service.classifyElements(classifyElementsOptions).execute().getResult(); - - System.out.println(response); - } - - @Test - public void testExtractTables() throws FileNotFoundException { - ExtractTablesOptions extractTablesOptions = new ExtractTablesOptions.Builder() - .file(TABLE_FILE) - .fileContentType("image/png") - .build(); - TableReturn response = service.extractTables(extractTablesOptions).execute().getResult(); - - System.out.println(response); - } - - @Test - public void testCompareDocuments() throws FileNotFoundException { - CompareDocumentsOptions compareDocumentsOptions = new CompareDocumentsOptions.Builder() - .file1(CONTRACT_A) - .file1ContentType(HttpMediaType.APPLICATION_PDF) - .file2(CONTRACT_B) - .file2ContentType(HttpMediaType.APPLICATION_PDF) - .build(); - CompareReturn response = service.compareDocuments(compareDocumentsOptions).execute().getResult(); - - System.out.println(response); - } - - @Test - public void testFeedbackOperations() { - String userId = "lp_java"; - String comment = "could be better"; - String text = "1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist " - + "Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing " - + "infrastructure."; - ShortDoc shortDoc = new ShortDoc.Builder() - .title("doc title") - .hash("") - .build(); - Location location = new Location.Builder() - .begin(241) - .end(237) - .build(); - OriginalLabelsIn.Builder originalLabelsInBuilder = new OriginalLabelsIn.Builder(); - Label label1 = new Label.Builder() - .nature("Obligation") - .party("IBM") - .build(); - List ids1 = Arrays.asList("85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795"); - TypeLabel typeLabel1 = new TypeLabel.Builder() - .label(label1) - .provenanceIds(ids1) - .build(); - Label label2 = new Label.Builder() - .nature("End User") - .party("Exclusion") - .build(); - List ids2 = Arrays.asList("85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795"); - TypeLabel typeLabel2 = new TypeLabel.Builder() - .label(label2) - .provenanceIds(ids2) - .build(); - List types = Arrays.asList(typeLabel1, typeLabel2); - originalLabelsInBuilder.types(types); - Category category1 = new Category.Builder() - .label(Category.Label.RESPONSIBILITIES) - .provenanceIds(new ArrayList()) - .build(); - Category category2 = new Category.Builder() - .label(Category.Label.AMENDMENTS) - .provenanceIds(new ArrayList()) - .build(); - originalLabelsInBuilder.categories(Arrays.asList(category1, category2)); - UpdatedLabelsIn.Builder updatedLabelsInBuilder = new UpdatedLabelsIn.Builder(); - Label label3 = new Label.Builder() - .nature("Disclaimer") - .party("buyer") - .build(); - TypeLabel typeLabel3 = new TypeLabel.Builder() - .label(label3) - .build(); - updatedLabelsInBuilder.types(Arrays.asList(typeLabel1, typeLabel3)); - updatedLabelsInBuilder.categories(Arrays.asList(category1, category2)); - FeedbackDataInput feedbackDataInput = new FeedbackDataInput.Builder() - .document(shortDoc) - .location(location) - .text(text) - .originalLabels(originalLabelsInBuilder.build()) - .updatedLabels(updatedLabelsInBuilder.build()) - .feedbackType("element_classification") - .modelId("contracts") - .modelVersion("11.00") - .build(); - - AddFeedbackOptions addFeedbackOptions = new AddFeedbackOptions.Builder() - .userId(userId) - .comment(comment) - .feedbackData(feedbackDataInput) - .build(); - FeedbackReturn feedbackReturn = service.addFeedback(addFeedbackOptions).execute().getResult(); - String feedbackId = feedbackReturn.getFeedbackId(); - - GetFeedbackOptions getFeedbackOptions = new GetFeedbackOptions.Builder() - .feedbackId(feedbackId) - .build(); - GetFeedback getFeedback = service - .getFeedback(getFeedbackOptions) - .addHeader("x-watson-metadata", "customer_id=sdk-test-customer-id") - .execute().getResult(); - assertEquals(text, getFeedback.getFeedbackData().getText()); - - DeleteFeedbackOptions deleteFeedbackOptions = new DeleteFeedbackOptions.Builder() - .feedbackId(feedbackId) - .build(); - service.deleteFeedback(deleteFeedbackOptions).execute(); - - FeedbackList feedbackList = service.listFeedback().execute().getResult(); - List allFeedback = feedbackList.getFeedback(); - boolean successfullyDeleted = true; - for (GetFeedback feedback : allFeedback) { - if (feedback.getFeedbackId().equals(feedbackId)) { - successfullyDeleted = false; - break; - } - } - assertTrue(successfullyDeleted); - } - - @Test - @Ignore - public void testBatchOperations() throws FileNotFoundException { - String bucketLocation = "us-south"; - String inputBucketName = "compare-comply-integration-test-bucket-input"; - String outputBucketName = "compare-comply-integration-test-bucket-output"; - - CreateBatchOptions createBatchOptions = new CreateBatchOptions.Builder() - .function(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION) - .inputBucketLocation(bucketLocation) - .inputBucketName(inputBucketName) - .inputCredentialsFile(INPUT_CREDENTIALS_FILE) - .outputBucketLocation(bucketLocation) - .outputBucketName(outputBucketName) - .outputCredentialsFile(OUTPUT_CREDENTIALS_FILE) - .build(); - BatchStatus createBatchResponse = service.createBatch(createBatchOptions).execute().getResult(); - String batchId = createBatchResponse.getBatchId(); - - GetBatchOptions getBatchOptions = new GetBatchOptions.Builder() - .batchId(batchId) - .build(); - BatchStatus getBatchResponse = service.getBatch(getBatchOptions).execute().getResult(); - assertNotNull(getBatchResponse); - - UpdateBatchOptions updateBatchOptions = new UpdateBatchOptions.Builder() - .batchId(batchId) - .action(UpdateBatchOptions.Action.RESCAN) - .build(); - BatchStatus updateBatchResponse = service.updateBatch(updateBatchOptions).execute().getResult(); - assertTrue(updateBatchResponse.getCreated().before(updateBatchResponse.getUpdated())); - - Batches listBatchesResponse = service.listBatches().execute().getResult(); - List batches = listBatchesResponse.getBatches(); - boolean batchFound = false; - for (BatchStatus batch : batches) { - if (batch.getBatchId().equals(batchId)) { - batchFound = true; - break; - } - } - assertTrue(batchFound); - } -} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceTest.java deleted file mode 100644 index ab983e58ad8..00000000000 --- a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.ibm.watson.compare_comply.v1; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.common.WatsonServiceTest; -import org.junit.Assume; -import org.junit.Before; - -public class CompareComplyServiceTest extends WatsonServiceTest { - private static final String VERSION = "2018-10-15"; - - private CompareComply service; - - public CompareComply getService() { - return this.service; - } - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String apiKey = getProperty("compare_comply.apikey"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); - - Authenticator authenticator = new IamAuthenticator(apiKey); - service = new CompareComply(VERSION, authenticator); - service.setServiceUrl(getProperty("compare_comply.url")); - service.setDefaultHeaders(getDefaultHeaders()); - } -} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java deleted file mode 100644 index eece53e0ed6..00000000000 --- a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java +++ /dev/null @@ -1,1174 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.compare_comply.v1; - -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.compare_comply.v1.model.AddFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.BatchStatus; -import com.ibm.watson.compare_comply.v1.model.Batches; -import com.ibm.watson.compare_comply.v1.model.Category; -import com.ibm.watson.compare_comply.v1.model.ClassifyElementsOptions; -import com.ibm.watson.compare_comply.v1.model.ClassifyReturn; -import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions; -import com.ibm.watson.compare_comply.v1.model.CompareReturn; -import com.ibm.watson.compare_comply.v1.model.ContractAmts; -import com.ibm.watson.compare_comply.v1.model.ContractCurrencies; -import com.ibm.watson.compare_comply.v1.model.ContractTerms; -import com.ibm.watson.compare_comply.v1.model.ContractTypes; -import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions; -import com.ibm.watson.compare_comply.v1.model.CreateBatchOptions; -import com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.EffectiveDates; -import com.ibm.watson.compare_comply.v1.model.ExtractTablesOptions; -import com.ibm.watson.compare_comply.v1.model.FeedbackDataInput; -import com.ibm.watson.compare_comply.v1.model.FeedbackList; -import com.ibm.watson.compare_comply.v1.model.FeedbackReturn; -import com.ibm.watson.compare_comply.v1.model.GetBatchOptions; -import com.ibm.watson.compare_comply.v1.model.GetFeedback; -import com.ibm.watson.compare_comply.v1.model.GetFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.HTMLReturn; -import com.ibm.watson.compare_comply.v1.model.Label; -import com.ibm.watson.compare_comply.v1.model.ListBatchesOptions; -import com.ibm.watson.compare_comply.v1.model.ListFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.Location; -import com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn; -import com.ibm.watson.compare_comply.v1.model.OriginalLabelsOut; -import com.ibm.watson.compare_comply.v1.model.Parties; -import com.ibm.watson.compare_comply.v1.model.PaymentTerms; -import com.ibm.watson.compare_comply.v1.model.ShortDoc; -import com.ibm.watson.compare_comply.v1.model.TableReturn; -import com.ibm.watson.compare_comply.v1.model.TerminationDates; -import com.ibm.watson.compare_comply.v1.model.TypeLabel; -import com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions; -import com.ibm.watson.compare_comply.v1.model.UpdatedLabelsIn; -import com.ibm.watson.compare_comply.v1.model.UpdatedLabelsOut; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.Locale; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class CompareComplyTest extends WatsonServiceUnitTest { - private static final String VERSION = "2018-10-15"; - private static final String RESOURCE = "src/test/resources/compare_comply/"; - - private static final String COMMENT = "comment"; - private static final String USER_ID = "user_id"; - private static final String PROVENANCE_ID = "provenance_id"; - private static final File SAMPLE_PDF = new File(RESOURCE + "test-pdf.pdf"); - private static final String FILENAME = "filename"; - private static final String CONTENT_TYPE_PDF = "application/pdf"; - private static final String LABEL = "label"; - private static final String BUCKET_LOCATION = "bucket_location"; - private static final String BUCKET_NAME = "bucket_name"; - private static final File CREDENTIALS_FILE = new File(RESOURCE + "credentials.json"); - private static final String FEEDBACK_ID = "feedback_id"; - private static final String FEEDBACK_TYPE = "feedback_type"; - private static final String MODEL_ID = "model_id"; - private static final String MODEL_VERSION = "model_version"; - private static final String TEXT = "text"; - private static final String BATCH_ID = "batch_id"; - private static final String NATURE = "nature"; - private static final String PARTY = "party"; - private static final Date DATE = new Date(); - private static final String CATEGORY_ADDED = "category_added"; - private static final String CATEGORY_REMOVED = "category_removed"; - private static final String CATEGORY_NOT_CHANGED = "category_not_changed"; - private static final String DOCUMENT_TITLE = "document_title"; - private static final String SORT = "sort"; - private static final String TYPE_ADDED = "type_added"; - private static final String TYPE_REMOVED = "type_removed"; - private static final String TYPE_NOT_CHANGED = "type_not_changed"; - private static final Long BEGIN = 0L; - private static final Long END = 1L; - private static final Double BEGIN_DOUBLE = 0.0; - private static final Double END_DOUBLE = 1.0; - private static final String HASH = "hash"; - private static final String TITLE = "title"; - private static final String NUM_PAGES = "20"; - private static final String AUTHOR = "author"; - private static final String PUBLICATION_DATE = "06-12-1995"; - private static final String HTML = "html"; - private static final String DOCUMENT_LABEL = "document_label"; - private static final String TYPE = "type"; - private static final String REFRESH_CURSOR = "refresh_cursor"; - private static final String NEXT_CURSOR = "next_cursor"; - private static final String REFRESH_URL = "refresh_url"; - private static final String NEXT_URL = "next_url"; - private static final Long TOTAL = 1000L; - private static final Long PENDING = 300L; - private static final Long SUCCESSFUL = 400L; - private static final Long FAILED = 500L; - private static final String STATUS = "status"; - private static final String CELL_ID = "cell_id"; - private static final Long ROW_INDEX_BEGIN = 2000L; - private static final Long ROW_INDEX_END = 3000L; - private static final Long COLUMN_INDEX_BEGIN = 4000L; - private static final Long COLUMN_INDEX_END = 5000L; - private static final String ID = "id"; - private static final String TEXT_NORMALIZED = "text_normalized"; - private static final Long LEVEL = 12L; - private static final String ROLE = "role"; - private static final String NAME = "name"; - private static final Long PAGE_LIMIT = 7L; - private static final String CURSOR = "cursor"; - private static final String VALUE = "value"; - private static final String UNIT = "unit"; - private static final Double NUMERIC_VALUE = 21.0; - - private static final String CONVERT_TO_HTML_PATH = String.format( - "/v1/html_conversion?version=%s", - VERSION); - private static final String CLASSIFY_ELEMENTS_PATH = String.format( - "/v1/element_classification?version=%s", - VERSION); - private static final String EXTRACT_TABLES_PATH = String.format( - "/v1/tables?version=%s", - VERSION); - private static final String COMPARE_DOCUMENTS_PATH = String.format( - "/v1/comparison?version=%s", - VERSION); - private static final String FEEDBACK_PATH = String.format( - "/v1/feedback?version=%s", - VERSION); - private static final String SPECIFIC_FEEDBACK_PATH = String.format( - "/v1/feedback/%s?version=%s", - FEEDBACK_ID, - VERSION); - private static final String CREATE_BATCH_PATH = String.format( - "/v1/batches?version=%s&function=%s", - VERSION, - CreateBatchOptions.Function.ELEMENT_CLASSIFICATION); - private static final String GET_BATCH_PATH = String.format( - "/v1/batches/%s?version=%s", - BATCH_ID, - VERSION); - private static final String LIST_BATCHES_PATH = String.format( - "/v1/batches?version=%s", - VERSION); - private static final String UPDATE_BATCH_PATH = String.format( - "/v1/batches/%s?version=%s&action=%s", - BATCH_ID, - VERSION, - UpdateBatchOptions.Action.CANCEL); - - private CompareComply service; - private Date testDateValue; - private DateFormat dateFormat; - private HTMLReturn convertToHtmlResponse; - private ClassifyReturn classifyElementsResponse; - private TableReturn extractTablesResponse; - private CompareReturn compareDocumentsResponse; - private FeedbackReturn addFeedbackResponse; - private GetFeedback getFeedbackResponse; - private FeedbackList listFeedbackResponse; - private BatchStatus batchStatusResponse; - private Batches batchesResponse; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - String dateString = "1995-06-12T01:11:11.111+0000"; - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - testDateValue = dateFormat.parse(dateString); - - convertToHtmlResponse = loadFixture(RESOURCE + "html-return.json", HTMLReturn.class); - classifyElementsResponse = loadFixture(RESOURCE + "classify-return.json", ClassifyReturn.class); - extractTablesResponse = loadFixture(RESOURCE + "table-return.json", TableReturn.class); - compareDocumentsResponse = loadFixture(RESOURCE + "compare-return.json", CompareReturn.class); - addFeedbackResponse = loadFixture(RESOURCE + "feedback-return.json", FeedbackReturn.class); - getFeedbackResponse = loadFixture(RESOURCE + "get-feedback.json", GetFeedback.class); - listFeedbackResponse = loadFixture(RESOURCE + "feedback-list.json", FeedbackList.class); - batchStatusResponse = loadFixture(RESOURCE + "batch-status.json", BatchStatus.class); - batchesResponse = loadFixture(RESOURCE + "batches.json", Batches.class); - - service = new CompareComply(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } - - // --- MODELS --- - - @Test - public void testAddFeedbackOptions() { - Location location = new Location.Builder() - .begin(BEGIN) - .end(END) - .build(); - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - UpdatedLabelsIn updatedLabelsIn = new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - FeedbackDataInput feedbackDataInput = new FeedbackDataInput.Builder() - .feedbackType(FEEDBACK_TYPE) - .location(location) - .originalLabels(originalLabelsIn) - .text(TEXT) - .updatedLabels(updatedLabelsIn) - .build(); - - AddFeedbackOptions addFeedbackOptions = new AddFeedbackOptions.Builder() - .comment(COMMENT) - .feedbackData(feedbackDataInput) - .userId(USER_ID) - .build(); - addFeedbackOptions = addFeedbackOptions.newBuilder().build(); - - assertEquals(COMMENT, addFeedbackOptions.comment()); - assertEquals(feedbackDataInput, addFeedbackOptions.feedbackData()); - assertEquals(USER_ID, addFeedbackOptions.userId()); - } - - @Test - public void testClassifyElementsOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - ClassifyElementsOptions classifyElementsOptions = new ClassifyElementsOptions.Builder() - .file(fileInputStream) - .fileContentType(HttpMediaType.APPLICATION_PDF) - .model(ClassifyElementsOptions.Model.CONTRACTS) - .build(); - classifyElementsOptions = classifyElementsOptions.newBuilder().build(); - - assertEquals(fileInputStream, classifyElementsOptions.file()); - assertEquals(HttpMediaType.APPLICATION_PDF, classifyElementsOptions.fileContentType()); - assertEquals(ClassifyElementsOptions.Model.CONTRACTS, classifyElementsOptions.model()); - } - - @Test - public void testCompareDocumentsOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - CompareDocumentsOptions compareDocumentsOptions = new CompareDocumentsOptions.Builder() - .file1(fileInputStream) - .file1ContentType(CONTENT_TYPE_PDF) - .file1Label(LABEL) - .file2(fileInputStream) - .file2ContentType(CONTENT_TYPE_PDF) - .file2Label(LABEL) - .model(CompareDocumentsOptions.Model.CONTRACTS) - .build(); - compareDocumentsOptions = compareDocumentsOptions.newBuilder().build(); - - assertEquals(fileInputStream, compareDocumentsOptions.file1()); - assertEquals(CONTENT_TYPE_PDF, compareDocumentsOptions.file1ContentType()); - assertEquals(LABEL, compareDocumentsOptions.file1Label()); - assertEquals(fileInputStream, compareDocumentsOptions.file2()); - assertEquals(CONTENT_TYPE_PDF, compareDocumentsOptions.file2ContentType()); - assertEquals(LABEL, compareDocumentsOptions.file2Label()); - assertEquals(CompareDocumentsOptions.Model.CONTRACTS, compareDocumentsOptions.model()); - } - - @Test - public void testConvertToHtmlOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - ConvertToHtmlOptions convertToHtmlOptions = new ConvertToHtmlOptions.Builder() - .file(fileInputStream) - .fileContentType(CONTENT_TYPE_PDF) - .model(ConvertToHtmlOptions.Model.CONTRACTS) - .build(); - convertToHtmlOptions = convertToHtmlOptions.newBuilder().build(); - - assertEquals(fileInputStream, convertToHtmlOptions.file()); - assertEquals(CONTENT_TYPE_PDF, convertToHtmlOptions.fileContentType()); - assertEquals(ConvertToHtmlOptions.Model.CONTRACTS, convertToHtmlOptions.model()); - } - - @Test - public void testCreateBatchOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(CREDENTIALS_FILE); - CreateBatchOptions createBatchOptions = new CreateBatchOptions.Builder() - .function(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION) - .inputBucketLocation(BUCKET_LOCATION) - .inputBucketName(BUCKET_NAME) - .inputCredentialsFile(fileInputStream) - .model(CreateBatchOptions.Model.CONTRACTS) - .outputBucketLocation(BUCKET_LOCATION) - .outputBucketName(BUCKET_NAME) - .outputCredentialsFile(fileInputStream) - .build(); - createBatchOptions = createBatchOptions.newBuilder().build(); - - assertEquals(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION, createBatchOptions.function()); - assertEquals(BUCKET_LOCATION, createBatchOptions.inputBucketLocation()); - assertEquals(BUCKET_NAME, createBatchOptions.inputBucketName()); - assertEquals(fileInputStream, createBatchOptions.inputCredentialsFile()); - assertEquals(CreateBatchOptions.Model.CONTRACTS, createBatchOptions.model()); - assertEquals(BUCKET_LOCATION, createBatchOptions.outputBucketLocation()); - assertEquals(BUCKET_NAME, createBatchOptions.outputBucketName()); - assertEquals(fileInputStream, createBatchOptions.outputCredentialsFile()); - } - - @Test - public void testDeleteFeedbackOptions() { - DeleteFeedbackOptions deleteFeedbackOptions = new DeleteFeedbackOptions.Builder() - .feedbackId(FEEDBACK_ID) - .model(DeleteFeedbackOptions.Model.CONTRACTS) - .build(); - deleteFeedbackOptions = deleteFeedbackOptions.newBuilder().build(); - - assertEquals(FEEDBACK_ID, deleteFeedbackOptions.feedbackId()); - assertEquals(DeleteFeedbackOptions.Model.CONTRACTS, deleteFeedbackOptions.model()); - } - - @Test - public void testExtractTablesOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - ExtractTablesOptions extractTablesOptions = new ExtractTablesOptions.Builder() - .file(fileInputStream) - .fileContentType(HttpMediaType.APPLICATION_PDF) - .model(ExtractTablesOptions.Model.TABLES) - .build(); - extractTablesOptions = extractTablesOptions.newBuilder().build(); - - assertEquals(fileInputStream, extractTablesOptions.file()); - assertEquals(HttpMediaType.APPLICATION_PDF, extractTablesOptions.fileContentType()); - assertEquals(ExtractTablesOptions.Model.TABLES, extractTablesOptions.model()); - } - - @Test - public void testFeedbackDataInput() { - ShortDoc shortDoc = new ShortDoc.Builder().build(); - Location location = new Location.Builder() - .begin(BEGIN) - .end(END) - .build(); - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - UpdatedLabelsIn updatedLabelsIn = new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - - FeedbackDataInput feedbackDataInput = new FeedbackDataInput.Builder() - .document(shortDoc) - .feedbackType(FEEDBACK_TYPE) - .location(location) - .modelId(MODEL_ID) - .modelVersion(MODEL_VERSION) - .originalLabels(originalLabelsIn) - .text(TEXT) - .updatedLabels(updatedLabelsIn) - .build(); - - assertEquals(shortDoc, feedbackDataInput.document()); - assertEquals(FEEDBACK_TYPE, feedbackDataInput.feedbackType()); - assertEquals(location, feedbackDataInput.location()); - assertEquals(MODEL_ID, feedbackDataInput.modelId()); - assertEquals(MODEL_VERSION, feedbackDataInput.modelVersion()); - assertEquals(originalLabelsIn, feedbackDataInput.originalLabels()); - assertEquals(TEXT, feedbackDataInput.text()); - assertEquals(updatedLabelsIn, feedbackDataInput.updatedLabels()); - } - - @Test - public void testListBatchesOptions() { - ListBatchesOptions listBatchesOptions = new ListBatchesOptions.Builder().build(); - ListBatchesOptions newListBatchesOptions = listBatchesOptions.newBuilder().build(); - - assertEquals(listBatchesOptions, newListBatchesOptions); - } - - @Test - public void testGetBatchOptions() { - GetBatchOptions getBatchOptions = new GetBatchOptions.Builder() - .batchId(BATCH_ID) - .build(); - getBatchOptions = getBatchOptions.newBuilder().build(); - - assertEquals(BATCH_ID, getBatchOptions.batchId()); - } - - @Test - public void testGetFeedbackOptions() { - GetFeedbackOptions getFeedbackOptions = new GetFeedbackOptions.Builder() - .feedbackId(FEEDBACK_ID) - .model(GetFeedbackOptions.Model.CONTRACTS) - .build(); - getFeedbackOptions = getFeedbackOptions.newBuilder().build(); - - assertEquals(FEEDBACK_ID, getFeedbackOptions.feedbackId()); - assertEquals(GetFeedbackOptions.Model.CONTRACTS, getFeedbackOptions.model()); - } - - @Test - public void testLabel() { - Label label = new Label.Builder() - .nature(NATURE) - .party(PARTY) - .build(); - - assertEquals(NATURE, label.nature()); - assertEquals(PARTY, label.party()); - } - - @Test - public void testListFeedbackOptions() { - ListFeedbackOptions listFeedbackOptions = new ListFeedbackOptions.Builder() - .after(DATE) - .before(DATE) - .categoryAdded(CATEGORY_ADDED) - .categoryRemoved(CATEGORY_REMOVED) - .categoryNotChanged(CATEGORY_NOT_CHANGED) - .pageLimit(PAGE_LIMIT) - .documentTitle(DOCUMENT_TITLE) - .feedbackType(FEEDBACK_TYPE) - .includeTotal(true) - .modelId(MODEL_ID) - .modelVersion(MODEL_VERSION) - .cursor(CURSOR) - .sort(SORT) - .typeAdded(TYPE_ADDED) - .typeRemoved(TYPE_REMOVED) - .typeNotChanged(TYPE_NOT_CHANGED) - .build(); - listFeedbackOptions = listFeedbackOptions.newBuilder().build(); - - assertEquals(DATE, listFeedbackOptions.after()); - assertEquals(DATE, listFeedbackOptions.before()); - assertEquals(CATEGORY_ADDED, listFeedbackOptions.categoryAdded()); - assertEquals(CATEGORY_REMOVED, listFeedbackOptions.categoryRemoved()); - assertEquals(CATEGORY_NOT_CHANGED, listFeedbackOptions.categoryNotChanged()); - assertEquals(PAGE_LIMIT, listFeedbackOptions.pageLimit()); - assertEquals(DOCUMENT_TITLE, listFeedbackOptions.documentTitle()); - assertEquals(FEEDBACK_TYPE, listFeedbackOptions.feedbackType()); - assertEquals(MODEL_ID, listFeedbackOptions.modelId()); - assertEquals(MODEL_VERSION, listFeedbackOptions.modelVersion()); - assertEquals(CURSOR, listFeedbackOptions.cursor()); - assertEquals(TYPE_ADDED, listFeedbackOptions.typeAdded()); - assertEquals(TYPE_REMOVED, listFeedbackOptions.typeRemoved()); - assertEquals(TYPE_NOT_CHANGED, listFeedbackOptions.typeNotChanged()); - assertEquals(true, listFeedbackOptions.includeTotal()); - } - - @Test - public void testLocation() { - Location location = new Location.Builder() - .begin(BEGIN) - .end(END) - .build(); - - assertEquals(BEGIN, location.begin()); - assertEquals(END, location.end()); - } - - @Test - public void testOriginalLabelsIn() { - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - - assertEquals(category, originalLabelsIn.categories().get(0)); - assertEquals(typeLabel, originalLabelsIn.types().get(0)); - } - - @Test - public void testShortDoc() { - ShortDoc shortDoc = new ShortDoc.Builder() - .hash(HASH) - .title(TITLE) - .build(); - - assertEquals(HASH, shortDoc.hash()); - assertEquals(TITLE, shortDoc.title()); - } - - @Test - public void testTypeLabel() { - Label label = new Label.Builder() - .nature(NATURE) - .party(PARTY) - .build(); - TypeLabel typeLabel = new TypeLabel.Builder() - .label(label) - .provenanceIds(Collections.singletonList(PROVENANCE_ID)) - .build(); - - assertEquals(label, typeLabel.label()); - assertEquals(PROVENANCE_ID, typeLabel.provenanceIds().get(0)); - } - - @Test - public void testUpdateBatchOptions() { - UpdateBatchOptions updateBatchOptions = new UpdateBatchOptions.Builder() - .action(UpdateBatchOptions.Action.CANCEL) - .batchId(BATCH_ID) - .model(UpdateBatchOptions.Model.CONTRACTS) - .build(); - updateBatchOptions = updateBatchOptions.newBuilder().build(); - - assertEquals(UpdateBatchOptions.Action.CANCEL, updateBatchOptions.action()); - assertEquals(BATCH_ID, updateBatchOptions.batchId()); - assertEquals(UpdateBatchOptions.Model.CONTRACTS, updateBatchOptions.model()); - } - - @Test - public void testUpdatedLabelsIn() { - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - UpdatedLabelsIn updatedLabelsIn = new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - - assertEquals(category, updatedLabelsIn.categories().get(0)); - assertEquals(typeLabel, updatedLabelsIn.types().get(0)); - } - - // --- METHODS --- - - @Test - public void testConvertToHtml() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(convertToHtmlResponse)); - - ConvertToHtmlOptions convertToHtmlOptions = new ConvertToHtmlOptions.Builder() - .file(SAMPLE_PDF) - .build(); - HTMLReturn response = service.convertToHtml(convertToHtmlOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONVERT_TO_HTML_PATH, request.getPath()); - assertEquals(NUM_PAGES, response.getNumPages()); - assertEquals(AUTHOR, response.getAuthor()); - assertEquals(PUBLICATION_DATE, response.getPublicationDate()); - assertEquals(TITLE, response.getTitle()); - assertEquals(HTML, response.getHtml()); - } - - @Test - public void testClassifyElements() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(classifyElementsResponse)); - - ClassifyElementsOptions classifyElementsOptions = new ClassifyElementsOptions.Builder() - .file(SAMPLE_PDF) - .build(); - ClassifyReturn response = service.classifyElements(classifyElementsOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CLASSIFY_ELEMENTS_PATH, request.getPath()); - assertEquals(TITLE, response.getDocument().getTitle()); - assertEquals(HTML, response.getDocument().getHtml()); - assertEquals(HASH, response.getDocument().getHash()); - assertEquals(LABEL, response.getDocument().getLabel()); - assertEquals(MODEL_ID, response.getModelId()); - assertEquals(MODEL_VERSION, response.getModelVersion()); - assertEquals(BEGIN, response.getElements().get(0).getLocation().begin()); - assertEquals(END, response.getElements().get(0).getLocation().end()); - assertEquals(TEXT, response.getElements().get(0).getText()); - assertEquals(NATURE, response.getElements().get(0).getTypes().get(0).label().nature()); - assertEquals(PARTY, response.getElements().get(0).getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, response.getElements().get(0).getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, response.getElements().get(0).getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, response.getElements().get(0).getCategories().get(0).provenanceIds().get(0)); - assertEquals(TYPE, response.getElements().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getElements().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, response.getElements().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals(END, response.getElements().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(BEGIN, response.getTables().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getText()); - assertEquals(BEGIN, response.getTables().get(0).getSectionTitle().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getSectionTitle().getLocation().end()); - assertEquals(CELL_ID, response.getTables().get(0).getTableHeaders().get(0).getCellId()); - assertEquals(BEGIN_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("begin")); - assertEquals(END_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getTableHeaders().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getColumnHeaders().get(0).getCellId()); - assertEquals(BEGIN_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("begin")); - assertEquals(END_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getColumnHeaders().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getTables().get(0).getColumnHeaders().get(0).getTextNormalized()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getRowHeaders().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getRowHeaders().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getRowHeaders().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getRowHeaders().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getTables().get(0).getRowHeaders().get(0).getTextNormalized()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getBodyCells().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getBodyCells().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getBodyCells().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd()); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0)); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0)); - assertEquals(TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0)); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0)); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0)); - assertEquals(TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0)); - assertEquals(TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, - response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals(END, - response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getText()); - assertEquals(CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getLocation() - .begin()); - assertEquals(END, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getText()); - assertEquals(TEXT, response.getTables().get(0).getTitle().getText()); - assertEquals(BEGIN, response.getTables().get(0).getTitle().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getTitle().getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getContexts().get(0).getText()); - assertEquals(BEGIN, response.getTables().get(0).getContexts().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getContexts().get(0).getLocation().end()); - assertEquals(TEXT, response.getDocumentStructure().getSectionTitles().get(0).getText()); - assertEquals(BEGIN, response.getDocumentStructure().getSectionTitles().get(0).getLocation().begin()); - assertEquals(END, response.getDocumentStructure().getSectionTitles().get(0).getLocation().end()); - assertEquals(LEVEL, response.getDocumentStructure().getSectionTitles().get(0).getLevel()); - assertEquals(BEGIN, - response.getDocumentStructure().getSectionTitles().get(0).getElementLocations().get(0).getBegin()); - assertEquals(END, - response.getDocumentStructure().getSectionTitles().get(0).getElementLocations().get(0).getEnd()); - assertEquals(TEXT, response.getDocumentStructure().getLeadingSentences().get(0).getText()); - assertEquals(BEGIN, response.getDocumentStructure().getLeadingSentences().get(0).getLocation().begin()); - assertEquals(END, response.getDocumentStructure().getLeadingSentences().get(0).getLocation().end()); - assertEquals(BEGIN, - response.getDocumentStructure().getLeadingSentences().get(0).getElementLocations().get(0).getBegin()); - assertEquals(END, - response.getDocumentStructure().getLeadingSentences().get(0).getElementLocations().get(0).getEnd()); - assertEquals(BEGIN, response.getDocumentStructure().getParagraphs().get(0).getLocation().begin()); - assertEquals(END, response.getDocumentStructure().getParagraphs().get(0).getLocation().end()); - assertEquals(PARTY, response.getParties().get(0).getParty()); - assertEquals(Parties.Importance.UNKNOWN, response.getParties().get(0).getImportance()); - assertEquals(ROLE, response.getParties().get(0).getRole()); - assertEquals(TEXT, response.getParties().get(0).getAddresses().get(0).getText()); - assertEquals(BEGIN, response.getParties().get(0).getAddresses().get(0).getLocation().begin()); - assertEquals(END, response.getParties().get(0).getAddresses().get(0).getLocation().end()); - assertEquals(NAME, response.getParties().get(0).getContacts().get(0).getName()); - assertEquals(ROLE, response.getParties().get(0).getContacts().get(0).getRole()); - assertEquals(TEXT, response.getParties().get(0).getMentions().get(0).getText()); - assertEquals(BEGIN, response.getParties().get(0).getMentions().get(0).getLocation().begin()); - assertEquals(END, response.getParties().get(0).getMentions().get(0).getLocation().end()); - assertEquals(TEXT, response.getEffectiveDates().get(0).getText()); - assertEquals(BEGIN, response.getEffectiveDates().get(0).getLocation().begin()); - assertEquals(END, response.getEffectiveDates().get(0).getLocation().end()); - assertEquals(EffectiveDates.ConfidenceLevel.HIGH, response.getEffectiveDates().get(0).getConfidenceLevel()); - assertEquals(TEXT_NORMALIZED, response.getEffectiveDates().get(0).getTextNormalized()); - assertEquals(PROVENANCE_ID, response.getEffectiveDates().get(0).getProvenanceIds().get(0)); - assertEquals(TEXT, response.getContractAmounts().get(0).getText()); - assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().begin()); - assertEquals(END, response.getContractAmounts().get(0).getLocation().end()); - assertEquals(ContractAmts.ConfidenceLevel.HIGH, response.getContractAmounts().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getContractAmounts().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getContractAmounts().get(0).getTextNormalized()); - assertEquals(VALUE, response.getContractAmounts().get(0).getInterpretation().getValue()); - assertEquals(NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue()); - assertEquals(UNIT, response.getContractAmounts().get(0).getInterpretation().getUnit()); - assertEquals(PROVENANCE_ID, response.getContractAmounts().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().begin()); - assertEquals(END, response.getContractAmounts().get(0).getLocation().end()); - assertEquals(TEXT, response.getTerminationDates().get(0).getText()); - assertEquals(BEGIN, response.getTerminationDates().get(0).getLocation().begin()); - assertEquals(END, response.getTerminationDates().get(0).getLocation().end()); - assertEquals(TerminationDates.ConfidenceLevel.HIGH, response.getTerminationDates().get(0).getConfidenceLevel()); - assertEquals(TEXT_NORMALIZED, response.getTerminationDates().get(0).getTextNormalized()); - assertEquals(PROVENANCE_ID, response.getTerminationDates().get(0).getProvenanceIds().get(0)); - assertEquals(TEXT, response.getContractTypes().get(0).getText()); - assertEquals(BEGIN, response.getContractTypes().get(0).getLocation().begin()); - assertEquals(END, response.getContractTypes().get(0).getLocation().end()); - assertEquals(ContractTypes.ConfidenceLevel.HIGH, response.getContractTypes().get(0).getConfidenceLevel()); - assertEquals(ContractTerms.ConfidenceLevel.HIGH, response.getContractTerms().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getContractTerms().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getContractTerms().get(0).getTextNormalized()); - assertEquals(VALUE, response.getContractTerms().get(0).getInterpretation().getValue()); - assertEquals(NUMERIC_VALUE, response.getContractTerms().get(0).getInterpretation().getNumericValue()); - assertEquals(UNIT, response.getContractTerms().get(0).getInterpretation().getUnit()); - assertEquals(PROVENANCE_ID, response.getContractTerms().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getContractTerms().get(0).getLocation().begin()); - assertEquals(END, response.getContractTerms().get(0).getLocation().end()); - assertEquals(PaymentTerms.ConfidenceLevel.HIGH, response.getPaymentTerms().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getPaymentTerms().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getPaymentTerms().get(0).getTextNormalized()); - assertEquals(VALUE, response.getPaymentTerms().get(0).getInterpretation().getValue()); - assertEquals(NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue()); - assertEquals(UNIT, response.getPaymentTerms().get(0).getInterpretation().getUnit()); - assertEquals(PROVENANCE_ID, response.getPaymentTerms().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getPaymentTerms().get(0).getLocation().begin()); - assertEquals(END, response.getPaymentTerms().get(0).getLocation().end()); - assertEquals(ContractCurrencies.ConfidenceLevel.HIGH, response.getContractCurrencies().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getContractCurrencies().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getContractCurrencies().get(0).getTextNormalized()); - assertEquals(PROVENANCE_ID, response.getContractCurrencies().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getContractCurrencies().get(0).getLocation().begin()); - assertEquals(END, response.getContractCurrencies().get(0).getLocation().end()); - } - - @Test - public void testExtractTables() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(extractTablesResponse)); - - ExtractTablesOptions extractTablesOptions = new ExtractTablesOptions.Builder() - .file(SAMPLE_PDF) - .build(); - TableReturn response = service.extractTables(extractTablesOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(EXTRACT_TABLES_PATH, request.getPath()); - assertEquals(HTML, response.getDocument().getHtml()); - assertEquals(TITLE, response.getDocument().getTitle()); - assertEquals(HASH, response.getDocument().getHash()); - assertEquals(MODEL_ID, response.getModelId()); - assertEquals(MODEL_VERSION, response.getModelVersion()); - assertEquals(BEGIN, response.getTables().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getText()); - assertEquals(BEGIN, response.getTables().get(0).getSectionTitle().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getSectionTitle().getLocation().end()); - assertEquals(CELL_ID, response.getTables().get(0).getTableHeaders().get(0).getCellId()); - assertEquals(BEGIN_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("begin")); - assertEquals(END_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getTableHeaders().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getColumnHeaders().get(0).getCellId()); - assertEquals(BEGIN_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("begin")); - assertEquals(END_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getColumnHeaders().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getTables().get(0).getColumnHeaders().get(0).getTextNormalized()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getRowHeaders().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getRowHeaders().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getRowHeaders().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getRowHeaders().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getTables().get(0).getRowHeaders().get(0).getTextNormalized()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getBodyCells().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getBodyCells().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getBodyCells().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd()); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0)); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0)); - assertEquals(TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0)); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0)); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0)); - assertEquals(TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0)); - assertEquals(TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, - response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals(END, - response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getText()); - assertEquals(CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getLocation() - .begin()); - assertEquals(END, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getText()); - } - - @Test - public void testCompareDocuments() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(compareDocumentsResponse)); - - CompareDocumentsOptions compareDocumentsOptions = new CompareDocumentsOptions.Builder() - .file1(SAMPLE_PDF) - .file2(SAMPLE_PDF) - .build(); - CompareReturn response = service.compareDocuments(compareDocumentsOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COMPARE_DOCUMENTS_PATH, request.getPath()); - assertEquals(TITLE, response.getDocuments().get(0).getTitle()); - assertEquals(HTML, response.getDocuments().get(0).getHtml()); - assertEquals(HASH, response.getDocuments().get(0).getHash()); - assertEquals(LABEL, response.getDocuments().get(0).getLabel()); - assertEquals(DOCUMENT_LABEL, response.getAlignedElements().get(0).getElementPair().get(0).getDocumentLabel()); - assertEquals(TEXT, response.getAlignedElements().get(0).getElementPair().get(0).getText()); - assertEquals(BEGIN, response.getAlignedElements().get(0).getElementPair().get(0).getLocation().begin()); - assertEquals(END, response.getAlignedElements().get(0).getElementPair().get(0).getLocation().end()); - assertEquals(NATURE, - response.getAlignedElements().get(0).getElementPair().get(0).getTypes().get(0).getLabel().nature()); - assertEquals(PARTY, - response.getAlignedElements().get(0).getElementPair().get(0).getTypes().get(0).getLabel().party()); - assertEquals(LABEL, response.getAlignedElements().get(0).getElementPair().get(0).getCategories().get(0).getLabel()); - assertEquals(TYPE, response.getAlignedElements().get(0).getElementPair().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getAlignedElements().get(0).getElementPair().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, - response.getAlignedElements().get(0).getElementPair().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals(END, - response.getAlignedElements().get(0).getElementPair().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(true, response.getAlignedElements().get(0).isIdenticalText()); - assertEquals(PROVENANCE_ID, response.getAlignedElements().get(0).getProvenanceIds().get(0)); - assertTrue(response.getAlignedElements().get(0).isSignificantElements()); - assertEquals(DOCUMENT_LABEL, response.getUnalignedElements().get(0).getDocumentLabel()); - assertEquals(TEXT, response.getUnalignedElements().get(0).getText()); - assertEquals(BEGIN, response.getUnalignedElements().get(0).getLocation().begin()); - assertEquals(END, response.getUnalignedElements().get(0).getLocation().end()); - assertEquals(NATURE, response.getUnalignedElements().get(0).getTypes().get(0).getLabel().nature()); - assertEquals(PARTY, response.getUnalignedElements().get(0).getTypes().get(0).getLabel().party()); - assertEquals(LABEL, response.getUnalignedElements().get(0).getCategories().get(0).getLabel()); - assertEquals(TYPE, response.getUnalignedElements().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getUnalignedElements().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, response.getUnalignedElements().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals(END, response.getUnalignedElements().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(MODEL_ID, response.getModelId()); - assertEquals(MODEL_VERSION, response.getModelVersion()); - } - - @Test - public void testAddFeedback() throws InterruptedException { - server.enqueue(jsonResponse(addFeedbackResponse)); - - Location location = new Location.Builder() - .begin(BEGIN) - .end(END) - .build(); - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - UpdatedLabelsIn updatedLabelsIn = new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - FeedbackDataInput feedbackDataInput = new FeedbackDataInput.Builder() - .feedbackType(FEEDBACK_TYPE) - .location(location) - .originalLabels(originalLabelsIn) - .text(TEXT) - .updatedLabels(updatedLabelsIn) - .build(); - AddFeedbackOptions addFeedbackOptions = new AddFeedbackOptions.Builder() - .feedbackData(feedbackDataInput) - .build(); - FeedbackReturn response = service.addFeedback(addFeedbackOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(FEEDBACK_PATH, request.getPath()); - assertEquals(FEEDBACK_ID, response.getFeedbackId()); - assertEquals(USER_ID, response.getUserId()); - assertEquals(COMMENT, response.getComment()); - assertEquals(testDateValue, response.getCreated()); - assertEquals(FEEDBACK_TYPE, response.getFeedbackData().getFeedbackType()); - assertEquals(TITLE, response.getFeedbackData().getDocument().title()); - assertEquals(HASH, response.getFeedbackData().getDocument().hash()); - assertEquals(MODEL_ID, response.getFeedbackData().getModelId()); - assertEquals(MODEL_VERSION, response.getFeedbackData().getModelVersion()); - assertEquals(BEGIN, response.getFeedbackData().getLocation().begin()); - assertEquals(END, response.getFeedbackData().getLocation().end()); - assertEquals(TEXT, response.getFeedbackData().getText()); - assertEquals(NATURE, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().nature()); - assertEquals(PARTY, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getOriginalLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, response.getFeedbackData().getOriginalLabels().getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getOriginalLabels().getCategories().get(0).provenanceIds().get(0)); - assertEquals(OriginalLabelsOut.Modification.ADDED, - response.getFeedbackData().getOriginalLabels().getModification()); - assertEquals(NATURE, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().nature()); - assertEquals(PARTY, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getUpdatedLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, - response.getFeedbackData().getUpdatedLabels().getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getUpdatedLabels().getCategories().get(0).provenanceIds().get(0)); - assertEquals(UpdatedLabelsOut.Modification.ADDED, - response.getFeedbackData().getUpdatedLabels().getModification()); - assertEquals(REFRESH_CURSOR, response.getFeedbackData().getPagination().getRefreshCursor()); - assertEquals(NEXT_CURSOR, response.getFeedbackData().getPagination().getNextCursor()); - assertEquals(REFRESH_URL, response.getFeedbackData().getPagination().getRefreshUrl()); - assertEquals(NEXT_URL, response.getFeedbackData().getPagination().getNextUrl()); - assertEquals(TOTAL, response.getFeedbackData().getPagination().getTotal()); - } - - @Test - public void testDeleteFeedback() throws InterruptedException { - server.enqueue(new MockResponse()); - - DeleteFeedbackOptions deleteFeedbackOptions = new DeleteFeedbackOptions.Builder() - .feedbackId(FEEDBACK_ID) - .build(); - service.deleteFeedback(deleteFeedbackOptions).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(SPECIFIC_FEEDBACK_PATH, request.getPath()); - } - - @Test - public void testGetFeedback() throws InterruptedException { - server.enqueue(jsonResponse(getFeedbackResponse)); - - GetFeedbackOptions getFeedbackOptions = new GetFeedbackOptions.Builder() - .feedbackId(FEEDBACK_ID) - .build(); - GetFeedback response = service.getFeedback(getFeedbackOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(SPECIFIC_FEEDBACK_PATH, request.getPath()); - assertEquals(FEEDBACK_ID, response.getFeedbackId()); - assertEquals(COMMENT, response.getComment()); - assertEquals(testDateValue, response.getCreated()); - assertEquals(FEEDBACK_TYPE, response.getFeedbackData().getFeedbackType()); - assertEquals(TITLE, response.getFeedbackData().getDocument().title()); - assertEquals(HASH, response.getFeedbackData().getDocument().hash()); - assertEquals(MODEL_ID, response.getFeedbackData().getModelId()); - assertEquals(MODEL_VERSION, response.getFeedbackData().getModelVersion()); - assertEquals(BEGIN, response.getFeedbackData().getLocation().begin()); - assertEquals(END, response.getFeedbackData().getLocation().end()); - assertEquals(TEXT, response.getFeedbackData().getText()); - assertEquals(NATURE, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().nature()); - assertEquals(PARTY, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getOriginalLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, response.getFeedbackData().getOriginalLabels().getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getOriginalLabels().getCategories().get(0).provenanceIds().get(0)); - assertEquals(OriginalLabelsOut.Modification.ADDED, - response.getFeedbackData().getOriginalLabels().getModification()); - assertEquals(NATURE, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().nature()); - assertEquals(PARTY, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getUpdatedLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, response.getFeedbackData().getUpdatedLabels().getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, - response.getFeedbackData().getUpdatedLabels().getCategories().get(0).provenanceIds().get(0)); - assertEquals(UpdatedLabelsOut.Modification.ADDED, - response.getFeedbackData().getUpdatedLabels().getModification()); - assertEquals(REFRESH_CURSOR, response.getFeedbackData().getPagination().getRefreshCursor()); - assertEquals(NEXT_CURSOR, response.getFeedbackData().getPagination().getNextCursor()); - assertEquals(REFRESH_URL, response.getFeedbackData().getPagination().getRefreshUrl()); - assertEquals(NEXT_URL, response.getFeedbackData().getPagination().getNextUrl()); - assertEquals(TOTAL, response.getFeedbackData().getPagination().getTotal()); - } - - @Test - public void testListFeedbackWithOptions() throws InterruptedException { - server.enqueue(jsonResponse(listFeedbackResponse)); - - ListFeedbackOptions listFeedbackOptions = new ListFeedbackOptions.Builder().build(); - FeedbackList response = service.listFeedback(listFeedbackOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertFeedbackListResponse(request, response); - } - - @Test - public void testListFeedbackWithoutOptions() throws InterruptedException { - server.enqueue(jsonResponse(listFeedbackResponse)); - - FeedbackList response = service.listFeedback().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertFeedbackListResponse(request, response); - } - - @Test - public void testCreateBatch() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(batchStatusResponse)); - - CreateBatchOptions createBatchOptions = new CreateBatchOptions.Builder() - .function(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION) - .inputCredentialsFile(CREDENTIALS_FILE) - .inputBucketLocation(BUCKET_LOCATION) - .inputBucketName(BUCKET_NAME) - .outputCredentialsFile(CREDENTIALS_FILE) - .outputBucketLocation(BUCKET_LOCATION) - .outputBucketName(BUCKET_NAME) - .build(); - BatchStatus response = service.createBatch(createBatchOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CREATE_BATCH_PATH, request.getPath()); - assertBatchStatusResponse(response); - } - - @Test - public void testGetBatch() throws InterruptedException { - server.enqueue(jsonResponse(batchStatusResponse)); - - GetBatchOptions getBatchOptions = new GetBatchOptions.Builder() - .batchId(BATCH_ID) - .build(); - BatchStatus response = service.getBatch(getBatchOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_BATCH_PATH, request.getPath()); - assertBatchStatusResponse(response); - } - - @Test - public void testListBatchesWithOptions() throws InterruptedException { - server.enqueue(jsonResponse(batchesResponse)); - - ListBatchesOptions listBatchesOptions = new ListBatchesOptions.Builder().build(); - Batches response = service.listBatches(listBatchesOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertBatchesResponse(request, response); - } - - @Test - public void testListBatchesWithoutOptions() throws InterruptedException { - server.enqueue(jsonResponse(batchesResponse)); - - Batches response = service.listBatches().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertBatchesResponse(request, response); - } - - @Test - public void testUpdateBatch() throws InterruptedException { - server.enqueue(jsonResponse(batchStatusResponse)); - - UpdateBatchOptions updateBatchOptions = new UpdateBatchOptions.Builder() - .action(UpdateBatchOptions.Action.CANCEL) - .batchId(BATCH_ID) - .build(); - BatchStatus response = service.updateBatch(updateBatchOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(UPDATE_BATCH_PATH, request.getPath()); - assertBatchStatusResponse(response); - } - - private void assertFeedbackListResponse(RecordedRequest request, FeedbackList response) { - assertEquals(FEEDBACK_PATH, request.getPath()); - assertEquals(FEEDBACK_ID, response.getFeedback().get(0).getFeedbackId()); - assertEquals(COMMENT, response.getFeedback().get(0).getComment()); - assertEquals(testDateValue, response.getFeedback().get(0).getCreated()); - assertEquals(FEEDBACK_TYPE, response.getFeedback().get(0).getFeedbackData().getFeedbackType()); - assertEquals(TITLE, response.getFeedback().get(0).getFeedbackData().getDocument().title()); - assertEquals(HASH, response.getFeedback().get(0).getFeedbackData().getDocument().hash()); - assertEquals(MODEL_ID, response.getFeedback().get(0).getFeedbackData().getModelId()); - assertEquals(MODEL_VERSION, response.getFeedback().get(0).getFeedbackData().getModelVersion()); - assertEquals(BEGIN, response.getFeedback().get(0).getFeedbackData().getLocation().begin()); - assertEquals(END, response.getFeedback().get(0).getFeedbackData().getLocation().end()); - assertEquals(TEXT, response.getFeedback().get(0).getFeedbackData().getText()); - assertEquals(NATURE, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getTypes().get(0).label().nature()); - assertEquals(PARTY, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getTypes().get(0).provenanceIds() - .get(0)); - assertEquals(LABEL, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getCategories().get(0).provenanceIds() - .get(0)); - assertEquals(OriginalLabelsOut.Modification.ADDED, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getModification()); - assertEquals(NATURE, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getTypes().get(0).label().nature()); - assertEquals(PARTY, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getTypes().get(0).label().party()); - assertEquals(PROVENANCE_ID, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getCategories().get(0).label()); - assertEquals(PROVENANCE_ID, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getCategories().get(0).provenanceIds() - .get(0)); - assertEquals(UpdatedLabelsOut.Modification.ADDED, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getModification()); - assertEquals(REFRESH_CURSOR, response.getFeedback().get(0).getFeedbackData().getPagination().getRefreshCursor()); - assertEquals(NEXT_CURSOR, response.getFeedback().get(0).getFeedbackData().getPagination().getNextCursor()); - assertEquals(REFRESH_URL, response.getFeedback().get(0).getFeedbackData().getPagination().getRefreshUrl()); - assertEquals(NEXT_URL, response.getFeedback().get(0).getFeedbackData().getPagination().getNextUrl()); - assertEquals(TOTAL, response.getFeedback().get(0).getFeedbackData().getPagination().getTotal()); - } - - private void assertBatchStatusResponse(BatchStatus response) { - assertEquals(BatchStatus.Function.ELEMENT_CLASSIFICATION, response.getFunction()); - assertEquals(BUCKET_LOCATION, response.getInputBucketLocation()); - assertEquals(BUCKET_NAME, response.getInputBucketName()); - assertEquals(BUCKET_LOCATION, response.getOutputBucketLocation()); - assertEquals(BUCKET_NAME, response.getOutputBucketName()); - assertEquals(BATCH_ID, response.getBatchId()); - assertEquals(TOTAL, response.getDocumentCounts().getTotal()); - assertEquals(PENDING, response.getDocumentCounts().getPending()); - assertEquals(SUCCESSFUL, response.getDocumentCounts().getSuccessful()); - assertEquals(FAILED, response.getDocumentCounts().getFailed()); - assertEquals(STATUS, response.getStatus()); - assertEquals(testDateValue, response.getCreated()); - assertEquals(testDateValue, response.getUpdated()); - } - - private void assertBatchesResponse(RecordedRequest request, Batches response) { - assertEquals(LIST_BATCHES_PATH, request.getPath()); - assertBatchStatusResponse(response.getBatches().get(0)); - } -} diff --git a/compare-comply/src/test/resources/compare_comply/batch-status.json b/compare-comply/src/test/resources/compare_comply/batch-status.json deleted file mode 100644 index b5ec6e67164..00000000000 --- a/compare-comply/src/test/resources/compare_comply/batch-status.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "function": "element_classification", - "input_bucket_location": "bucket_location", - "input_bucket_name": "bucket_name", - "output_bucket_location": "bucket_location", - "output_bucket_name": "bucket_name", - "batch_id": "batch_id", - "document_counts": { - "total": 1000, - "pending": 300, - "successful": 400, - "failed": 500 - }, - "status": "status", - "created": "1995-06-12T01:11:11.111Z", - "updated": "1995-06-12T01:11:11.111Z" -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/batches.json b/compare-comply/src/test/resources/compare_comply/batches.json deleted file mode 100644 index 4fc00bdb54a..00000000000 --- a/compare-comply/src/test/resources/compare_comply/batches.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "batches": [ - { - "function": "element_classification", - "input_bucket_location": "bucket_location", - "input_bucket_name": "bucket_name", - "output_bucket_location": "bucket_location", - "output_bucket_name": "bucket_name", - "batch_id": "batch_id", - "document_counts": { - "total": 1000, - "pending": 300, - "successful": 400, - "failed": 500 - }, - "status": "status", - "created": "1995-06-12T01:11:11.111Z", - "updated": "1995-06-12T01:11:11.111Z" - } - ] -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/classify-return.json b/compare-comply/src/test/resources/compare_comply/classify-return.json deleted file mode 100644 index 2d274b434b5..00000000000 --- a/compare-comply/src/test/resources/compare_comply/classify-return.json +++ /dev/null @@ -1,368 +0,0 @@ -{ - "document": { - "title": "title", - "html": "html", - "hash": "hash", - "label": "label" - }, - "model_id": "model_id", - "model_version": "model_version", - "elements": [ - { - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "attributes": [ - { - "type": "type", - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "tables": [ - { - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "section_title": { - "location": { - "begin": 0, - "end": 1 - } - }, - "table_headers": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0.0, - "end": 1.0 - }, - "text": "text", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000 - } - ], - "row_headers": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "text_normalized": "text_normalized", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000 - } - ], - "column_headers": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0.0, - "end": 1.0 - }, - "text": "text", - "text_normalized": "text_normalized", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000 - } - ], - "body_cells": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000, - "row_header_ids": [ - "id" - ], - "row_header_texts": [ - "text" - ], - "row_header_texts_normalized": [ - "text_normalized" - ], - "column_header_ids": [ - "id" - ], - "column_header_texts": [ - "text" - ], - "column_header_texts_normalized": [ - "text_normalized" - ], - "attributes": [ - { - "type": "type", - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "key_value_pairs": [ - { - "key": { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text" - }, - "value": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text" - } - ] - } - ], - "title": { - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - }, - "contexts": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "document_structure": { - "section_titles": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "level": 12, - "element_locations": [ - { - "begin": 0, - "end": 1 - } - ] - } - ], - "leading_sentences": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "element_locations": [ - { - "begin": 0, - "end": 1 - } - ] - } - ], - "paragraphs": [ - { - "location": { - "begin": 0, - "end": 1 - } - } - ] - }, - "parties": [ - { - "party": "party", - "importance": "Unknown", - "role": "role", - "addresses": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ], - "contacts": [ - { - "name": "name", - "role": "role" - } - ], - "mentions": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "effective_dates": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "confidence_level": "High", - "text_normalized": "text_normalized", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "contract_amounts": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "confidence_level": "High", - "text_normalized": "text_normalized", - "interpretation": { - "value": "value", - "numeric_value": 21, - "unit": "unit" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "termination_dates": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "confidence_level": "High", - "text_normalized": "text_normalized", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "contract_types": [ - { - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "confidence_level": "High" - } - ], - "contract_terms": [ - { - "confidence_level": "High", - "text": "text", - "text_normalized": "text_normalized", - "interpretation": { - "value": "value", - "numeric_value": 21, - "unit": "unit" - }, - "provenance_ids": [ - "provenance_id" - ], - "location": { - "begin": 0, - "end": 1 - } - } - ], - "payment_terms": [ - { - "confidence_level": "High", - "text": "text", - "text_normalized": "text_normalized", - "interpretation": { - "value": "value", - "numeric_value": 21, - "unit": "unit" - }, - "provenance_ids": [ - "provenance_id" - ], - "location": { - "begin": 0, - "end": 1 - } - } - ], - "contract_currencies": [ - { - "confidence_level": "High", - "text": "text", - "text_normalized": "text_normalized", - "provenance_ids": [ - "provenance_id" - ], - "location": { - "begin": 0, - "end": 1 - } - } - ] -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/compare-return.json b/compare-comply/src/test/resources/compare_comply/compare-return.json deleted file mode 100644 index d9bde2bb2f6..00000000000 --- a/compare-comply/src/test/resources/compare_comply/compare-return.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "documents": [ - { - "title": "title", - "html": "html", - "hash": "hash", - "label": "label" - } - ], - "aligned_elements": [ - { - "element_pair": [ - { - "document_label": "document_label", - "text": "text", - "location": { - "begin": 0, - "end": 1 - }, - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - } - } - ], - "categories": [ - { - "label": "label" - } - ], - "attributes": [ - { - "type": "type", - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "identical_text": true, - "provenance_ids": [ - "provenance_id" - ], - "significant_elements": true - } - ], - "unaligned_elements": [ - { - "document_label": "document_label", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - } - } - ], - "categories": [ - { - "label": "label" - } - ], - "attributes": [ - { - "type": "type", - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "model_id": "model_id", - "model_version": "model_version" -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/contract-a.pdf b/compare-comply/src/test/resources/compare_comply/contract-a.pdf deleted file mode 100644 index 09f4999b5a1..00000000000 Binary files a/compare-comply/src/test/resources/compare_comply/contract-a.pdf and /dev/null differ diff --git a/compare-comply/src/test/resources/compare_comply/contract-b.pdf b/compare-comply/src/test/resources/compare_comply/contract-b.pdf deleted file mode 100644 index 13433fad52e..00000000000 Binary files a/compare-comply/src/test/resources/compare_comply/contract-b.pdf and /dev/null differ diff --git a/compare-comply/src/test/resources/compare_comply/credentials.json b/compare-comply/src/test/resources/compare_comply/credentials.json deleted file mode 100644 index a11ffea9fc8..00000000000 --- a/compare-comply/src/test/resources/compare_comply/credentials.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "username": "username", - "password": "password" -} diff --git a/compare-comply/src/test/resources/compare_comply/feedback-list.json b/compare-comply/src/test/resources/compare_comply/feedback-list.json deleted file mode 100644 index 6c9c41dc980..00000000000 --- a/compare-comply/src/test/resources/compare_comply/feedback-list.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "feedback": [ - { - "feedback_id": "feedback_id", - "comment": "comment", - "created": "1995-06-12T01:11:11.111Z", - "feedback_data": { - "feedback_type": "feedback_type", - "document": { - "title": "title", - "hash": "hash" - }, - "model_id": "model_id", - "model_version": "model_version", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "original_labels": { - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "modification": "added" - }, - "updated_labels": { - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "modification": "added" - }, - "pagination": { - "refresh_cursor": "refresh_cursor", - "next_cursor": "next_cursor", - "refresh_url": "refresh_url", - "next_url": "next_url", - "total": 1000 - } - } - } - ] -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/feedback-return.json b/compare-comply/src/test/resources/compare_comply/feedback-return.json deleted file mode 100644 index 66b58603392..00000000000 --- a/compare-comply/src/test/resources/compare_comply/feedback-return.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "feedback_id": "feedback_id", - "user_id": "user_id", - "comment": "comment", - "created": "1995-06-12T01:11:11.111Z", - "feedback_data": { - "feedback_type": "feedback_type", - "document": { - "title": "title", - "hash": "hash" - }, - "model_id": "model_id", - "model_version": "model_version", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "original_labels": { - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "modification": "added" - }, - "updated_labels": { - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "modification": "added" - }, - "pagination": { - "refresh_cursor": "refresh_cursor", - "next_cursor": "next_cursor", - "refresh_url": "refresh_url", - "next_url": "next_url", - "total": 1000 - } - } -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/get-feedback.json b/compare-comply/src/test/resources/compare_comply/get-feedback.json deleted file mode 100644 index ac130a7ee19..00000000000 --- a/compare-comply/src/test/resources/compare_comply/get-feedback.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "feedback_id": "feedback_id", - "comment": "comment", - "created": "1995-06-12T01:11:11.111Z", - "feedback_data": { - "feedback_type": "feedback_type", - "document": { - "title": "title", - "hash": "hash" - }, - "model_id": "model_id", - "model_version": "model_version", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "original_labels": { - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "modification": "added" - }, - "updated_labels": { - "types": [ - { - "label": { - "nature": "nature", - "party": "party" - }, - "provenance_ids": [ - "provenance_id" - ] - } - ], - "categories": [ - { - "label": "label", - "provenance_ids": [ - "provenance_id" - ] - } - ], - "modification": "added" - }, - "pagination": { - "refresh_cursor": "refresh_cursor", - "next_cursor": "next_cursor", - "refresh_url": "refresh_url", - "next_url": "next_url", - "total": 1000 - } - } -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/html-return.json b/compare-comply/src/test/resources/compare_comply/html-return.json deleted file mode 100644 index 406f9a70bcc..00000000000 --- a/compare-comply/src/test/resources/compare_comply/html-return.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "num_pages": "20", - "author": "author", - "publication_date": "06-12-1995", - "title": "title", - "html": "html" -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/table-return.json b/compare-comply/src/test/resources/compare_comply/table-return.json deleted file mode 100644 index dc7537776db..00000000000 --- a/compare-comply/src/test/resources/compare_comply/table-return.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "document": { - "html": "html", - "title": "title", - "hash": "hash" - }, - "model_id": "model_id", - "model_version": "model_version", - "tables": [ - { - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "section_title": { - "location": { - "begin": 0, - "end": 1 - } - }, - "table_headers": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0.0, - "end": 1.0 - }, - "text": "text", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000 - } - ], - "row_headers": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "text_normalized": "text_normalized", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000 - } - ], - "column_headers": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0.0, - "end": 1.0 - }, - "text": "text", - "text_normalized": "text_normalized", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000 - } - ], - "body_cells": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text", - "row_index_begin": 2000, - "row_index_end": 3000, - "column_index_begin": 4000, - "column_index_end": 5000, - "row_header_ids": [ - "id" - ], - "row_header_texts": [ - "text" - ], - "row_header_texts_normalized": [ - "text_normalized" - ], - "column_header_ids": [ - "id" - ], - "column_header_texts": [ - "text" - ], - "column_header_texts_normalized": [ - "text_normalized" - ], - "attributes": [ - { - "type": "type", - "text": "text", - "location": { - "begin": 0, - "end": 1 - } - } - ] - } - ], - "key_value_pairs": [ - { - "key": { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text" - }, - "value": [ - { - "cell_id": "cell_id", - "location": { - "begin": 0, - "end": 1 - }, - "text": "text" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/compare-comply/src/test/resources/compare_comply/test-pdf.pdf b/compare-comply/src/test/resources/compare_comply/test-pdf.pdf deleted file mode 100644 index bf1241ab635..00000000000 Binary files a/compare-comply/src/test/resources/compare_comply/test-pdf.pdf and /dev/null differ diff --git a/compare-comply/src/test/resources/compare_comply/test-table.png b/compare-comply/src/test/resources/compare_comply/test-table.png deleted file mode 100644 index e709df6a132..00000000000 Binary files a/compare-comply/src/test/resources/compare_comply/test-table.png and /dev/null differ diff --git a/config b/config new file mode 100644 index 00000000000..183087e346f --- /dev/null +++ b/config @@ -0,0 +1 @@ +{"spec":"/Users/jeffarn/Programming/sdks/developer-cloud--api-definitions/apis/text-to-speech-v1.json"} diff --git a/config.properties.enc b/config.properties.enc new file mode 100644 index 00000000000..e1b43a48eaa Binary files /dev/null and b/config.properties.enc differ diff --git a/discovery/README.md b/discovery/README.md index 14d3e80ca6e..2d138ececc3 100644 --- a/discovery/README.md +++ b/discovery/README.md @@ -8,35 +8,21 @@ com.ibm.watson discovery - 8.3.1 + 16.2.0 ``` ##### Gradle ```gradle -'com.ibm.watson:discovery:8.3.1' +'com.ibm.watson:discovery:16.2.0' ``` ## Usage -This SDK supports both the Discovery v1 and v2 APIs. Please note that the Discovery v2 API is accessible **only** on Cloud Pak for Data. +This SDK supports the Discovery v2 APIs. -Otherwise, the APIs are fairly similar, offering the ability to manage collections of documents and query them for insights. You can learn more about the Discovery service [here](https://cloud.ibm.com/docs/discovery?topic=discovery-gs-api). - -### Using Discovery v1 - -```java -// Make sure to use the Discovery v1 import! -Authenticator authenticator = new IamAuthenticator(""); -Discovery discovery = new Discovery("2019-04-30", authenticator); - -//Build an empty query on an existing environment/collection -String environmentId = ""; -String collectionId = ""; -QueryOptions queryOptions = new QueryOptions.Builder(environmentId, collectionId).build(); -QueryResponse queryResponse = discovery.query(queryOptions).execute().getResult(); -``` +Otherwise, the APIs are fairly similar, offering the ability to manage collections of documents and query them for insights. You can learn more about the Discovery service [here](https://cloud.ibm.com/apidocs/discovery-data). ### Using Discovery v2 diff --git a/discovery/build.gradle b/discovery/build.gradle deleted file mode 100644 index d9dc2b74f77..00000000000 --- a/discovery/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyleTest { - ignoreFailures = false -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/discovery/gradle.properties b/discovery/gradle.properties deleted file mode 100644 index 83014d93897..00000000000 --- a/discovery/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:discovery -ARTIFACT_ID=discovery -NAME=IBM Watson Java SDK - Discovery -DESCRIPTION=Java client library to use the IBM Discovery API \ No newline at end of file diff --git a/discovery/pom.xml b/discovery/pom.xml new file mode 100644 index 00000000000..b17db397aeb --- /dev/null +++ b/discovery/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + discovery + jar + IBM Watson Java SDK - Discovery + + + + com.ibm.cloud + sdk-core + + + ${project.groupId} + common + compile + + + ${project.groupId} + common + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + diff --git a/discovery/src/main/java/com/ibm/watson/discovery/query/AggregationType.java b/discovery/src/main/java/com/ibm/watson/discovery/query/AggregationType.java index a2d65f6ffb9..2a239269e0e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/query/AggregationType.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/query/AggregationType.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2019. + * (C) Copyright IBM Corp. 2017, 2020. * * 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 @@ -12,23 +12,69 @@ */ package com.ibm.watson.discovery.query; -/** - * Aggregation types. - */ +/** Aggregation types. */ public enum AggregationType { - TERM("term"), FILTER("filter"), NESTED("nested"), HISTOGRAM("histogram"), TIMESLICE("timeslice"), TOP_HITS( - "top_hits"), UNIQUE_COUNT("unique_count"), MAX("max"), MIN("min"), AVERAGE("average"), SUM("sum"); + + /** The term. */ + TERM("term"), + + /** The filter. */ + FILTER("filter"), + + /** The nested. */ + NESTED("nested"), + + /** The histogram. */ + HISTOGRAM("histogram"), + + /** The timeslice. */ + TIMESLICE("timeslice"), + + /** The top hits. */ + TOP_HITS("top_hits"), + + /** The unique count. */ + UNIQUE_COUNT("unique_count"), + + /** The max. */ + MAX("max"), + + /** The min. */ + MIN("min"), + + /** The average. */ + AVERAGE("average"), + + /** The sum. */ + SUM("sum"); private final String name; + /** + * Instantiates a new aggregation type. + * + * @param name the name + */ AggregationType(String name) { this.name = name; } + /** + * Gets the name. + * + * @return the name + */ public String getName() { return name; } + /** + * Value of ignore case. + * + * @param value the value + * @return the aggregation type + * @throws IllegalArgumentException the illegal argument exception + */ public static AggregationType valueOfIgnoreCase(String value) throws IllegalArgumentException { for (AggregationType aggregationType : values()) { if (aggregationType.getName().equalsIgnoreCase(value)) { @@ -38,6 +84,11 @@ public static AggregationType valueOfIgnoreCase(String value) throws IllegalArgu throw new IllegalArgumentException(value + " is not a valid Aggregation"); } + /** + * To string. + * + * @return the string + */ @Override public String toString() { return name; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/query/Operator.java b/discovery/src/main/java/com/ibm/watson/discovery/query/Operator.java index f5e181a38fe..df973a97fea 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/query/Operator.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/query/Operator.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2019. + * (C) Copyright IBM Corp. 2017, 2020. * * 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 @@ -12,35 +12,115 @@ */ package com.ibm.watson.discovery.query; -/** - * Query Language Operator Syntax. - */ +/** Query Language Operator Syntax. */ public enum Operator { - FIELD_SEPARATOR("."), EQUALS("::"), CONTAINS(":"), ESCAPE("\\"), FUZZY("~"), OR("|"), AND(","), NOT( - "!"), NEST_AGGREGATION("."), LESS_THAN("<"), LESS_THAN_OR_EQUAL_TO("<="), GREATER_THAN( - ">"), GREATER_THAN_OR_EQUAL_TO(">="), BOOST("^"), WILDCARD("*", false), OPENING_GROUPING( - "("), CLOSING_GROUPING(")"), OPENING_ARRAY("["), CLOSING_ARRAY("]"), DOUBLE_QUOTE("\""); + + /** The field separator. */ + FIELD_SEPARATOR("."), + + /** The equals. */ + EQUALS("::"), + + /** The contains. */ + CONTAINS(":"), + + /** The escape. */ + ESCAPE("\\"), + + /** The fuzzy. */ + FUZZY("~"), + + /** The or. */ + OR("|"), + + /** The and. */ + AND(","), + + /** The not. */ + NOT("!"), + + /** The nest aggregation. */ + NEST_AGGREGATION("."), + + /** The less than. */ + LESS_THAN("<"), + + /** The less than or equal to. */ + LESS_THAN_OR_EQUAL_TO("<="), + + /** The greater than. */ + GREATER_THAN(">"), + + /** The greater than or equal to. */ + GREATER_THAN_OR_EQUAL_TO(">="), + + /** The boost. */ + BOOST("^"), + + /** The wildcard. */ + WILDCARD("*", false), + + /** The opening grouping. */ + OPENING_GROUPING("("), + + /** The closing grouping. */ + CLOSING_GROUPING(")"), + + /** The opening array. */ + OPENING_ARRAY("["), + + /** The closing array. */ + CLOSING_ARRAY("]"), + + /** The double quote. */ + DOUBLE_QUOTE("\""); private final String symbol; private final boolean escape; + /** + * Instantiates a new operator. + * + * @param symbol the symbol + */ Operator(String symbol) { this(symbol, true); } + /** + * Instantiates a new operator. + * + * @param symbol the symbol + * @param escape the escape + */ Operator(String symbol, boolean escape) { this.symbol = symbol; this.escape = escape; } + /** + * Gets the symbol. + * + * @return the symbol + */ public String getSymbol() { return symbol; } + /** + * Should escape. + * + * @return true, if successful + */ public boolean shouldEscape() { return escape; } + /** + * To string. + * + * @return the string + */ @Override public String toString() { return symbol; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java deleted file mode 100644 index 54bc541edb4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java +++ /dev/null @@ -1,2526 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.discovery.v1.model.AddDocumentOptions; -import com.ibm.watson.discovery.v1.model.AddTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.Collection; -import com.ibm.watson.discovery.v1.model.Completions; -import com.ibm.watson.discovery.v1.model.Configuration; -import com.ibm.watson.discovery.v1.model.CreateCollectionOptions; -import com.ibm.watson.discovery.v1.model.CreateConfigurationOptions; -import com.ibm.watson.discovery.v1.model.CreateCredentialsOptions; -import com.ibm.watson.discovery.v1.model.CreateEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.CreateEventOptions; -import com.ibm.watson.discovery.v1.model.CreateEventResponse; -import com.ibm.watson.discovery.v1.model.CreateExpansionsOptions; -import com.ibm.watson.discovery.v1.model.CreateGatewayOptions; -import com.ibm.watson.discovery.v1.model.CreateStopwordListOptions; -import com.ibm.watson.discovery.v1.model.CreateTokenizationDictionaryOptions; -import com.ibm.watson.discovery.v1.model.CreateTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.Credentials; -import com.ibm.watson.discovery.v1.model.CredentialsList; -import com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.DeleteCollectionOptions; -import com.ibm.watson.discovery.v1.model.DeleteCollectionResponse; -import com.ibm.watson.discovery.v1.model.DeleteConfigurationOptions; -import com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse; -import com.ibm.watson.discovery.v1.model.DeleteCredentials; -import com.ibm.watson.discovery.v1.model.DeleteCredentialsOptions; -import com.ibm.watson.discovery.v1.model.DeleteDocumentOptions; -import com.ibm.watson.discovery.v1.model.DeleteDocumentResponse; -import com.ibm.watson.discovery.v1.model.DeleteEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.DeleteEnvironmentResponse; -import com.ibm.watson.discovery.v1.model.DeleteExpansionsOptions; -import com.ibm.watson.discovery.v1.model.DeleteGatewayOptions; -import com.ibm.watson.discovery.v1.model.DeleteStopwordListOptions; -import com.ibm.watson.discovery.v1.model.DeleteTokenizationDictionaryOptions; -import com.ibm.watson.discovery.v1.model.DeleteTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.DeleteTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.DeleteUserDataOptions; -import com.ibm.watson.discovery.v1.model.DocumentAccepted; -import com.ibm.watson.discovery.v1.model.DocumentStatus; -import com.ibm.watson.discovery.v1.model.Environment; -import com.ibm.watson.discovery.v1.model.Expansions; -import com.ibm.watson.discovery.v1.model.FederatedQueryNoticesOptions; -import com.ibm.watson.discovery.v1.model.FederatedQueryOptions; -import com.ibm.watson.discovery.v1.model.Gateway; -import com.ibm.watson.discovery.v1.model.GatewayDelete; -import com.ibm.watson.discovery.v1.model.GatewayList; -import com.ibm.watson.discovery.v1.model.GetAutocompletionOptions; -import com.ibm.watson.discovery.v1.model.GetCollectionOptions; -import com.ibm.watson.discovery.v1.model.GetConfigurationOptions; -import com.ibm.watson.discovery.v1.model.GetCredentialsOptions; -import com.ibm.watson.discovery.v1.model.GetDocumentStatusOptions; -import com.ibm.watson.discovery.v1.model.GetEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.GetGatewayOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsEventRateOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryEventOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryNoResultsOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryTokenEventOptions; -import com.ibm.watson.discovery.v1.model.GetStopwordListStatusOptions; -import com.ibm.watson.discovery.v1.model.GetTokenizationDictionaryStatusOptions; -import com.ibm.watson.discovery.v1.model.GetTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.GetTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionFieldsOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionFieldsResponse; -import com.ibm.watson.discovery.v1.model.ListCollectionsOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionsResponse; -import com.ibm.watson.discovery.v1.model.ListConfigurationsOptions; -import com.ibm.watson.discovery.v1.model.ListConfigurationsResponse; -import com.ibm.watson.discovery.v1.model.ListCredentialsOptions; -import com.ibm.watson.discovery.v1.model.ListEnvironmentsOptions; -import com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse; -import com.ibm.watson.discovery.v1.model.ListExpansionsOptions; -import com.ibm.watson.discovery.v1.model.ListFieldsOptions; -import com.ibm.watson.discovery.v1.model.ListGatewaysOptions; -import com.ibm.watson.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.ListTrainingExamplesOptions; -import com.ibm.watson.discovery.v1.model.LogQueryResponse; -import com.ibm.watson.discovery.v1.model.MetricResponse; -import com.ibm.watson.discovery.v1.model.MetricTokenResponse; -import com.ibm.watson.discovery.v1.model.QueryLogOptions; -import com.ibm.watson.discovery.v1.model.QueryNoticesOptions; -import com.ibm.watson.discovery.v1.model.QueryNoticesResponse; -import com.ibm.watson.discovery.v1.model.QueryOptions; -import com.ibm.watson.discovery.v1.model.QueryResponse; -import com.ibm.watson.discovery.v1.model.TokenDictStatusResponse; -import com.ibm.watson.discovery.v1.model.TrainingDataSet; -import com.ibm.watson.discovery.v1.model.TrainingExample; -import com.ibm.watson.discovery.v1.model.TrainingExampleList; -import com.ibm.watson.discovery.v1.model.TrainingQuery; -import com.ibm.watson.discovery.v1.model.UpdateCollectionOptions; -import com.ibm.watson.discovery.v1.model.UpdateConfigurationOptions; -import com.ibm.watson.discovery.v1.model.UpdateCredentialsOptions; -import com.ibm.watson.discovery.v1.model.UpdateDocumentOptions; -import com.ibm.watson.discovery.v1.model.UpdateEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.UpdateTrainingExampleOptions; -import java.util.Map; -import java.util.Map.Entry; -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 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. - * - * @version v1 - * @see Discovery - */ -public class Discovery extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "discovery"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/discovery/api"; - - private String versionDate; - - /** - * Constructs a new `Discovery` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public Discovery(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `Discovery` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public Discovery(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `Discovery` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public Discovery(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `Discovery` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public Discovery(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Create an environment. - * - * Creates a new environment for private data. An environment must be created before collections can be created. - * - * **Note**: You can create only one environment for private data per service instance. An attempt to create another - * environment results in an error. - * - * @param createEnvironmentOptions the {@link CreateEnvironmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Environment} - */ - public ServiceCall createEnvironment(CreateEnvironmentOptions createEnvironmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createEnvironmentOptions, - "createEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createEnvironment"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createEnvironmentOptions.name()); - if (createEnvironmentOptions.description() != null) { - contentJson.addProperty("description", createEnvironmentOptions.description()); - } - if (createEnvironmentOptions.size() != null) { - contentJson.addProperty("size", createEnvironmentOptions.size()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List environments. - * - * List existing environments for the service instance. - * - * @param listEnvironmentsOptions the {@link ListEnvironmentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListEnvironmentsResponse} - */ - public ServiceCall listEnvironments(ListEnvironmentsOptions listEnvironmentsOptions) { - String[] pathSegments = { "v1/environments" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listEnvironments"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listEnvironmentsOptions != null) { - if (listEnvironmentsOptions.name() != null) { - builder.query("name", listEnvironmentsOptions.name()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List environments. - * - * List existing environments for the service instance. - * - * @return a {@link ServiceCall} with a response type of {@link ListEnvironmentsResponse} - */ - public ServiceCall listEnvironments() { - return listEnvironments(null); - } - - /** - * Get environment info. - * - * @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Environment} - */ - public ServiceCall getEnvironment(GetEnvironmentOptions getEnvironmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getEnvironmentOptions, - "getEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - String[] pathParameters = { getEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getEnvironment"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update an environment. - * - * Updates an environment. The environment's **name** and **description** parameters can be changed. You must specify - * a **name** for the environment. - * - * @param updateEnvironmentOptions the {@link UpdateEnvironmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Environment} - */ - public ServiceCall updateEnvironment(UpdateEnvironmentOptions updateEnvironmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateEnvironmentOptions, - "updateEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - String[] pathParameters = { updateEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateEnvironment"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (updateEnvironmentOptions.name() != null) { - contentJson.addProperty("name", updateEnvironmentOptions.name()); - } - if (updateEnvironmentOptions.description() != null) { - contentJson.addProperty("description", updateEnvironmentOptions.description()); - } - if (updateEnvironmentOptions.size() != null) { - contentJson.addProperty("size", updateEnvironmentOptions.size()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete environment. - * - * @param deleteEnvironmentOptions the {@link DeleteEnvironmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteEnvironmentResponse} - */ - public ServiceCall deleteEnvironment(DeleteEnvironmentOptions deleteEnvironmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteEnvironmentOptions, - "deleteEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - String[] pathParameters = { deleteEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteEnvironment"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List fields across collections. - * - * Gets a list of the unique fields (and their types) stored in the indexes of the specified collections. - * - * @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse} - */ - public ServiceCall listFields(ListFieldsOptions listFieldsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listFieldsOptions, - "listFieldsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "fields" }; - String[] pathParameters = { listFieldsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listFields"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add configuration. - * - * Creates a new configuration. - * - * If the input configuration contains the **configuration_id**, **created**, or **updated** properties, then they are - * ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be - * removed when copying a configuration. - * - * The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. - * This makes it easier to use newer configuration files with older versions of the API and the service. It also makes - * it possible for the tooling to add additional metadata and information to the configuration. - * - * @param createConfigurationOptions the {@link CreateConfigurationOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Configuration} - */ - public ServiceCall createConfiguration(CreateConfigurationOptions createConfigurationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createConfigurationOptions, - "createConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { createConfigurationOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createConfiguration"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createConfigurationOptions.name()); - if (createConfigurationOptions.description() != null) { - contentJson.addProperty("description", createConfigurationOptions.description()); - } - if (createConfigurationOptions.conversions() != null) { - contentJson.add("conversions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createConfigurationOptions.conversions())); - } - if (createConfigurationOptions.enrichments() != null) { - contentJson.add("enrichments", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createConfigurationOptions.enrichments())); - } - if (createConfigurationOptions.normalizations() != null) { - contentJson.add("normalizations", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createConfigurationOptions.normalizations())); - } - if (createConfigurationOptions.source() != null) { - contentJson.add("source", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createConfigurationOptions.source())); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List configurations. - * - * Lists existing configurations for the service instance. - * - * @param listConfigurationsOptions the {@link ListConfigurationsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListConfigurationsResponse} - */ - public ServiceCall listConfigurations( - ListConfigurationsOptions listConfigurationsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listConfigurationsOptions, - "listConfigurationsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { listConfigurationsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listConfigurations"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listConfigurationsOptions.name() != null) { - builder.query("name", listConfigurationsOptions.name()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get configuration details. - * - * @param getConfigurationOptions the {@link GetConfigurationOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Configuration} - */ - public ServiceCall getConfiguration(GetConfigurationOptions getConfigurationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getConfigurationOptions, - "getConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { getConfigurationOptions.environmentId(), getConfigurationOptions.configurationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getConfiguration"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update a configuration. - * - * Replaces an existing configuration. - * * Completely replaces the original configuration. - * * The **configuration_id**, **updated**, and **created** fields are accepted in the request, but they are - * ignored, and an error is not generated. It is also acceptable for users to submit an updated configuration with - * none of the three properties. - * * Documents are processed with a snapshot of the configuration as it was at the time the document was submitted - * to be ingested. This means that already submitted documents will not see any updates made to the configuration. - * - * @param updateConfigurationOptions the {@link UpdateConfigurationOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Configuration} - */ - public ServiceCall updateConfiguration(UpdateConfigurationOptions updateConfigurationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateConfigurationOptions, - "updateConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { updateConfigurationOptions.environmentId(), updateConfigurationOptions - .configurationId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateConfiguration"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", updateConfigurationOptions.name()); - if (updateConfigurationOptions.description() != null) { - contentJson.addProperty("description", updateConfigurationOptions.description()); - } - if (updateConfigurationOptions.conversions() != null) { - contentJson.add("conversions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateConfigurationOptions.conversions())); - } - if (updateConfigurationOptions.enrichments() != null) { - contentJson.add("enrichments", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateConfigurationOptions.enrichments())); - } - if (updateConfigurationOptions.normalizations() != null) { - contentJson.add("normalizations", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateConfigurationOptions.normalizations())); - } - if (updateConfigurationOptions.source() != null) { - contentJson.add("source", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateConfigurationOptions.source())); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a configuration. - * - * The deletion is performed unconditionally. A configuration deletion request succeeds even if the configuration is - * referenced by a collection or document ingestion. However, documents that have already been submitted for - * processing continue to use the deleted configuration. Documents are always processed with a snapshot of the - * configuration as it existed at the time the document was submitted. - * - * @param deleteConfigurationOptions the {@link DeleteConfigurationOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteConfigurationResponse} - */ - public ServiceCall deleteConfiguration( - DeleteConfigurationOptions deleteConfigurationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteConfigurationOptions, - "deleteConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { deleteConfigurationOptions.environmentId(), deleteConfigurationOptions - .configurationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteConfiguration"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create a collection. - * - * @param createCollectionOptions the {@link CreateCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall createCollection(CreateCollectionOptions createCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createCollectionOptions, - "createCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { createCollectionOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createCollectionOptions.name()); - if (createCollectionOptions.description() != null) { - contentJson.addProperty("description", createCollectionOptions.description()); - } - if (createCollectionOptions.configurationId() != null) { - contentJson.addProperty("configuration_id", createCollectionOptions.configurationId()); - } - if (createCollectionOptions.language() != null) { - contentJson.addProperty("language", createCollectionOptions.language()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List collections. - * - * Lists existing collections for the service instance. - * - * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionsResponse} - */ - public ServiceCall listCollections(ListCollectionsOptions listCollectionsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listCollectionsOptions, - "listCollectionsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { listCollectionsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollections"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listCollectionsOptions.name() != null) { - builder.query("name", listCollectionsOptions.name()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get collection details. - * - * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall getCollection(GetCollectionOptions getCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getCollectionOptions, - "getCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { getCollectionOptions.environmentId(), getCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update a collection. - * - * @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall updateCollection(UpdateCollectionOptions updateCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateCollectionOptions, - "updateCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", updateCollectionOptions.name()); - if (updateCollectionOptions.description() != null) { - contentJson.addProperty("description", updateCollectionOptions.description()); - } - if (updateCollectionOptions.configurationId() != null) { - contentJson.addProperty("configuration_id", updateCollectionOptions.configurationId()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a collection. - * - * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteCollectionResponse} - */ - public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCollectionOptions, - "deleteCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { deleteCollectionOptions.environmentId(), deleteCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List collection fields. - * - * Gets a list of the unique fields (and their types) stored in the index. - * - * @param listCollectionFieldsOptions the {@link ListCollectionFieldsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse} - */ - public ServiceCall listCollectionFields( - ListCollectionFieldsOptions listCollectionFieldsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listCollectionFieldsOptions, - "listCollectionFieldsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "fields" }; - String[] pathParameters = { listCollectionFieldsOptions.environmentId(), listCollectionFieldsOptions - .collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollectionFields"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get the expansion list. - * - * Returns the current expansion list for the specified collection. If an expansion list is not specified, an object - * with empty expansion arrays is returned. - * - * @param listExpansionsOptions the {@link ListExpansionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Expansions} - */ - public ServiceCall listExpansions(ListExpansionsOptions listExpansionsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listExpansionsOptions, - "listExpansionsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "expansions" }; - String[] pathParameters = { listExpansionsOptions.environmentId(), listExpansionsOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listExpansions"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create or update expansion list. - * - * Create or replace the Expansion list for this collection. The maximum number of expanded terms per collection is - * `500`. The current expansion list is replaced with the uploaded content. - * - * @param createExpansionsOptions the {@link CreateExpansionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Expansions} - */ - public ServiceCall createExpansions(CreateExpansionsOptions createExpansionsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createExpansionsOptions, - "createExpansionsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "expansions" }; - String[] pathParameters = { createExpansionsOptions.environmentId(), createExpansionsOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createExpansions"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.add("expansions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createExpansionsOptions - .expansions())); - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete the expansion list. - * - * Remove the expansion information for this collection. The expansion list must be deleted to disable query expansion - * for a collection. - * - * @param deleteExpansionsOptions the {@link DeleteExpansionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteExpansions(DeleteExpansionsOptions deleteExpansionsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteExpansionsOptions, - "deleteExpansionsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "expansions" }; - String[] pathParameters = { deleteExpansionsOptions.environmentId(), deleteExpansionsOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteExpansions"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get tokenization dictionary status. - * - * Returns the current status of the tokenization dictionary for the specified collection. - * - * @param getTokenizationDictionaryStatusOptions the {@link GetTokenizationDictionaryStatusOptions} containing the - * options for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} - */ - public ServiceCall getTokenizationDictionaryStatus( - GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getTokenizationDictionaryStatusOptions, - "getTokenizationDictionaryStatusOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" }; - String[] pathParameters = { getTokenizationDictionaryStatusOptions.environmentId(), - getTokenizationDictionaryStatusOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTokenizationDictionaryStatus"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create tokenization dictionary. - * - * Upload a custom tokenization dictionary to use with the specified collection. - * - * @param createTokenizationDictionaryOptions the {@link CreateTokenizationDictionaryOptions} containing the options - * for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} - */ - public ServiceCall createTokenizationDictionary( - CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createTokenizationDictionaryOptions, - "createTokenizationDictionaryOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" }; - String[] pathParameters = { createTokenizationDictionaryOptions.environmentId(), createTokenizationDictionaryOptions - .collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTokenizationDictionary"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (createTokenizationDictionaryOptions.tokenizationRules() != null) { - contentJson.add("tokenization_rules", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createTokenizationDictionaryOptions.tokenizationRules())); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete tokenization dictionary. - * - * Delete the tokenization dictionary from the collection. - * - * @param deleteTokenizationDictionaryOptions the {@link DeleteTokenizationDictionaryOptions} containing the options - * for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteTokenizationDictionary( - DeleteTokenizationDictionaryOptions deleteTokenizationDictionaryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteTokenizationDictionaryOptions, - "deleteTokenizationDictionaryOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" }; - String[] pathParameters = { deleteTokenizationDictionaryOptions.environmentId(), deleteTokenizationDictionaryOptions - .collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteTokenizationDictionary"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get stopword list status. - * - * Returns the current status of the stopword list for the specified collection. - * - * @param getStopwordListStatusOptions the {@link GetStopwordListStatusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} - */ - public ServiceCall getStopwordListStatus( - GetStopwordListStatusOptions getStopwordListStatusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getStopwordListStatusOptions, - "getStopwordListStatusOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "word_lists/stopwords" }; - String[] pathParameters = { getStopwordListStatusOptions.environmentId(), getStopwordListStatusOptions - .collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getStopwordListStatus"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create stopword list. - * - * Upload a custom stopword list to use with the specified collection. - * - * @param createStopwordListOptions the {@link CreateStopwordListOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} - */ - public ServiceCall createStopwordList(CreateStopwordListOptions createStopwordListOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createStopwordListOptions, - "createStopwordListOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "word_lists/stopwords" }; - String[] pathParameters = { createStopwordListOptions.environmentId(), createStopwordListOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createStopwordList"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody stopwordFileBody = RequestUtils.inputStreamBody(createStopwordListOptions.stopwordFile(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("stopword_file", createStopwordListOptions.stopwordFilename(), stopwordFileBody); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a custom stopword list. - * - * Delete a custom stopword list from the collection. After a custom stopword list is deleted, the default list is - * used for the collection. - * - * @param deleteStopwordListOptions the {@link DeleteStopwordListOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteStopwordList(DeleteStopwordListOptions deleteStopwordListOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteStopwordListOptions, - "deleteStopwordListOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "word_lists/stopwords" }; - String[] pathParameters = { deleteStopwordListOptions.environmentId(), deleteStopwordListOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteStopwordList"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add a document. - * - * Add a document to a collection with optional metadata. - * - * * The **version** query parameter is still required. - * - * * Returns immediately after the system has accepted the document for processing. - * - * * The user must provide document content, metadata, or both. If the request is missing both document content and - * metadata, it is rejected. - * - * * The user can set the **Content-Type** parameter on the **file** part to indicate the media type of the - * document. If the **Content-Type** parameter is missing or is one of the generic media types (for example, - * `application/octet-stream`), then the service attempts to automatically detect the document's media type. - * - * * The following field names are reserved and will be filtered out if present after normalization: `id`, `score`, - * `highlight`, and any field with the prefix of: `_`, `+`, or `-` - * - * * Fields with empty name values after normalization are filtered out before indexing. - * - * * Fields containing the following characters after normalization are filtered out before indexing: `#` and `,` - * - * **Note:** Documents can be added with a specific **document_id** by using the - * **_/v1/environments/{environment_id}/collections/{collection_id}/documents** method. - * - * @param addDocumentOptions the {@link AddDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} - */ - public ServiceCall addDocument(AddDocumentOptions addDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addDocumentOptions, - "addDocumentOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((addDocumentOptions.file() != null) || (addDocumentOptions - .metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = { "v1/environments", "collections", "documents" }; - String[] pathParameters = { addDocumentOptions.environmentId(), addDocumentOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "addDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (addDocumentOptions.file() != null) { - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(addDocumentOptions.file(), addDocumentOptions - .fileContentType()); - multipartBuilder.addFormDataPart("file", addDocumentOptions.filename(), fileBody); - } - if (addDocumentOptions.metadata() != null) { - multipartBuilder.addFormDataPart("metadata", addDocumentOptions.metadata()); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get document details. - * - * Fetch status details about a submitted document. **Note:** this operation does not return the document itself. - * Instead, it returns only the document's processing status and any notices (warnings or errors) that were generated - * when the document was ingested. Use the query API to retrieve the actual document content. - * - * @param getDocumentStatusOptions the {@link GetDocumentStatusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentStatus} - */ - public ServiceCall getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentStatusOptions, - "getDocumentStatusOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "documents" }; - String[] pathParameters = { getDocumentStatusOptions.environmentId(), getDocumentStatusOptions.collectionId(), - getDocumentStatusOptions.documentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getDocumentStatus"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update a document. - * - * Replace an existing document or add a document with a specified **document_id**. Starts ingesting a document with - * optional metadata. - * - * **Note:** When uploading a new document with this method it automatically replaces any document stored with the - * same **document_id** if it exists. - * - * @param updateDocumentOptions the {@link UpdateDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} - */ - public ServiceCall updateDocument(UpdateDocumentOptions updateDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateDocumentOptions, - "updateDocumentOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((updateDocumentOptions.file() != null) || (updateDocumentOptions - .metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = { "v1/environments", "collections", "documents" }; - String[] pathParameters = { updateDocumentOptions.environmentId(), updateDocumentOptions.collectionId(), - updateDocumentOptions.documentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (updateDocumentOptions.file() != null) { - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(updateDocumentOptions.file(), updateDocumentOptions - .fileContentType()); - multipartBuilder.addFormDataPart("file", updateDocumentOptions.filename(), fileBody); - } - if (updateDocumentOptions.metadata() != null) { - multipartBuilder.addFormDataPart("metadata", updateDocumentOptions.metadata()); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a document. - * - * 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'. - * - * @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteDocumentResponse} - */ - public ServiceCall deleteDocument(DeleteDocumentOptions deleteDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDocumentOptions, - "deleteDocumentOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "documents" }; - String[] pathParameters = { deleteDocumentOptions.environmentId(), deleteDocumentOptions.collectionId(), - deleteDocumentOptions.documentId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Query a collection. - * - * By using this method, you can construct long queries. For details, see the [Discovery - * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts). - * - * @param queryOptions the {@link QueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryResponse} - */ - public ServiceCall query(QueryOptions queryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(queryOptions, - "queryOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "query" }; - String[] pathParameters = { queryOptions.environmentId(), queryOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "query"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (queryOptions.xWatsonLoggingOptOut() != null) { - builder.header("X-Watson-Logging-Opt-Out", queryOptions.xWatsonLoggingOptOut()); - } - final JsonObject contentJson = new JsonObject(); - if (queryOptions.filter() != null) { - contentJson.addProperty("filter", queryOptions.filter()); - } - if (queryOptions.query() != null) { - contentJson.addProperty("query", queryOptions.query()); - } - if (queryOptions.naturalLanguageQuery() != null) { - contentJson.addProperty("natural_language_query", queryOptions.naturalLanguageQuery()); - } - if (queryOptions.passages() != null) { - contentJson.addProperty("passages", queryOptions.passages()); - } - if (queryOptions.aggregation() != null) { - contentJson.addProperty("aggregation", queryOptions.aggregation()); - } - if (queryOptions.count() != null) { - contentJson.addProperty("count", queryOptions.count()); - } - if (queryOptions.xReturn() != null) { - contentJson.addProperty("return", queryOptions.xReturn()); - } - if (queryOptions.offset() != null) { - contentJson.addProperty("offset", queryOptions.offset()); - } - if (queryOptions.sort() != null) { - contentJson.addProperty("sort", queryOptions.sort()); - } - if (queryOptions.highlight() != null) { - contentJson.addProperty("highlight", queryOptions.highlight()); - } - if (queryOptions.passagesFields() != null) { - contentJson.addProperty("passages.fields", queryOptions.passagesFields()); - } - if (queryOptions.passagesCount() != null) { - contentJson.addProperty("passages.count", queryOptions.passagesCount()); - } - if (queryOptions.passagesCharacters() != null) { - contentJson.addProperty("passages.characters", queryOptions.passagesCharacters()); - } - if (queryOptions.deduplicate() != null) { - contentJson.addProperty("deduplicate", queryOptions.deduplicate()); - } - if (queryOptions.deduplicateField() != null) { - contentJson.addProperty("deduplicate.field", queryOptions.deduplicateField()); - } - if (queryOptions.similar() != null) { - contentJson.addProperty("similar", queryOptions.similar()); - } - if (queryOptions.similarDocumentIds() != null) { - contentJson.addProperty("similar.document_ids", queryOptions.similarDocumentIds()); - } - if (queryOptions.similarFields() != null) { - contentJson.addProperty("similar.fields", queryOptions.similarFields()); - } - if (queryOptions.bias() != null) { - contentJson.addProperty("bias", queryOptions.bias()); - } - if (queryOptions.spellingSuggestions() != null) { - contentJson.addProperty("spelling_suggestions", queryOptions.spellingSuggestions()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Query system notices. - * - * Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when - * ingesting documents and performing relevance training. See the [Discovery - * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts) for - * more details on the query language. - * - * @param queryNoticesOptions the {@link QueryNoticesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse} - */ - public ServiceCall queryNotices(QueryNoticesOptions queryNoticesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(queryNoticesOptions, - "queryNoticesOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "notices" }; - String[] pathParameters = { queryNoticesOptions.environmentId(), queryNoticesOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryNotices"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (queryNoticesOptions.filter() != null) { - builder.query("filter", queryNoticesOptions.filter()); - } - if (queryNoticesOptions.query() != null) { - builder.query("query", queryNoticesOptions.query()); - } - if (queryNoticesOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", queryNoticesOptions.naturalLanguageQuery()); - } - if (queryNoticesOptions.passages() != null) { - builder.query("passages", String.valueOf(queryNoticesOptions.passages())); - } - if (queryNoticesOptions.aggregation() != null) { - builder.query("aggregation", queryNoticesOptions.aggregation()); - } - if (queryNoticesOptions.count() != null) { - builder.query("count", String.valueOf(queryNoticesOptions.count())); - } - if (queryNoticesOptions.xReturn() != null) { - builder.query("return", RequestUtils.join(queryNoticesOptions.xReturn(), ",")); - } - if (queryNoticesOptions.offset() != null) { - builder.query("offset", String.valueOf(queryNoticesOptions.offset())); - } - if (queryNoticesOptions.sort() != null) { - builder.query("sort", RequestUtils.join(queryNoticesOptions.sort(), ",")); - } - if (queryNoticesOptions.highlight() != null) { - builder.query("highlight", String.valueOf(queryNoticesOptions.highlight())); - } - if (queryNoticesOptions.passagesFields() != null) { - builder.query("passages.fields", RequestUtils.join(queryNoticesOptions.passagesFields(), ",")); - } - if (queryNoticesOptions.passagesCount() != null) { - builder.query("passages.count", String.valueOf(queryNoticesOptions.passagesCount())); - } - if (queryNoticesOptions.passagesCharacters() != null) { - builder.query("passages.characters", String.valueOf(queryNoticesOptions.passagesCharacters())); - } - if (queryNoticesOptions.deduplicateField() != null) { - builder.query("deduplicate.field", queryNoticesOptions.deduplicateField()); - } - if (queryNoticesOptions.similar() != null) { - builder.query("similar", String.valueOf(queryNoticesOptions.similar())); - } - if (queryNoticesOptions.similarDocumentIds() != null) { - builder.query("similar.document_ids", RequestUtils.join(queryNoticesOptions.similarDocumentIds(), ",")); - } - if (queryNoticesOptions.similarFields() != null) { - builder.query("similar.fields", RequestUtils.join(queryNoticesOptions.similarFields(), ",")); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Query multiple collections. - * - * By using this method, you can construct long queries that search multiple collection. For details, see the - * [Discovery - * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts). - * - * @param federatedQueryOptions the {@link FederatedQueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryResponse} - */ - public ServiceCall federatedQuery(FederatedQueryOptions federatedQueryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(federatedQueryOptions, - "federatedQueryOptions cannot be null"); - String[] pathSegments = { "v1/environments", "query" }; - String[] pathParameters = { federatedQueryOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "federatedQuery"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (federatedQueryOptions.xWatsonLoggingOptOut() != null) { - builder.header("X-Watson-Logging-Opt-Out", federatedQueryOptions.xWatsonLoggingOptOut()); - } - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("collection_ids", federatedQueryOptions.collectionIds()); - if (federatedQueryOptions.filter() != null) { - contentJson.addProperty("filter", federatedQueryOptions.filter()); - } - if (federatedQueryOptions.query() != null) { - contentJson.addProperty("query", federatedQueryOptions.query()); - } - if (federatedQueryOptions.naturalLanguageQuery() != null) { - contentJson.addProperty("natural_language_query", federatedQueryOptions.naturalLanguageQuery()); - } - if (federatedQueryOptions.passages() != null) { - contentJson.addProperty("passages", federatedQueryOptions.passages()); - } - if (federatedQueryOptions.aggregation() != null) { - contentJson.addProperty("aggregation", federatedQueryOptions.aggregation()); - } - if (federatedQueryOptions.count() != null) { - contentJson.addProperty("count", federatedQueryOptions.count()); - } - if (federatedQueryOptions.xReturn() != null) { - contentJson.addProperty("return", federatedQueryOptions.xReturn()); - } - if (federatedQueryOptions.offset() != null) { - contentJson.addProperty("offset", federatedQueryOptions.offset()); - } - if (federatedQueryOptions.sort() != null) { - contentJson.addProperty("sort", federatedQueryOptions.sort()); - } - if (federatedQueryOptions.highlight() != null) { - contentJson.addProperty("highlight", federatedQueryOptions.highlight()); - } - if (federatedQueryOptions.passagesFields() != null) { - contentJson.addProperty("passages.fields", federatedQueryOptions.passagesFields()); - } - if (federatedQueryOptions.passagesCount() != null) { - contentJson.addProperty("passages.count", federatedQueryOptions.passagesCount()); - } - if (federatedQueryOptions.passagesCharacters() != null) { - contentJson.addProperty("passages.characters", federatedQueryOptions.passagesCharacters()); - } - if (federatedQueryOptions.deduplicate() != null) { - contentJson.addProperty("deduplicate", federatedQueryOptions.deduplicate()); - } - if (federatedQueryOptions.deduplicateField() != null) { - contentJson.addProperty("deduplicate.field", federatedQueryOptions.deduplicateField()); - } - if (federatedQueryOptions.similar() != null) { - contentJson.addProperty("similar", federatedQueryOptions.similar()); - } - if (federatedQueryOptions.similarDocumentIds() != null) { - contentJson.addProperty("similar.document_ids", federatedQueryOptions.similarDocumentIds()); - } - if (federatedQueryOptions.similarFields() != null) { - contentJson.addProperty("similar.fields", federatedQueryOptions.similarFields()); - } - if (federatedQueryOptions.bias() != null) { - contentJson.addProperty("bias", federatedQueryOptions.bias()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Query multiple collection system notices. - * - * Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when - * ingesting documents and performing relevance training. See the [Discovery - * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts) for - * more details on the query language. - * - * @param federatedQueryNoticesOptions the {@link FederatedQueryNoticesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse} - */ - public ServiceCall federatedQueryNotices( - FederatedQueryNoticesOptions federatedQueryNoticesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(federatedQueryNoticesOptions, - "federatedQueryNoticesOptions cannot be null"); - String[] pathSegments = { "v1/environments", "notices" }; - String[] pathParameters = { federatedQueryNoticesOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "federatedQueryNotices"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("collection_ids", RequestUtils.join(federatedQueryNoticesOptions.collectionIds(), ",")); - if (federatedQueryNoticesOptions.filter() != null) { - builder.query("filter", federatedQueryNoticesOptions.filter()); - } - if (federatedQueryNoticesOptions.query() != null) { - builder.query("query", federatedQueryNoticesOptions.query()); - } - if (federatedQueryNoticesOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", federatedQueryNoticesOptions.naturalLanguageQuery()); - } - if (federatedQueryNoticesOptions.aggregation() != null) { - builder.query("aggregation", federatedQueryNoticesOptions.aggregation()); - } - if (federatedQueryNoticesOptions.count() != null) { - builder.query("count", String.valueOf(federatedQueryNoticesOptions.count())); - } - if (federatedQueryNoticesOptions.xReturn() != null) { - builder.query("return", RequestUtils.join(federatedQueryNoticesOptions.xReturn(), ",")); - } - if (federatedQueryNoticesOptions.offset() != null) { - builder.query("offset", String.valueOf(federatedQueryNoticesOptions.offset())); - } - if (federatedQueryNoticesOptions.sort() != null) { - builder.query("sort", RequestUtils.join(federatedQueryNoticesOptions.sort(), ",")); - } - if (federatedQueryNoticesOptions.highlight() != null) { - builder.query("highlight", String.valueOf(federatedQueryNoticesOptions.highlight())); - } - if (federatedQueryNoticesOptions.deduplicateField() != null) { - builder.query("deduplicate.field", federatedQueryNoticesOptions.deduplicateField()); - } - if (federatedQueryNoticesOptions.similar() != null) { - builder.query("similar", String.valueOf(federatedQueryNoticesOptions.similar())); - } - if (federatedQueryNoticesOptions.similarDocumentIds() != null) { - builder.query("similar.document_ids", RequestUtils.join(federatedQueryNoticesOptions.similarDocumentIds(), ",")); - } - if (federatedQueryNoticesOptions.similarFields() != null) { - builder.query("similar.fields", RequestUtils.join(federatedQueryNoticesOptions.similarFields(), ",")); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get Autocomplete Suggestions. - * - * Returns completion query suggestions for the specified prefix. /n/n **Important:** this method is only valid when - * using the Cloud Pak version of Discovery. - * - * @param getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Completions} - */ - public ServiceCall getAutocompletion(GetAutocompletionOptions getAutocompletionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getAutocompletionOptions, - "getAutocompletionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "autocompletion" }; - String[] pathParameters = { getAutocompletionOptions.environmentId(), getAutocompletionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getAutocompletion"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("prefix", getAutocompletionOptions.prefix()); - if (getAutocompletionOptions.field() != null) { - builder.query("field", getAutocompletionOptions.field()); - } - if (getAutocompletionOptions.count() != null) { - builder.query("count", String.valueOf(getAutocompletionOptions.count())); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List training data. - * - * Lists the training data for the specified collection. - * - * @param listTrainingDataOptions the {@link ListTrainingDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingDataSet} - */ - public ServiceCall listTrainingData(ListTrainingDataOptions listTrainingDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listTrainingDataOptions, - "listTrainingDataOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data" }; - String[] pathParameters = { listTrainingDataOptions.environmentId(), listTrainingDataOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add query to training data. - * - * Adds a query to the training data for this collection. The query can contain a filter and natural language query. - * - * @param addTrainingDataOptions the {@link AddTrainingDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} - */ - public ServiceCall addTrainingData(AddTrainingDataOptions addTrainingDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addTrainingDataOptions, - "addTrainingDataOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data" }; - String[] pathParameters = { addTrainingDataOptions.environmentId(), addTrainingDataOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "addTrainingData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (addTrainingDataOptions.naturalLanguageQuery() != null) { - contentJson.addProperty("natural_language_query", addTrainingDataOptions.naturalLanguageQuery()); - } - if (addTrainingDataOptions.filter() != null) { - contentJson.addProperty("filter", addTrainingDataOptions.filter()); - } - if (addTrainingDataOptions.examples() != null) { - contentJson.add("examples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addTrainingDataOptions - .examples())); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete all training data. - * - * Deletes all training data from a collection. - * - * @param deleteAllTrainingDataOptions the {@link DeleteAllTrainingDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteAllTrainingData(DeleteAllTrainingDataOptions deleteAllTrainingDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteAllTrainingDataOptions, - "deleteAllTrainingDataOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data" }; - String[] pathParameters = { deleteAllTrainingDataOptions.environmentId(), deleteAllTrainingDataOptions - .collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteAllTrainingData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get details about a query. - * - * Gets details for a specific training data query, including the query string and all examples. - * - * @param getTrainingDataOptions the {@link GetTrainingDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} - */ - public ServiceCall getTrainingData(GetTrainingDataOptions getTrainingDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getTrainingDataOptions, - "getTrainingDataOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data" }; - String[] pathParameters = { getTrainingDataOptions.environmentId(), getTrainingDataOptions.collectionId(), - getTrainingDataOptions.queryId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a training data query. - * - * Removes the training data query and all associated examples from the training data set. - * - * @param deleteTrainingDataOptions the {@link DeleteTrainingDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteTrainingData(DeleteTrainingDataOptions deleteTrainingDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteTrainingDataOptions, - "deleteTrainingDataOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data" }; - String[] pathParameters = { deleteTrainingDataOptions.environmentId(), deleteTrainingDataOptions.collectionId(), - deleteTrainingDataOptions.queryId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteTrainingData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List examples for a training data query. - * - * List all examples for this training data query. - * - * @param listTrainingExamplesOptions the {@link ListTrainingExamplesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExampleList} - */ - public ServiceCall listTrainingExamples( - ListTrainingExamplesOptions listTrainingExamplesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listTrainingExamplesOptions, - "listTrainingExamplesOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" }; - String[] pathParameters = { listTrainingExamplesOptions.environmentId(), listTrainingExamplesOptions.collectionId(), - listTrainingExamplesOptions.queryId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingExamples"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add example to training data query. - * - * Adds a example to this training data query. - * - * @param createTrainingExampleOptions the {@link CreateTrainingExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExample} - */ - public ServiceCall createTrainingExample(CreateTrainingExampleOptions createTrainingExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createTrainingExampleOptions, - "createTrainingExampleOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" }; - String[] pathParameters = { createTrainingExampleOptions.environmentId(), createTrainingExampleOptions - .collectionId(), createTrainingExampleOptions.queryId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTrainingExample"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (createTrainingExampleOptions.documentId() != null) { - contentJson.addProperty("document_id", createTrainingExampleOptions.documentId()); - } - if (createTrainingExampleOptions.crossReference() != null) { - contentJson.addProperty("cross_reference", createTrainingExampleOptions.crossReference()); - } - if (createTrainingExampleOptions.relevance() != null) { - contentJson.addProperty("relevance", createTrainingExampleOptions.relevance()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete example for training data query. - * - * Deletes the example document with the given ID from the training data query. - * - * @param deleteTrainingExampleOptions the {@link DeleteTrainingExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteTrainingExample(DeleteTrainingExampleOptions deleteTrainingExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteTrainingExampleOptions, - "deleteTrainingExampleOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" }; - String[] pathParameters = { deleteTrainingExampleOptions.environmentId(), deleteTrainingExampleOptions - .collectionId(), deleteTrainingExampleOptions.queryId(), deleteTrainingExampleOptions.exampleId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteTrainingExample"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Change label or cross reference for example. - * - * Changes the label or cross reference query for this training data example. - * - * @param updateTrainingExampleOptions the {@link UpdateTrainingExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExample} - */ - public ServiceCall updateTrainingExample(UpdateTrainingExampleOptions updateTrainingExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateTrainingExampleOptions, - "updateTrainingExampleOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" }; - String[] pathParameters = { updateTrainingExampleOptions.environmentId(), updateTrainingExampleOptions - .collectionId(), updateTrainingExampleOptions.queryId(), updateTrainingExampleOptions.exampleId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateTrainingExample"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (updateTrainingExampleOptions.crossReference() != null) { - contentJson.addProperty("cross_reference", updateTrainingExampleOptions.crossReference()); - } - if (updateTrainingExampleOptions.relevance() != null) { - contentJson.addProperty("relevance", updateTrainingExampleOptions.relevance()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get details for training data example. - * - * Gets the details for this training example. - * - * @param getTrainingExampleOptions the {@link GetTrainingExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExample} - */ - public ServiceCall getTrainingExample(GetTrainingExampleOptions getTrainingExampleOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getTrainingExampleOptions, - "getTrainingExampleOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" }; - String[] pathParameters = { getTrainingExampleOptions.environmentId(), getTrainingExampleOptions.collectionId(), - getTrainingExampleOptions.queryId(), getTrainingExampleOptions.exampleId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingExample"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete labeled data. - * - * Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with - * the customer ID. - * - * 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?topic=discovery-information-security#information-security). - * - * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, - "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteUserData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.query("customer_id", deleteUserDataOptions.customerId()); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create event. - * - * The **Events** API can be used to create log entries that are associated with specific queries. For example, you - * can record which documents in the results set were "clicked" by a user and when that click occurred. - * - * @param createEventOptions the {@link CreateEventOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link CreateEventResponse} - */ - public ServiceCall createEvent(CreateEventOptions createEventOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createEventOptions, - "createEventOptions cannot be null"); - String[] pathSegments = { "v1/events" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createEvent"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("type", createEventOptions.type()); - contentJson.add("data", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEventOptions.data())); - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Search the query and event log. - * - * Searches the query and event log to find query sessions that match the specified criteria. Searching the **logs** - * endpoint uses the standard Discovery query syntax for the parameters that are supported. - * - * @param queryLogOptions the {@link QueryLogOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogQueryResponse} - */ - public ServiceCall queryLog(QueryLogOptions queryLogOptions) { - String[] pathSegments = { "v1/logs" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryLog"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (queryLogOptions != null) { - if (queryLogOptions.filter() != null) { - builder.query("filter", queryLogOptions.filter()); - } - if (queryLogOptions.query() != null) { - builder.query("query", queryLogOptions.query()); - } - if (queryLogOptions.count() != null) { - builder.query("count", String.valueOf(queryLogOptions.count())); - } - if (queryLogOptions.offset() != null) { - builder.query("offset", String.valueOf(queryLogOptions.offset())); - } - if (queryLogOptions.sort() != null) { - builder.query("sort", RequestUtils.join(queryLogOptions.sort(), ",")); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Search the query and event log. - * - * Searches the query and event log to find query sessions that match the specified criteria. Searching the **logs** - * endpoint uses the standard Discovery query syntax for the parameters that are supported. - * - * @return a {@link ServiceCall} with a response type of {@link LogQueryResponse} - */ - public ServiceCall queryLog() { - return queryLog(null); - } - - /** - * Number of queries over time. - * - * Total number of queries using the **natural_language_query** parameter over a specific time window. - * - * @param getMetricsQueryOptions the {@link GetMetricsQueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsQuery(GetMetricsQueryOptions getMetricsQueryOptions) { - String[] pathSegments = { "v1/metrics/number_of_queries" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQuery"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getMetricsQueryOptions != null) { - if (getMetricsQueryOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsQueryOptions.startTime())); - } - if (getMetricsQueryOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsQueryOptions.endTime())); - } - if (getMetricsQueryOptions.resultType() != null) { - builder.query("result_type", getMetricsQueryOptions.resultType()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Number of queries over time. - * - * Total number of queries using the **natural_language_query** parameter over a specific time window. - * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsQuery() { - return getMetricsQuery(null); - } - - /** - * Number of queries with an event over time. - * - * Total number of queries using the **natural_language_query** parameter that have a corresponding "click" event over - * a specified time window. This metric requires having integrated event tracking in your application using the - * **Events** API. - * - * @param getMetricsQueryEventOptions the {@link GetMetricsQueryEventOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsQueryEvent(GetMetricsQueryEventOptions getMetricsQueryEventOptions) { - String[] pathSegments = { "v1/metrics/number_of_queries_with_event" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryEvent"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getMetricsQueryEventOptions != null) { - if (getMetricsQueryEventOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsQueryEventOptions.startTime())); - } - if (getMetricsQueryEventOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsQueryEventOptions.endTime())); - } - if (getMetricsQueryEventOptions.resultType() != null) { - builder.query("result_type", getMetricsQueryEventOptions.resultType()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Number of queries with an event over time. - * - * Total number of queries using the **natural_language_query** parameter that have a corresponding "click" event over - * a specified time window. This metric requires having integrated event tracking in your application using the - * **Events** API. - * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsQueryEvent() { - return getMetricsQueryEvent(null); - } - - /** - * Number of queries with no search results over time. - * - * Total number of queries using the **natural_language_query** parameter that have no results returned over a - * specified time window. - * - * @param getMetricsQueryNoResultsOptions the {@link GetMetricsQueryNoResultsOptions} containing the options for the - * call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsQueryNoResults( - GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptions) { - String[] pathSegments = { "v1/metrics/number_of_queries_with_no_search_results" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryNoResults"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getMetricsQueryNoResultsOptions != null) { - if (getMetricsQueryNoResultsOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsQueryNoResultsOptions.startTime())); - } - if (getMetricsQueryNoResultsOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsQueryNoResultsOptions.endTime())); - } - if (getMetricsQueryNoResultsOptions.resultType() != null) { - builder.query("result_type", getMetricsQueryNoResultsOptions.resultType()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Number of queries with no search results over time. - * - * Total number of queries using the **natural_language_query** parameter that have no results returned over a - * specified time window. - * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsQueryNoResults() { - return getMetricsQueryNoResults(null); - } - - /** - * Percentage of queries with an associated event. - * - * The percentage of queries using the **natural_language_query** parameter that have a corresponding "click" event - * over a specified time window. This metric requires having integrated event tracking in your application using the - * **Events** API. - * - * @param getMetricsEventRateOptions the {@link GetMetricsEventRateOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsEventRate(GetMetricsEventRateOptions getMetricsEventRateOptions) { - String[] pathSegments = { "v1/metrics/event_rate" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsEventRate"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getMetricsEventRateOptions != null) { - if (getMetricsEventRateOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsEventRateOptions.startTime())); - } - if (getMetricsEventRateOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsEventRateOptions.endTime())); - } - if (getMetricsEventRateOptions.resultType() != null) { - builder.query("result_type", getMetricsEventRateOptions.resultType()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Percentage of queries with an associated event. - * - * The percentage of queries using the **natural_language_query** parameter that have a corresponding "click" event - * over a specified time window. This metric requires having integrated event tracking in your application using the - * **Events** API. - * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} - */ - public ServiceCall getMetricsEventRate() { - return getMetricsEventRate(null); - } - - /** - * Most frequent query tokens with an event. - * - * The most frequent query tokens parsed from the **natural_language_query** parameter and their corresponding "click" - * event rate within the recording period (queries and events are stored for 30 days). A query token is an individual - * word or unigram within the query string. - * - * @param getMetricsQueryTokenEventOptions the {@link GetMetricsQueryTokenEventOptions} containing the options for the - * call - * @return a {@link ServiceCall} with a response type of {@link MetricTokenResponse} - */ - public ServiceCall getMetricsQueryTokenEvent( - GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptions) { - String[] pathSegments = { "v1/metrics/top_query_tokens_with_event_rate" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryTokenEvent"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getMetricsQueryTokenEventOptions != null) { - if (getMetricsQueryTokenEventOptions.count() != null) { - builder.query("count", String.valueOf(getMetricsQueryTokenEventOptions.count())); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Most frequent query tokens with an event. - * - * The most frequent query tokens parsed from the **natural_language_query** parameter and their corresponding "click" - * event rate within the recording period (queries and events are stored for 30 days). A query token is an individual - * word or unigram within the query string. - * - * @return a {@link ServiceCall} with a response type of {@link MetricTokenResponse} - */ - public ServiceCall getMetricsQueryTokenEvent() { - return getMetricsQueryTokenEvent(null); - } - - /** - * List credentials. - * - * List all the source credentials that have been created for this service instance. - * - * **Note:** All credentials are sent over an encrypted connection and encrypted at rest. - * - * @param listCredentialsOptions the {@link ListCredentialsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link CredentialsList} - */ - public ServiceCall listCredentials(ListCredentialsOptions listCredentialsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listCredentialsOptions, - "listCredentialsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "credentials" }; - String[] pathParameters = { listCredentialsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCredentials"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create credentials. - * - * Creates a set of credentials to connect to a remote source. Created credentials are used in a configuration to - * associate a collection with the remote source. - * - * **Note:** All credentials are sent over an encrypted connection and encrypted at rest. - * - * @param createCredentialsOptions the {@link CreateCredentialsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Credentials} - */ - public ServiceCall createCredentials(CreateCredentialsOptions createCredentialsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createCredentialsOptions, - "createCredentialsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "credentials" }; - String[] pathParameters = { createCredentialsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCredentials"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (createCredentialsOptions.sourceType() != null) { - contentJson.addProperty("source_type", createCredentialsOptions.sourceType()); - } - if (createCredentialsOptions.credentialDetails() != null) { - contentJson.add("credential_details", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createCredentialsOptions.credentialDetails())); - } - if (createCredentialsOptions.status() != null) { - contentJson.addProperty("status", createCredentialsOptions.status()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * View Credentials. - * - * Returns details about the specified credentials. - * - * **Note:** Secure credential information such as a password or SSH key is never returned and must be obtained from - * the source system. - * - * @param getCredentialsOptions the {@link GetCredentialsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Credentials} - */ - public ServiceCall getCredentials(GetCredentialsOptions getCredentialsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getCredentialsOptions, - "getCredentialsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "credentials" }; - String[] pathParameters = { getCredentialsOptions.environmentId(), getCredentialsOptions.credentialId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCredentials"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update credentials. - * - * Updates an existing set of source credentials. - * - * **Note:** All credentials are sent over an encrypted connection and encrypted at rest. - * - * @param updateCredentialsOptions the {@link UpdateCredentialsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Credentials} - */ - public ServiceCall updateCredentials(UpdateCredentialsOptions updateCredentialsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateCredentialsOptions, - "updateCredentialsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "credentials" }; - String[] pathParameters = { updateCredentialsOptions.environmentId(), updateCredentialsOptions.credentialId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateCredentials"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (updateCredentialsOptions.sourceType() != null) { - contentJson.addProperty("source_type", updateCredentialsOptions.sourceType()); - } - if (updateCredentialsOptions.credentialDetails() != null) { - contentJson.add("credential_details", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateCredentialsOptions.credentialDetails())); - } - if (updateCredentialsOptions.status() != null) { - contentJson.addProperty("status", updateCredentialsOptions.status()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete credentials. - * - * Deletes a set of stored credentials from your Discovery instance. - * - * @param deleteCredentialsOptions the {@link DeleteCredentialsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteCredentials} - */ - public ServiceCall deleteCredentials(DeleteCredentialsOptions deleteCredentialsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCredentialsOptions, - "deleteCredentialsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "credentials" }; - String[] pathParameters = { deleteCredentialsOptions.environmentId(), deleteCredentialsOptions.credentialId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteCredentials"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List Gateways. - * - * List the currently configured gateways. - * - * @param listGatewaysOptions the {@link ListGatewaysOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link GatewayList} - */ - public ServiceCall listGateways(ListGatewaysOptions listGatewaysOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listGatewaysOptions, - "listGatewaysOptions cannot be null"); - String[] pathSegments = { "v1/environments", "gateways" }; - String[] pathParameters = { listGatewaysOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listGateways"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create Gateway. - * - * Create a gateway configuration to use with a remotely installed gateway. - * - * @param createGatewayOptions the {@link CreateGatewayOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Gateway} - */ - public ServiceCall createGateway(CreateGatewayOptions createGatewayOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createGatewayOptions, - "createGatewayOptions cannot be null"); - String[] pathSegments = { "v1/environments", "gateways" }; - String[] pathParameters = { createGatewayOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createGateway"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (createGatewayOptions.name() != null) { - contentJson.addProperty("name", createGatewayOptions.name()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List Gateway Details. - * - * List information about the specified gateway. - * - * @param getGatewayOptions the {@link GetGatewayOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Gateway} - */ - public ServiceCall getGateway(GetGatewayOptions getGatewayOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getGatewayOptions, - "getGatewayOptions cannot be null"); - String[] pathSegments = { "v1/environments", "gateways" }; - String[] pathParameters = { getGatewayOptions.environmentId(), getGatewayOptions.gatewayId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getGateway"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete Gateway. - * - * Delete the specified gateway configuration. - * - * @param deleteGatewayOptions the {@link DeleteGatewayOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link GatewayDelete} - */ - public ServiceCall deleteGateway(DeleteGatewayOptions deleteGatewayOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteGatewayOptions, - "deleteGatewayOptions cannot be null"); - String[] pathSegments = { "v1/environments", "gateways" }; - String[] pathParameters = { deleteGatewayOptions.environmentId(), deleteGatewayOptions.gatewayId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteGateway"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java deleted file mode 100644 index 6ba0cfb460c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.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 { - - protected String environmentId; - protected String collectionId; - protected InputStream file; - protected String filename; - protected String fileContentType; - protected String metadata; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private InputStream file; - private String filename; - private String fileContentType; - private String metadata; - - private Builder(AddDocumentOptions addDocumentOptions) { - this.environmentId = addDocumentOptions.environmentId; - this.collectionId = addDocumentOptions.collectionId; - this.file = addDocumentOptions.file; - this.filename = addDocumentOptions.filename; - this.fileContentType = addDocumentOptions.fileContentType; - this.metadata = addDocumentOptions.metadata; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a AddDocumentOptions. - * - * @return the addDocumentOptions - */ - public AddDocumentOptions build() { - return new AddDocumentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the AddDocumentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - 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 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; - } - } - - protected AddDocumentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId 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."); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - file = builder.file; - filename = builder.filename; - fileContentType = builder.fileContentType; - metadata = builder.metadata; - } - - /** - * New builder. - * - * @return a AddDocumentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * 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 configuration 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java deleted file mode 100644 index 0345928df2f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addTrainingData options. - */ -public class AddTrainingDataOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String naturalLanguageQuery; - protected String filter; - protected List examples; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String naturalLanguageQuery; - private String filter; - private List examples; - - private Builder(AddTrainingDataOptions addTrainingDataOptions) { - this.environmentId = addTrainingDataOptions.environmentId; - this.collectionId = addTrainingDataOptions.collectionId; - this.naturalLanguageQuery = addTrainingDataOptions.naturalLanguageQuery; - this.filter = addTrainingDataOptions.filter; - this.examples = addTrainingDataOptions.examples; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a AddTrainingDataOptions. - * - * @return the addTrainingDataOptions - */ - public AddTrainingDataOptions build() { - return new AddTrainingDataOptions(this); - } - - /** - * Adds an examples to examples. - * - * @param examples the new examples - * @return the AddTrainingDataOptions builder - */ - public Builder addExamples(TrainingExample examples) { - com.ibm.cloud.sdk.core.util.Validator.notNull(examples, - "examples cannot be null"); - if (this.examples == null) { - this.examples = new ArrayList(); - } - this.examples.add(examples); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the AddTrainingDataOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the AddTrainingDataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the naturalLanguageQuery. - * - * @param naturalLanguageQuery the naturalLanguageQuery - * @return the AddTrainingDataOptions builder - */ - public Builder naturalLanguageQuery(String naturalLanguageQuery) { - this.naturalLanguageQuery = naturalLanguageQuery; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the AddTrainingDataOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. - * - * @param examples the examples - * @return the AddTrainingDataOptions builder - */ - public Builder examples(List examples) { - this.examples = examples; - return this; - } - } - - protected AddTrainingDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - naturalLanguageQuery = builder.naturalLanguageQuery; - filter = builder.filter; - examples = builder.examples; - } - - /** - * New builder. - * - * @return a AddTrainingDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the naturalLanguageQuery. - * - * The natural text query for the new training query. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the filter. - * - * The filter used on the collection before the **natural_language_query** is applied. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the examples. - * - * Array of training examples. - * - * @return the examples - */ - public List examples() { - return examples; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java deleted file mode 100644 index 8d61224a4c0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Aggregation results for the specified query. - */ -public class AggregationResult extends GenericModel { - - protected String key; - @SerializedName("matching_results") - protected Long matchingResults; - protected List aggregations; - - /** - * Gets the key. - * - * Key that matched the aggregation type. - * - * @return the key - */ - public String getKey() { - return key; - } - - /** - * Gets the matchingResults. - * - * Number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the aggregations. - * - * Aggregations returned in the case of chained aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java deleted file mode 100644 index 9b49c6f9ec5..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -/** - * Calculation. - */ -public class Calculation extends QueryAggregation { - - protected String field; - protected Double value; - - /** - * Gets the field. - * - * The field where the aggregation is located in the document. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the value. - * - * Value of the aggregation. - * - * @return the value - */ - public Double getValue() { - return value; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java deleted file mode 100644 index 967e555c205..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.Date; - -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 { - - /** - * The status of the collection. - */ - public interface Status { - /** active. */ - String ACTIVE = "active"; - /** pending. */ - String PENDING = "pending"; - /** maintenance. */ - String MAINTENANCE = "maintenance"; - } - - @SerializedName("collection_id") - protected String collectionId; - protected String name; - protected String description; - protected Date created; - protected Date updated; - protected String status; - @SerializedName("configuration_id") - protected String configurationId; - protected String language; - @SerializedName("document_counts") - protected DocumentCounts documentCounts; - @SerializedName("disk_usage") - protected CollectionDiskUsage diskUsage; - @SerializedName("training_status") - protected TrainingStatus trainingStatus; - @SerializedName("crawl_status") - protected CollectionCrawlStatus crawlStatus; - @SerializedName("smart_document_understanding") - protected SduStatus smartDocumentUnderstanding; - - /** - * 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; - } - - /** - * Gets the description. - * - * The description of the collection. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the created. - * - * The creation date of the collection in the format yyyy-MM-dd'T'HH:mmcon:ss.SSS'Z'. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp of when the collection was last updated in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the status. - * - * The status of the collection. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the configurationId. - * - * The unique identifier of the collection's configuration. - * - * @return the configurationId - */ - public String getConfigurationId() { - return configurationId; - } - - /** - * Gets the language. - * - * The language of the documents stored in the collection. Permitted values include `en` (English), `de` (German), and - * `es` (Spanish). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the documentCounts. - * - * Object containing collection document count information. - * - * @return the documentCounts - */ - public DocumentCounts getDocumentCounts() { - return documentCounts; - } - - /** - * Gets the diskUsage. - * - * Summary of the disk usage statistics for this collection. - * - * @return the diskUsage - */ - public CollectionDiskUsage getDiskUsage() { - return diskUsage; - } - - /** - * Gets the trainingStatus. - * - * Training status details. - * - * @return the trainingStatus - */ - public TrainingStatus getTrainingStatus() { - return trainingStatus; - } - - /** - * Gets the crawlStatus. - * - * Object containing information about the crawl status of this collection. - * - * @return the crawlStatus - */ - public CollectionCrawlStatus getCrawlStatus() { - return crawlStatus; - } - - /** - * Gets the smartDocumentUnderstanding. - * - * Object containing smart document understanding information for this collection. - * - * @return the smartDocumentUnderstanding - */ - public SduStatus getSmartDocumentUnderstanding() { - return smartDocumentUnderstanding; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java deleted file mode 100644 index 78168a406a7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing information about the crawl status of this collection. - */ -public class CollectionCrawlStatus extends GenericModel { - - @SerializedName("source_crawl") - protected SourceStatus sourceCrawl; - - /** - * Gets the sourceCrawl. - * - * Object containing source crawl status information. - * - * @return the sourceCrawl - */ - public SourceStatus getSourceCrawl() { - return sourceCrawl; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java deleted file mode 100644 index 6063ccea01f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Summary of the disk usage statistics for this collection. - */ -public class CollectionDiskUsage extends GenericModel { - - @SerializedName("used_bytes") - protected Long usedBytes; - - /** - * Gets the usedBytes. - * - * Number of bytes used by the collection. - * - * @return the usedBytes - */ - public Long getUsedBytes() { - return usedBytes; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java deleted file mode 100644 index bc3a9e33b7e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Summary of the collection usage in the environment. - */ -public class CollectionUsage extends GenericModel { - - protected Long available; - @SerializedName("maximum_allowed") - protected Long maximumAllowed; - - /** - * Gets the available. - * - * Number of active collections in the environment. - * - * @return the available - */ - public Long getAvailable() { - return available; - } - - /** - * Gets the maximumAllowed. - * - * Total number of collections allowed in the environment. - * - * @return the maximumAllowed - */ - public Long getMaximumAllowed() { - return maximumAllowed; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java deleted file mode 100644 index affe6a916c2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.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 { - - protected List completions; - - /** - * Gets the completions. - * - * Array of autcomplete suggestion based on the provided prefix. - * - * @return the completions - */ - public List getCompletions() { - return completions; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java deleted file mode 100644 index f62ecb38e00..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A custom configuration for the environment. - */ -public class Configuration extends GenericModel { - - @SerializedName("configuration_id") - protected String configurationId; - protected String name; - protected Date created; - protected Date updated; - protected String description; - protected Conversions conversions; - protected List enrichments; - protected List normalizations; - protected Source source; - - /** - * Builder. - */ - public static class Builder { - private String configurationId; - private String name; - private Date created; - private Date updated; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - private Source source; - - private Builder(Configuration configuration) { - this.configurationId = configuration.configurationId; - this.name = configuration.name; - this.created = configuration.created; - this.updated = configuration.updated; - this.description = configuration.description; - this.conversions = configuration.conversions; - this.enrichments = configuration.enrichments; - this.normalizations = configuration.normalizations; - this.source = configuration.source; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this.name = name; - } - - /** - * Builds a Configuration. - * - * @return the configuration - */ - public Configuration build() { - return new Configuration(this); - } - - /** - * Adds an enrichment to enrichments. - * - * @param enrichment the new enrichment - * @return the Configuration builder - */ - public Builder addEnrichment(Enrichment enrichment) { - com.ibm.cloud.sdk.core.util.Validator.notNull(enrichment, - "enrichment cannot be null"); - if (this.enrichments == null) { - this.enrichments = new ArrayList(); - } - this.enrichments.add(enrichment); - return this; - } - - /** - * Adds an normalization to normalizations. - * - * @param normalization the new normalization - * @return the Configuration builder - */ - public Builder addNormalization(NormalizationOperation normalization) { - com.ibm.cloud.sdk.core.util.Validator.notNull(normalization, - "normalization cannot be null"); - if (this.normalizations == null) { - this.normalizations = new ArrayList(); - } - this.normalizations.add(normalization); - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the Configuration builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the Configuration builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the created. - * - * @param created the created - * @return the Configuration builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Configuration builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the Configuration builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conversions. - * - * @param conversions the conversions - * @return the Configuration builder - */ - public Builder conversions(Conversions conversions) { - this.conversions = conversions; - return this; - } - - /** - * Set the enrichments. - * Existing enrichments will be replaced. - * - * @param enrichments the enrichments - * @return the Configuration builder - */ - public Builder enrichments(List enrichments) { - this.enrichments = enrichments; - return this; - } - - /** - * Set the normalizations. - * Existing normalizations will be replaced. - * - * @param normalizations the normalizations - * @return the Configuration builder - */ - public Builder normalizations(List normalizations) { - this.normalizations = normalizations; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the Configuration builder - */ - public Builder source(Source source) { - this.source = source; - return this; - } - } - - protected Configuration(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - configurationId = builder.configurationId; - name = builder.name; - created = builder.created; - updated = builder.updated; - description = builder.description; - conversions = builder.conversions; - enrichments = builder.enrichments; - normalizations = builder.normalizations; - source = builder.source; - } - - /** - * New builder. - * - * @return a Configuration builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the configurationId. - * - * The unique identifier of the configuration. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } - - /** - * Gets the name. - * - * The name of the configuration. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the created. - * - * The creation date of the configuration in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. - * - * @return the created - */ - public Date created() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp of when the configuration was last updated in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. - * - * @return the updated - */ - public Date updated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the configuration, if available. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the conversions. - * - * Document conversion settings. - * - * @return the conversions - */ - public Conversions conversions() { - return conversions; - } - - /** - * Gets the enrichments. - * - * An array of document enrichment settings for the configuration. - * - * @return the enrichments - */ - public List enrichments() { - return enrichments; - } - - /** - * Gets the normalizations. - * - * Defines operations that can be used to transform the final output JSON into a normalized form. Operations are - * executed in the order that they appear in the array. - * - * @return the normalizations - */ - public List normalizations() { - return normalizations; - } - - /** - * Gets the source. - * - * Object containing source parameters for the configuration. - * - * @return the source - */ - public Source source() { - return source; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java deleted file mode 100644 index b7cb2707dfd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Document conversion settings. - */ -public class Conversions extends GenericModel { - - protected PdfSettings pdf; - protected WordSettings word; - protected HtmlSettings html; - protected SegmentSettings segment; - @SerializedName("json_normalizations") - protected List jsonNormalizations; - @SerializedName("image_text_recognition") - protected Boolean imageTextRecognition; - - /** - * Builder. - */ - public static class Builder { - private PdfSettings pdf; - private WordSettings word; - private HtmlSettings html; - private SegmentSettings segment; - private List jsonNormalizations; - private Boolean imageTextRecognition; - - private Builder(Conversions conversions) { - this.pdf = conversions.pdf; - this.word = conversions.word; - this.html = conversions.html; - this.segment = conversions.segment; - this.jsonNormalizations = conversions.jsonNormalizations; - this.imageTextRecognition = conversions.imageTextRecognition; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a Conversions. - * - * @return the conversions - */ - public Conversions build() { - return new Conversions(this); - } - - /** - * Adds an normalization to jsonNormalizations. - * - * @param normalization the new normalization - * @return the Conversions builder - */ - public Builder addNormalization(NormalizationOperation normalization) { - com.ibm.cloud.sdk.core.util.Validator.notNull(normalization, - "normalization cannot be null"); - if (this.jsonNormalizations == null) { - this.jsonNormalizations = new ArrayList(); - } - this.jsonNormalizations.add(normalization); - return this; - } - - /** - * Set the pdf. - * - * @param pdf the pdf - * @return the Conversions builder - */ - public Builder pdf(PdfSettings pdf) { - this.pdf = pdf; - return this; - } - - /** - * Set the word. - * - * @param word the word - * @return the Conversions builder - */ - public Builder word(WordSettings word) { - this.word = word; - return this; - } - - /** - * Set the html. - * - * @param html the html - * @return the Conversions builder - */ - public Builder html(HtmlSettings html) { - this.html = html; - return this; - } - - /** - * Set the segment. - * - * @param segment the segment - * @return the Conversions builder - */ - public Builder segment(SegmentSettings segment) { - this.segment = segment; - return this; - } - - /** - * Set the jsonNormalizations. - * Existing jsonNormalizations will be replaced. - * - * @param jsonNormalizations the jsonNormalizations - * @return the Conversions builder - */ - public Builder jsonNormalizations(List jsonNormalizations) { - this.jsonNormalizations = jsonNormalizations; - return this; - } - - /** - * Set the imageTextRecognition. - * - * @param imageTextRecognition the imageTextRecognition - * @return the Conversions builder - */ - public Builder imageTextRecognition(Boolean imageTextRecognition) { - this.imageTextRecognition = imageTextRecognition; - return this; - } - } - - protected Conversions(Builder builder) { - pdf = builder.pdf; - word = builder.word; - html = builder.html; - segment = builder.segment; - jsonNormalizations = builder.jsonNormalizations; - imageTextRecognition = builder.imageTextRecognition; - } - - /** - * New builder. - * - * @return a Conversions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the pdf. - * - * A list of PDF conversion settings. - * - * @return the pdf - */ - public PdfSettings pdf() { - return pdf; - } - - /** - * Gets the word. - * - * A list of Word conversion settings. - * - * @return the word - */ - public WordSettings word() { - return word; - } - - /** - * Gets the html. - * - * A list of HTML conversion settings. - * - * @return the html - */ - public HtmlSettings html() { - return html; - } - - /** - * Gets the segment. - * - * A list of Document Segmentation settings. - * - * @return the segment - */ - public SegmentSettings segment() { - return segment; - } - - /** - * Gets the jsonNormalizations. - * - * Defines operations that can be used to transform the final output JSON into a normalized form. Operations are - * executed in the order that they appear in the array. - * - * @return the jsonNormalizations - */ - public List jsonNormalizations() { - return jsonNormalizations; - } - - /** - * Gets the imageTextRecognition. - * - * When `true`, automatic text extraction from images (this includes images embedded in supported document formats, - * for example PDF, and suppported image formats, for example TIFF) is performed on documents uploaded to the - * collection. This field is supported on **Advanced** and higher plans only. **Lite** plans do not support image text - * recognition. - * - * @return the imageTextRecognition - */ - public Boolean imageTextRecognition() { - return imageTextRecognition; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java deleted file mode 100644 index 840647f5949..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createCollection options. - */ -public class CreateCollectionOptions extends GenericModel { - - /** - * The language of the documents stored in the collection, in the form of an ISO 639-1 language code. - */ - public interface Language { - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** de. */ - String DE = "de"; - /** ar. */ - String AR = "ar"; - /** fr. */ - String FR = "fr"; - /** it. */ - String IT = "it"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - /** pt. */ - String PT = "pt"; - /** nl. */ - String NL = "nl"; - /** zh-CN. */ - String ZH_CN = "zh-CN"; - } - - protected String environmentId; - protected String name; - protected String description; - protected String configurationId; - protected String language; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - private String description; - private String configurationId; - private String language; - - private Builder(CreateCollectionOptions createCollectionOptions) { - this.environmentId = createCollectionOptions.environmentId; - this.name = createCollectionOptions.name; - this.description = createCollectionOptions.description; - this.configurationId = createCollectionOptions.configurationId; - this.language = createCollectionOptions.language; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param name the name - */ - public Builder(String environmentId, String name) { - this.environmentId = environmentId; - this.name = name; - } - - /** - * Builds a CreateCollectionOptions. - * - * @return the createCollectionOptions - */ - public CreateCollectionOptions build() { - return new CreateCollectionOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateCollectionOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateCollectionOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateCollectionOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the CreateCollectionOptions builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the CreateCollectionOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - } - - protected CreateCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - environmentId = builder.environmentId; - name = builder.name; - description = builder.description; - configurationId = builder.configurationId; - language = builder.language; - } - - /** - * New builder. - * - * @return a CreateCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * The name of the collection to be created. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * A description of the collection. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the configurationId. - * - * The ID of the configuration in which the collection is to be created. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } - - /** - * Gets the language. - * - * The language of the documents stored in the collection, in the form of an ISO 639-1 language code. - * - * @return the language - */ - public String language() { - return language; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java deleted file mode 100644 index 70fc9b8f3ba..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createConfiguration options. - */ -public class CreateConfigurationOptions extends GenericModel { - - protected String environmentId; - protected String name; - protected String description; - protected Conversions conversions; - protected List enrichments; - protected List normalizations; - protected Source source; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - private Source source; - - private Builder(CreateConfigurationOptions createConfigurationOptions) { - this.environmentId = createConfigurationOptions.environmentId; - this.name = createConfigurationOptions.name; - this.description = createConfigurationOptions.description; - this.conversions = createConfigurationOptions.conversions; - this.enrichments = createConfigurationOptions.enrichments; - this.normalizations = createConfigurationOptions.normalizations; - this.source = createConfigurationOptions.source; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param name the name - */ - public Builder(String environmentId, String name) { - this.environmentId = environmentId; - this.name = name; - } - - /** - * Builds a CreateConfigurationOptions. - * - * @return the createConfigurationOptions - */ - public CreateConfigurationOptions build() { - return new CreateConfigurationOptions(this); - } - - /** - * Adds an enrichment to enrichments. - * - * @param enrichment the new enrichment - * @return the CreateConfigurationOptions builder - */ - public Builder addEnrichment(Enrichment enrichment) { - com.ibm.cloud.sdk.core.util.Validator.notNull(enrichment, - "enrichment cannot be null"); - if (this.enrichments == null) { - this.enrichments = new ArrayList(); - } - this.enrichments.add(enrichment); - return this; - } - - /** - * Adds an normalization to normalizations. - * - * @param normalization the new normalization - * @return the CreateConfigurationOptions builder - */ - public Builder addNormalization(NormalizationOperation normalization) { - com.ibm.cloud.sdk.core.util.Validator.notNull(normalization, - "normalization cannot be null"); - if (this.normalizations == null) { - this.normalizations = new ArrayList(); - } - this.normalizations.add(normalization); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateConfigurationOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateConfigurationOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateConfigurationOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conversions. - * - * @param conversions the conversions - * @return the CreateConfigurationOptions builder - */ - public Builder conversions(Conversions conversions) { - this.conversions = conversions; - return this; - } - - /** - * Set the enrichments. - * Existing enrichments will be replaced. - * - * @param enrichments the enrichments - * @return the CreateConfigurationOptions builder - */ - public Builder enrichments(List enrichments) { - this.enrichments = enrichments; - return this; - } - - /** - * Set the normalizations. - * Existing normalizations will be replaced. - * - * @param normalizations the normalizations - * @return the CreateConfigurationOptions builder - */ - public Builder normalizations(List normalizations) { - this.normalizations = normalizations; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the CreateConfigurationOptions builder - */ - public Builder source(Source source) { - this.source = source; - return this; - } - - /** - * Set the configuration. - * - * @param configuration the configuration - * @return the CreateConfigurationOptions builder - */ - public Builder configuration(Configuration configuration) { - this.name = configuration.name(); - this.description = configuration.description(); - this.conversions = configuration.conversions(); - this.enrichments = configuration.enrichments(); - this.normalizations = configuration.normalizations(); - this.source = configuration.source(); - return this; - } - } - - protected CreateConfigurationOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - environmentId = builder.environmentId; - name = builder.name; - description = builder.description; - conversions = builder.conversions; - enrichments = builder.enrichments; - normalizations = builder.normalizations; - source = builder.source; - } - - /** - * New builder. - * - * @return a CreateConfigurationOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * The name of the configuration. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * The description of the configuration, if available. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the conversions. - * - * Document conversion settings. - * - * @return the conversions - */ - public Conversions conversions() { - return conversions; - } - - /** - * Gets the enrichments. - * - * An array of document enrichment settings for the configuration. - * - * @return the enrichments - */ - public List enrichments() { - return enrichments; - } - - /** - * Gets the normalizations. - * - * Defines operations that can be used to transform the final output JSON into a normalized form. Operations are - * executed in the order that they appear in the array. - * - * @return the normalizations - */ - public List normalizations() { - return normalizations; - } - - /** - * Gets the source. - * - * Object containing source parameters for the configuration. - * - * @return the source - */ - public Source source() { - return source; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java deleted file mode 100644 index 8f788e007e3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createCredentials options. - */ -public class CreateCredentialsOptions extends GenericModel { - - /** - * The source that this credentials object connects to. - * - `box` indicates the credentials are used to connect an instance of Enterprise Box. - * - `salesforce` indicates the credentials are used to connect to Salesforce. - * - `sharepoint` indicates the credentials are used to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the credentials are used to perform a web crawl. - * = `cloud_object_storage` indicates the credentials are used to connect to an IBM Cloud Object Store. - */ - public interface SourceType { - /** box. */ - String BOX = "box"; - /** salesforce. */ - String SALESFORCE = "salesforce"; - /** sharepoint. */ - String SHAREPOINT = "sharepoint"; - /** web_crawl. */ - String WEB_CRAWL = "web_crawl"; - /** cloud_object_storage. */ - String CLOUD_OBJECT_STORAGE = "cloud_object_storage"; - } - - /** - * The current status of this set of credentials. `connected` indicates that the credentials are available to use with - * the source configuration of a collection. `invalid` refers to the credentials (for example, the password provided - * has expired) and must be corrected before they can be used with a collection. - */ - public interface Status { - /** connected. */ - String CONNECTED = "connected"; - /** invalid. */ - String INVALID = "invalid"; - } - - protected String environmentId; - protected String sourceType; - protected CredentialDetails credentialDetails; - protected String status; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String sourceType; - private CredentialDetails credentialDetails; - private String status; - - private Builder(CreateCredentialsOptions createCredentialsOptions) { - this.environmentId = createCredentialsOptions.environmentId; - this.sourceType = createCredentialsOptions.sourceType; - this.credentialDetails = createCredentialsOptions.credentialDetails; - this.status = createCredentialsOptions.status; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a CreateCredentialsOptions. - * - * @return the createCredentialsOptions - */ - public CreateCredentialsOptions build() { - return new CreateCredentialsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateCredentialsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the sourceType. - * - * @param sourceType the sourceType - * @return the CreateCredentialsOptions builder - */ - public Builder sourceType(String sourceType) { - this.sourceType = sourceType; - return this; - } - - /** - * Set the credentialDetails. - * - * @param credentialDetails the credentialDetails - * @return the CreateCredentialsOptions builder - */ - public Builder credentialDetails(CredentialDetails credentialDetails) { - this.credentialDetails = credentialDetails; - return this; - } - - /** - * Set the status. - * - * @param status the status - * @return the CreateCredentialsOptions builder - */ - public Builder status(String status) { - this.status = status; - return this; - } - - /** - * Set the credentials. - * - * @param credentials the credentials - * @return the CreateCredentialsOptions builder - */ - public Builder credentials(Credentials credentials) { - this.sourceType = credentials.sourceType(); - this.credentialDetails = credentials.credentialDetails(); - this.status = credentials.status(); - return this; - } - } - - protected CreateCredentialsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - sourceType = builder.sourceType; - credentialDetails = builder.credentialDetails; - status = builder.status; - } - - /** - * New builder. - * - * @return a CreateCredentialsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the sourceType. - * - * The source that this credentials object connects to. - * - `box` indicates the credentials are used to connect an instance of Enterprise Box. - * - `salesforce` indicates the credentials are used to connect to Salesforce. - * - `sharepoint` indicates the credentials are used to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the credentials are used to perform a web crawl. - * = `cloud_object_storage` indicates the credentials are used to connect to an IBM Cloud Object Store. - * - * @return the sourceType - */ - public String sourceType() { - return sourceType; - } - - /** - * Gets the credentialDetails. - * - * Object containing details of the stored credentials. - * - * Obtain credentials for your source from the administrator of the source. - * - * @return the credentialDetails - */ - public CredentialDetails credentialDetails() { - return credentialDetails; - } - - /** - * Gets the status. - * - * The current status of this set of credentials. `connected` indicates that the credentials are available to use with - * the source configuration of a collection. `invalid` refers to the credentials (for example, the password provided - * has expired) and must be corrected before they can be used with a collection. - * - * @return the status - */ - public String status() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java deleted file mode 100644 index e2d2a149a58..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createEnvironment options. - */ -public class CreateEnvironmentOptions extends GenericModel { - - /** - * Size of the environment. In the Lite plan the default and only accepted value is `LT`, in all other plans the - * default is `S`. - */ - public interface Size { - /** LT. */ - String LT = "LT"; - /** XS. */ - String XS = "XS"; - /** S. */ - String S = "S"; - /** MS. */ - String MS = "MS"; - /** M. */ - String M = "M"; - /** ML. */ - String ML = "ML"; - /** L. */ - String L = "L"; - /** XL. */ - String XL = "XL"; - /** XXL. */ - String XXL = "XXL"; - /** XXXL. */ - String XXXL = "XXXL"; - } - - protected String name; - protected String description; - protected String size; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String description; - private String size; - - private Builder(CreateEnvironmentOptions createEnvironmentOptions) { - this.name = createEnvironmentOptions.name; - this.description = createEnvironmentOptions.description; - this.size = createEnvironmentOptions.size; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this.name = name; - } - - /** - * Builds a CreateEnvironmentOptions. - * - * @return the createEnvironmentOptions - */ - public CreateEnvironmentOptions build() { - return new CreateEnvironmentOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateEnvironmentOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateEnvironmentOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the size. - * - * @param size the size - * @return the CreateEnvironmentOptions builder - */ - public Builder size(String size) { - this.size = size; - return this; - } - } - - protected CreateEnvironmentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - name = builder.name; - description = builder.description; - size = builder.size; - } - - /** - * New builder. - * - * @return a CreateEnvironmentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * Name that identifies the environment. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * Description of the environment. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the size. - * - * Size of the environment. In the Lite plan the default and only accepted value is `LT`, in all other plans the - * default is `S`. - * - * @return the size - */ - public String size() { - return size; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java deleted file mode 100644 index 8a0e3f19a41..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createEvent options. - */ -public class CreateEventOptions extends GenericModel { - - /** - * The event type to be created. - */ - public interface Type { - /** click. */ - String CLICK = "click"; - } - - protected String type; - protected EventData data; - - /** - * Builder. - */ - public static class Builder { - private String type; - private EventData data; - - private Builder(CreateEventOptions createEventOptions) { - this.type = createEventOptions.type; - this.data = createEventOptions.data; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param type the type - * @param data the data - */ - public Builder(String type, EventData data) { - this.type = type; - this.data = data; - } - - /** - * Builds a CreateEventOptions. - * - * @return the createEventOptions - */ - public CreateEventOptions build() { - return new CreateEventOptions(this); - } - - /** - * Set the type. - * - * @param type the type - * @return the CreateEventOptions builder - */ - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * Set the data. - * - * @param data the data - * @return the CreateEventOptions builder - */ - public Builder data(EventData data) { - this.data = data; - return this; - } - } - - protected CreateEventOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, - "type cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.data, - "data cannot be null"); - type = builder.type; - data = builder.data; - } - - /** - * New builder. - * - * @return a CreateEventOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the type. - * - * The event type to be created. - * - * @return the type - */ - public String type() { - return type; - } - - /** - * Gets the data. - * - * Query event data object. - * - * @return the data - */ - public EventData data() { - return data; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java deleted file mode 100644 index 1f4fc8a61d8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object defining the event being created. - */ -public class CreateEventResponse extends GenericModel { - - /** - * The event type that was created. - */ - public interface Type { - /** click. */ - String CLICK = "click"; - } - - protected String type; - protected EventData data; - - /** - * Gets the type. - * - * The event type that was created. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the data. - * - * Query event data object. - * - * @return the data - */ - public EventData getData() { - return data; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java deleted file mode 100644 index 0fb5a20ac58..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createExpansions options. - */ -public class CreateExpansionsOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected List expansions; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private List expansions; - - private Builder(CreateExpansionsOptions createExpansionsOptions) { - this.environmentId = createExpansionsOptions.environmentId; - this.collectionId = createExpansionsOptions.collectionId; - this.expansions = createExpansionsOptions.expansions; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param expansions the expansions - */ - public Builder(String environmentId, String collectionId, List expansions) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.expansions = expansions; - } - - /** - * Builds a CreateExpansionsOptions. - * - * @return the createExpansionsOptions - */ - public CreateExpansionsOptions build() { - return new CreateExpansionsOptions(this); - } - - /** - * Adds an expansions to expansions. - * - * @param expansions the new expansions - * @return the CreateExpansionsOptions builder - */ - public Builder addExpansions(Expansion expansions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(expansions, - "expansions cannot be null"); - if (this.expansions == null) { - this.expansions = new ArrayList(); - } - this.expansions.add(expansions); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateExpansionsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the CreateExpansionsOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the expansions. - * Existing expansions will be replaced. - * - * @param expansions the expansions - * @return the CreateExpansionsOptions builder - */ - public Builder expansions(List expansions) { - this.expansions = expansions; - return this; - } - - /** - * Set the expansions. - * - * @param expansions the expansions - * @return the CreateExpansionsOptions builder - */ - public Builder expansions(Expansions expansions) { - this.expansions = expansions.expansions(); - return this; - } - } - - protected CreateExpansionsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.expansions, - "expansions cannot be null"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - expansions = builder.expansions; - } - - /** - * New builder. - * - * @return a CreateExpansionsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the expansions. - * - * An array of query expansion definitions. - * - * Each object in the **expansions** array represents a term or set of terms that will be expanded into other terms. - * Each expansion object can be configured as bidirectional or unidirectional. Bidirectional means that all terms are - * expanded to all other terms in the object. Unidirectional means that a set list of terms can be expanded into a - * second list of terms. - * - * To create a bi-directional expansion specify an **expanded_terms** array. When found in a query, all items in the - * **expanded_terms** array are then expanded to the other items in the same array. - * - * To create a uni-directional expansion, specify both an array of **input_terms** and an array of - * **expanded_terms**. When items in the **input_terms** array are present in a query, they are expanded using the - * items listed in the **expanded_terms** array. - * - * @return the expansions - */ - public List expansions() { - return expansions; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java deleted file mode 100644 index f41e99a5069..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createGateway options. - */ -public class CreateGatewayOptions extends GenericModel { - - protected String environmentId; - protected String name; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - - private Builder(CreateGatewayOptions createGatewayOptions) { - this.environmentId = createGatewayOptions.environmentId; - this.name = createGatewayOptions.name; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a CreateGatewayOptions. - * - * @return the createGatewayOptions - */ - public CreateGatewayOptions build() { - return new CreateGatewayOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateGatewayOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateGatewayOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - } - - protected CreateGatewayOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - name = builder.name; - } - - /** - * New builder. - * - * @return a CreateGatewayOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * User-defined name. - * - * @return the name - */ - public String name() { - return name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java deleted file mode 100644 index 3d7485c587b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.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 createStopwordList options. - */ -public class CreateStopwordListOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected InputStream stopwordFile; - protected String stopwordFilename; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private InputStream stopwordFile; - private String stopwordFilename; - - private Builder(CreateStopwordListOptions createStopwordListOptions) { - this.environmentId = createStopwordListOptions.environmentId; - this.collectionId = createStopwordListOptions.collectionId; - this.stopwordFile = createStopwordListOptions.stopwordFile; - this.stopwordFilename = createStopwordListOptions.stopwordFilename; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param stopwordFile the stopwordFile - * @param stopwordFilename the stopwordFilename - */ - public Builder(String environmentId, String collectionId, InputStream stopwordFile, String stopwordFilename) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.stopwordFile = stopwordFile; - this.stopwordFilename = stopwordFilename; - } - - /** - * Builds a CreateStopwordListOptions. - * - * @return the createStopwordListOptions - */ - public CreateStopwordListOptions build() { - return new CreateStopwordListOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateStopwordListOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the CreateStopwordListOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the stopwordFile. - * - * @param stopwordFile the stopwordFile - * @return the CreateStopwordListOptions builder - */ - public Builder stopwordFile(InputStream stopwordFile) { - this.stopwordFile = stopwordFile; - return this; - } - - /** - * Set the stopwordFilename. - * - * @param stopwordFilename the stopwordFilename - * @return the CreateStopwordListOptions builder - */ - public Builder stopwordFilename(String stopwordFilename) { - this.stopwordFilename = stopwordFilename; - return this; - } - - /** - * Set the stopwordFile. - * - * @param stopwordFile the stopwordFile - * @return the CreateStopwordListOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder stopwordFile(File stopwordFile) throws FileNotFoundException { - this.stopwordFile = new FileInputStream(stopwordFile); - this.stopwordFilename = stopwordFile.getName(); - return this; - } - } - - protected CreateStopwordListOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.stopwordFile, - "stopwordFile cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.stopwordFilename, - "stopwordFilename cannot be null"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - stopwordFile = builder.stopwordFile; - stopwordFilename = builder.stopwordFilename; - } - - /** - * New builder. - * - * @return a CreateStopwordListOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the stopwordFile. - * - * The content of the stopword list to ingest. - * - * @return the stopwordFile - */ - public InputStream stopwordFile() { - return stopwordFile; - } - - /** - * Gets the stopwordFilename. - * - * The filename for stopwordFile. - * - * @return the stopwordFilename - */ - public String stopwordFilename() { - return stopwordFilename; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java deleted file mode 100644 index 7efefe52d1c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createTokenizationDictionary options. - */ -public class CreateTokenizationDictionaryOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected List tokenizationRules; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private List tokenizationRules; - - private Builder(CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) { - this.environmentId = createTokenizationDictionaryOptions.environmentId; - this.collectionId = createTokenizationDictionaryOptions.collectionId; - this.tokenizationRules = createTokenizationDictionaryOptions.tokenizationRules; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a CreateTokenizationDictionaryOptions. - * - * @return the createTokenizationDictionaryOptions - */ - public CreateTokenizationDictionaryOptions build() { - return new CreateTokenizationDictionaryOptions(this); - } - - /** - * Adds an tokenizationRules to tokenizationRules. - * - * @param tokenizationRules the new tokenizationRules - * @return the CreateTokenizationDictionaryOptions builder - */ - public Builder addTokenizationRules(TokenDictRule tokenizationRules) { - com.ibm.cloud.sdk.core.util.Validator.notNull(tokenizationRules, - "tokenizationRules cannot be null"); - if (this.tokenizationRules == null) { - this.tokenizationRules = new ArrayList(); - } - this.tokenizationRules.add(tokenizationRules); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateTokenizationDictionaryOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the CreateTokenizationDictionaryOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the tokenizationRules. - * Existing tokenizationRules will be replaced. - * - * @param tokenizationRules the tokenizationRules - * @return the CreateTokenizationDictionaryOptions builder - */ - public Builder tokenizationRules(List tokenizationRules) { - this.tokenizationRules = tokenizationRules; - return this; - } - } - - protected CreateTokenizationDictionaryOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - tokenizationRules = builder.tokenizationRules; - } - - /** - * New builder. - * - * @return a CreateTokenizationDictionaryOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the tokenizationRules. - * - * An array of tokenization rules. Each rule contains, the original `text` string, component `tokens`, any alternate - * character set `readings`, and which `part_of_speech` the text is from. - * - * @return the tokenizationRules - */ - public List tokenizationRules() { - return tokenizationRules; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java deleted file mode 100644 index e92d6851cbd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createTrainingExample options. - */ -public class CreateTrainingExampleOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - protected String documentId; - protected String crossReference; - protected Long relevance; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - private String documentId; - private String crossReference; - private Long relevance; - - private Builder(CreateTrainingExampleOptions createTrainingExampleOptions) { - this.environmentId = createTrainingExampleOptions.environmentId; - this.collectionId = createTrainingExampleOptions.collectionId; - this.queryId = createTrainingExampleOptions.queryId; - this.documentId = createTrainingExampleOptions.documentId; - this.crossReference = createTrainingExampleOptions.crossReference; - this.relevance = createTrainingExampleOptions.relevance; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - */ - public Builder(String environmentId, String collectionId, String queryId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - } - - /** - * Builds a CreateTrainingExampleOptions. - * - * @return the createTrainingExampleOptions - */ - public CreateTrainingExampleOptions build() { - return new CreateTrainingExampleOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the CreateTrainingExampleOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the CreateTrainingExampleOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the CreateTrainingExampleOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the CreateTrainingExampleOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - - /** - * Set the crossReference. - * - * @param crossReference the crossReference - * @return the CreateTrainingExampleOptions builder - */ - public Builder crossReference(String crossReference) { - this.crossReference = crossReference; - return this; - } - - /** - * Set the relevance. - * - * @param relevance the relevance - * @return the CreateTrainingExampleOptions builder - */ - public Builder relevance(long relevance) { - this.relevance = relevance; - return this; - } - - /** - * Set the trainingExample. - * - * @param trainingExample the trainingExample - * @return the CreateTrainingExampleOptions builder - */ - public Builder trainingExample(TrainingExample trainingExample) { - this.documentId = trainingExample.documentId(); - this.crossReference = trainingExample.crossReference(); - this.relevance = trainingExample.relevance(); - return this; - } - } - - protected CreateTrainingExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - documentId = builder.documentId; - crossReference = builder.crossReference; - relevance = builder.relevance; - } - - /** - * New builder. - * - * @return a CreateTrainingExampleOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } - - /** - * Gets the documentId. - * - * The document ID associated with this training example. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } - - /** - * Gets the crossReference. - * - * The cross reference associated with this training example. - * - * @return the crossReference - */ - public String crossReference() { - return crossReference; - } - - /** - * Gets the relevance. - * - * The relevance of the training example. - * - * @return the relevance - */ - public Long relevance() { - return relevance; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java deleted file mode 100644 index 78357bb802f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java +++ /dev/null @@ -1,642 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing details of the stored credentials. - * - * Obtain credentials for your source from the administrator of the source. - */ -public class CredentialDetails extends GenericModel { - - /** - * The authentication method for this credentials definition. The **credential_type** specified must be supported by - * the **source_type**. The following combinations are possible: - * - * - `"source_type": "box"` - valid `credential_type`s: `oauth2` - * - `"source_type": "salesforce"` - valid `credential_type`s: `username_password` - * - `"source_type": "sharepoint"` - valid `credential_type`s: `saml` with **source_version** of `online`, or - * `ntlm_v1` with **source_version** of `2016` - * - `"source_type": "web_crawl"` - valid `credential_type`s: `noauth` or `basic` - * - "source_type": "cloud_object_storage"` - valid `credential_type`s: `aws4_hmac`. - */ - public interface CredentialType { - /** oauth2. */ - String OAUTH2 = "oauth2"; - /** saml. */ - String SAML = "saml"; - /** username_password. */ - String USERNAME_PASSWORD = "username_password"; //pragma: whitelist secret - /** noauth. */ - String NOAUTH = "noauth"; - /** basic. */ - String BASIC = "basic"; - /** ntlm_v1. */ - String NTLM_V1 = "ntlm_v1"; - /** aws4_hmac. */ - String AWS4_HMAC = "aws4_hmac"; - } - - /** - * The type of Sharepoint repository to connect to. Only valid, and required, with a **source_type** of `sharepoint`. - */ - public interface SourceVersion { - /** online. */ - String ONLINE = "online"; - } - - @SerializedName("credential_type") - protected String credentialType; - @SerializedName("client_id") - protected String clientId; - @SerializedName("enterprise_id") - protected String enterpriseId; - protected String url; - protected String username; - @SerializedName("organization_url") - protected String organizationUrl; - @SerializedName("site_collection.path") - protected String siteCollectionPath; - @SerializedName("client_secret") - protected String clientSecret; - @SerializedName("public_key_id") - protected String publicKeyId; - @SerializedName("private_key") - protected String privateKey; - protected String passphrase; - protected String password; - @SerializedName("gateway_id") - protected String gatewayId; - @SerializedName("source_version") - protected String sourceVersion; - @SerializedName("web_application_url") - protected String webApplicationUrl; - protected String domain; - protected String endpoint; - @SerializedName("access_key_id") - protected String accessKeyId; - @SerializedName("secret_access_key") - protected String secretAccessKey; - - /** - * Builder. - */ - public static class Builder { - private String credentialType; - private String clientId; - private String enterpriseId; - private String url; - private String username; - private String organizationUrl; - private String siteCollectionPath; - private String clientSecret; - private String publicKeyId; - private String privateKey; - private String passphrase; - private String password; - private String gatewayId; - private String sourceVersion; - private String webApplicationUrl; - private String domain; - private String endpoint; - private String accessKeyId; - private String secretAccessKey; - - private Builder(CredentialDetails credentialDetails) { - this.credentialType = credentialDetails.credentialType; - this.clientId = credentialDetails.clientId; - this.enterpriseId = credentialDetails.enterpriseId; - this.url = credentialDetails.url; - this.username = credentialDetails.username; - this.organizationUrl = credentialDetails.organizationUrl; - this.siteCollectionPath = credentialDetails.siteCollectionPath; - this.clientSecret = credentialDetails.clientSecret; - this.publicKeyId = credentialDetails.publicKeyId; - this.privateKey = credentialDetails.privateKey; - this.passphrase = credentialDetails.passphrase; - this.password = credentialDetails.password; //pragma: whitelist secret - this.gatewayId = credentialDetails.gatewayId; - this.sourceVersion = credentialDetails.sourceVersion; - this.webApplicationUrl = credentialDetails.webApplicationUrl; - this.domain = credentialDetails.domain; - this.endpoint = credentialDetails.endpoint; - this.accessKeyId = credentialDetails.accessKeyId; - this.secretAccessKey = credentialDetails.secretAccessKey; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CredentialDetails. - * - * @return the credentialDetails - */ - public CredentialDetails build() { - return new CredentialDetails(this); - } - - /** - * Set the credentialType. - * - * @param credentialType the credentialType - * @return the CredentialDetails builder - */ - public Builder credentialType(String credentialType) { - this.credentialType = credentialType; - return this; - } - - /** - * Set the clientId. - * - * @param clientId the clientId - * @return the CredentialDetails builder - */ - public Builder clientId(String clientId) { - this.clientId = clientId; - return this; - } - - /** - * Set the enterpriseId. - * - * @param enterpriseId the enterpriseId - * @return the CredentialDetails builder - */ - public Builder enterpriseId(String enterpriseId) { - this.enterpriseId = enterpriseId; - return this; - } - - /** - * Set the url. - * - * @param url the url - * @return the CredentialDetails builder - */ - public Builder url(String url) { - this.url = url; - return this; - } - - /** - * Set the username. - * - * @param username the username - * @return the CredentialDetails builder - */ - public Builder username(String username) { - this.username = username; - return this; - } - - /** - * Set the organizationUrl. - * - * @param organizationUrl the organizationUrl - * @return the CredentialDetails builder - */ - public Builder organizationUrl(String organizationUrl) { - this.organizationUrl = organizationUrl; - return this; - } - - /** - * Set the siteCollectionPath. - * - * @param siteCollectionPath the siteCollectionPath - * @return the CredentialDetails builder - */ - public Builder siteCollectionPath(String siteCollectionPath) { - this.siteCollectionPath = siteCollectionPath; - return this; - } - - /** - * Set the clientSecret. - * - * @param clientSecret the clientSecret - * @return the CredentialDetails builder - */ - public Builder clientSecret(String clientSecret) { - this.clientSecret = clientSecret; - return this; - } - - /** - * Set the publicKeyId. - * - * @param publicKeyId the publicKeyId - * @return the CredentialDetails builder - */ - public Builder publicKeyId(String publicKeyId) { - this.publicKeyId = publicKeyId; - return this; - } - - /** - * Set the privateKey. - * - * @param privateKey the privateKey - * @return the CredentialDetails builder - */ - public Builder privateKey(String privateKey) { - this.privateKey = privateKey; - return this; - } - - /** - * Set the passphrase. - * - * @param passphrase the passphrase - * @return the CredentialDetails builder - */ - public Builder passphrase(String passphrase) { - this.passphrase = passphrase; - return this; - } - - /** - * Set the password. - * - * @param password the password - * @return the CredentialDetails builder - */ - public Builder password(String password) { - this.password = password; //pragma: whitelist secret - return this; - } - - /** - * Set the gatewayId. - * - * @param gatewayId the gatewayId - * @return the CredentialDetails builder - */ - public Builder gatewayId(String gatewayId) { - this.gatewayId = gatewayId; - return this; - } - - /** - * Set the sourceVersion. - * - * @param sourceVersion the sourceVersion - * @return the CredentialDetails builder - */ - public Builder sourceVersion(String sourceVersion) { - this.sourceVersion = sourceVersion; - return this; - } - - /** - * Set the webApplicationUrl. - * - * @param webApplicationUrl the webApplicationUrl - * @return the CredentialDetails builder - */ - public Builder webApplicationUrl(String webApplicationUrl) { - this.webApplicationUrl = webApplicationUrl; - return this; - } - - /** - * Set the domain. - * - * @param domain the domain - * @return the CredentialDetails builder - */ - public Builder domain(String domain) { - this.domain = domain; - return this; - } - - /** - * Set the endpoint. - * - * @param endpoint the endpoint - * @return the CredentialDetails builder - */ - public Builder endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /** - * Set the accessKeyId. - * - * @param accessKeyId the accessKeyId - * @return the CredentialDetails builder - */ - public Builder accessKeyId(String accessKeyId) { - this.accessKeyId = accessKeyId; - return this; - } - - /** - * Set the secretAccessKey. - * - * @param secretAccessKey the secretAccessKey - * @return the CredentialDetails builder - */ - public Builder secretAccessKey(String secretAccessKey) { - this.secretAccessKey = secretAccessKey; - return this; - } - } - - protected CredentialDetails(Builder builder) { - credentialType = builder.credentialType; - clientId = builder.clientId; - enterpriseId = builder.enterpriseId; - url = builder.url; - username = builder.username; - organizationUrl = builder.organizationUrl; - siteCollectionPath = builder.siteCollectionPath; - clientSecret = builder.clientSecret; - publicKeyId = builder.publicKeyId; - privateKey = builder.privateKey; - passphrase = builder.passphrase; - password = builder.password; //pragma: whitelist secret - gatewayId = builder.gatewayId; - sourceVersion = builder.sourceVersion; - webApplicationUrl = builder.webApplicationUrl; - domain = builder.domain; - endpoint = builder.endpoint; - accessKeyId = builder.accessKeyId; - secretAccessKey = builder.secretAccessKey; - } - - /** - * New builder. - * - * @return a CredentialDetails builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the credentialType. - * - * The authentication method for this credentials definition. The **credential_type** specified must be supported by - * the **source_type**. The following combinations are possible: - * - * - `"source_type": "box"` - valid `credential_type`s: `oauth2` - * - `"source_type": "salesforce"` - valid `credential_type`s: `username_password` - * - `"source_type": "sharepoint"` - valid `credential_type`s: `saml` with **source_version** of `online`, or - * `ntlm_v1` with **source_version** of `2016` - * - `"source_type": "web_crawl"` - valid `credential_type`s: `noauth` or `basic` - * - "source_type": "cloud_object_storage"` - valid `credential_type`s: `aws4_hmac`. - * - * @return the credentialType - */ - public String credentialType() { - return credentialType; - } - - /** - * Gets the clientId. - * - * The **client_id** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `oauth2`. - * - * @return the clientId - */ - public String clientId() { - return clientId; - } - - /** - * Gets the enterpriseId. - * - * The **enterprise_id** of the Box site that these credentials connect to. Only valid, and required, with a - * **source_type** of `box`. - * - * @return the enterpriseId - */ - public String enterpriseId() { - return enterpriseId; - } - - /** - * Gets the url. - * - * The **url** of the source that these credentials connect to. Only valid, and required, with a **credential_type** - * of `username_password`, `noauth`, and `basic`. - * - * @return the url - */ - public String url() { - return url; - } - - /** - * Gets the username. - * - * The **username** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `saml`, `username_password`, `basic`, or `ntlm_v1`. - * - * @return the username - */ - public String username() { - return username; - } - - /** - * Gets the organizationUrl. - * - * The **organization_url** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `saml`. - * - * @return the organizationUrl - */ - public String organizationUrl() { - return organizationUrl; - } - - /** - * Gets the siteCollectionPath. - * - * The **site_collection.path** of the source that these credentials connect to. Only valid, and required, with a - * **source_type** of `sharepoint`. - * - * @return the siteCollectionPath - */ - public String siteCollectionPath() { - return siteCollectionPath; - } - - /** - * Gets the clientSecret. - * - * The **client_secret** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `oauth2`. This value is never returned and is only used when creating or modifying - * **credentials**. - * - * @return the clientSecret - */ - public String clientSecret() { - return clientSecret; - } - - /** - * Gets the publicKeyId. - * - * The **public_key_id** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `oauth2`. This value is never returned and is only used when creating or modifying - * **credentials**. - * - * @return the publicKeyId - */ - public String publicKeyId() { - return publicKeyId; - } - - /** - * Gets the privateKey. - * - * The **private_key** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `oauth2`. This value is never returned and is only used when creating or modifying - * **credentials**. - * - * @return the privateKey - */ - public String privateKey() { - return privateKey; - } - - /** - * Gets the passphrase. - * - * The **passphrase** of the source that these credentials connect to. Only valid, and required, with a - * **credential_type** of `oauth2`. This value is never returned and is only used when creating or modifying - * **credentials**. - * - * @return the passphrase - */ - public String passphrase() { - return passphrase; - } - - /** - * Gets the password. - * - * The **password** of the source that these credentials connect to. Only valid, and required, with - * **credential_type**s of `saml`, `username_password`, `basic`, or `ntlm_v1`. - * - * **Note:** When used with a **source_type** of `salesforce`, the password consists of the Salesforce password and a - * valid Salesforce security token concatenated. This value is never returned and is only used when creating or - * modifying **credentials**. - * - * @return the password - */ - public String password() { - return password; - } - - /** - * Gets the gatewayId. - * - * The ID of the **gateway** to be connected through (when connecting to intranet sites). Only valid with a - * **credential_type** of `noauth`, `basic`, or `ntlm_v1`. Gateways are created using the - * `/v1/environments/{environment_id}/gateways` methods. - * - * @return the gatewayId - */ - public String gatewayId() { - return gatewayId; - } - - /** - * Gets the sourceVersion. - * - * The type of Sharepoint repository to connect to. Only valid, and required, with a **source_type** of `sharepoint`. - * - * @return the sourceVersion - */ - public String sourceVersion() { - return sourceVersion; - } - - /** - * Gets the webApplicationUrl. - * - * SharePoint OnPrem WebApplication URL. Only valid, and required, with a **source_version** of `2016`. If a port is - * not supplied, the default to port `80` for http and port `443` for https connections are used. - * - * @return the webApplicationUrl - */ - public String webApplicationUrl() { - return webApplicationUrl; - } - - /** - * Gets the domain. - * - * The domain used to log in to your OnPrem SharePoint account. Only valid, and required, with a **source_version** of - * `2016`. - * - * @return the domain - */ - public String domain() { - return domain; - } - - /** - * Gets the endpoint. - * - * The endpoint associated with the cloud object store that your are connecting to. Only valid, and required, with a - * **credential_type** of `aws4_hmac`. - * - * @return the endpoint - */ - public String endpoint() { - return endpoint; - } - - /** - * Gets the accessKeyId. - * - * The access key ID associated with the cloud object store. Only valid, and required, with a **credential_type** of - * `aws4_hmac`. This value is never returned and is only used when creating or modifying **credentials**. For more - * infomation, see the [cloud object store - * documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-uhc-hmac-credentials-main). - * - * @return the accessKeyId - */ - public String accessKeyId() { - return accessKeyId; - } - - /** - * Gets the secretAccessKey. - * - * The secret access key associated with the cloud object store. Only valid, and required, with a **credential_type** - * of `aws4_hmac`. This value is never returned and is only used when creating or modifying **credentials**. For more - * infomation, see the [cloud object store - * documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-uhc-hmac-credentials-main). - * - * @return the secretAccessKey - */ - public String secretAccessKey() { - return secretAccessKey; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java deleted file mode 100644 index 40b8fdc72ed..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing credential information. - */ -public class Credentials extends GenericModel { - - /** - * The source that this credentials object connects to. - * - `box` indicates the credentials are used to connect an instance of Enterprise Box. - * - `salesforce` indicates the credentials are used to connect to Salesforce. - * - `sharepoint` indicates the credentials are used to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the credentials are used to perform a web crawl. - * = `cloud_object_storage` indicates the credentials are used to connect to an IBM Cloud Object Store. - */ - public interface SourceType { - /** box. */ - String BOX = "box"; - /** salesforce. */ - String SALESFORCE = "salesforce"; - /** sharepoint. */ - String SHAREPOINT = "sharepoint"; - /** web_crawl. */ - String WEB_CRAWL = "web_crawl"; - /** cloud_object_storage. */ - String CLOUD_OBJECT_STORAGE = "cloud_object_storage"; - } - - /** - * The current status of this set of credentials. `connected` indicates that the credentials are available to use with - * the source configuration of a collection. `invalid` refers to the credentials (for example, the password provided - * has expired) and must be corrected before they can be used with a collection. - */ - public interface Status { - /** connected. */ - String CONNECTED = "connected"; - /** invalid. */ - String INVALID = "invalid"; - } - - @SerializedName("credential_id") - protected String credentialId; - @SerializedName("source_type") - protected String sourceType; - @SerializedName("credential_details") - protected CredentialDetails credentialDetails; - protected String status; - - /** - * Builder. - */ - public static class Builder { - private String credentialId; - private String sourceType; - private CredentialDetails credentialDetails; - private String status; - - private Builder(Credentials credentials) { - this.credentialId = credentials.credentialId; - this.sourceType = credentials.sourceType; - this.credentialDetails = credentials.credentialDetails; - this.status = credentials.status; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a Credentials. - * - * @return the credentials - */ - public Credentials build() { - return new Credentials(this); - } - - /** - * Set the credentialId. - * - * @param credentialId the credentialId - * @return the Credentials builder - */ - public Builder credentialId(String credentialId) { - this.credentialId = credentialId; - return this; - } - - /** - * Set the sourceType. - * - * @param sourceType the sourceType - * @return the Credentials builder - */ - public Builder sourceType(String sourceType) { - this.sourceType = sourceType; - return this; - } - - /** - * Set the credentialDetails. - * - * @param credentialDetails the credentialDetails - * @return the Credentials builder - */ - public Builder credentialDetails(CredentialDetails credentialDetails) { - this.credentialDetails = credentialDetails; - return this; - } - - /** - * Set the status. - * - * @param status the status - * @return the Credentials builder - */ - public Builder status(String status) { - this.status = status; - return this; - } - } - - protected Credentials(Builder builder) { - credentialId = builder.credentialId; - sourceType = builder.sourceType; - credentialDetails = builder.credentialDetails; - status = builder.status; - } - - /** - * New builder. - * - * @return a Credentials builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the credentialId. - * - * Unique identifier for this set of credentials. - * - * @return the credentialId - */ - public String credentialId() { - return credentialId; - } - - /** - * Gets the sourceType. - * - * The source that this credentials object connects to. - * - `box` indicates the credentials are used to connect an instance of Enterprise Box. - * - `salesforce` indicates the credentials are used to connect to Salesforce. - * - `sharepoint` indicates the credentials are used to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the credentials are used to perform a web crawl. - * = `cloud_object_storage` indicates the credentials are used to connect to an IBM Cloud Object Store. - * - * @return the sourceType - */ - public String sourceType() { - return sourceType; - } - - /** - * Gets the credentialDetails. - * - * Object containing details of the stored credentials. - * - * Obtain credentials for your source from the administrator of the source. - * - * @return the credentialDetails - */ - public CredentialDetails credentialDetails() { - return credentialDetails; - } - - /** - * Gets the status. - * - * The current status of this set of credentials. `connected` indicates that the credentials are available to use with - * the source configuration of a collection. `invalid` refers to the credentials (for example, the password provided - * has expired) and must be corrected before they can be used with a collection. - * - * @return the status - */ - public String status() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java deleted file mode 100644 index 010951da4cf..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing array of credential definitions. - */ -public class CredentialsList extends GenericModel { - - protected List credentials; - - /** - * Gets the credentials. - * - * An array of credential definitions that were created for this instance. - * - * @return the credentials - */ - public List getCredentials() { - return credentials; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java deleted file mode 100644 index 64db3c94e85..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteAllTrainingData options. - */ -public class DeleteAllTrainingDataOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteAllTrainingDataOptions deleteAllTrainingDataOptions) { - this.environmentId = deleteAllTrainingDataOptions.environmentId; - this.collectionId = deleteAllTrainingDataOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a DeleteAllTrainingDataOptions. - * - * @return the deleteAllTrainingDataOptions - */ - public DeleteAllTrainingDataOptions build() { - return new DeleteAllTrainingDataOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteAllTrainingDataOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteAllTrainingDataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected DeleteAllTrainingDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a DeleteAllTrainingDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java deleted file mode 100644 index 0538f94374a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteCollection options. - */ -public class DeleteCollectionOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteCollectionOptions deleteCollectionOptions) { - this.environmentId = deleteCollectionOptions.environmentId; - this.collectionId = deleteCollectionOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a DeleteCollectionOptions. - * - * @return the deleteCollectionOptions - */ - public DeleteCollectionOptions build() { - return new DeleteCollectionOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteCollectionOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteCollectionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected DeleteCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a DeleteCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java deleted file mode 100644 index 0f2bd4ab94f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response object returned when deleting a colleciton. - */ -public class DeleteCollectionResponse extends GenericModel { - - /** - * The status of the collection. The status of a successful deletion operation is `deleted`. - */ - public interface Status { - /** deleted. */ - String DELETED = "deleted"; - } - - @SerializedName("collection_id") - protected String collectionId; - protected String status; - - /** - * Gets the collectionId. - * - * The unique identifier of the collection that is being deleted. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } - - /** - * Gets the status. - * - * The status of the collection. The status of a successful deletion operation is `deleted`. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java deleted file mode 100644 index 12b89dd52fb..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteConfiguration options. - */ -public class DeleteConfigurationOptions extends GenericModel { - - protected String environmentId; - protected String configurationId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String configurationId; - - private Builder(DeleteConfigurationOptions deleteConfigurationOptions) { - this.environmentId = deleteConfigurationOptions.environmentId; - this.configurationId = deleteConfigurationOptions.configurationId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param configurationId the configurationId - */ - public Builder(String environmentId, String configurationId) { - this.environmentId = environmentId; - this.configurationId = configurationId; - } - - /** - * Builds a DeleteConfigurationOptions. - * - * @return the deleteConfigurationOptions - */ - public DeleteConfigurationOptions build() { - return new DeleteConfigurationOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteConfigurationOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the DeleteConfigurationOptions builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - } - - protected DeleteConfigurationOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.configurationId, - "configurationId cannot be empty"); - environmentId = builder.environmentId; - configurationId = builder.configurationId; - } - - /** - * New builder. - * - * @return a DeleteConfigurationOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the configurationId. - * - * The ID of the configuration. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java deleted file mode 100644 index db469a0e2df..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information returned when a configuration is deleted. - */ -public class DeleteConfigurationResponse extends GenericModel { - - /** - * Status of the configuration. A deleted configuration has the status deleted. - */ - public interface Status { - /** deleted. */ - String DELETED = "deleted"; - } - - @SerializedName("configuration_id") - protected String configurationId; - protected String status; - protected List notices; - - /** - * Gets the configurationId. - * - * The unique identifier for the configuration. - * - * @return the configurationId - */ - public String getConfigurationId() { - return configurationId; - } - - /** - * Gets the status. - * - * Status of the configuration. A deleted configuration has the status deleted. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the notices. - * - * An array of notice messages, if any. - * - * @return the notices - */ - public List getNotices() { - return notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java deleted file mode 100644 index c26612fae0e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object returned after credentials are deleted. - */ -public class DeleteCredentials extends GenericModel { - - /** - * The status of the deletion request. - */ - public interface Status { - /** deleted. */ - String DELETED = "deleted"; - } - - @SerializedName("credential_id") - protected String credentialId; - protected String status; - - /** - * Gets the credentialId. - * - * The unique identifier of the credentials that have been deleted. - * - * @return the credentialId - */ - public String getCredentialId() { - return credentialId; - } - - /** - * Gets the status. - * - * The status of the deletion request. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java deleted file mode 100644 index 20d28723399..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteCredentials options. - */ -public class DeleteCredentialsOptions extends GenericModel { - - protected String environmentId; - protected String credentialId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String credentialId; - - private Builder(DeleteCredentialsOptions deleteCredentialsOptions) { - this.environmentId = deleteCredentialsOptions.environmentId; - this.credentialId = deleteCredentialsOptions.credentialId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param credentialId the credentialId - */ - public Builder(String environmentId, String credentialId) { - this.environmentId = environmentId; - this.credentialId = credentialId; - } - - /** - * Builds a DeleteCredentialsOptions. - * - * @return the deleteCredentialsOptions - */ - public DeleteCredentialsOptions build() { - return new DeleteCredentialsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteCredentialsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the credentialId. - * - * @param credentialId the credentialId - * @return the DeleteCredentialsOptions builder - */ - public Builder credentialId(String credentialId) { - this.credentialId = credentialId; - return this; - } - } - - protected DeleteCredentialsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.credentialId, - "credentialId cannot be empty"); - environmentId = builder.environmentId; - credentialId = builder.credentialId; - } - - /** - * New builder. - * - * @return a DeleteCredentialsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the credentialId. - * - * The unique identifier for a set of source credentials. - * - * @return the credentialId - */ - public String credentialId() { - return credentialId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java deleted file mode 100644 index 142efc1b217..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteDocument options. - */ -public class DeleteDocumentOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String documentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String documentId; - - private Builder(DeleteDocumentOptions deleteDocumentOptions) { - this.environmentId = deleteDocumentOptions.environmentId; - this.collectionId = deleteDocumentOptions.collectionId; - this.documentId = deleteDocumentOptions.documentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param documentId the documentId - */ - public Builder(String environmentId, String collectionId, String documentId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.documentId = documentId; - } - - /** - * Builds a DeleteDocumentOptions. - * - * @return the deleteDocumentOptions - */ - public DeleteDocumentOptions build() { - return new DeleteDocumentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteDocumentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteDocumentOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the DeleteDocumentOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - } - - protected DeleteDocumentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.documentId, - "documentId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - documentId = builder.documentId; - } - - /** - * New builder. - * - * @return a DeleteDocumentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the documentId. - * - * The ID of the document. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java deleted file mode 100644 index c5693267b78..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information returned when a document is deleted. - */ -public class DeleteDocumentResponse extends GenericModel { - - /** - * Status of the document. A deleted document has the status deleted. - */ - public interface Status { - /** deleted. */ - String DELETED = "deleted"; - } - - @SerializedName("document_id") - protected String documentId; - protected String status; - - /** - * Gets the documentId. - * - * The unique identifier of the document. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the status. - * - * Status of the document. A deleted document has the status deleted. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java deleted file mode 100644 index d43999f2607..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteEnvironment options. - */ -public class DeleteEnvironmentOptions extends GenericModel { - - protected String environmentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - - private Builder(DeleteEnvironmentOptions deleteEnvironmentOptions) { - this.environmentId = deleteEnvironmentOptions.environmentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a DeleteEnvironmentOptions. - * - * @return the deleteEnvironmentOptions - */ - public DeleteEnvironmentOptions build() { - return new DeleteEnvironmentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteEnvironmentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - } - - protected DeleteEnvironmentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - } - - /** - * New builder. - * - * @return a DeleteEnvironmentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java deleted file mode 100644 index 605838e3c65..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response object returned when deleting an environment. - */ -public class DeleteEnvironmentResponse extends GenericModel { - - /** - * Status of the environment. - */ - public interface Status { - /** deleted. */ - String DELETED = "deleted"; - } - - @SerializedName("environment_id") - protected String environmentId; - protected String status; - - /** - * Gets the environmentId. - * - * The unique identifier for the environment. - * - * @return the environmentId - */ - public String getEnvironmentId() { - return environmentId; - } - - /** - * Gets the status. - * - * Status of the environment. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java deleted file mode 100644 index b151e801b97..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteExpansions options. - */ -public class DeleteExpansionsOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteExpansionsOptions deleteExpansionsOptions) { - this.environmentId = deleteExpansionsOptions.environmentId; - this.collectionId = deleteExpansionsOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a DeleteExpansionsOptions. - * - * @return the deleteExpansionsOptions - */ - public DeleteExpansionsOptions build() { - return new DeleteExpansionsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteExpansionsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteExpansionsOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected DeleteExpansionsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a DeleteExpansionsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java deleted file mode 100644 index d1634add6fd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteGateway options. - */ -public class DeleteGatewayOptions extends GenericModel { - - protected String environmentId; - protected String gatewayId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String gatewayId; - - private Builder(DeleteGatewayOptions deleteGatewayOptions) { - this.environmentId = deleteGatewayOptions.environmentId; - this.gatewayId = deleteGatewayOptions.gatewayId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param gatewayId the gatewayId - */ - public Builder(String environmentId, String gatewayId) { - this.environmentId = environmentId; - this.gatewayId = gatewayId; - } - - /** - * Builds a DeleteGatewayOptions. - * - * @return the deleteGatewayOptions - */ - public DeleteGatewayOptions build() { - return new DeleteGatewayOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteGatewayOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the gatewayId. - * - * @param gatewayId the gatewayId - * @return the DeleteGatewayOptions builder - */ - public Builder gatewayId(String gatewayId) { - this.gatewayId = gatewayId; - return this; - } - } - - protected DeleteGatewayOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.gatewayId, - "gatewayId cannot be empty"); - environmentId = builder.environmentId; - gatewayId = builder.gatewayId; - } - - /** - * New builder. - * - * @return a DeleteGatewayOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the gatewayId. - * - * The requested gateway ID. - * - * @return the gatewayId - */ - public String gatewayId() { - return gatewayId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java deleted file mode 100644 index d90f7295505..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteStopwordList options. - */ -public class DeleteStopwordListOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteStopwordListOptions deleteStopwordListOptions) { - this.environmentId = deleteStopwordListOptions.environmentId; - this.collectionId = deleteStopwordListOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a DeleteStopwordListOptions. - * - * @return the deleteStopwordListOptions - */ - public DeleteStopwordListOptions build() { - return new DeleteStopwordListOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteStopwordListOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteStopwordListOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected DeleteStopwordListOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a DeleteStopwordListOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java deleted file mode 100644 index 0c64b26fd68..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteTokenizationDictionary options. - */ -public class DeleteTokenizationDictionaryOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteTokenizationDictionaryOptions deleteTokenizationDictionaryOptions) { - this.environmentId = deleteTokenizationDictionaryOptions.environmentId; - this.collectionId = deleteTokenizationDictionaryOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a DeleteTokenizationDictionaryOptions. - * - * @return the deleteTokenizationDictionaryOptions - */ - public DeleteTokenizationDictionaryOptions build() { - return new DeleteTokenizationDictionaryOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteTokenizationDictionaryOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteTokenizationDictionaryOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected DeleteTokenizationDictionaryOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a DeleteTokenizationDictionaryOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java deleted file mode 100644 index 0f4618e6697..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteTrainingData options. - */ -public class DeleteTrainingDataOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - - private Builder(DeleteTrainingDataOptions deleteTrainingDataOptions) { - this.environmentId = deleteTrainingDataOptions.environmentId; - this.collectionId = deleteTrainingDataOptions.collectionId; - this.queryId = deleteTrainingDataOptions.queryId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - */ - public Builder(String environmentId, String collectionId, String queryId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - } - - /** - * Builds a DeleteTrainingDataOptions. - * - * @return the deleteTrainingDataOptions - */ - public DeleteTrainingDataOptions build() { - return new DeleteTrainingDataOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteTrainingDataOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteTrainingDataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the DeleteTrainingDataOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - } - - protected DeleteTrainingDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - } - - /** - * New builder. - * - * @return a DeleteTrainingDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java deleted file mode 100644 index 54f7b895970..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteTrainingExample options. - */ -public class DeleteTrainingExampleOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - protected String exampleId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - - private Builder(DeleteTrainingExampleOptions deleteTrainingExampleOptions) { - this.environmentId = deleteTrainingExampleOptions.environmentId; - this.collectionId = deleteTrainingExampleOptions.collectionId; - this.queryId = deleteTrainingExampleOptions.queryId; - this.exampleId = deleteTrainingExampleOptions.exampleId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - * @param exampleId the exampleId - */ - public Builder(String environmentId, String collectionId, String queryId, String exampleId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - this.exampleId = exampleId; - } - - /** - * Builds a DeleteTrainingExampleOptions. - * - * @return the deleteTrainingExampleOptions - */ - public DeleteTrainingExampleOptions build() { - return new DeleteTrainingExampleOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the DeleteTrainingExampleOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteTrainingExampleOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the DeleteTrainingExampleOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - - /** - * Set the exampleId. - * - * @param exampleId the exampleId - * @return the DeleteTrainingExampleOptions builder - */ - public Builder exampleId(String exampleId) { - this.exampleId = exampleId; - return this; - } - } - - protected DeleteTrainingExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.exampleId, - "exampleId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - exampleId = builder.exampleId; - } - - /** - * New builder. - * - * @return a DeleteTrainingExampleOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } - - /** - * Gets the exampleId. - * - * The ID of the document as it is indexed. - * - * @return the exampleId - */ - public String exampleId() { - return exampleId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java deleted file mode 100644 index c9dd2314eec..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - protected String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - this.customerId = deleteUserDataOptions.customerId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customerId the customerId - */ - public Builder(String customerId) { - this.customerId = customerId; - } - - /** - * Builds a DeleteUserDataOptions. - * - * @return the deleteUserDataOptions - */ - public DeleteUserDataOptions build() { - return new DeleteUserDataOptions(this); - } - - /** - * Set the customerId. - * - * @param customerId the customerId - * @return the DeleteUserDataOptions builder - */ - public Builder customerId(String customerId) { - this.customerId = customerId; - return this; - } - } - - protected DeleteUserDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, - "customerId cannot be null"); - customerId = builder.customerId; - } - - /** - * New builder. - * - * @return a DeleteUserDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customerId. - * - * The customer ID for which all data is to be deleted. - * - * @return the customerId - */ - public String customerId() { - return customerId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java deleted file mode 100644 index d6c7ac2d4e4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Summary of the disk usage statistics for the environment. - */ -public class DiskUsage extends GenericModel { - - @SerializedName("used_bytes") - protected Long usedBytes; - @SerializedName("maximum_allowed_bytes") - protected Long maximumAllowedBytes; - - /** - * Gets the usedBytes. - * - * Number of bytes within the environment's disk capacity that are currently used to store data. - * - * @return the usedBytes - */ - public Long getUsedBytes() { - return usedBytes; - } - - /** - * Gets the maximumAllowedBytes. - * - * Total number of bytes available in the environment's disk capacity. - * - * @return the maximumAllowedBytes - */ - public Long getMaximumAllowedBytes() { - return maximumAllowedBytes; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java deleted file mode 100644 index b6619f9afbc..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information returned after an uploaded document is accepted. - */ -public class DocumentAccepted extends GenericModel { - - /** - * Status of the document in the ingestion process. A status of `processing` is returned for documents that are - * ingested with a *version* date before `2019-01-01`. The `pending` status is returned for all others. - */ - public interface Status { - /** processing. */ - String PROCESSING = "processing"; - /** pending. */ - String PENDING = "pending"; - } - - @SerializedName("document_id") - protected String documentId; - protected String status; - protected List notices; - - /** - * Gets the documentId. - * - * The unique identifier of the ingested document. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the status. - * - * Status of the document in the ingestion process. A status of `processing` is returned for documents that are - * ingested with a *version* date before `2019-01-01`. The `pending` status is returned for all others. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the notices. - * - * Array of notices produced by the document-ingestion process. - * - * @return the notices - */ - public List getNotices() { - return notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java deleted file mode 100644 index 3bdd956fd97..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing collection document count information. - */ -public class DocumentCounts extends GenericModel { - - protected Long available; - protected Long processing; - protected Long failed; - protected Long pending; - - /** - * Gets the available. - * - * The total number of available documents in the collection. - * - * @return the available - */ - public Long getAvailable() { - return available; - } - - /** - * Gets the processing. - * - * The number of documents in the collection that are currently being processed. - * - * @return the processing - */ - public Long getProcessing() { - return processing; - } - - /** - * Gets the failed. - * - * The number of documents in the collection that failed to be ingested. - * - * @return the failed - */ - public Long getFailed() { - return failed; - } - - /** - * Gets the pending. - * - * The number of documents that have been uploaded to the collection, but have not yet started processing. - * - * @return the pending - */ - public Long getPending() { - return pending; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java deleted file mode 100644 index 891eae235b1..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Status information about a submitted document. - */ -public class DocumentStatus extends GenericModel { - - /** - * Status of the document in the ingestion process. - */ - public interface Status { - /** available. */ - String AVAILABLE = "available"; - /** available with notices. */ - String AVAILABLE_WITH_NOTICES = "available with notices"; - /** failed. */ - String FAILED = "failed"; - /** processing. */ - String PROCESSING = "processing"; - /** pending. */ - String PENDING = "pending"; - } - - /** - * The type of the original source file. - */ - public interface FileType { - /** pdf. */ - String PDF = "pdf"; - /** html. */ - String HTML = "html"; - /** word. */ - String WORD = "word"; - /** json. */ - String JSON = "json"; - } - - @SerializedName("document_id") - protected String documentId; - @SerializedName("configuration_id") - protected String configurationId; - protected String status; - @SerializedName("status_description") - protected String statusDescription; - protected String filename; - @SerializedName("file_type") - protected String fileType; - protected String sha1; - protected List notices; - - /** - * Gets the documentId. - * - * The unique identifier of the document. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the configurationId. - * - * The unique identifier for the configuration. - * - * @return the configurationId - */ - public String getConfigurationId() { - return configurationId; - } - - /** - * Gets the status. - * - * Status of the document in the ingestion process. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the statusDescription. - * - * Description of the document status. - * - * @return the statusDescription - */ - public String getStatusDescription() { - return statusDescription; - } - - /** - * Gets the filename. - * - * Name of the original source file (if available). - * - * @return the filename - */ - public String getFilename() { - return filename; - } - - /** - * Gets the fileType. - * - * The type of the original source file. - * - * @return the fileType - */ - public String getFileType() { - return fileType; - } - - /** - * Gets the sha1. - * - * The SHA-1 hash of the original source file (formatted as a hexadecimal string). - * - * @return the sha1 - */ - public String getSha1() { - return sha1; - } - - /** - * Gets the notices. - * - * Array of notices produced by the document-ingestion process. - * - * @return the notices - */ - public List getNotices() { - return notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java deleted file mode 100644 index ebb8b303663..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Enrichment step to perform on the document. Each enrichment is performed on the specified field in the order that - * they are listed in the configuration. - */ -public class Enrichment extends GenericModel { - - protected String description; - @SerializedName("destination_field") - protected String destinationField; - @SerializedName("source_field") - protected String sourceField; - protected Boolean overwrite; - protected String enrichment; - @SerializedName("ignore_downstream_errors") - protected Boolean ignoreDownstreamErrors; - protected EnrichmentOptions options; - - /** - * Builder. - */ - public static class Builder { - private String description; - private String destinationField; - private String sourceField; - private Boolean overwrite; - private String enrichment; - private Boolean ignoreDownstreamErrors; - private EnrichmentOptions options; - - private Builder(Enrichment enrichment) { - this.description = enrichment.description; - this.destinationField = enrichment.destinationField; - this.sourceField = enrichment.sourceField; - this.overwrite = enrichment.overwrite; - this.enrichment = enrichment.enrichment; - this.ignoreDownstreamErrors = enrichment.ignoreDownstreamErrors; - this.options = enrichment.options; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param destinationField the destinationField - * @param sourceField the sourceField - * @param enrichment the enrichment - */ - public Builder(String destinationField, String sourceField, String enrichment) { - this.destinationField = destinationField; - this.sourceField = sourceField; - this.enrichment = enrichment; - } - - /** - * Builds a Enrichment. - * - * @return the enrichment - */ - public Enrichment build() { - return new Enrichment(this); - } - - /** - * Set the description. - * - * @param description the description - * @return the Enrichment builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the destinationField. - * - * @param destinationField the destinationField - * @return the Enrichment builder - */ - public Builder destinationField(String destinationField) { - this.destinationField = destinationField; - return this; - } - - /** - * Set the sourceField. - * - * @param sourceField the sourceField - * @return the Enrichment builder - */ - public Builder sourceField(String sourceField) { - this.sourceField = sourceField; - return this; - } - - /** - * Set the overwrite. - * - * @param overwrite the overwrite - * @return the Enrichment builder - */ - public Builder overwrite(Boolean overwrite) { - this.overwrite = overwrite; - return this; - } - - /** - * Set the enrichment. - * - * @param enrichment the enrichment - * @return the Enrichment builder - */ - public Builder enrichment(String enrichment) { - this.enrichment = enrichment; - return this; - } - - /** - * Set the ignoreDownstreamErrors. - * - * @param ignoreDownstreamErrors the ignoreDownstreamErrors - * @return the Enrichment builder - */ - public Builder ignoreDownstreamErrors(Boolean ignoreDownstreamErrors) { - this.ignoreDownstreamErrors = ignoreDownstreamErrors; - return this; - } - - /** - * Set the options. - * - * @param options the options - * @return the Enrichment builder - */ - public Builder options(EnrichmentOptions options) { - this.options = options; - return this; - } - } - - protected Enrichment(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.destinationField, - "destinationField cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.sourceField, - "sourceField cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.enrichment, - "enrichment cannot be null"); - description = builder.description; - destinationField = builder.destinationField; - sourceField = builder.sourceField; - overwrite = builder.overwrite; - enrichment = builder.enrichment; - ignoreDownstreamErrors = builder.ignoreDownstreamErrors; - options = builder.options; - } - - /** - * New builder. - * - * @return a Enrichment builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the description. - * - * Describes what the enrichment step does. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the destinationField. - * - * Field where enrichments will be stored. This field must already exist or be at most 1 level deeper than an existing - * field. For example, if `text` is a top-level field with no sub-fields, `text.foo` is a valid destination but - * `text.foo.bar` is not. - * - * @return the destinationField - */ - public String destinationField() { - return destinationField; - } - - /** - * Gets the sourceField. - * - * Field to be enriched. - * - * Arrays can be specified as the **source_field** if the **enrichment** service for this enrichment is set to - * `natural_language_undstanding`. - * - * @return the sourceField - */ - public String sourceField() { - return sourceField; - } - - /** - * Gets the overwrite. - * - * Indicates that the enrichments will overwrite the destination_field field if it already exists. - * - * @return the overwrite - */ - public Boolean overwrite() { - return overwrite; - } - - /** - * Gets the enrichment. - * - * Name of the enrichment service to call. Current options are `natural_language_understanding` and `elements`. - * - * When using `natual_language_understanding`, the **options** object must contain Natural Language Understanding - * options. - * - * When using `elements` the **options** object must contain Element Classification options. Additionally, when using - * the `elements` enrichment the configuration specified and files ingested must meet all the criteria specified in - * [the - * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-element-classification#element-classification). - * - * @return the enrichment - */ - public String enrichment() { - return enrichment; - } - - /** - * Gets the ignoreDownstreamErrors. - * - * If true, then most errors generated during the enrichment process will be treated as warnings and will not cause - * the document to fail processing. - * - * @return the ignoreDownstreamErrors - */ - public Boolean ignoreDownstreamErrors() { - return ignoreDownstreamErrors; - } - - /** - * Gets the options. - * - * Options which are specific to a particular enrichment. - * - * @return the options - */ - public EnrichmentOptions options() { - return options; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java deleted file mode 100644 index 1a10fe79508..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Options which are specific to a particular enrichment. - */ -public class EnrichmentOptions extends GenericModel { - - /** - * ISO 639-1 code indicating the language to use for the analysis. This code overrides the automatic language - * detection performed by the service. Valid codes are `ar` (Arabic), `en` (English), `fr` (French), `de` (German), - * `it` (Italian), `pt` (Portuguese), `ru` (Russian), `es` (Spanish), and `sv` (Swedish). **Note:** Not all features - * support all languages, automatic detection is recommended. - */ - public interface Language { - /** ar. */ - String AR = "ar"; - /** en. */ - String EN = "en"; - /** fr. */ - String FR = "fr"; - /** de. */ - String DE = "de"; - /** it. */ - String IT = "it"; - /** pt. */ - String PT = "pt"; - /** ru. */ - String RU = "ru"; - /** es. */ - String ES = "es"; - /** sv. */ - String SV = "sv"; - } - - protected NluEnrichmentFeatures features; - protected String language; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private NluEnrichmentFeatures features; - private String language; - private String model; - - private Builder(EnrichmentOptions enrichmentOptions) { - this.features = enrichmentOptions.features; - this.language = enrichmentOptions.language; - this.model = enrichmentOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a EnrichmentOptions. - * - * @return the enrichmentOptions - */ - public EnrichmentOptions build() { - return new EnrichmentOptions(this); - } - - /** - * Set the features. - * - * @param features the features - * @return the EnrichmentOptions builder - */ - public Builder features(NluEnrichmentFeatures features) { - this.features = features; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the EnrichmentOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the EnrichmentOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - protected EnrichmentOptions(Builder builder) { - features = builder.features; - language = builder.language; - model = builder.model; - } - - /** - * New builder. - * - * @return a EnrichmentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the features. - * - * Object containing Natural Language Understanding features to be used. - * - * @return the features - */ - public NluEnrichmentFeatures features() { - return features; - } - - /** - * Gets the language. - * - * ISO 639-1 code indicating the language to use for the analysis. This code overrides the automatic language - * detection performed by the service. Valid codes are `ar` (Arabic), `en` (English), `fr` (French), `de` (German), - * `it` (Italian), `pt` (Portuguese), `ru` (Russian), `es` (Spanish), and `sv` (Swedish). **Note:** Not all features - * support all languages, automatic detection is recommended. - * - * @return the language - */ - public String language() { - return language; - } - - /** - * Gets the model. - * - * *For use with `elements` enrichments only.* The element extraction model to use. Models available are: `contract`. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java deleted file mode 100644 index 962000e24d2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about an environment. - */ -public class Environment extends GenericModel { - - /** - * Current status of the environment. `resizing` is displayed when a request to increase the environment size has been - * made, but is still in the process of being completed. - */ - public interface Status { - /** active. */ - String ACTIVE = "active"; - /** pending. */ - String PENDING = "pending"; - /** maintenance. */ - String MAINTENANCE = "maintenance"; - /** resizing. */ - String RESIZING = "resizing"; - } - - /** - * Current size of the environment. - */ - public interface Size { - /** LT. */ - String LT = "LT"; - /** XS. */ - String XS = "XS"; - /** S. */ - String S = "S"; - /** MS. */ - String MS = "MS"; - /** M. */ - String M = "M"; - /** ML. */ - String ML = "ML"; - /** L. */ - String L = "L"; - /** XL. */ - String XL = "XL"; - /** XXL. */ - String XXL = "XXL"; - /** XXXL. */ - String XXXL = "XXXL"; - } - - @SerializedName("environment_id") - protected String environmentId; - protected String name; - protected String description; - protected Date created; - protected Date updated; - protected String status; - @SerializedName("read_only") - protected Boolean readOnly; - protected String size; - @SerializedName("requested_size") - protected String requestedSize; - @SerializedName("index_capacity") - protected IndexCapacity indexCapacity; - @SerializedName("search_status") - protected SearchStatus searchStatus; - - /** - * Gets the environmentId. - * - * Unique identifier for the environment. - * - * @return the environmentId - */ - public String getEnvironmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * Name that identifies the environment. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the description. - * - * Description of the environment. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the created. - * - * Creation date of the environment, in the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * Date of most recent environment update, in the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the status. - * - * Current status of the environment. `resizing` is displayed when a request to increase the environment size has been - * made, but is still in the process of being completed. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the readOnly. - * - * If `true`, the environment contains read-only collections that are maintained by IBM. - * - * @return the readOnly - */ - public Boolean isReadOnly() { - return readOnly; - } - - /** - * Gets the size. - * - * Current size of the environment. - * - * @return the size - */ - public String getSize() { - return size; - } - - /** - * Gets the requestedSize. - * - * The new size requested for this environment. Only returned when the environment *status* is `resizing`. - * - * *Note:* Querying and indexing can still be performed during an environment upsize. - * - * @return the requestedSize - */ - public String getRequestedSize() { - return requestedSize; - } - - /** - * Gets the indexCapacity. - * - * Details about the resource usage and capacity of the environment. - * - * @return the indexCapacity - */ - public IndexCapacity getIndexCapacity() { - return indexCapacity; - } - - /** - * Gets the searchStatus. - * - * Information about the Continuous Relevancy Training for this environment. - * - * @return the searchStatus - */ - public SearchStatus getSearchStatus() { - return searchStatus; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java deleted file mode 100644 index 5acb38773a7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Summary of the document usage statistics for the environment. - */ -public class EnvironmentDocuments extends GenericModel { - - protected Long available; - @SerializedName("maximum_allowed") - protected Long maximumAllowed; - - /** - * Gets the available documents. - * - * Number of documents indexed for the environment. - * - * @return the available - */ - public Long getAvailable() { - return available; - } - - /** - * Gets the maximumAllowed. - * - * Total number of documents allowed in the environment's capacity. - * - * @return the maximumAllowed - */ - public Long getMaximumAllowed() { - return maximumAllowed; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java deleted file mode 100644 index b43b599fdf2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Query event data object. - */ -public class EventData extends GenericModel { - - @SerializedName("environment_id") - protected String environmentId; - @SerializedName("session_token") - protected String sessionToken; - @SerializedName("client_timestamp") - protected Date clientTimestamp; - @SerializedName("display_rank") - protected Long displayRank; - @SerializedName("collection_id") - protected String collectionId; - @SerializedName("document_id") - protected String documentId; - @SerializedName("query_id") - protected String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String sessionToken; - private Date clientTimestamp; - private Long displayRank; - private String collectionId; - private String documentId; - private String queryId; - - private Builder(EventData eventData) { - this.environmentId = eventData.environmentId; - this.sessionToken = eventData.sessionToken; - this.clientTimestamp = eventData.clientTimestamp; - this.displayRank = eventData.displayRank; - this.collectionId = eventData.collectionId; - this.documentId = eventData.documentId; - this.queryId = eventData.queryId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param sessionToken the sessionToken - * @param collectionId the collectionId - * @param documentId the documentId - */ - public Builder(String environmentId, String sessionToken, String collectionId, String documentId) { - this.environmentId = environmentId; - this.sessionToken = sessionToken; - this.collectionId = collectionId; - this.documentId = documentId; - } - - /** - * Builds a EventData. - * - * @return the eventData - */ - public EventData build() { - return new EventData(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the EventData builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the sessionToken. - * - * @param sessionToken the sessionToken - * @return the EventData builder - */ - public Builder sessionToken(String sessionToken) { - this.sessionToken = sessionToken; - return this; - } - - /** - * Set the clientTimestamp. - * - * @param clientTimestamp the clientTimestamp - * @return the EventData builder - */ - public Builder clientTimestamp(Date clientTimestamp) { - this.clientTimestamp = clientTimestamp; - return this; - } - - /** - * Set the displayRank. - * - * @param displayRank the displayRank - * @return the EventData builder - */ - public Builder displayRank(long displayRank) { - this.displayRank = displayRank; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the EventData builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the EventData builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the EventData builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - } - - protected EventData(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.environmentId, - "environmentId cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.sessionToken, - "sessionToken cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionId, - "collectionId cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.documentId, - "documentId cannot be null"); - environmentId = builder.environmentId; - sessionToken = builder.sessionToken; - clientTimestamp = builder.clientTimestamp; - displayRank = builder.displayRank; - collectionId = builder.collectionId; - documentId = builder.documentId; - queryId = builder.queryId; - } - - /** - * New builder. - * - * @return a EventData builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The **environment_id** associated with the query that the event is associated with. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the sessionToken. - * - * The session token that was returned as part of the query results that this event is associated with. - * - * @return the sessionToken - */ - public String sessionToken() { - return sessionToken; - } - - /** - * Gets the clientTimestamp. - * - * The optional timestamp for the event that was created. If not provided, the time that the event was created in the - * log was used. - * - * @return the clientTimestamp - */ - public Date clientTimestamp() { - return clientTimestamp; - } - - /** - * Gets the displayRank. - * - * The rank of the result item which the event is associated with. - * - * @return the displayRank - */ - public Long displayRank() { - return displayRank; - } - - /** - * Gets the collectionId. - * - * The **collection_id** of the document that this event is associated with. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the documentId. - * - * The **document_id** of the document that this event is associated with. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } - - /** - * Gets the queryId. - * - * The query identifier stored in the log. The query and any events associated with that query are stored with the - * same **query_id**. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java deleted file mode 100644 index 56ebff00498..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An expansion definition. Each object respresents one set of expandable strings. For example, you could have - * expansions for the word `hot` in one object, and expansions for the word `cold` in another. - */ -public class Expansion extends GenericModel { - - @SerializedName("input_terms") - protected List inputTerms; - @SerializedName("expanded_terms") - protected List expandedTerms; - - /** - * Builder. - */ - public static class Builder { - private List inputTerms; - private List expandedTerms; - - private Builder(Expansion expansion) { - this.inputTerms = expansion.inputTerms; - this.expandedTerms = expansion.expandedTerms; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param expandedTerms the expandedTerms - */ - public Builder(List expandedTerms) { - this.expandedTerms = expandedTerms; - } - - /** - * Builds a Expansion. - * - * @return the expansion - */ - public Expansion build() { - return new Expansion(this); - } - - /** - * Adds an inputTerms to inputTerms. - * - * @param inputTerms the new inputTerms - * @return the Expansion builder - */ - public Builder addInputTerms(String inputTerms) { - com.ibm.cloud.sdk.core.util.Validator.notNull(inputTerms, - "inputTerms cannot be null"); - if (this.inputTerms == null) { - this.inputTerms = new ArrayList(); - } - this.inputTerms.add(inputTerms); - return this; - } - - /** - * Adds an expandedTerms to expandedTerms. - * - * @param expandedTerms the new expandedTerms - * @return the Expansion builder - */ - public Builder addExpandedTerms(String expandedTerms) { - com.ibm.cloud.sdk.core.util.Validator.notNull(expandedTerms, - "expandedTerms cannot be null"); - if (this.expandedTerms == null) { - this.expandedTerms = new ArrayList(); - } - this.expandedTerms.add(expandedTerms); - return this; - } - - /** - * Set the inputTerms. - * Existing inputTerms will be replaced. - * - * @param inputTerms the inputTerms - * @return the Expansion builder - */ - public Builder inputTerms(List inputTerms) { - this.inputTerms = inputTerms; - return this; - } - - /** - * Set the expandedTerms. - * Existing expandedTerms will be replaced. - * - * @param expandedTerms the expandedTerms - * @return the Expansion builder - */ - public Builder expandedTerms(List expandedTerms) { - this.expandedTerms = expandedTerms; - return this; - } - } - - protected Expansion(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.expandedTerms, - "expandedTerms cannot be null"); - inputTerms = builder.inputTerms; - expandedTerms = builder.expandedTerms; - } - - /** - * New builder. - * - * @return a Expansion builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the inputTerms. - * - * A list of terms that will be expanded for this expansion. If specified, only the items in this list are expanded. - * - * @return the inputTerms - */ - public List inputTerms() { - return inputTerms; - } - - /** - * Gets the expandedTerms. - * - * A list of terms that this expansion will be expanded to. If specified without **input_terms**, it also functions as - * the input term list. - * - * @return the expandedTerms - */ - public List expandedTerms() { - return expandedTerms; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java deleted file mode 100644 index 6c9fe393c00..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The query expansion definitions for the specified collection. - */ -public class Expansions extends GenericModel { - - protected List expansions; - - /** - * Builder. - */ - public static class Builder { - private List expansions; - - private Builder(Expansions expansions) { - this.expansions = expansions.expansions; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param expansions the expansions - */ - public Builder(List expansions) { - this.expansions = expansions; - } - - /** - * Builds a Expansions. - * - * @return the expansions - */ - public Expansions build() { - return new Expansions(this); - } - - /** - * Adds an expansions to expansions. - * - * @param expansions the new expansions - * @return the Expansions builder - */ - public Builder addExpansions(Expansion expansions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(expansions, - "expansions cannot be null"); - if (this.expansions == null) { - this.expansions = new ArrayList(); - } - this.expansions.add(expansions); - return this; - } - - /** - * Set the expansions. - * Existing expansions will be replaced. - * - * @param expansions the expansions - * @return the Expansions builder - */ - public Builder expansions(List expansions) { - this.expansions = expansions; - return this; - } - } - - protected Expansions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.expansions, - "expansions cannot be null"); - expansions = builder.expansions; - } - - /** - * New builder. - * - * @return a Expansions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the expansions. - * - * An array of query expansion definitions. - * - * Each object in the **expansions** array represents a term or set of terms that will be expanded into other terms. - * Each expansion object can be configured as bidirectional or unidirectional. Bidirectional means that all terms are - * expanded to all other terms in the object. Unidirectional means that a set list of terms can be expanded into a - * second list of terms. - * - * To create a bi-directional expansion specify an **expanded_terms** array. When found in a query, all items in the - * **expanded_terms** array are then expanded to the other items in the same array. - * - * To create a uni-directional expansion, specify both an array of **input_terms** and an array of - * **expanded_terms**. When items in the **input_terms** array are present in a query, they are expanded using the - * items listed in the **expanded_terms** array. - * - * @return the expansions - */ - public List expansions() { - return expansions; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java deleted file mode 100644 index bb8124bce1d..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java +++ /dev/null @@ -1,569 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The federatedQueryNotices options. - */ -public class FederatedQueryNoticesOptions extends GenericModel { - - protected String environmentId; - protected List collectionIds; - protected String filter; - protected String query; - protected String naturalLanguageQuery; - protected String aggregation; - protected Long count; - protected List xReturn; - protected Long offset; - protected List sort; - protected Boolean highlight; - protected String deduplicateField; - protected Boolean similar; - protected List similarDocumentIds; - protected List similarFields; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private List collectionIds; - private String filter; - private String query; - private String naturalLanguageQuery; - private String aggregation; - private Long count; - private List xReturn; - private Long offset; - private List sort; - private Boolean highlight; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private List similarFields; - - private Builder(FederatedQueryNoticesOptions federatedQueryNoticesOptions) { - this.environmentId = federatedQueryNoticesOptions.environmentId; - this.collectionIds = federatedQueryNoticesOptions.collectionIds; - this.filter = federatedQueryNoticesOptions.filter; - this.query = federatedQueryNoticesOptions.query; - this.naturalLanguageQuery = federatedQueryNoticesOptions.naturalLanguageQuery; - this.aggregation = federatedQueryNoticesOptions.aggregation; - this.count = federatedQueryNoticesOptions.count; - this.xReturn = federatedQueryNoticesOptions.xReturn; - this.offset = federatedQueryNoticesOptions.offset; - this.sort = federatedQueryNoticesOptions.sort; - this.highlight = federatedQueryNoticesOptions.highlight; - this.deduplicateField = federatedQueryNoticesOptions.deduplicateField; - this.similar = federatedQueryNoticesOptions.similar; - this.similarDocumentIds = federatedQueryNoticesOptions.similarDocumentIds; - this.similarFields = federatedQueryNoticesOptions.similarFields; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionIds the collectionIds - */ - public Builder(String environmentId, List collectionIds) { - this.environmentId = environmentId; - this.collectionIds = collectionIds; - } - - /** - * Builds a FederatedQueryNoticesOptions. - * - * @return the federatedQueryNoticesOptions - */ - public FederatedQueryNoticesOptions build() { - return new FederatedQueryNoticesOptions(this); - } - - /** - * Adds an collectionIds to collectionIds. - * - * @param collectionIds the new collectionIds - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addCollectionIds(String collectionIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, - "collectionIds cannot be null"); - if (this.collectionIds == null) { - this.collectionIds = new ArrayList(); - } - this.collectionIds.add(collectionIds); - return this; - } - - /** - * Adds an returnField to xReturn. - * - * @param returnField the new returnField - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addReturnField(String returnField) { - com.ibm.cloud.sdk.core.util.Validator.notNull(returnField, - "returnField cannot be null"); - if (this.xReturn == null) { - this.xReturn = new ArrayList(); - } - this.xReturn.add(returnField); - return this; - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addSort(String sort) { - com.ibm.cloud.sdk.core.util.Validator.notNull(sort, - "sort cannot be null"); - if (this.sort == null) { - this.sort = new ArrayList(); - } - this.sort.add(sort); - return this; - } - - /** - * Adds an similarDocumentIds to similarDocumentIds. - * - * @param similarDocumentIds the new similarDocumentIds - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addSimilarDocumentIds(String similarDocumentIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(similarDocumentIds, - "similarDocumentIds cannot be null"); - if (this.similarDocumentIds == null) { - this.similarDocumentIds = new ArrayList(); - } - this.similarDocumentIds.add(similarDocumentIds); - return this; - } - - /** - * Adds an similarFields to similarFields. - * - * @param similarFields the new similarFields - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addSimilarFields(String similarFields) { - com.ibm.cloud.sdk.core.util.Validator.notNull(similarFields, - "similarFields cannot be null"); - if (this.similarFields == null) { - this.similarFields = new ArrayList(); - } - this.similarFields.add(similarFields); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the FederatedQueryNoticesOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionIds. - * Existing collectionIds will be replaced. - * - * @param collectionIds the collectionIds - * @return the FederatedQueryNoticesOptions builder - */ - public Builder collectionIds(List collectionIds) { - this.collectionIds = collectionIds; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the FederatedQueryNoticesOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the FederatedQueryNoticesOptions builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the naturalLanguageQuery. - * - * @param naturalLanguageQuery the naturalLanguageQuery - * @return the FederatedQueryNoticesOptions builder - */ - public Builder naturalLanguageQuery(String naturalLanguageQuery) { - this.naturalLanguageQuery = naturalLanguageQuery; - return this; - } - - /** - * Set the aggregation. - * - * @param aggregation the aggregation - * @return the FederatedQueryNoticesOptions builder - */ - public Builder aggregation(String aggregation) { - this.aggregation = aggregation; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the FederatedQueryNoticesOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the xReturn. - * Existing xReturn will be replaced. - * - * @param xReturn the xReturn - * @return the FederatedQueryNoticesOptions builder - */ - public Builder xReturn(List xReturn) { - this.xReturn = xReturn; - return this; - } - - /** - * Set the offset. - * - * @param offset the offset - * @return the FederatedQueryNoticesOptions builder - */ - public Builder offset(long offset) { - this.offset = offset; - return this; - } - - /** - * Set the sort. - * Existing sort will be replaced. - * - * @param sort the sort - * @return the FederatedQueryNoticesOptions builder - */ - public Builder sort(List sort) { - this.sort = sort; - return this; - } - - /** - * Set the highlight. - * - * @param highlight the highlight - * @return the FederatedQueryNoticesOptions builder - */ - public Builder highlight(Boolean highlight) { - this.highlight = highlight; - return this; - } - - /** - * Set the deduplicateField. - * - * @param deduplicateField the deduplicateField - * @return the FederatedQueryNoticesOptions builder - */ - public Builder deduplicateField(String deduplicateField) { - this.deduplicateField = deduplicateField; - return this; - } - - /** - * Set the similar. - * - * @param similar the similar - * @return the FederatedQueryNoticesOptions builder - */ - public Builder similar(Boolean similar) { - this.similar = similar; - return this; - } - - /** - * Set the similarDocumentIds. - * Existing similarDocumentIds will be replaced. - * - * @param similarDocumentIds the similarDocumentIds - * @return the FederatedQueryNoticesOptions builder - */ - public Builder similarDocumentIds(List similarDocumentIds) { - this.similarDocumentIds = similarDocumentIds; - return this; - } - - /** - * Set the similarFields. - * Existing similarFields will be replaced. - * - * @param similarFields the similarFields - * @return the FederatedQueryNoticesOptions builder - */ - public Builder similarFields(List similarFields) { - this.similarFields = similarFields; - return this; - } - } - - protected FederatedQueryNoticesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionIds, - "collectionIds cannot be null"); - environmentId = builder.environmentId; - collectionIds = builder.collectionIds; - filter = builder.filter; - query = builder.query; - naturalLanguageQuery = builder.naturalLanguageQuery; - aggregation = builder.aggregation; - count = builder.count; - xReturn = builder.xReturn; - offset = builder.offset; - sort = builder.sort; - highlight = builder.highlight; - deduplicateField = builder.deduplicateField; - similar = builder.similar; - similarDocumentIds = builder.similarDocumentIds; - similarFields = builder.similarFields; - } - - /** - * New builder. - * - * @return a FederatedQueryNoticesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionIds. - * - * A comma-separated list of collection IDs to be queried against. - * - * @return the collectionIds - */ - public List collectionIds() { - return collectionIds; - } - - /** - * Gets the filter. - * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the query. - * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. - * - * @return the query - */ - public String query() { - return query; - } - - /** - * Gets the naturalLanguageQuery. - * - * A natural language query that returns relevant documents by utilizing training data and natural language - * understanding. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the aggregation. - * - * An aggregation search that returns an exact answer by combining query search with filters. Useful for applications - * to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of results to return. The maximum for the **count** and **offset** values together in any one query is - * **10000**. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the xReturn. - * - * A comma-separated list of the portion of the document hierarchy to return. - * - * @return the xReturn - */ - public List xReturn() { - return xReturn; - } - - /** - * Gets the offset. - * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. The maximum for the **count** and **offset** values - * together in any one query is **10000**. - * - * @return the offset - */ - public Long offset() { - return offset; - } - - /** - * Gets the sort. - * - * A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by - * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no - * prefix is specified. - * - * @return the sort - */ - public List sort() { - return sort; - } - - /** - * Gets the highlight. - * - * When true, a highlight field is returned for each result which contains the fields which match the query with - * `` tags around the matching query terms. - * - * @return the highlight - */ - public Boolean highlight() { - return highlight; - } - - /** - * Gets the deduplicateField. - * - * When specified, duplicate results based on the field specified are removed from the returned results. Duplicate - * comparison is limited to the current query only, **offset** is not considered. This parameter is currently Beta - * functionality. - * - * @return the deduplicateField - */ - public String deduplicateField() { - return deduplicateField; - } - - /** - * Gets the similar. - * - * When `true`, results are returned based on their similarity to the document IDs specified in the - * **similar.document_ids** parameter. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs to find similar documents. - * - * **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search - * with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied - * and reduce the scope. - * - * @return the similarDocumentIds - */ - public List similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not - * specified, the entire document is used for comparison. - * - * @return the similarFields - */ - public List similarFields() { - return similarFields; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java deleted file mode 100644 index 77d7be425ed..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java +++ /dev/null @@ -1,668 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The federatedQuery options. - */ -public class FederatedQueryOptions extends GenericModel { - - protected String environmentId; - protected String collectionIds; - protected String filter; - protected String query; - protected String naturalLanguageQuery; - protected Boolean passages; - protected String aggregation; - protected Long count; - protected String xReturn; - protected Long offset; - protected String sort; - protected Boolean highlight; - protected String passagesFields; - protected Long passagesCount; - protected Long passagesCharacters; - protected Boolean deduplicate; - protected String deduplicateField; - protected Boolean similar; - protected String similarDocumentIds; - protected String similarFields; - protected String bias; - protected Boolean xWatsonLoggingOptOut; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionIds; - private String filter; - private String query; - private String naturalLanguageQuery; - private Boolean passages; - private String aggregation; - private Long count; - private String xReturn; - private Long offset; - private String sort; - private Boolean highlight; - private String passagesFields; - private Long passagesCount; - private Long passagesCharacters; - private Boolean deduplicate; - private String deduplicateField; - private Boolean similar; - private String similarDocumentIds; - private String similarFields; - private String bias; - private Boolean xWatsonLoggingOptOut; - - private Builder(FederatedQueryOptions federatedQueryOptions) { - this.environmentId = federatedQueryOptions.environmentId; - this.collectionIds = federatedQueryOptions.collectionIds; - this.filter = federatedQueryOptions.filter; - this.query = federatedQueryOptions.query; - this.naturalLanguageQuery = federatedQueryOptions.naturalLanguageQuery; - this.passages = federatedQueryOptions.passages; - this.aggregation = federatedQueryOptions.aggregation; - this.count = federatedQueryOptions.count; - this.xReturn = federatedQueryOptions.xReturn; - this.offset = federatedQueryOptions.offset; - this.sort = federatedQueryOptions.sort; - this.highlight = federatedQueryOptions.highlight; - this.passagesFields = federatedQueryOptions.passagesFields; - this.passagesCount = federatedQueryOptions.passagesCount; - this.passagesCharacters = federatedQueryOptions.passagesCharacters; - this.deduplicate = federatedQueryOptions.deduplicate; - this.deduplicateField = federatedQueryOptions.deduplicateField; - this.similar = federatedQueryOptions.similar; - this.similarDocumentIds = federatedQueryOptions.similarDocumentIds; - this.similarFields = federatedQueryOptions.similarFields; - this.bias = federatedQueryOptions.bias; - this.xWatsonLoggingOptOut = federatedQueryOptions.xWatsonLoggingOptOut; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionIds the collectionIds - */ - public Builder(String environmentId, String collectionIds) { - this.environmentId = environmentId; - this.collectionIds = collectionIds; - } - - /** - * Builds a FederatedQueryOptions. - * - * @return the federatedQueryOptions - */ - public FederatedQueryOptions build() { - return new FederatedQueryOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the FederatedQueryOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionIds. - * - * @param collectionIds the collectionIds - * @return the FederatedQueryOptions builder - */ - public Builder collectionIds(String collectionIds) { - this.collectionIds = collectionIds; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the FederatedQueryOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the FederatedQueryOptions builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the naturalLanguageQuery. - * - * @param naturalLanguageQuery the naturalLanguageQuery - * @return the FederatedQueryOptions builder - */ - public Builder naturalLanguageQuery(String naturalLanguageQuery) { - this.naturalLanguageQuery = naturalLanguageQuery; - return this; - } - - /** - * Set the passages. - * - * @param passages the passages - * @return the FederatedQueryOptions builder - */ - public Builder passages(Boolean passages) { - this.passages = passages; - return this; - } - - /** - * Set the aggregation. - * - * @param aggregation the aggregation - * @return the FederatedQueryOptions builder - */ - public Builder aggregation(String aggregation) { - this.aggregation = aggregation; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the FederatedQueryOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the xReturn. - * - * @param xReturn the xReturn - * @return the FederatedQueryOptions builder - */ - public Builder xReturn(String xReturn) { - this.xReturn = xReturn; - return this; - } - - /** - * Set the offset. - * - * @param offset the offset - * @return the FederatedQueryOptions builder - */ - public Builder offset(long offset) { - this.offset = offset; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the FederatedQueryOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the highlight. - * - * @param highlight the highlight - * @return the FederatedQueryOptions builder - */ - public Builder highlight(Boolean highlight) { - this.highlight = highlight; - return this; - } - - /** - * Set the passagesFields. - * - * @param passagesFields the passagesFields - * @return the FederatedQueryOptions builder - */ - public Builder passagesFields(String passagesFields) { - this.passagesFields = passagesFields; - return this; - } - - /** - * Set the passagesCount. - * - * @param passagesCount the passagesCount - * @return the FederatedQueryOptions builder - */ - public Builder passagesCount(long passagesCount) { - this.passagesCount = passagesCount; - return this; - } - - /** - * Set the passagesCharacters. - * - * @param passagesCharacters the passagesCharacters - * @return the FederatedQueryOptions builder - */ - public Builder passagesCharacters(long passagesCharacters) { - this.passagesCharacters = passagesCharacters; - return this; - } - - /** - * Set the deduplicate. - * - * @param deduplicate the deduplicate - * @return the FederatedQueryOptions builder - */ - public Builder deduplicate(Boolean deduplicate) { - this.deduplicate = deduplicate; - return this; - } - - /** - * Set the deduplicateField. - * - * @param deduplicateField the deduplicateField - * @return the FederatedQueryOptions builder - */ - public Builder deduplicateField(String deduplicateField) { - this.deduplicateField = deduplicateField; - return this; - } - - /** - * Set the similar. - * - * @param similar the similar - * @return the FederatedQueryOptions builder - */ - public Builder similar(Boolean similar) { - this.similar = similar; - return this; - } - - /** - * Set the similarDocumentIds. - * - * @param similarDocumentIds the similarDocumentIds - * @return the FederatedQueryOptions builder - */ - public Builder similarDocumentIds(String similarDocumentIds) { - this.similarDocumentIds = similarDocumentIds; - return this; - } - - /** - * Set the similarFields. - * - * @param similarFields the similarFields - * @return the FederatedQueryOptions builder - */ - public Builder similarFields(String similarFields) { - this.similarFields = similarFields; - return this; - } - - /** - * Set the bias. - * - * @param bias the bias - * @return the FederatedQueryOptions builder - */ - public Builder bias(String bias) { - this.bias = bias; - return this; - } - - /** - * Set the xWatsonLoggingOptOut. - * - * @param xWatsonLoggingOptOut the xWatsonLoggingOptOut - * @return the FederatedQueryOptions builder - */ - public Builder xWatsonLoggingOptOut(Boolean xWatsonLoggingOptOut) { - this.xWatsonLoggingOptOut = xWatsonLoggingOptOut; - return this; - } - } - - protected FederatedQueryOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionIds, - "collectionIds cannot be null"); - environmentId = builder.environmentId; - collectionIds = builder.collectionIds; - filter = builder.filter; - query = builder.query; - naturalLanguageQuery = builder.naturalLanguageQuery; - passages = builder.passages; - aggregation = builder.aggregation; - count = builder.count; - xReturn = builder.xReturn; - offset = builder.offset; - sort = builder.sort; - highlight = builder.highlight; - passagesFields = builder.passagesFields; - passagesCount = builder.passagesCount; - passagesCharacters = builder.passagesCharacters; - deduplicate = builder.deduplicate; - deduplicateField = builder.deduplicateField; - similar = builder.similar; - similarDocumentIds = builder.similarDocumentIds; - similarFields = builder.similarFields; - bias = builder.bias; - xWatsonLoggingOptOut = builder.xWatsonLoggingOptOut; - } - - /** - * New builder. - * - * @return a FederatedQueryOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionIds. - * - * A comma-separated list of collection IDs to be queried against. - * - * @return the collectionIds - */ - public String collectionIds() { - return collectionIds; - } - - /** - * Gets the filter. - * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the query. - * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. Use a query search when you want to find the most relevant search results. - * - * @return the query - */ - public String query() { - return query; - } - - /** - * Gets the naturalLanguageQuery. - * - * A natural language query that returns relevant documents by utilizing training data and natural language - * understanding. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the passages. - * - * A passages query that returns the most relevant passages from the results. - * - * @return the passages - */ - public Boolean passages() { - return passages; - } - - /** - * Gets the aggregation. - * - * An aggregation search that returns an exact answer by combining query search with filters. Useful for applications - * to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of results to return. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the xReturn. - * - * A comma-separated list of the portion of the document hierarchy to return. - * - * @return the xReturn - */ - public String xReturn() { - return xReturn; - } - - /** - * Gets the offset. - * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. - * - * @return the offset - */ - public Long offset() { - return offset; - } - - /** - * Gets the sort. - * - * A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by - * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no - * prefix is specified. This parameter cannot be used in the same query as the **bias** parameter. - * - * @return the sort - */ - public String sort() { - return sort; - } - - /** - * Gets the highlight. - * - * When true, a highlight field is returned for each result which contains the fields which match the query with - * `` tags around the matching query terms. - * - * @return the highlight - */ - public Boolean highlight() { - return highlight; - } - - /** - * Gets the passagesFields. - * - * A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level - * fields are included. - * - * @return the passagesFields - */ - public String passagesFields() { - return passagesFields; - } - - /** - * Gets the passagesCount. - * - * The maximum number of passages to return. The search returns fewer passages if the requested total is not found. - * The default is `10`. The maximum is `100`. - * - * @return the passagesCount - */ - public Long passagesCount() { - return passagesCount; - } - - /** - * Gets the passagesCharacters. - * - * The approximate number of characters that any one passage will have. - * - * @return the passagesCharacters - */ - public Long passagesCharacters() { - return passagesCharacters; - } - - /** - * Gets the deduplicate. - * - * When `true`, and used with a Watson Discovery News collection, duplicate results (based on the contents of the - * **title** field) are removed. Duplicate comparison is limited to the current query only; **offset** is not - * considered. This parameter is currently Beta functionality. - * - * @return the deduplicate - */ - public Boolean deduplicate() { - return deduplicate; - } - - /** - * Gets the deduplicateField. - * - * When specified, duplicate results based on the field specified are removed from the returned results. Duplicate - * comparison is limited to the current query only, **offset** is not considered. This parameter is currently Beta - * functionality. - * - * @return the deduplicateField - */ - public String deduplicateField() { - return deduplicateField; - } - - /** - * Gets the similar. - * - * When `true`, results are returned based on their similarity to the document IDs specified in the - * **similar.document_ids** parameter. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs to find similar documents. - * - * **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search - * with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied - * and reduce the scope. - * - * @return the similarDocumentIds - */ - public String similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not - * specified, the entire document is used for comparison. - * - * @return the similarFields - */ - public String similarFields() { - return similarFields; - } - - /** - * Gets the bias. - * - * Field which the returned results will be biased against. The specified field must be either a **date** or - * **number** format. When a **date** type field is specified returned results are biased towards field values closer - * to the current date. When a **number** type field is specified, returned results are biased towards higher field - * values. This parameter cannot be used in the same query as the **sort** parameter. - * - * @return the bias - */ - public String bias() { - return bias; - } - - /** - * Gets the xWatsonLoggingOptOut. - * - * If `true`, queries are not stored in the Discovery **Logs** endpoint. - * - * @return the xWatsonLoggingOptOut - */ - public Boolean xWatsonLoggingOptOut() { - return xWatsonLoggingOptOut; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java deleted file mode 100644 index 73700403a81..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing field details. - */ -public class Field extends GenericModel { - - /** - * The type of the field. - */ - public interface Type { - /** nested. */ - String NESTED = "nested"; - /** string. */ - String STRING = "string"; - /** date. */ - String DATE = "date"; - /** long. */ - String X_LONG = "long"; - /** integer. */ - String INTEGER = "integer"; - /** short. */ - String X_SHORT = "short"; - /** byte. */ - String X_BYTE = "byte"; - /** double. */ - String X_DOUBLE = "double"; - /** float. */ - String X_FLOAT = "float"; - /** boolean. */ - String X_BOOLEAN = "boolean"; - /** binary. */ - String BINARY = "binary"; - } - - protected String field; - protected String type; - - /** - * Gets the field. - * - * The name of the field. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the type. - * - * The type of the field. - * - * @return the type - */ - public String getType() { - return type; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java deleted file mode 100644 index 05835673d22..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -/** - * Filter. - */ -public class Filter extends QueryAggregation { - - protected String match; - - /** - * Gets the match. - * - * The match the aggregated results queried for. - * - * @return the match - */ - public String getMatch() { - return match; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java deleted file mode 100644 index afe998c7d82..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Font matching configuration. - */ -public class FontSetting extends GenericModel { - - protected Long level; - @SerializedName("min_size") - protected Long minSize; - @SerializedName("max_size") - protected Long maxSize; - protected Boolean bold; - protected Boolean italic; - protected String name; - - /** - * Builder. - */ - public static class Builder { - private Long level; - private Long minSize; - private Long maxSize; - private Boolean bold; - private Boolean italic; - private String name; - - private Builder(FontSetting fontSetting) { - this.level = fontSetting.level; - this.minSize = fontSetting.minSize; - this.maxSize = fontSetting.maxSize; - this.bold = fontSetting.bold; - this.italic = fontSetting.italic; - this.name = fontSetting.name; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a FontSetting. - * - * @return the fontSetting - */ - public FontSetting build() { - return new FontSetting(this); - } - - /** - * Set the level. - * - * @param level the level - * @return the FontSetting builder - */ - public Builder level(long level) { - this.level = level; - return this; - } - - /** - * Set the minSize. - * - * @param minSize the minSize - * @return the FontSetting builder - */ - public Builder minSize(long minSize) { - this.minSize = minSize; - return this; - } - - /** - * Set the maxSize. - * - * @param maxSize the maxSize - * @return the FontSetting builder - */ - public Builder maxSize(long maxSize) { - this.maxSize = maxSize; - return this; - } - - /** - * Set the bold. - * - * @param bold the bold - * @return the FontSetting builder - */ - public Builder bold(Boolean bold) { - this.bold = bold; - return this; - } - - /** - * Set the italic. - * - * @param italic the italic - * @return the FontSetting builder - */ - public Builder italic(Boolean italic) { - this.italic = italic; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the FontSetting builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - } - - protected FontSetting(Builder builder) { - level = builder.level; - minSize = builder.minSize; - maxSize = builder.maxSize; - bold = builder.bold; - italic = builder.italic; - name = builder.name; - } - - /** - * New builder. - * - * @return a FontSetting builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the level. - * - * The HTML heading level that any content with the matching font is converted to. - * - * @return the level - */ - public Long level() { - return level; - } - - /** - * Gets the minSize. - * - * The minimum size of the font to match. - * - * @return the minSize - */ - public Long minSize() { - return minSize; - } - - /** - * Gets the maxSize. - * - * The maximum size of the font to match. - * - * @return the maxSize - */ - public Long maxSize() { - return maxSize; - } - - /** - * Gets the bold. - * - * When `true`, the font is matched if it is bold. - * - * @return the bold - */ - public Boolean bold() { - return bold; - } - - /** - * Gets the italic. - * - * When `true`, the font is matched if it is italic. - * - * @return the italic - */ - public Boolean italic() { - return italic; - } - - /** - * Gets the name. - * - * The name of the font. - * - * @return the name - */ - public String name() { - return name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java deleted file mode 100644 index 4492775330f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object describing a specific gateway. - */ -public class Gateway extends GenericModel { - - /** - * The current status of the gateway. `connected` means the gateway is connected to the remotly installed gateway. - * `idle` means this gateway is not currently in use. - */ - public interface Status { - /** connected. */ - String CONNECTED = "connected"; - /** idle. */ - String IDLE = "idle"; - } - - @SerializedName("gateway_id") - protected String gatewayId; - protected String name; - protected String status; - protected String token; - @SerializedName("token_id") - protected String tokenId; - - /** - * Gets the gatewayId. - * - * The gateway ID of the gateway. - * - * @return the gatewayId - */ - public String getGatewayId() { - return gatewayId; - } - - /** - * Gets the name. - * - * The user defined name of the gateway. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the status. - * - * The current status of the gateway. `connected` means the gateway is connected to the remotly installed gateway. - * `idle` means this gateway is not currently in use. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the token. - * - * The generated **token** for this gateway. The value of this field is used when configuring the remotly installed - * gateway. - * - * @return the token - */ - public String getToken() { - return token; - } - - /** - * Gets the tokenId. - * - * The generated **token_id** for this gateway. The value of this field is used when configuring the remotly installed - * gateway. - * - * @return the tokenId - */ - public String getTokenId() { - return tokenId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java deleted file mode 100644 index cb2df3cd841..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Gatway deletion confirmation. - */ -public class GatewayDelete extends GenericModel { - - @SerializedName("gateway_id") - protected String gatewayId; - protected String status; - - /** - * Gets the gatewayId. - * - * The gateway ID of the deleted gateway. - * - * @return the gatewayId - */ - public String getGatewayId() { - return gatewayId; - } - - /** - * Gets the status. - * - * The status of the request. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java deleted file mode 100644 index e18d69efceb..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing gateways array. - */ -public class GatewayList extends GenericModel { - - protected List gateways; - - /** - * Gets the gateways. - * - * Array of configured gateway connections. - * - * @return the gateways - */ - public List getGateways() { - return gateways; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java deleted file mode 100644 index e481178de2c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getAutocompletion options. - */ -public class GetAutocompletionOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String prefix; - protected String field; - protected Long count; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String prefix; - private String field; - private Long count; - - private Builder(GetAutocompletionOptions getAutocompletionOptions) { - this.environmentId = getAutocompletionOptions.environmentId; - this.collectionId = getAutocompletionOptions.collectionId; - this.prefix = getAutocompletionOptions.prefix; - this.field = getAutocompletionOptions.field; - this.count = getAutocompletionOptions.count; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param prefix the prefix - */ - public Builder(String environmentId, String collectionId, String prefix) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.prefix = prefix; - } - - /** - * Builds a GetAutocompletionOptions. - * - * @return the getAutocompletionOptions - */ - public GetAutocompletionOptions build() { - return new GetAutocompletionOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetAutocompletionOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetAutocompletionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the prefix. - * - * @param prefix the prefix - * @return the GetAutocompletionOptions builder - */ - public Builder prefix(String prefix) { - this.prefix = prefix; - return this; - } - - /** - * Set the field. - * - * @param field the field - * @return the GetAutocompletionOptions builder - */ - public Builder field(String field) { - this.field = field; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the GetAutocompletionOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - } - - protected GetAutocompletionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.prefix, - "prefix cannot be null"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - prefix = builder.prefix; - field = builder.field; - count = builder.count; - } - - /** - * New builder. - * - * @return a GetAutocompletionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the prefix. - * - * The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to `Hot`, `Housing`, or `How - * do I upgrade`. Possible completions are. - * - * @return the prefix - */ - public String prefix() { - return prefix; - } - - /** - * Gets the field. - * - * The field in the result documents that autocompletion suggestions are identified from. - * - * @return the field - */ - public String field() { - return field; - } - - /** - * Gets the count. - * - * The number of autocompletion suggestions to return. - * - * @return the count - */ - public Long count() { - return count; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java deleted file mode 100644 index 59406c16448..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getCollection options. - */ -public class GetCollectionOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(GetCollectionOptions getCollectionOptions) { - this.environmentId = getCollectionOptions.environmentId; - this.collectionId = getCollectionOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a GetCollectionOptions. - * - * @return the getCollectionOptions - */ - public GetCollectionOptions build() { - return new GetCollectionOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetCollectionOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetCollectionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected GetCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a GetCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java deleted file mode 100644 index cfa31a4de99..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getConfiguration options. - */ -public class GetConfigurationOptions extends GenericModel { - - protected String environmentId; - protected String configurationId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String configurationId; - - private Builder(GetConfigurationOptions getConfigurationOptions) { - this.environmentId = getConfigurationOptions.environmentId; - this.configurationId = getConfigurationOptions.configurationId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param configurationId the configurationId - */ - public Builder(String environmentId, String configurationId) { - this.environmentId = environmentId; - this.configurationId = configurationId; - } - - /** - * Builds a GetConfigurationOptions. - * - * @return the getConfigurationOptions - */ - public GetConfigurationOptions build() { - return new GetConfigurationOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetConfigurationOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the GetConfigurationOptions builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - } - - protected GetConfigurationOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.configurationId, - "configurationId cannot be empty"); - environmentId = builder.environmentId; - configurationId = builder.configurationId; - } - - /** - * New builder. - * - * @return a GetConfigurationOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the configurationId. - * - * The ID of the configuration. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java deleted file mode 100644 index 774093b74bd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getCredentials options. - */ -public class GetCredentialsOptions extends GenericModel { - - protected String environmentId; - protected String credentialId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String credentialId; - - private Builder(GetCredentialsOptions getCredentialsOptions) { - this.environmentId = getCredentialsOptions.environmentId; - this.credentialId = getCredentialsOptions.credentialId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param credentialId the credentialId - */ - public Builder(String environmentId, String credentialId) { - this.environmentId = environmentId; - this.credentialId = credentialId; - } - - /** - * Builds a GetCredentialsOptions. - * - * @return the getCredentialsOptions - */ - public GetCredentialsOptions build() { - return new GetCredentialsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetCredentialsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the credentialId. - * - * @param credentialId the credentialId - * @return the GetCredentialsOptions builder - */ - public Builder credentialId(String credentialId) { - this.credentialId = credentialId; - return this; - } - } - - protected GetCredentialsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.credentialId, - "credentialId cannot be empty"); - environmentId = builder.environmentId; - credentialId = builder.credentialId; - } - - /** - * New builder. - * - * @return a GetCredentialsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the credentialId. - * - * The unique identifier for a set of source credentials. - * - * @return the credentialId - */ - public String credentialId() { - return credentialId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java deleted file mode 100644 index 14de7b799b4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getDocumentStatus options. - */ -public class GetDocumentStatusOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String documentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String documentId; - - private Builder(GetDocumentStatusOptions getDocumentStatusOptions) { - this.environmentId = getDocumentStatusOptions.environmentId; - this.collectionId = getDocumentStatusOptions.collectionId; - this.documentId = getDocumentStatusOptions.documentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param documentId the documentId - */ - public Builder(String environmentId, String collectionId, String documentId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.documentId = documentId; - } - - /** - * Builds a GetDocumentStatusOptions. - * - * @return the getDocumentStatusOptions - */ - public GetDocumentStatusOptions build() { - return new GetDocumentStatusOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetDocumentStatusOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetDocumentStatusOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the GetDocumentStatusOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - } - - protected GetDocumentStatusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.documentId, - "documentId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - documentId = builder.documentId; - } - - /** - * New builder. - * - * @return a GetDocumentStatusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the documentId. - * - * The ID of the document. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java deleted file mode 100644 index 18d157abccc..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getEnvironment options. - */ -public class GetEnvironmentOptions extends GenericModel { - - protected String environmentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - - private Builder(GetEnvironmentOptions getEnvironmentOptions) { - this.environmentId = getEnvironmentOptions.environmentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a GetEnvironmentOptions. - * - * @return the getEnvironmentOptions - */ - public GetEnvironmentOptions build() { - return new GetEnvironmentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetEnvironmentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - } - - protected GetEnvironmentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - } - - /** - * New builder. - * - * @return a GetEnvironmentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java deleted file mode 100644 index 4270f73e4ba..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getGateway options. - */ -public class GetGatewayOptions extends GenericModel { - - protected String environmentId; - protected String gatewayId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String gatewayId; - - private Builder(GetGatewayOptions getGatewayOptions) { - this.environmentId = getGatewayOptions.environmentId; - this.gatewayId = getGatewayOptions.gatewayId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param gatewayId the gatewayId - */ - public Builder(String environmentId, String gatewayId) { - this.environmentId = environmentId; - this.gatewayId = gatewayId; - } - - /** - * Builds a GetGatewayOptions. - * - * @return the getGatewayOptions - */ - public GetGatewayOptions build() { - return new GetGatewayOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetGatewayOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the gatewayId. - * - * @param gatewayId the gatewayId - * @return the GetGatewayOptions builder - */ - public Builder gatewayId(String gatewayId) { - this.gatewayId = gatewayId; - return this; - } - } - - protected GetGatewayOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.gatewayId, - "gatewayId cannot be empty"); - environmentId = builder.environmentId; - gatewayId = builder.gatewayId; - } - - /** - * New builder. - * - * @return a GetGatewayOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the gatewayId. - * - * The requested gateway ID. - * - * @return the gatewayId - */ - public String gatewayId() { - return gatewayId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java deleted file mode 100644 index 1a2fef401ff..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getMetricsEventRate options. - */ -public class GetMetricsEventRateOptions extends GenericModel { - - /** - * The type of result to consider when calculating the metric. - */ - public interface ResultType { - /** document. */ - String DOCUMENT = "document"; - } - - protected Date startTime; - protected Date endTime; - protected String resultType; - - /** - * Builder. - */ - public static class Builder { - private Date startTime; - private Date endTime; - private String resultType; - - private Builder(GetMetricsEventRateOptions getMetricsEventRateOptions) { - this.startTime = getMetricsEventRateOptions.startTime; - this.endTime = getMetricsEventRateOptions.endTime; - this.resultType = getMetricsEventRateOptions.resultType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a GetMetricsEventRateOptions. - * - * @return the getMetricsEventRateOptions - */ - public GetMetricsEventRateOptions build() { - return new GetMetricsEventRateOptions(this); - } - - /** - * Set the startTime. - * - * @param startTime the startTime - * @return the GetMetricsEventRateOptions builder - */ - public Builder startTime(Date startTime) { - this.startTime = startTime; - return this; - } - - /** - * Set the endTime. - * - * @param endTime the endTime - * @return the GetMetricsEventRateOptions builder - */ - public Builder endTime(Date endTime) { - this.endTime = endTime; - return this; - } - - /** - * Set the resultType. - * - * @param resultType the resultType - * @return the GetMetricsEventRateOptions builder - */ - public Builder resultType(String resultType) { - this.resultType = resultType; - return this; - } - } - - protected GetMetricsEventRateOptions(Builder builder) { - startTime = builder.startTime; - endTime = builder.endTime; - resultType = builder.resultType; - } - - /** - * New builder. - * - * @return a GetMetricsEventRateOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the startTime. - * - * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the startTime - */ - public Date startTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the endTime - */ - public Date endTime() { - return endTime; - } - - /** - * Gets the resultType. - * - * The type of result to consider when calculating the metric. - * - * @return the resultType - */ - public String resultType() { - return resultType; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java deleted file mode 100644 index c04e311cd65..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getMetricsQueryEvent options. - */ -public class GetMetricsQueryEventOptions extends GenericModel { - - /** - * The type of result to consider when calculating the metric. - */ - public interface ResultType { - /** document. */ - String DOCUMENT = "document"; - } - - protected Date startTime; - protected Date endTime; - protected String resultType; - - /** - * Builder. - */ - public static class Builder { - private Date startTime; - private Date endTime; - private String resultType; - - private Builder(GetMetricsQueryEventOptions getMetricsQueryEventOptions) { - this.startTime = getMetricsQueryEventOptions.startTime; - this.endTime = getMetricsQueryEventOptions.endTime; - this.resultType = getMetricsQueryEventOptions.resultType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a GetMetricsQueryEventOptions. - * - * @return the getMetricsQueryEventOptions - */ - public GetMetricsQueryEventOptions build() { - return new GetMetricsQueryEventOptions(this); - } - - /** - * Set the startTime. - * - * @param startTime the startTime - * @return the GetMetricsQueryEventOptions builder - */ - public Builder startTime(Date startTime) { - this.startTime = startTime; - return this; - } - - /** - * Set the endTime. - * - * @param endTime the endTime - * @return the GetMetricsQueryEventOptions builder - */ - public Builder endTime(Date endTime) { - this.endTime = endTime; - return this; - } - - /** - * Set the resultType. - * - * @param resultType the resultType - * @return the GetMetricsQueryEventOptions builder - */ - public Builder resultType(String resultType) { - this.resultType = resultType; - return this; - } - } - - protected GetMetricsQueryEventOptions(Builder builder) { - startTime = builder.startTime; - endTime = builder.endTime; - resultType = builder.resultType; - } - - /** - * New builder. - * - * @return a GetMetricsQueryEventOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the startTime. - * - * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the startTime - */ - public Date startTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the endTime - */ - public Date endTime() { - return endTime; - } - - /** - * Gets the resultType. - * - * The type of result to consider when calculating the metric. - * - * @return the resultType - */ - public String resultType() { - return resultType; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java deleted file mode 100644 index 1c58b19f679..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getMetricsQueryNoResults options. - */ -public class GetMetricsQueryNoResultsOptions extends GenericModel { - - /** - * The type of result to consider when calculating the metric. - */ - public interface ResultType { - /** document. */ - String DOCUMENT = "document"; - } - - protected Date startTime; - protected Date endTime; - protected String resultType; - - /** - * Builder. - */ - public static class Builder { - private Date startTime; - private Date endTime; - private String resultType; - - private Builder(GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptions) { - this.startTime = getMetricsQueryNoResultsOptions.startTime; - this.endTime = getMetricsQueryNoResultsOptions.endTime; - this.resultType = getMetricsQueryNoResultsOptions.resultType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a GetMetricsQueryNoResultsOptions. - * - * @return the getMetricsQueryNoResultsOptions - */ - public GetMetricsQueryNoResultsOptions build() { - return new GetMetricsQueryNoResultsOptions(this); - } - - /** - * Set the startTime. - * - * @param startTime the startTime - * @return the GetMetricsQueryNoResultsOptions builder - */ - public Builder startTime(Date startTime) { - this.startTime = startTime; - return this; - } - - /** - * Set the endTime. - * - * @param endTime the endTime - * @return the GetMetricsQueryNoResultsOptions builder - */ - public Builder endTime(Date endTime) { - this.endTime = endTime; - return this; - } - - /** - * Set the resultType. - * - * @param resultType the resultType - * @return the GetMetricsQueryNoResultsOptions builder - */ - public Builder resultType(String resultType) { - this.resultType = resultType; - return this; - } - } - - protected GetMetricsQueryNoResultsOptions(Builder builder) { - startTime = builder.startTime; - endTime = builder.endTime; - resultType = builder.resultType; - } - - /** - * New builder. - * - * @return a GetMetricsQueryNoResultsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the startTime. - * - * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the startTime - */ - public Date startTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the endTime - */ - public Date endTime() { - return endTime; - } - - /** - * Gets the resultType. - * - * The type of result to consider when calculating the metric. - * - * @return the resultType - */ - public String resultType() { - return resultType; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java deleted file mode 100644 index a700d0b0fbf..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getMetricsQuery options. - */ -public class GetMetricsQueryOptions extends GenericModel { - - /** - * The type of result to consider when calculating the metric. - */ - public interface ResultType { - /** document. */ - String DOCUMENT = "document"; - } - - protected Date startTime; - protected Date endTime; - protected String resultType; - - /** - * Builder. - */ - public static class Builder { - private Date startTime; - private Date endTime; - private String resultType; - - private Builder(GetMetricsQueryOptions getMetricsQueryOptions) { - this.startTime = getMetricsQueryOptions.startTime; - this.endTime = getMetricsQueryOptions.endTime; - this.resultType = getMetricsQueryOptions.resultType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a GetMetricsQueryOptions. - * - * @return the getMetricsQueryOptions - */ - public GetMetricsQueryOptions build() { - return new GetMetricsQueryOptions(this); - } - - /** - * Set the startTime. - * - * @param startTime the startTime - * @return the GetMetricsQueryOptions builder - */ - public Builder startTime(Date startTime) { - this.startTime = startTime; - return this; - } - - /** - * Set the endTime. - * - * @param endTime the endTime - * @return the GetMetricsQueryOptions builder - */ - public Builder endTime(Date endTime) { - this.endTime = endTime; - return this; - } - - /** - * Set the resultType. - * - * @param resultType the resultType - * @return the GetMetricsQueryOptions builder - */ - public Builder resultType(String resultType) { - this.resultType = resultType; - return this; - } - } - - protected GetMetricsQueryOptions(Builder builder) { - startTime = builder.startTime; - endTime = builder.endTime; - resultType = builder.resultType; - } - - /** - * New builder. - * - * @return a GetMetricsQueryOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the startTime. - * - * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the startTime - */ - public Date startTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the endTime - */ - public Date endTime() { - return endTime; - } - - /** - * Gets the resultType. - * - * The type of result to consider when calculating the metric. - * - * @return the resultType - */ - public String resultType() { - return resultType; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java deleted file mode 100644 index 7f865c5a8b0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getMetricsQueryTokenEvent options. - */ -public class GetMetricsQueryTokenEventOptions extends GenericModel { - - protected Long count; - - /** - * Builder. - */ - public static class Builder { - private Long count; - - private Builder(GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptions) { - this.count = getMetricsQueryTokenEventOptions.count; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a GetMetricsQueryTokenEventOptions. - * - * @return the getMetricsQueryTokenEventOptions - */ - public GetMetricsQueryTokenEventOptions build() { - return new GetMetricsQueryTokenEventOptions(this); - } - - /** - * Set the count. - * - * @param count the count - * @return the GetMetricsQueryTokenEventOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - } - - protected GetMetricsQueryTokenEventOptions(Builder builder) { - count = builder.count; - } - - /** - * New builder. - * - * @return a GetMetricsQueryTokenEventOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the count. - * - * Number of results to return. The maximum for the **count** and **offset** values together in any one query is - * **10000**. - * - * @return the count - */ - public Long count() { - return count; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java deleted file mode 100644 index b89602cd8ca..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getStopwordListStatus options. - */ -public class GetStopwordListStatusOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(GetStopwordListStatusOptions getStopwordListStatusOptions) { - this.environmentId = getStopwordListStatusOptions.environmentId; - this.collectionId = getStopwordListStatusOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a GetStopwordListStatusOptions. - * - * @return the getStopwordListStatusOptions - */ - public GetStopwordListStatusOptions build() { - return new GetStopwordListStatusOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetStopwordListStatusOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetStopwordListStatusOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected GetStopwordListStatusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a GetStopwordListStatusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java deleted file mode 100644 index 4f55ad26fe3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getTokenizationDictionaryStatus options. - */ -public class GetTokenizationDictionaryStatusOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions) { - this.environmentId = getTokenizationDictionaryStatusOptions.environmentId; - this.collectionId = getTokenizationDictionaryStatusOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a GetTokenizationDictionaryStatusOptions. - * - * @return the getTokenizationDictionaryStatusOptions - */ - public GetTokenizationDictionaryStatusOptions build() { - return new GetTokenizationDictionaryStatusOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetTokenizationDictionaryStatusOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetTokenizationDictionaryStatusOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected GetTokenizationDictionaryStatusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a GetTokenizationDictionaryStatusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java deleted file mode 100644 index def3624b902..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getTrainingData options. - */ -public class GetTrainingDataOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - - private Builder(GetTrainingDataOptions getTrainingDataOptions) { - this.environmentId = getTrainingDataOptions.environmentId; - this.collectionId = getTrainingDataOptions.collectionId; - this.queryId = getTrainingDataOptions.queryId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - */ - public Builder(String environmentId, String collectionId, String queryId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - } - - /** - * Builds a GetTrainingDataOptions. - * - * @return the getTrainingDataOptions - */ - public GetTrainingDataOptions build() { - return new GetTrainingDataOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetTrainingDataOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetTrainingDataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the GetTrainingDataOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - } - - protected GetTrainingDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - } - - /** - * New builder. - * - * @return a GetTrainingDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java deleted file mode 100644 index c38957e0c47..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getTrainingExample options. - */ -public class GetTrainingExampleOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - protected String exampleId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - - private Builder(GetTrainingExampleOptions getTrainingExampleOptions) { - this.environmentId = getTrainingExampleOptions.environmentId; - this.collectionId = getTrainingExampleOptions.collectionId; - this.queryId = getTrainingExampleOptions.queryId; - this.exampleId = getTrainingExampleOptions.exampleId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - * @param exampleId the exampleId - */ - public Builder(String environmentId, String collectionId, String queryId, String exampleId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - this.exampleId = exampleId; - } - - /** - * Builds a GetTrainingExampleOptions. - * - * @return the getTrainingExampleOptions - */ - public GetTrainingExampleOptions build() { - return new GetTrainingExampleOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the GetTrainingExampleOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetTrainingExampleOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the GetTrainingExampleOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - - /** - * Set the exampleId. - * - * @param exampleId the exampleId - * @return the GetTrainingExampleOptions builder - */ - public Builder exampleId(String exampleId) { - this.exampleId = exampleId; - return this; - } - } - - protected GetTrainingExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.exampleId, - "exampleId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - exampleId = builder.exampleId; - } - - /** - * New builder. - * - * @return a GetTrainingExampleOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } - - /** - * Gets the exampleId. - * - * The ID of the document as it is indexed. - * - * @return the exampleId - */ - public String exampleId() { - return exampleId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java deleted file mode 100644 index 24af1a51c90..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -/** - * Histogram. - */ -public class Histogram extends QueryAggregation { - - protected String field; - protected Long interval; - - /** - * Gets the field. - * - * The field where the aggregation is located in the document. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the interval. - * - * Interval of the aggregation. (For 'histogram' type). - * - * @return the interval - */ - public Long getInterval() { - return interval; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java deleted file mode 100644 index a15971a42f4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A list of HTML conversion settings. - */ -public class HtmlSettings extends GenericModel { - - @SerializedName("exclude_tags_completely") - protected List excludeTagsCompletely; - @SerializedName("exclude_tags_keep_content") - protected List excludeTagsKeepContent; - @SerializedName("keep_content") - protected XPathPatterns keepContent; - @SerializedName("exclude_content") - protected XPathPatterns excludeContent; - @SerializedName("keep_tag_attributes") - protected List keepTagAttributes; - @SerializedName("exclude_tag_attributes") - protected List excludeTagAttributes; - - /** - * Builder. - */ - public static class Builder { - private List excludeTagsCompletely; - private List excludeTagsKeepContent; - private XPathPatterns keepContent; - private XPathPatterns excludeContent; - private List keepTagAttributes; - private List excludeTagAttributes; - - private Builder(HtmlSettings htmlSettings) { - this.excludeTagsCompletely = htmlSettings.excludeTagsCompletely; - this.excludeTagsKeepContent = htmlSettings.excludeTagsKeepContent; - this.keepContent = htmlSettings.keepContent; - this.excludeContent = htmlSettings.excludeContent; - this.keepTagAttributes = htmlSettings.keepTagAttributes; - this.excludeTagAttributes = htmlSettings.excludeTagAttributes; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a HtmlSettings. - * - * @return the htmlSettings - */ - public HtmlSettings build() { - return new HtmlSettings(this); - } - - /** - * Adds an excludeTagsCompletely to excludeTagsCompletely. - * - * @param excludeTagsCompletely the new excludeTagsCompletely - * @return the HtmlSettings builder - */ - public Builder addExcludeTagsCompletely(String excludeTagsCompletely) { - com.ibm.cloud.sdk.core.util.Validator.notNull(excludeTagsCompletely, - "excludeTagsCompletely cannot be null"); - if (this.excludeTagsCompletely == null) { - this.excludeTagsCompletely = new ArrayList(); - } - this.excludeTagsCompletely.add(excludeTagsCompletely); - return this; - } - - /** - * Adds an excludeTagsKeepContent to excludeTagsKeepContent. - * - * @param excludeTagsKeepContent the new excludeTagsKeepContent - * @return the HtmlSettings builder - */ - public Builder addExcludeTagsKeepContent(String excludeTagsKeepContent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(excludeTagsKeepContent, - "excludeTagsKeepContent cannot be null"); - if (this.excludeTagsKeepContent == null) { - this.excludeTagsKeepContent = new ArrayList(); - } - this.excludeTagsKeepContent.add(excludeTagsKeepContent); - return this; - } - - /** - * Adds an keepTagAttributes to keepTagAttributes. - * - * @param keepTagAttributes the new keepTagAttributes - * @return the HtmlSettings builder - */ - public Builder addKeepTagAttributes(String keepTagAttributes) { - com.ibm.cloud.sdk.core.util.Validator.notNull(keepTagAttributes, - "keepTagAttributes cannot be null"); - if (this.keepTagAttributes == null) { - this.keepTagAttributes = new ArrayList(); - } - this.keepTagAttributes.add(keepTagAttributes); - return this; - } - - /** - * Adds an excludeTagAttributes to excludeTagAttributes. - * - * @param excludeTagAttributes the new excludeTagAttributes - * @return the HtmlSettings builder - */ - public Builder addExcludeTagAttributes(String excludeTagAttributes) { - com.ibm.cloud.sdk.core.util.Validator.notNull(excludeTagAttributes, - "excludeTagAttributes cannot be null"); - if (this.excludeTagAttributes == null) { - this.excludeTagAttributes = new ArrayList(); - } - this.excludeTagAttributes.add(excludeTagAttributes); - return this; - } - - /** - * Set the excludeTagsCompletely. - * Existing excludeTagsCompletely will be replaced. - * - * @param excludeTagsCompletely the excludeTagsCompletely - * @return the HtmlSettings builder - */ - public Builder excludeTagsCompletely(List excludeTagsCompletely) { - this.excludeTagsCompletely = excludeTagsCompletely; - return this; - } - - /** - * Set the excludeTagsKeepContent. - * Existing excludeTagsKeepContent will be replaced. - * - * @param excludeTagsKeepContent the excludeTagsKeepContent - * @return the HtmlSettings builder - */ - public Builder excludeTagsKeepContent(List excludeTagsKeepContent) { - this.excludeTagsKeepContent = excludeTagsKeepContent; - return this; - } - - /** - * Set the keepContent. - * - * @param keepContent the keepContent - * @return the HtmlSettings builder - */ - public Builder keepContent(XPathPatterns keepContent) { - this.keepContent = keepContent; - return this; - } - - /** - * Set the excludeContent. - * - * @param excludeContent the excludeContent - * @return the HtmlSettings builder - */ - public Builder excludeContent(XPathPatterns excludeContent) { - this.excludeContent = excludeContent; - return this; - } - - /** - * Set the keepTagAttributes. - * Existing keepTagAttributes will be replaced. - * - * @param keepTagAttributes the keepTagAttributes - * @return the HtmlSettings builder - */ - public Builder keepTagAttributes(List keepTagAttributes) { - this.keepTagAttributes = keepTagAttributes; - return this; - } - - /** - * Set the excludeTagAttributes. - * Existing excludeTagAttributes will be replaced. - * - * @param excludeTagAttributes the excludeTagAttributes - * @return the HtmlSettings builder - */ - public Builder excludeTagAttributes(List excludeTagAttributes) { - this.excludeTagAttributes = excludeTagAttributes; - return this; - } - } - - protected HtmlSettings(Builder builder) { - excludeTagsCompletely = builder.excludeTagsCompletely; - excludeTagsKeepContent = builder.excludeTagsKeepContent; - keepContent = builder.keepContent; - excludeContent = builder.excludeContent; - keepTagAttributes = builder.keepTagAttributes; - excludeTagAttributes = builder.excludeTagAttributes; - } - - /** - * New builder. - * - * @return a HtmlSettings builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the excludeTagsCompletely. - * - * Array of HTML tags that are excluded completely. - * - * @return the excludeTagsCompletely - */ - public List excludeTagsCompletely() { - return excludeTagsCompletely; - } - - /** - * Gets the excludeTagsKeepContent. - * - * Array of HTML tags which are excluded but still retain content. - * - * @return the excludeTagsKeepContent - */ - public List excludeTagsKeepContent() { - return excludeTagsKeepContent; - } - - /** - * Gets the keepContent. - * - * Object containing an array of XPaths. - * - * @return the keepContent - */ - public XPathPatterns keepContent() { - return keepContent; - } - - /** - * Gets the excludeContent. - * - * Object containing an array of XPaths. - * - * @return the excludeContent - */ - public XPathPatterns excludeContent() { - return excludeContent; - } - - /** - * Gets the keepTagAttributes. - * - * An array of HTML tag attributes to keep in the converted document. - * - * @return the keepTagAttributes - */ - public List keepTagAttributes() { - return keepTagAttributes; - } - - /** - * Gets the excludeTagAttributes. - * - * Array of HTML tag attributes to exclude. - * - * @return the excludeTagAttributes - */ - public List excludeTagAttributes() { - return excludeTagAttributes; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java deleted file mode 100644 index 14df068474f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about the resource usage and capacity of the environment. - */ -public class IndexCapacity extends GenericModel { - - protected EnvironmentDocuments documents; - @SerializedName("disk_usage") - protected DiskUsage diskUsage; - protected CollectionUsage collections; - - /** - * Gets the documents. - * - * Summary of the document usage statistics for the environment. - * - * @return the documents - */ - public EnvironmentDocuments getDocuments() { - return documents; - } - - /** - * Gets the diskUsage. - * - * Summary of the disk usage statistics for the environment. - * - * @return the diskUsage - */ - public DiskUsage getDiskUsage() { - return diskUsage; - } - - /** - * Gets the collections. - * - * Summary of the collection usage in the environment. - * - * @return the collections - */ - public CollectionUsage getCollections() { - return collections; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java deleted file mode 100644 index 29b4052642a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listCollectionFields options. - */ -public class ListCollectionFieldsOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(ListCollectionFieldsOptions listCollectionFieldsOptions) { - this.environmentId = listCollectionFieldsOptions.environmentId; - this.collectionId = listCollectionFieldsOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a ListCollectionFieldsOptions. - * - * @return the listCollectionFieldsOptions - */ - public ListCollectionFieldsOptions build() { - return new ListCollectionFieldsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListCollectionFieldsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the ListCollectionFieldsOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected ListCollectionFieldsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a ListCollectionFieldsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java deleted file mode 100644 index 5fc70cc38ff..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The list of fetched fields. - * - * The fields are returned using a fully qualified name format, however, the format differs slightly from that used by - * the query operations. - * - * * Fields which contain nested JSON objects are assigned a type of "nested". - * - * * Fields which belong to a nested object are prefixed with `.properties` (for example, - * `warnings.properties.severity` means that the `warnings` object has a property called `severity`). - * - * * Fields returned from the News collection are prefixed with `v{N}-fullnews-t3-{YEAR}.mappings` (for example, - * `v5-fullnews-t3-2016.mappings.text.properties.author`). - */ -public class ListCollectionFieldsResponse extends GenericModel { - - protected List fields; - - /** - * Gets the fields. - * - * An array containing information about each field in the collections. - * - * @return the fields - */ - public List getFields() { - return fields; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java deleted file mode 100644 index 93ae7923d28..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listCollections options. - */ -public class ListCollectionsOptions extends GenericModel { - - protected String environmentId; - protected String name; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - - private Builder(ListCollectionsOptions listCollectionsOptions) { - this.environmentId = listCollectionsOptions.environmentId; - this.name = listCollectionsOptions.name; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a ListCollectionsOptions. - * - * @return the listCollectionsOptions - */ - public ListCollectionsOptions build() { - return new ListCollectionsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListCollectionsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the ListCollectionsOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - } - - protected ListCollectionsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - name = builder.name; - } - - /** - * New builder. - * - * @return a ListCollectionsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * Find collections with the given name. - * - * @return the name - */ - public String name() { - return name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java deleted file mode 100644 index 70831dc1b83..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response object containing an array of collection details. - */ -public class ListCollectionsResponse extends GenericModel { - - protected List collections; - - /** - * Gets the collections. - * - * An array containing information about each collection in the environment. - * - * @return the collections - */ - public List getCollections() { - return collections; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java deleted file mode 100644 index 42a027ba302..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listConfigurations options. - */ -public class ListConfigurationsOptions extends GenericModel { - - protected String environmentId; - protected String name; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - - private Builder(ListConfigurationsOptions listConfigurationsOptions) { - this.environmentId = listConfigurationsOptions.environmentId; - this.name = listConfigurationsOptions.name; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a ListConfigurationsOptions. - * - * @return the listConfigurationsOptions - */ - public ListConfigurationsOptions build() { - return new ListConfigurationsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListConfigurationsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the ListConfigurationsOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - } - - protected ListConfigurationsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - name = builder.name; - } - - /** - * New builder. - * - * @return a ListConfigurationsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * Find configurations with the given name. - * - * @return the name - */ - public String name() { - return name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java deleted file mode 100644 index 75ba5602a15..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing an array of available configurations. - */ -public class ListConfigurationsResponse extends GenericModel { - - protected List configurations; - - /** - * Gets the configurations. - * - * An array of configurations that are available for the service instance. - * - * @return the configurations - */ - public List getConfigurations() { - return configurations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java deleted file mode 100644 index a73825edf6e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listCredentials options. - */ -public class ListCredentialsOptions extends GenericModel { - - protected String environmentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - - private Builder(ListCredentialsOptions listCredentialsOptions) { - this.environmentId = listCredentialsOptions.environmentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a ListCredentialsOptions. - * - * @return the listCredentialsOptions - */ - public ListCredentialsOptions build() { - return new ListCredentialsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListCredentialsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - } - - protected ListCredentialsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - } - - /** - * New builder. - * - * @return a ListCredentialsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java deleted file mode 100644 index d4ec36bfec7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listEnvironments options. - */ -public class ListEnvironmentsOptions extends GenericModel { - - protected String name; - - /** - * Builder. - */ - public static class Builder { - private String name; - - private Builder(ListEnvironmentsOptions listEnvironmentsOptions) { - this.name = listEnvironmentsOptions.name; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListEnvironmentsOptions. - * - * @return the listEnvironmentsOptions - */ - public ListEnvironmentsOptions build() { - return new ListEnvironmentsOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the ListEnvironmentsOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - } - - protected ListEnvironmentsOptions(Builder builder) { - name = builder.name; - } - - /** - * New builder. - * - * @return a ListEnvironmentsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * Show only the environment with the given name. - * - * @return the name - */ - public String name() { - return name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java deleted file mode 100644 index 782e985a64c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response object containing an array of configured environments. - */ -public class ListEnvironmentsResponse extends GenericModel { - - protected List environments; - - /** - * Gets the environments. - * - * An array of [environments] that are available for the service instance. - * - * @return the environments - */ - public List getEnvironments() { - return environments; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java deleted file mode 100644 index 9e77e082845..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listExpansions options. - */ -public class ListExpansionsOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(ListExpansionsOptions listExpansionsOptions) { - this.environmentId = listExpansionsOptions.environmentId; - this.collectionId = listExpansionsOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a ListExpansionsOptions. - * - * @return the listExpansionsOptions - */ - public ListExpansionsOptions build() { - return new ListExpansionsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListExpansionsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the ListExpansionsOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected ListExpansionsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a ListExpansionsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java deleted file mode 100644 index 3c16f2fb5de..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listFields options. - */ -public class ListFieldsOptions extends GenericModel { - - protected String environmentId; - protected List collectionIds; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private List collectionIds; - - private Builder(ListFieldsOptions listFieldsOptions) { - this.environmentId = listFieldsOptions.environmentId; - this.collectionIds = listFieldsOptions.collectionIds; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionIds the collectionIds - */ - public Builder(String environmentId, List collectionIds) { - this.environmentId = environmentId; - this.collectionIds = collectionIds; - } - - /** - * Builds a ListFieldsOptions. - * - * @return the listFieldsOptions - */ - public ListFieldsOptions build() { - return new ListFieldsOptions(this); - } - - /** - * Adds an collectionIds to collectionIds. - * - * @param collectionIds the new collectionIds - * @return the ListFieldsOptions builder - */ - public Builder addCollectionIds(String collectionIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, - "collectionIds cannot be null"); - if (this.collectionIds == null) { - this.collectionIds = new ArrayList(); - } - this.collectionIds.add(collectionIds); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListFieldsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionIds. - * Existing collectionIds will be replaced. - * - * @param collectionIds the collectionIds - * @return the ListFieldsOptions builder - */ - public Builder collectionIds(List collectionIds) { - this.collectionIds = collectionIds; - return this; - } - } - - protected ListFieldsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionIds, - "collectionIds cannot be null"); - environmentId = builder.environmentId; - collectionIds = builder.collectionIds; - } - - /** - * New builder. - * - * @return a ListFieldsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionIds. - * - * A comma-separated list of collection IDs to be queried against. - * - * @return the collectionIds - */ - public List collectionIds() { - return collectionIds; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java deleted file mode 100644 index dd28496a6da..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listGateways options. - */ -public class ListGatewaysOptions extends GenericModel { - - protected String environmentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - - private Builder(ListGatewaysOptions listGatewaysOptions) { - this.environmentId = listGatewaysOptions.environmentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a ListGatewaysOptions. - * - * @return the listGatewaysOptions - */ - public ListGatewaysOptions build() { - return new ListGatewaysOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListGatewaysOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - } - - protected ListGatewaysOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - } - - /** - * New builder. - * - * @return a ListGatewaysOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java deleted file mode 100644 index 828b41496db..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listTrainingData options. - */ -public class ListTrainingDataOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(ListTrainingDataOptions listTrainingDataOptions) { - this.environmentId = listTrainingDataOptions.environmentId; - this.collectionId = listTrainingDataOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a ListTrainingDataOptions. - * - * @return the listTrainingDataOptions - */ - public ListTrainingDataOptions build() { - return new ListTrainingDataOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListTrainingDataOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the ListTrainingDataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected ListTrainingDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a ListTrainingDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java deleted file mode 100644 index 5de2ad960b7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listTrainingExamples options. - */ -public class ListTrainingExamplesOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - - private Builder(ListTrainingExamplesOptions listTrainingExamplesOptions) { - this.environmentId = listTrainingExamplesOptions.environmentId; - this.collectionId = listTrainingExamplesOptions.collectionId; - this.queryId = listTrainingExamplesOptions.queryId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - */ - public Builder(String environmentId, String collectionId, String queryId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - } - - /** - * Builds a ListTrainingExamplesOptions. - * - * @return the listTrainingExamplesOptions - */ - public ListTrainingExamplesOptions build() { - return new ListTrainingExamplesOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the ListTrainingExamplesOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the ListTrainingExamplesOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the ListTrainingExamplesOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - } - - protected ListTrainingExamplesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - } - - /** - * New builder. - * - * @return a ListTrainingExamplesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java deleted file mode 100644 index 0f7e45a8335..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing results that match the requested **logs** query. - */ -public class LogQueryResponse extends GenericModel { - - @SerializedName("matching_results") - protected Long matchingResults; - protected List results; - - /** - * Gets the matchingResults. - * - * Number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the results. - * - * Array of log query response results. - * - * @return the results - */ - public List getResults() { - return results; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java deleted file mode 100644 index 1a1e4cebe3c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Individual result object for a **logs** query. Each object represents either a query to a Discovery collection or an - * event that is associated with a query. - */ -public class LogQueryResponseResult extends GenericModel { - - /** - * The type of log entry returned. - * - * **query** indicates that the log represents the results of a call to the single collection **query** method. - * - * **event** indicates that the log represents a call to the **events** API. - */ - public interface DocumentType { - /** query. */ - String QUERY = "query"; - /** event. */ - String EVENT = "event"; - } - - /** - * The type of event that this object respresents. Possible values are - * - * - `query` the log of a query to a collection - * - * - `click` the result of a call to the **events** endpoint. - */ - public interface EventType { - /** click. */ - String CLICK = "click"; - /** query. */ - String QUERY = "query"; - } - - /** - * The type of result that this **event** is associated with. Only returned with logs of type `event`. - */ - public interface ResultType { - /** document. */ - String DOCUMENT = "document"; - } - - @SerializedName("environment_id") - protected String environmentId; - @SerializedName("customer_id") - protected String customerId; - @SerializedName("document_type") - protected String documentType; - @SerializedName("natural_language_query") - protected String naturalLanguageQuery; - @SerializedName("document_results") - protected LogQueryResponseResultDocuments documentResults; - @SerializedName("created_timestamp") - protected Date createdTimestamp; - @SerializedName("client_timestamp") - protected Date clientTimestamp; - @SerializedName("query_id") - protected String queryId; - @SerializedName("session_token") - protected String sessionToken; - @SerializedName("collection_id") - protected String collectionId; - @SerializedName("display_rank") - protected Long displayRank; - @SerializedName("document_id") - protected String documentId; - @SerializedName("event_type") - protected String eventType; - @SerializedName("result_type") - protected String resultType; - - /** - * Gets the environmentId. - * - * The environment ID that is associated with this log entry. - * - * @return the environmentId - */ - public String getEnvironmentId() { - return environmentId; - } - - /** - * Gets the customerId. - * - * The **customer_id** label that was specified in the header of the query or event API call that corresponds to this - * log entry. - * - * @return the customerId - */ - public String getCustomerId() { - return customerId; - } - - /** - * Gets the documentType. - * - * The type of log entry returned. - * - * **query** indicates that the log represents the results of a call to the single collection **query** method. - * - * **event** indicates that the log represents a call to the **events** API. - * - * @return the documentType - */ - public String getDocumentType() { - return documentType; - } - - /** - * Gets the naturalLanguageQuery. - * - * The value of the **natural_language_query** query parameter that was used to create these results. Only returned - * with logs of type **query**. - * - * **Note:** Other query parameters (such as **filter** or **deduplicate**) might have been used with this query, but - * are not recorded. - * - * @return the naturalLanguageQuery - */ - public String getNaturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the documentResults. - * - * Object containing result information that was returned by the query used to create this log entry. Only returned - * with logs of type `query`. - * - * @return the documentResults - */ - public LogQueryResponseResultDocuments getDocumentResults() { - return documentResults; - } - - /** - * Gets the createdTimestamp. - * - * Date that the log result was created. Returned in `YYYY-MM-DDThh:mm:ssZ` format. - * - * @return the createdTimestamp - */ - public Date getCreatedTimestamp() { - return createdTimestamp; - } - - /** - * Gets the clientTimestamp. - * - * Date specified by the user when recording an event. Returned in `YYYY-MM-DDThh:mm:ssZ` format. Only returned with - * logs of type **event**. - * - * @return the clientTimestamp - */ - public Date getClientTimestamp() { - return clientTimestamp; - } - - /** - * Gets the queryId. - * - * Identifier that corresponds to the **natural_language_query** string used in the original or associated query. All - * **event** and **query** log entries that have the same original **natural_language_query** string also have them - * same **query_id**. This field can be used to recall all **event** and **query** log results that have the same - * original query (**event** logs do not contain the original **natural_language_query** field). - * - * @return the queryId - */ - public String getQueryId() { - return queryId; - } - - /** - * Gets the sessionToken. - * - * Unique identifier (within a 24-hour period) that identifies a single `query` log and any `event` logs that were - * created for it. - * - * **Note:** If the exact same query is run at the exact same time on different days, the **session_token** for those - * queries might be identical. However, the **created_timestamp** differs. - * - * **Note:** Session tokens are case sensitive. To avoid matching on session tokens that are identical except for - * case, use the exact match operator (`::`) when you query for a specific session token. - * - * @return the sessionToken - */ - public String getSessionToken() { - return sessionToken; - } - - /** - * Gets the collectionId. - * - * The collection ID of the document associated with this event. Only returned with logs of type `event`. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } - - /** - * Gets the displayRank. - * - * The original display rank of the document associated with this event. Only returned with logs of type `event`. - * - * @return the displayRank - */ - public Long getDisplayRank() { - return displayRank; - } - - /** - * Gets the documentId. - * - * The document ID of the document associated with this event. Only returned with logs of type `event`. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the eventType. - * - * The type of event that this object respresents. Possible values are - * - * - `query` the log of a query to a collection - * - * - `click` the result of a call to the **events** endpoint. - * - * @return the eventType - */ - public String getEventType() { - return eventType; - } - - /** - * Gets the resultType. - * - * The type of result that this **event** is associated with. Only returned with logs of type `event`. - * - * @return the resultType - */ - public String getResultType() { - return resultType; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java deleted file mode 100644 index 03b3da8a0d6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing result information that was returned by the query used to create this log entry. Only returned with - * logs of type `query`. - */ -public class LogQueryResponseResultDocuments extends GenericModel { - - protected List results; - protected Long count; - - /** - * Gets the results. - * - * Array of log query response results. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * Gets the count. - * - * The number of results returned in the query associate with this log. - * - * @return the count - */ - public Long getCount() { - return count; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java deleted file mode 100644 index 39c42d5d172..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Each object in the **results** array corresponds to an individual document returned by the original query. - */ -public class LogQueryResponseResultDocumentsResult extends GenericModel { - - protected Long position; - @SerializedName("document_id") - protected String documentId; - protected Double score; - protected Double confidence; - @SerializedName("collection_id") - protected String collectionId; - - /** - * Gets the position. - * - * The result rank of this document. A position of `1` indicates that it was the first returned result. - * - * @return the position - */ - public Long getPosition() { - return position; - } - - /** - * Gets the documentId. - * - * The **document_id** of the document that this result represents. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the score. - * - * The raw score of this result. A higher score indicates a greater match to the query parameters. - * - * @return the score - */ - public Double getScore() { - return score; - } - - /** - * Gets the confidence. - * - * The confidence score of the result's analysis. A higher score indicating greater confidence. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } - - /** - * Gets the collectionId. - * - * The **collection_id** of the document represented by this result. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java deleted file mode 100644 index c0bfc543fd8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An aggregation analyzing log information for queries and events. - */ -public class MetricAggregation extends GenericModel { - - protected String interval; - @SerializedName("event_type") - protected String eventType; - protected List results; - - /** - * Gets the interval. - * - * The measurement interval for this metric. Metric intervals are always 1 day (`1d`). - * - * @return the interval - */ - public String getInterval() { - return interval; - } - - /** - * Gets the eventType. - * - * The event type associated with this metric result. This field, when present, will always be `click`. - * - * @return the eventType - */ - public String getEventType() { - return eventType; - } - - /** - * Gets the results. - * - * Array of metric aggregation query results. - * - * @return the results - */ - public List getResults() { - return results; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java deleted file mode 100644 index dd3ea9ea350..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Aggregation result data for the requested metric. - */ -public class MetricAggregationResult extends GenericModel { - - @SerializedName("key_as_string") - protected Date keyAsString; - protected Long key; - @SerializedName("matching_results") - protected Long matchingResults; - @SerializedName("event_rate") - protected Double eventRate; - - /** - * Gets the keyAsString. - * - * Date in string form representing the start of this interval. - * - * @return the keyAsString - */ - public Date getKeyAsString() { - return keyAsString; - } - - /** - * Gets the key. - * - * Unix epoch time equivalent of the **key_as_string**, that represents the start of this interval. - * - * @return the key - */ - public Long getKey() { - return key; - } - - /** - * Gets the matchingResults. - * - * Number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the eventRate. - * - * The number of queries with associated events divided by the total number of queries for the interval. Only returned - * with **event_rate** metrics. - * - * @return the eventRate - */ - public Double getEventRate() { - return eventRate; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java deleted file mode 100644 index 3907a962868..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The response generated from a call to a **metrics** method. - */ -public class MetricResponse extends GenericModel { - - protected List aggregations; - - /** - * Gets the aggregations. - * - * Array of metric aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java deleted file mode 100644 index e549774f839..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An aggregation analyzing log information for queries and events. - */ -public class MetricTokenAggregation extends GenericModel { - - @SerializedName("event_type") - protected String eventType; - protected List results; - - /** - * Gets the eventType. - * - * The event type associated with this metric result. This field, when present, will always be `click`. - * - * @return the eventType - */ - public String getEventType() { - return eventType; - } - - /** - * Gets the results. - * - * Array of results for the metric token aggregation. - * - * @return the results - */ - public List getResults() { - return results; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java deleted file mode 100644 index ea14bd0e6f4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Aggregation result data for the requested metric. - */ -public class MetricTokenAggregationResult extends GenericModel { - - protected String key; - @SerializedName("matching_results") - protected Long matchingResults; - @SerializedName("event_rate") - protected Double eventRate; - - /** - * Gets the key. - * - * The content of the **natural_language_query** parameter used in the query that this result represents. - * - * @return the key - */ - public String getKey() { - return key; - } - - /** - * Gets the matchingResults. - * - * Number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the eventRate. - * - * The number of queries with associated events divided by the total number of queries currently stored (queries and - * events are stored in the log for 30 days). - * - * @return the eventRate - */ - public Double getEventRate() { - return eventRate; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java deleted file mode 100644 index a3f452f5cc7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The response generated from a call to a **metrics** method that evaluates tokens. - */ -public class MetricTokenResponse extends GenericModel { - - protected List aggregations; - - /** - * Gets the aggregations. - * - * Array of metric token aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java deleted file mode 100644 index 89e4c8ed9ce..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -/** - * Nested. - */ -public class Nested extends QueryAggregation { - - protected String path; - - /** - * Gets the path. - * - * The area of the results the aggregation was restricted to. - * - * @return the path - */ - public String getPath() { - return path; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentCategories.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentCategories.java deleted file mode 100644 index b7b6e239db1..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentCategories.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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.v1.model; - -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; - -/** - * An object that indicates the Categories enrichment will be applied to the specified field. - */ -public class NluEnrichmentCategories extends DynamicModel { - - public NluEnrichmentCategories() { - super(new TypeToken() { - }); - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java deleted file mode 100644 index 34242ae2145..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object specifiying the concepts enrichment and related parameters. - */ -public class NluEnrichmentConcepts extends GenericModel { - - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private Long limit; - - private Builder(NluEnrichmentConcepts nluEnrichmentConcepts) { - this.limit = nluEnrichmentConcepts.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentConcepts. - * - * @return the nluEnrichmentConcepts - */ - public NluEnrichmentConcepts build() { - return new NluEnrichmentConcepts(this); - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the NluEnrichmentConcepts builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected NluEnrichmentConcepts(Builder builder) { - limit = builder.limit; - } - - /** - * New builder. - * - * @return a NluEnrichmentConcepts builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the limit. - * - * The maximum number of concepts enrichments to extact from each instance of the specified field. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java deleted file mode 100644 index 8b708f658c7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object specifying the emotion detection enrichment and related parameters. - */ -public class NluEnrichmentEmotion extends GenericModel { - - protected Boolean document; - protected List targets; - - /** - * Builder. - */ - public static class Builder { - private Boolean document; - private List targets; - - private Builder(NluEnrichmentEmotion nluEnrichmentEmotion) { - this.document = nluEnrichmentEmotion.document; - this.targets = nluEnrichmentEmotion.targets; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentEmotion. - * - * @return the nluEnrichmentEmotion - */ - public NluEnrichmentEmotion build() { - return new NluEnrichmentEmotion(this); - } - - /** - * Adds an target to targets. - * - * @param target the new target - * @return the NluEnrichmentEmotion builder - */ - public Builder addTarget(String target) { - com.ibm.cloud.sdk.core.util.Validator.notNull(target, - "target cannot be null"); - if (this.targets == null) { - this.targets = new ArrayList(); - } - this.targets.add(target); - return this; - } - - /** - * Set the document. - * - * @param document the document - * @return the NluEnrichmentEmotion builder - */ - public Builder document(Boolean document) { - this.document = document; - return this; - } - - /** - * Set the targets. - * Existing targets will be replaced. - * - * @param targets the targets - * @return the NluEnrichmentEmotion builder - */ - public Builder targets(List targets) { - this.targets = targets; - return this; - } - } - - protected NluEnrichmentEmotion(Builder builder) { - document = builder.document; - targets = builder.targets; - } - - /** - * New builder. - * - * @return a NluEnrichmentEmotion builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the document. - * - * When `true`, emotion detection is performed on the entire field. - * - * @return the document - */ - public Boolean document() { - return document; - } - - /** - * Gets the targets. - * - * A comma-separated list of target strings that will have any associated emotions detected. - * - * @return the targets - */ - public List targets() { - return targets; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java deleted file mode 100644 index 4bc405059f2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object speficying the Entities enrichment and related parameters. - */ -public class NluEnrichmentEntities extends GenericModel { - - protected Boolean sentiment; - protected Boolean emotion; - protected Long limit; - protected Boolean mentions; - @SerializedName("mention_types") - protected Boolean mentionTypes; - @SerializedName("sentence_locations") - protected Boolean sentenceLocations; - protected String model; - - /** - * Builder. - */ - public static class Builder { - private Boolean sentiment; - private Boolean emotion; - private Long limit; - private Boolean mentions; - private Boolean mentionTypes; - private Boolean sentenceLocations; - private String model; - - private Builder(NluEnrichmentEntities nluEnrichmentEntities) { - this.sentiment = nluEnrichmentEntities.sentiment; - this.emotion = nluEnrichmentEntities.emotion; - this.limit = nluEnrichmentEntities.limit; - this.mentions = nluEnrichmentEntities.mentions; - this.mentionTypes = nluEnrichmentEntities.mentionTypes; - this.sentenceLocations = nluEnrichmentEntities.sentenceLocations; - this.model = nluEnrichmentEntities.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentEntities. - * - * @return the nluEnrichmentEntities - */ - public NluEnrichmentEntities build() { - return new NluEnrichmentEntities(this); - } - - /** - * Set the sentiment. - * - * @param sentiment the sentiment - * @return the NluEnrichmentEntities builder - */ - public Builder sentiment(Boolean sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - * Set the emotion. - * - * @param emotion the emotion - * @return the NluEnrichmentEntities builder - */ - public Builder emotion(Boolean emotion) { - this.emotion = emotion; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the NluEnrichmentEntities builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - - /** - * Set the mentions. - * - * @param mentions the mentions - * @return the NluEnrichmentEntities builder - */ - public Builder mentions(Boolean mentions) { - this.mentions = mentions; - return this; - } - - /** - * Set the mentionTypes. - * - * @param mentionTypes the mentionTypes - * @return the NluEnrichmentEntities builder - */ - public Builder mentionTypes(Boolean mentionTypes) { - this.mentionTypes = mentionTypes; - return this; - } - - /** - * Set the sentenceLocations. - * - * @param sentenceLocations the sentenceLocations - * @return the NluEnrichmentEntities builder - */ - public Builder sentenceLocations(Boolean sentenceLocations) { - this.sentenceLocations = sentenceLocations; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the NluEnrichmentEntities builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - protected NluEnrichmentEntities(Builder builder) { - sentiment = builder.sentiment; - emotion = builder.emotion; - limit = builder.limit; - mentions = builder.mentions; - mentionTypes = builder.mentionTypes; - sentenceLocations = builder.sentenceLocations; - model = builder.model; - } - - /** - * New builder. - * - * @return a NluEnrichmentEntities builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the sentiment. - * - * When `true`, sentiment analysis of entities will be performed on the specified field. - * - * @return the sentiment - */ - public Boolean sentiment() { - return sentiment; - } - - /** - * Gets the emotion. - * - * When `true`, emotion detection of entities will be performed on the specified field. - * - * @return the emotion - */ - public Boolean emotion() { - return emotion; - } - - /** - * Gets the limit. - * - * The maximum number of entities to extract for each instance of the specified field. - * - * @return the limit - */ - public Long limit() { - return limit; - } - - /** - * Gets the mentions. - * - * When `true`, the number of mentions of each identified entity is recorded. The default is `false`. - * - * @return the mentions - */ - public Boolean mentions() { - return mentions; - } - - /** - * Gets the mentionTypes. - * - * When `true`, the types of mentions for each idetifieid entity is recorded. The default is `false`. - * - * @return the mentionTypes - */ - public Boolean mentionTypes() { - return mentionTypes; - } - - /** - * Gets the sentenceLocations. - * - * When `true`, a list of sentence locations for each instance of each identified entity is recorded. The default is - * `false`. - * - * @return the sentenceLocations - */ - public Boolean sentenceLocations() { - return sentenceLocations; - } - - /** - * Gets the model. - * - * The enrichement model to use with entity extraction. May be a custom model provided by Watson Knowledge Studio, or - * the default public model `alchemy`. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java deleted file mode 100644 index 7cea57e31ea..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing Natural Language Understanding features to be used. - */ -public class NluEnrichmentFeatures extends GenericModel { - - protected NluEnrichmentKeywords keywords; - protected NluEnrichmentEntities entities; - protected NluEnrichmentSentiment sentiment; - protected NluEnrichmentEmotion emotion; - protected NluEnrichmentCategories categories; - @SerializedName("semantic_roles") - protected NluEnrichmentSemanticRoles semanticRoles; - protected NluEnrichmentRelations relations; - protected NluEnrichmentConcepts concepts; - - /** - * Builder. - */ - public static class Builder { - private NluEnrichmentKeywords keywords; - private NluEnrichmentEntities entities; - private NluEnrichmentSentiment sentiment; - private NluEnrichmentEmotion emotion; - private NluEnrichmentCategories categories; - private NluEnrichmentSemanticRoles semanticRoles; - private NluEnrichmentRelations relations; - private NluEnrichmentConcepts concepts; - - private Builder(NluEnrichmentFeatures nluEnrichmentFeatures) { - this.keywords = nluEnrichmentFeatures.keywords; - this.entities = nluEnrichmentFeatures.entities; - this.sentiment = nluEnrichmentFeatures.sentiment; - this.emotion = nluEnrichmentFeatures.emotion; - this.categories = nluEnrichmentFeatures.categories; - this.semanticRoles = nluEnrichmentFeatures.semanticRoles; - this.relations = nluEnrichmentFeatures.relations; - this.concepts = nluEnrichmentFeatures.concepts; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentFeatures. - * - * @return the nluEnrichmentFeatures - */ - public NluEnrichmentFeatures build() { - return new NluEnrichmentFeatures(this); - } - - /** - * Set the keywords. - * - * @param keywords the keywords - * @return the NluEnrichmentFeatures builder - */ - public Builder keywords(NluEnrichmentKeywords keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the entities. - * - * @param entities the entities - * @return the NluEnrichmentFeatures builder - */ - public Builder entities(NluEnrichmentEntities entities) { - this.entities = entities; - return this; - } - - /** - * Set the sentiment. - * - * @param sentiment the sentiment - * @return the NluEnrichmentFeatures builder - */ - public Builder sentiment(NluEnrichmentSentiment sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - * Set the emotion. - * - * @param emotion the emotion - * @return the NluEnrichmentFeatures builder - */ - public Builder emotion(NluEnrichmentEmotion emotion) { - this.emotion = emotion; - return this; - } - - /** - * Set the categories. - * - * @param categories the categories - * @return the NluEnrichmentFeatures builder - */ - public Builder categories(NluEnrichmentCategories categories) { - this.categories = categories; - return this; - } - - /** - * Set the semanticRoles. - * - * @param semanticRoles the semanticRoles - * @return the NluEnrichmentFeatures builder - */ - public Builder semanticRoles(NluEnrichmentSemanticRoles semanticRoles) { - this.semanticRoles = semanticRoles; - return this; - } - - /** - * Set the relations. - * - * @param relations the relations - * @return the NluEnrichmentFeatures builder - */ - public Builder relations(NluEnrichmentRelations relations) { - this.relations = relations; - return this; - } - - /** - * Set the concepts. - * - * @param concepts the concepts - * @return the NluEnrichmentFeatures builder - */ - public Builder concepts(NluEnrichmentConcepts concepts) { - this.concepts = concepts; - return this; - } - } - - protected NluEnrichmentFeatures(Builder builder) { - keywords = builder.keywords; - entities = builder.entities; - sentiment = builder.sentiment; - emotion = builder.emotion; - categories = builder.categories; - semanticRoles = builder.semanticRoles; - relations = builder.relations; - concepts = builder.concepts; - } - - /** - * New builder. - * - * @return a NluEnrichmentFeatures builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the keywords. - * - * An object specifying the Keyword enrichment and related parameters. - * - * @return the keywords - */ - public NluEnrichmentKeywords keywords() { - return keywords; - } - - /** - * Gets the entities. - * - * An object speficying the Entities enrichment and related parameters. - * - * @return the entities - */ - public NluEnrichmentEntities entities() { - return entities; - } - - /** - * Gets the sentiment. - * - * An object specifying the sentiment extraction enrichment and related parameters. - * - * @return the sentiment - */ - public NluEnrichmentSentiment sentiment() { - return sentiment; - } - - /** - * Gets the emotion. - * - * An object specifying the emotion detection enrichment and related parameters. - * - * @return the emotion - */ - public NluEnrichmentEmotion emotion() { - return emotion; - } - - /** - * Gets the categories. - * - * An object that indicates the Categories enrichment will be applied to the specified field. - * - * @return the categories - */ - public NluEnrichmentCategories categories() { - return categories; - } - - /** - * Gets the semanticRoles. - * - * An object specifiying the semantic roles enrichment and related parameters. - * - * @return the semanticRoles - */ - public NluEnrichmentSemanticRoles semanticRoles() { - return semanticRoles; - } - - /** - * Gets the relations. - * - * An object specifying the relations enrichment and related parameters. - * - * @return the relations - */ - public NluEnrichmentRelations relations() { - return relations; - } - - /** - * Gets the concepts. - * - * An object specifiying the concepts enrichment and related parameters. - * - * @return the concepts - */ - public NluEnrichmentConcepts concepts() { - return concepts; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java deleted file mode 100644 index 3ac90babf41..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object specifying the Keyword enrichment and related parameters. - */ -public class NluEnrichmentKeywords extends GenericModel { - - protected Boolean sentiment; - protected Boolean emotion; - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private Boolean sentiment; - private Boolean emotion; - private Long limit; - - private Builder(NluEnrichmentKeywords nluEnrichmentKeywords) { - this.sentiment = nluEnrichmentKeywords.sentiment; - this.emotion = nluEnrichmentKeywords.emotion; - this.limit = nluEnrichmentKeywords.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentKeywords. - * - * @return the nluEnrichmentKeywords - */ - public NluEnrichmentKeywords build() { - return new NluEnrichmentKeywords(this); - } - - /** - * Set the sentiment. - * - * @param sentiment the sentiment - * @return the NluEnrichmentKeywords builder - */ - public Builder sentiment(Boolean sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - * Set the emotion. - * - * @param emotion the emotion - * @return the NluEnrichmentKeywords builder - */ - public Builder emotion(Boolean emotion) { - this.emotion = emotion; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the NluEnrichmentKeywords builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected NluEnrichmentKeywords(Builder builder) { - sentiment = builder.sentiment; - emotion = builder.emotion; - limit = builder.limit; - } - - /** - * New builder. - * - * @return a NluEnrichmentKeywords builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the sentiment. - * - * When `true`, sentiment analysis of keywords will be performed on the specified field. - * - * @return the sentiment - */ - public Boolean sentiment() { - return sentiment; - } - - /** - * Gets the emotion. - * - * When `true`, emotion detection of keywords will be performed on the specified field. - * - * @return the emotion - */ - public Boolean emotion() { - return emotion; - } - - /** - * Gets the limit. - * - * The maximum number of keywords to extract for each instance of the specified field. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java deleted file mode 100644 index c81a43f8c30..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object specifying the relations enrichment and related parameters. - */ -public class NluEnrichmentRelations extends GenericModel { - - protected String model; - - /** - * Builder. - */ - public static class Builder { - private String model; - - private Builder(NluEnrichmentRelations nluEnrichmentRelations) { - this.model = nluEnrichmentRelations.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentRelations. - * - * @return the nluEnrichmentRelations - */ - public NluEnrichmentRelations build() { - return new NluEnrichmentRelations(this); - } - - /** - * Set the model. - * - * @param model the model - * @return the NluEnrichmentRelations builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - protected NluEnrichmentRelations(Builder builder) { - model = builder.model; - } - - /** - * New builder. - * - * @return a NluEnrichmentRelations builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the model. - * - * *For use with `natural_language_understanding` enrichments only.* The enrichement model to use with relationship - * extraction. May be a custom model provided by Watson Knowledge Studio, the default public model is`en-news`. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java deleted file mode 100644 index 5d2d10f8ba0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object specifiying the semantic roles enrichment and related parameters. - */ -public class NluEnrichmentSemanticRoles extends GenericModel { - - protected Boolean entities; - protected Boolean keywords; - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private Boolean entities; - private Boolean keywords; - private Long limit; - - private Builder(NluEnrichmentSemanticRoles nluEnrichmentSemanticRoles) { - this.entities = nluEnrichmentSemanticRoles.entities; - this.keywords = nluEnrichmentSemanticRoles.keywords; - this.limit = nluEnrichmentSemanticRoles.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentSemanticRoles. - * - * @return the nluEnrichmentSemanticRoles - */ - public NluEnrichmentSemanticRoles build() { - return new NluEnrichmentSemanticRoles(this); - } - - /** - * Set the entities. - * - * @param entities the entities - * @return the NluEnrichmentSemanticRoles builder - */ - public Builder entities(Boolean entities) { - this.entities = entities; - return this; - } - - /** - * Set the keywords. - * - * @param keywords the keywords - * @return the NluEnrichmentSemanticRoles builder - */ - public Builder keywords(Boolean keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the NluEnrichmentSemanticRoles builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected NluEnrichmentSemanticRoles(Builder builder) { - entities = builder.entities; - keywords = builder.keywords; - limit = builder.limit; - } - - /** - * New builder. - * - * @return a NluEnrichmentSemanticRoles builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the entities. - * - * When `true`, entities are extracted from the identified sentence parts. - * - * @return the entities - */ - public Boolean entities() { - return entities; - } - - /** - * Gets the keywords. - * - * When `true`, keywords are extracted from the identified sentence parts. - * - * @return the keywords - */ - public Boolean keywords() { - return keywords; - } - - /** - * Gets the limit. - * - * The maximum number of semantic roles enrichments to extact from each instance of the specified field. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java deleted file mode 100644 index fb4461788c0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object specifying the sentiment extraction enrichment and related parameters. - */ -public class NluEnrichmentSentiment extends GenericModel { - - protected Boolean document; - protected List targets; - - /** - * Builder. - */ - public static class Builder { - private Boolean document; - private List targets; - - private Builder(NluEnrichmentSentiment nluEnrichmentSentiment) { - this.document = nluEnrichmentSentiment.document; - this.targets = nluEnrichmentSentiment.targets; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NluEnrichmentSentiment. - * - * @return the nluEnrichmentSentiment - */ - public NluEnrichmentSentiment build() { - return new NluEnrichmentSentiment(this); - } - - /** - * Adds an target to targets. - * - * @param target the new target - * @return the NluEnrichmentSentiment builder - */ - public Builder addTarget(String target) { - com.ibm.cloud.sdk.core.util.Validator.notNull(target, - "target cannot be null"); - if (this.targets == null) { - this.targets = new ArrayList(); - } - this.targets.add(target); - return this; - } - - /** - * Set the document. - * - * @param document the document - * @return the NluEnrichmentSentiment builder - */ - public Builder document(Boolean document) { - this.document = document; - return this; - } - - /** - * Set the targets. - * Existing targets will be replaced. - * - * @param targets the targets - * @return the NluEnrichmentSentiment builder - */ - public Builder targets(List targets) { - this.targets = targets; - return this; - } - } - - protected NluEnrichmentSentiment(Builder builder) { - document = builder.document; - targets = builder.targets; - } - - /** - * New builder. - * - * @return a NluEnrichmentSentiment builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the document. - * - * When `true`, sentiment analysis is performed on the entire field. - * - * @return the document - */ - public Boolean document() { - return document; - } - - /** - * Gets the targets. - * - * A comma-separated list of target strings that will have any associated sentiment analyzed. - * - * @return the targets - */ - public List targets() { - return targets; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java deleted file mode 100644 index b18d963d78a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing normalization operations. - */ -public class NormalizationOperation extends GenericModel { - - /** - * Identifies what type of operation to perform. - * - * **copy** - Copies the value of the **source_field** to the **destination_field** field. If the - * **destination_field** already exists, then the value of the **source_field** overwrites the original value of the - * **destination_field**. - * - * **move** - Renames (moves) the **source_field** to the **destination_field**. If the **destination_field** already - * exists, then the value of the **source_field** overwrites the original value of the **destination_field**. Rename - * is identical to copy, except that the **source_field** is removed after the value has been copied to the - * **destination_field** (it is the same as a _copy_ followed by a _remove_). - * - * **merge** - Merges the value of the **source_field** with the value of the **destination_field**. The - * **destination_field** is converted into an array if it is not already an array, and the value of the - * **source_field** is appended to the array. This operation removes the **source_field** after the merge. If the - * **source_field** does not exist in the current document, then the **destination_field** is still converted into an - * array (if it is not an array already). This conversion ensures the type for **destination_field** is consistent - * across all documents. - * - * **remove** - Deletes the **source_field** field. The **destination_field** is ignored for this operation. - * - * **remove_nulls** - Removes all nested null (blank) field values from the ingested document. **source_field** and - * **destination_field** are ignored by this operation because _remove_nulls_ operates on the entire ingested - * document. Typically, **remove_nulls** is invoked as the last normalization operation (if it is invoked at all, it - * can be time-expensive). - */ - public interface Operation { - /** copy. */ - String COPY = "copy"; - /** move. */ - String MOVE = "move"; - /** merge. */ - String MERGE = "merge"; - /** remove. */ - String REMOVE = "remove"; - /** remove_nulls. */ - String REMOVE_NULLS = "remove_nulls"; - } - - protected String operation; - @SerializedName("source_field") - protected String sourceField; - @SerializedName("destination_field") - protected String destinationField; - - /** - * Builder. - */ - public static class Builder { - private String operation; - private String sourceField; - private String destinationField; - - private Builder(NormalizationOperation normalizationOperation) { - this.operation = normalizationOperation.operation; - this.sourceField = normalizationOperation.sourceField; - this.destinationField = normalizationOperation.destinationField; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a NormalizationOperation. - * - * @return the normalizationOperation - */ - public NormalizationOperation build() { - return new NormalizationOperation(this); - } - - /** - * Set the operation. - * - * @param operation the operation - * @return the NormalizationOperation builder - */ - public Builder operation(String operation) { - this.operation = operation; - return this; - } - - /** - * Set the sourceField. - * - * @param sourceField the sourceField - * @return the NormalizationOperation builder - */ - public Builder sourceField(String sourceField) { - this.sourceField = sourceField; - return this; - } - - /** - * Set the destinationField. - * - * @param destinationField the destinationField - * @return the NormalizationOperation builder - */ - public Builder destinationField(String destinationField) { - this.destinationField = destinationField; - return this; - } - } - - protected NormalizationOperation(Builder builder) { - operation = builder.operation; - sourceField = builder.sourceField; - destinationField = builder.destinationField; - } - - /** - * New builder. - * - * @return a NormalizationOperation builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the operation. - * - * Identifies what type of operation to perform. - * - * **copy** - Copies the value of the **source_field** to the **destination_field** field. If the - * **destination_field** already exists, then the value of the **source_field** overwrites the original value of the - * **destination_field**. - * - * **move** - Renames (moves) the **source_field** to the **destination_field**. If the **destination_field** already - * exists, then the value of the **source_field** overwrites the original value of the **destination_field**. Rename - * is identical to copy, except that the **source_field** is removed after the value has been copied to the - * **destination_field** (it is the same as a _copy_ followed by a _remove_). - * - * **merge** - Merges the value of the **source_field** with the value of the **destination_field**. The - * **destination_field** is converted into an array if it is not already an array, and the value of the - * **source_field** is appended to the array. This operation removes the **source_field** after the merge. If the - * **source_field** does not exist in the current document, then the **destination_field** is still converted into an - * array (if it is not an array already). This conversion ensures the type for **destination_field** is consistent - * across all documents. - * - * **remove** - Deletes the **source_field** field. The **destination_field** is ignored for this operation. - * - * **remove_nulls** - Removes all nested null (blank) field values from the ingested document. **source_field** and - * **destination_field** are ignored by this operation because _remove_nulls_ operates on the entire ingested - * document. Typically, **remove_nulls** is invoked as the last normalization operation (if it is invoked at all, it - * can be time-expensive). - * - * @return the operation - */ - public String operation() { - return operation; - } - - /** - * Gets the sourceField. - * - * The source field for the operation. - * - * @return the sourceField - */ - public String sourceField() { - return sourceField; - } - - /** - * Gets the destinationField. - * - * The destination field for the operation. - * - * @return the destinationField - */ - public String destinationField() { - return destinationField; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java deleted file mode 100644 index d88119d7c74..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A notice produced for the collection. - */ -public class Notice extends GenericModel { - - /** - * Severity level of the notice. - */ - public interface Severity { - /** warning. */ - String WARNING = "warning"; - /** error. */ - String ERROR = "error"; - } - - @SerializedName("notice_id") - protected String noticeId; - protected Date created; - @SerializedName("document_id") - protected String documentId; - @SerializedName("query_id") - protected String queryId; - protected String severity; - protected String step; - protected String description; - - /** - * Gets the noticeId. - * - * Identifies the notice. Many notices might have the same ID. This field exists so that user applications can - * programmatically identify a notice and take automatic corrective action. Typical notice IDs include: - * `index_failed`, `index_failed_too_many_requests`, `index_failed_incompatible_field`, - * `index_failed_cluster_unavailable`, `ingestion_timeout`, `ingestion_error`, `bad_request`, `internal_error`, - * `missing_model`, `unsupported_model`, `smart_document_understanding_failed_incompatible_field`, - * `smart_document_understanding_failed_internal_error`, `smart_document_understanding_failed_internal_error`, - * `smart_document_understanding_failed_warning`, `smart_document_understanding_page_error`, - * `smart_document_understanding_page_warning`. **Note:** This is not a complete list, other values might be returned. - * - * @return the noticeId - */ - public String getNoticeId() { - return noticeId; - } - - /** - * Gets the created. - * - * The creation date of the collection in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the documentId. - * - * Unique identifier of the document. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the queryId. - * - * Unique identifier of the query used for relevance training. - * - * @return the queryId - */ - public String getQueryId() { - return queryId; - } - - /** - * Gets the severity. - * - * Severity level of the notice. - * - * @return the severity - */ - public String getSeverity() { - return severity; - } - - /** - * Gets the step. - * - * Ingestion or training step in which the notice occurred. Typical step values include: `classify_elements`, - * `smartDocumentUnderstanding`, `ingestion`, `indexing`, `convert`. **Note:** This is not a complete list, other - * values might be returned. - * - * @return the step - */ - public String getStep() { - return step; - } - - /** - * Gets the description. - * - * The description of the notice. - * - * @return the description - */ - public String getDescription() { - return description; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java deleted file mode 100644 index e3252193f0c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing heading detection conversion settings for PDF documents. - */ -public class PdfHeadingDetection extends GenericModel { - - protected List fonts; - - /** - * Builder. - */ - public static class Builder { - private List fonts; - - private Builder(PdfHeadingDetection pdfHeadingDetection) { - this.fonts = pdfHeadingDetection.fonts; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a PdfHeadingDetection. - * - * @return the pdfHeadingDetection - */ - public PdfHeadingDetection build() { - return new PdfHeadingDetection(this); - } - - /** - * Adds an fontSetting to fonts. - * - * @param fontSetting the new fontSetting - * @return the PdfHeadingDetection builder - */ - public Builder addFontSetting(FontSetting fontSetting) { - com.ibm.cloud.sdk.core.util.Validator.notNull(fontSetting, - "fontSetting cannot be null"); - if (this.fonts == null) { - this.fonts = new ArrayList(); - } - this.fonts.add(fontSetting); - return this; - } - - /** - * Set the fonts. - * Existing fonts will be replaced. - * - * @param fonts the fonts - * @return the PdfHeadingDetection builder - */ - public Builder fonts(List fonts) { - this.fonts = fonts; - return this; - } - } - - protected PdfHeadingDetection(Builder builder) { - fonts = builder.fonts; - } - - /** - * New builder. - * - * @return a PdfHeadingDetection builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the fonts. - * - * Array of font matching configurations. - * - * @return the fonts - */ - public List fonts() { - return fonts; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java deleted file mode 100644 index f4aa14ea1ad..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A list of PDF conversion settings. - */ -public class PdfSettings extends GenericModel { - - protected PdfHeadingDetection heading; - - /** - * Builder. - */ - public static class Builder { - private PdfHeadingDetection heading; - - private Builder(PdfSettings pdfSettings) { - this.heading = pdfSettings.heading; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a PdfSettings. - * - * @return the pdfSettings - */ - public PdfSettings build() { - return new PdfSettings(this); - } - - /** - * Set the heading. - * - * @param heading the heading - * @return the PdfSettings builder - */ - public Builder heading(PdfHeadingDetection heading) { - this.heading = heading; - return this; - } - } - - protected PdfSettings(Builder builder) { - heading = builder.heading; - } - - /** - * New builder. - * - * @return a PdfSettings builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the heading. - * - * Object containing heading detection conversion settings for PDF documents. - * - * @return the heading - */ - public PdfHeadingDetection heading() { - return heading; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java deleted file mode 100644 index 54f6057949d..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An aggregation produced by Discovery to analyze the input provided. - */ -public class QueryAggregation extends GenericModel { - @SuppressWarnings("unused") - protected static String discriminatorPropertyName = "type"; - protected static java.util.Map> discriminatorMapping; - static { - discriminatorMapping = new java.util.HashMap<>(); - discriminatorMapping.put("histogram", Histogram.class); - discriminatorMapping.put("max", Calculation.class); - discriminatorMapping.put("min", Calculation.class); - discriminatorMapping.put("average", Calculation.class); - discriminatorMapping.put("sum", Calculation.class); - discriminatorMapping.put("unique_count", Calculation.class); - discriminatorMapping.put("term", Term.class); - discriminatorMapping.put("filter", Filter.class); - discriminatorMapping.put("nested", Nested.class); - discriminatorMapping.put("timeslice", Timeslice.class); - discriminatorMapping.put("top_hits", TopHits.class); - } - - protected String type; - protected List results; - @SerializedName("matching_results") - protected Long matchingResults; - protected List aggregations; - - /** - * Gets the type. - * - * The type of aggregation command used. For example: term, filter, max, min, etc. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the results. - * - * Array of aggregation results. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * Gets the matchingResults. - * - * Number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the aggregations. - * - * Aggregations returned by Discovery. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java deleted file mode 100644 index d5adeec05b3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The queryLog options. - */ -public class QueryLogOptions extends GenericModel { - - protected String filter; - protected String query; - protected Long count; - protected Long offset; - protected List sort; - - /** - * Builder. - */ - public static class Builder { - private String filter; - private String query; - private Long count; - private Long offset; - private List sort; - - private Builder(QueryLogOptions queryLogOptions) { - this.filter = queryLogOptions.filter; - this.query = queryLogOptions.query; - this.count = queryLogOptions.count; - this.offset = queryLogOptions.offset; - this.sort = queryLogOptions.sort; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a QueryLogOptions. - * - * @return the queryLogOptions - */ - public QueryLogOptions build() { - return new QueryLogOptions(this); - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the QueryLogOptions builder - */ - public Builder addSort(String sort) { - com.ibm.cloud.sdk.core.util.Validator.notNull(sort, - "sort cannot be null"); - if (this.sort == null) { - this.sort = new ArrayList(); - } - this.sort.add(sort); - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the QueryLogOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the QueryLogOptions builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the QueryLogOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the offset. - * - * @param offset the offset - * @return the QueryLogOptions builder - */ - public Builder offset(long offset) { - this.offset = offset; - return this; - } - - /** - * Set the sort. - * Existing sort will be replaced. - * - * @param sort the sort - * @return the QueryLogOptions builder - */ - public Builder sort(List sort) { - this.sort = sort; - return this; - } - } - - protected QueryLogOptions(Builder builder) { - filter = builder.filter; - query = builder.query; - count = builder.count; - offset = builder.offset; - sort = builder.sort; - } - - /** - * New builder. - * - * @return a QueryLogOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the filter. - * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the query. - * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. - * - * @return the query - */ - public String query() { - return query; - } - - /** - * Gets the count. - * - * Number of results to return. The maximum for the **count** and **offset** values together in any one query is - * **10000**. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the offset. - * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. The maximum for the **count** and **offset** values - * together in any one query is **10000**. - * - * @return the offset - */ - public Long offset() { - return offset; - } - - /** - * Gets the sort. - * - * A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by - * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no - * prefix is specified. - * - * @return the sort - */ - public List sort() { - return sort; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java deleted file mode 100644 index 18f08faf110..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java +++ /dev/null @@ -1,674 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The queryNotices options. - */ -public class QueryNoticesOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String filter; - protected String query; - protected String naturalLanguageQuery; - protected Boolean passages; - protected String aggregation; - protected Long count; - protected List xReturn; - protected Long offset; - protected List sort; - protected Boolean highlight; - protected List passagesFields; - protected Long passagesCount; - protected Long passagesCharacters; - protected String deduplicateField; - protected Boolean similar; - protected List similarDocumentIds; - protected List similarFields; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String filter; - private String query; - private String naturalLanguageQuery; - private Boolean passages; - private String aggregation; - private Long count; - private List xReturn; - private Long offset; - private List sort; - private Boolean highlight; - private List passagesFields; - private Long passagesCount; - private Long passagesCharacters; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private List similarFields; - - private Builder(QueryNoticesOptions queryNoticesOptions) { - this.environmentId = queryNoticesOptions.environmentId; - this.collectionId = queryNoticesOptions.collectionId; - this.filter = queryNoticesOptions.filter; - this.query = queryNoticesOptions.query; - this.naturalLanguageQuery = queryNoticesOptions.naturalLanguageQuery; - this.passages = queryNoticesOptions.passages; - this.aggregation = queryNoticesOptions.aggregation; - this.count = queryNoticesOptions.count; - this.xReturn = queryNoticesOptions.xReturn; - this.offset = queryNoticesOptions.offset; - this.sort = queryNoticesOptions.sort; - this.highlight = queryNoticesOptions.highlight; - this.passagesFields = queryNoticesOptions.passagesFields; - this.passagesCount = queryNoticesOptions.passagesCount; - this.passagesCharacters = queryNoticesOptions.passagesCharacters; - this.deduplicateField = queryNoticesOptions.deduplicateField; - this.similar = queryNoticesOptions.similar; - this.similarDocumentIds = queryNoticesOptions.similarDocumentIds; - this.similarFields = queryNoticesOptions.similarFields; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a QueryNoticesOptions. - * - * @return the queryNoticesOptions - */ - public QueryNoticesOptions build() { - return new QueryNoticesOptions(this); - } - - /** - * Adds an returnField to xReturn. - * - * @param returnField the new returnField - * @return the QueryNoticesOptions builder - */ - public Builder addReturnField(String returnField) { - com.ibm.cloud.sdk.core.util.Validator.notNull(returnField, - "returnField cannot be null"); - if (this.xReturn == null) { - this.xReturn = new ArrayList(); - } - this.xReturn.add(returnField); - return this; - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the QueryNoticesOptions builder - */ - public Builder addSort(String sort) { - com.ibm.cloud.sdk.core.util.Validator.notNull(sort, - "sort cannot be null"); - if (this.sort == null) { - this.sort = new ArrayList(); - } - this.sort.add(sort); - return this; - } - - /** - * Adds an passagesFields to passagesFields. - * - * @param passagesFields the new passagesFields - * @return the QueryNoticesOptions builder - */ - public Builder addPassagesFields(String passagesFields) { - com.ibm.cloud.sdk.core.util.Validator.notNull(passagesFields, - "passagesFields cannot be null"); - if (this.passagesFields == null) { - this.passagesFields = new ArrayList(); - } - this.passagesFields.add(passagesFields); - return this; - } - - /** - * Adds an similarDocumentIds to similarDocumentIds. - * - * @param similarDocumentIds the new similarDocumentIds - * @return the QueryNoticesOptions builder - */ - public Builder addSimilarDocumentIds(String similarDocumentIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(similarDocumentIds, - "similarDocumentIds cannot be null"); - if (this.similarDocumentIds == null) { - this.similarDocumentIds = new ArrayList(); - } - this.similarDocumentIds.add(similarDocumentIds); - return this; - } - - /** - * Adds an similarFields to similarFields. - * - * @param similarFields the new similarFields - * @return the QueryNoticesOptions builder - */ - public Builder addSimilarFields(String similarFields) { - com.ibm.cloud.sdk.core.util.Validator.notNull(similarFields, - "similarFields cannot be null"); - if (this.similarFields == null) { - this.similarFields = new ArrayList(); - } - this.similarFields.add(similarFields); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the QueryNoticesOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the QueryNoticesOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the QueryNoticesOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the QueryNoticesOptions builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the naturalLanguageQuery. - * - * @param naturalLanguageQuery the naturalLanguageQuery - * @return the QueryNoticesOptions builder - */ - public Builder naturalLanguageQuery(String naturalLanguageQuery) { - this.naturalLanguageQuery = naturalLanguageQuery; - return this; - } - - /** - * Set the passages. - * - * @param passages the passages - * @return the QueryNoticesOptions builder - */ - public Builder passages(Boolean passages) { - this.passages = passages; - return this; - } - - /** - * Set the aggregation. - * - * @param aggregation the aggregation - * @return the QueryNoticesOptions builder - */ - public Builder aggregation(String aggregation) { - this.aggregation = aggregation; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the QueryNoticesOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the xReturn. - * Existing xReturn will be replaced. - * - * @param xReturn the xReturn - * @return the QueryNoticesOptions builder - */ - public Builder xReturn(List xReturn) { - this.xReturn = xReturn; - return this; - } - - /** - * Set the offset. - * - * @param offset the offset - * @return the QueryNoticesOptions builder - */ - public Builder offset(long offset) { - this.offset = offset; - return this; - } - - /** - * Set the sort. - * Existing sort will be replaced. - * - * @param sort the sort - * @return the QueryNoticesOptions builder - */ - public Builder sort(List sort) { - this.sort = sort; - return this; - } - - /** - * Set the highlight. - * - * @param highlight the highlight - * @return the QueryNoticesOptions builder - */ - public Builder highlight(Boolean highlight) { - this.highlight = highlight; - return this; - } - - /** - * Set the passagesFields. - * Existing passagesFields will be replaced. - * - * @param passagesFields the passagesFields - * @return the QueryNoticesOptions builder - */ - public Builder passagesFields(List passagesFields) { - this.passagesFields = passagesFields; - return this; - } - - /** - * Set the passagesCount. - * - * @param passagesCount the passagesCount - * @return the QueryNoticesOptions builder - */ - public Builder passagesCount(long passagesCount) { - this.passagesCount = passagesCount; - return this; - } - - /** - * Set the passagesCharacters. - * - * @param passagesCharacters the passagesCharacters - * @return the QueryNoticesOptions builder - */ - public Builder passagesCharacters(long passagesCharacters) { - this.passagesCharacters = passagesCharacters; - return this; - } - - /** - * Set the deduplicateField. - * - * @param deduplicateField the deduplicateField - * @return the QueryNoticesOptions builder - */ - public Builder deduplicateField(String deduplicateField) { - this.deduplicateField = deduplicateField; - return this; - } - - /** - * Set the similar. - * - * @param similar the similar - * @return the QueryNoticesOptions builder - */ - public Builder similar(Boolean similar) { - this.similar = similar; - return this; - } - - /** - * Set the similarDocumentIds. - * Existing similarDocumentIds will be replaced. - * - * @param similarDocumentIds the similarDocumentIds - * @return the QueryNoticesOptions builder - */ - public Builder similarDocumentIds(List similarDocumentIds) { - this.similarDocumentIds = similarDocumentIds; - return this; - } - - /** - * Set the similarFields. - * Existing similarFields will be replaced. - * - * @param similarFields the similarFields - * @return the QueryNoticesOptions builder - */ - public Builder similarFields(List similarFields) { - this.similarFields = similarFields; - return this; - } - } - - protected QueryNoticesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - filter = builder.filter; - query = builder.query; - naturalLanguageQuery = builder.naturalLanguageQuery; - passages = builder.passages; - aggregation = builder.aggregation; - count = builder.count; - xReturn = builder.xReturn; - offset = builder.offset; - sort = builder.sort; - highlight = builder.highlight; - passagesFields = builder.passagesFields; - passagesCount = builder.passagesCount; - passagesCharacters = builder.passagesCharacters; - deduplicateField = builder.deduplicateField; - similar = builder.similar; - similarDocumentIds = builder.similarDocumentIds; - similarFields = builder.similarFields; - } - - /** - * New builder. - * - * @return a QueryNoticesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the filter. - * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the query. - * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. - * - * @return the query - */ - public String query() { - return query; - } - - /** - * Gets the naturalLanguageQuery. - * - * A natural language query that returns relevant documents by utilizing training data and natural language - * understanding. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the passages. - * - * A passages query that returns the most relevant passages from the results. - * - * @return the passages - */ - public Boolean passages() { - return passages; - } - - /** - * Gets the aggregation. - * - * An aggregation search that returns an exact answer by combining query search with filters. Useful for applications - * to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of results to return. The maximum for the **count** and **offset** values together in any one query is - * **10000**. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the xReturn. - * - * A comma-separated list of the portion of the document hierarchy to return. - * - * @return the xReturn - */ - public List xReturn() { - return xReturn; - } - - /** - * Gets the offset. - * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. The maximum for the **count** and **offset** values - * together in any one query is **10000**. - * - * @return the offset - */ - public Long offset() { - return offset; - } - - /** - * Gets the sort. - * - * A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by - * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no - * prefix is specified. - * - * @return the sort - */ - public List sort() { - return sort; - } - - /** - * Gets the highlight. - * - * When true, a highlight field is returned for each result which contains the fields which match the query with - * `` tags around the matching query terms. - * - * @return the highlight - */ - public Boolean highlight() { - return highlight; - } - - /** - * Gets the passagesFields. - * - * A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level - * fields are included. - * - * @return the passagesFields - */ - public List passagesFields() { - return passagesFields; - } - - /** - * Gets the passagesCount. - * - * The maximum number of passages to return. The search returns fewer passages if the requested total is not found. - * - * @return the passagesCount - */ - public Long passagesCount() { - return passagesCount; - } - - /** - * Gets the passagesCharacters. - * - * The approximate number of characters that any one passage will have. - * - * @return the passagesCharacters - */ - public Long passagesCharacters() { - return passagesCharacters; - } - - /** - * Gets the deduplicateField. - * - * When specified, duplicate results based on the field specified are removed from the returned results. Duplicate - * comparison is limited to the current query only, **offset** is not considered. This parameter is currently Beta - * functionality. - * - * @return the deduplicateField - */ - public String deduplicateField() { - return deduplicateField; - } - - /** - * Gets the similar. - * - * When `true`, results are returned based on their similarity to the document IDs specified in the - * **similar.document_ids** parameter. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs to find similar documents. - * - * **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search - * with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied - * and reduce the scope. - * - * @return the similarDocumentIds - */ - public List similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not - * specified, the entire document is used for comparison. - * - * @return the similarFields - */ - public List similarFields() { - return similarFields; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java deleted file mode 100644 index 8509795e9b8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing notice query results. - */ -public class QueryNoticesResponse extends GenericModel { - - @SerializedName("matching_results") - protected Long matchingResults; - protected List results; - protected List aggregations; - protected List passages; - @SerializedName("duplicates_removed") - protected Long duplicatesRemoved; - - /** - * Gets the matchingResults. - * - * The number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the results. - * - * Array of document results that match the query. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * Gets the aggregations. - * - * Array of aggregation results that match the query. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } - - /** - * Gets the passages. - * - * Array of passage results that match the query. - * - * @return the passages - */ - public List getPassages() { - return passages; - } - - /** - * Gets the duplicatesRemoved. - * - * The number of duplicates removed from this notices query. - * - * @return the duplicatesRemoved - */ - public Long getDuplicatesRemoved() { - return duplicatesRemoved; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java deleted file mode 100644 index 491d093fad6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; - -/** - * Query result object. - */ -public class QueryNoticesResult extends DynamicModel { - - /** - * The type of the original source file. - */ - public interface FileType { - /** pdf. */ - String PDF = "pdf"; - /** html. */ - String HTML = "html"; - /** word. */ - String WORD = "word"; - /** json. */ - String JSON = "json"; - } - - @SerializedName("id") - protected String id; - @SerializedName("metadata") - protected Map metadata; - @SerializedName("collection_id") - protected String collectionId; - @SerializedName("result_metadata") - protected QueryResultMetadata resultMetadata; - @SerializedName("code") - protected Long code; - @SerializedName("filename") - protected String filename; - @SerializedName("file_type") - protected String fileType; - @SerializedName("sha1") - protected String sha1; - @SerializedName("notices") - protected List notices; - - public QueryNoticesResult() { - super(new TypeToken() { - }); - } - - /** - * Gets the id. - * - * The unique identifier of the document. - * - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * Gets the metadata. - * - * Metadata of the document. - * - * @return the metadata - */ - public Map getMetadata() { - return this.metadata; - } - - /** - * Gets the collectionId. - * - * The collection ID of the collection containing the document for this result. - * - * @return the collectionId - */ - public String getCollectionId() { - return this.collectionId; - } - - /** - * Gets the resultMetadata. - * - * Metadata of a query result. - * - * @return the resultMetadata - */ - public QueryResultMetadata getResultMetadata() { - return this.resultMetadata; - } - - /** - * Gets the code. - * - * The internal status code returned by the ingestion subsystem indicating the overall result of ingesting the source - * document. - * - * @return the code - */ - public Long getCode() { - return this.code; - } - - /** - * Gets the filename. - * - * Name of the original source file (if available). - * - * @return the filename - */ - public String getFilename() { - return this.filename; - } - - /** - * Gets the fileType. - * - * The type of the original source file. - * - * @return the fileType - */ - public String getFileType() { - return this.fileType; - } - - /** - * Gets the sha1. - * - * The SHA-1 hash of the original source file (formatted as a hexadecimal string). - * - * @return the sha1 - */ - public String getSha1() { - return this.sha1; - } - - /** - * Gets the notices. - * - * Array of notices for the document. - * - * @return the notices - */ - public List getNotices() { - return this.notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java deleted file mode 100644 index 9b627479e78..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The query options. - */ -public class QueryOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String filter; - protected String query; - protected String naturalLanguageQuery; - protected Boolean passages; - protected String aggregation; - protected Long count; - protected String xReturn; - protected Long offset; - protected String sort; - protected Boolean highlight; - protected String passagesFields; - protected Long passagesCount; - protected Long passagesCharacters; - protected Boolean deduplicate; - protected String deduplicateField; - protected Boolean similar; - protected String similarDocumentIds; - protected String similarFields; - protected String bias; - protected Boolean spellingSuggestions; - protected Boolean xWatsonLoggingOptOut; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String filter; - private String query; - private String naturalLanguageQuery; - private Boolean passages; - private String aggregation; - private Long count; - private String xReturn; - private Long offset; - private String sort; - private Boolean highlight; - private String passagesFields; - private Long passagesCount; - private Long passagesCharacters; - private Boolean deduplicate; - private String deduplicateField; - private Boolean similar; - private String similarDocumentIds; - private String similarFields; - private String bias; - private Boolean spellingSuggestions; - private Boolean xWatsonLoggingOptOut; - - private Builder(QueryOptions queryOptions) { - this.environmentId = queryOptions.environmentId; - this.collectionId = queryOptions.collectionId; - this.filter = queryOptions.filter; - this.query = queryOptions.query; - this.naturalLanguageQuery = queryOptions.naturalLanguageQuery; - this.passages = queryOptions.passages; - this.aggregation = queryOptions.aggregation; - this.count = queryOptions.count; - this.xReturn = queryOptions.xReturn; - this.offset = queryOptions.offset; - this.sort = queryOptions.sort; - this.highlight = queryOptions.highlight; - this.passagesFields = queryOptions.passagesFields; - this.passagesCount = queryOptions.passagesCount; - this.passagesCharacters = queryOptions.passagesCharacters; - this.deduplicate = queryOptions.deduplicate; - this.deduplicateField = queryOptions.deduplicateField; - this.similar = queryOptions.similar; - this.similarDocumentIds = queryOptions.similarDocumentIds; - this.similarFields = queryOptions.similarFields; - this.bias = queryOptions.bias; - this.spellingSuggestions = queryOptions.spellingSuggestions; - this.xWatsonLoggingOptOut = queryOptions.xWatsonLoggingOptOut; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - */ - public Builder(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - /** - * Builds a QueryOptions. - * - * @return the queryOptions - */ - public QueryOptions build() { - return new QueryOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the QueryOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the QueryOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the QueryOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the QueryOptions builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the naturalLanguageQuery. - * - * @param naturalLanguageQuery the naturalLanguageQuery - * @return the QueryOptions builder - */ - public Builder naturalLanguageQuery(String naturalLanguageQuery) { - this.naturalLanguageQuery = naturalLanguageQuery; - return this; - } - - /** - * Set the passages. - * - * @param passages the passages - * @return the QueryOptions builder - */ - public Builder passages(Boolean passages) { - this.passages = passages; - return this; - } - - /** - * Set the aggregation. - * - * @param aggregation the aggregation - * @return the QueryOptions builder - */ - public Builder aggregation(String aggregation) { - this.aggregation = aggregation; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the QueryOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the xReturn. - * - * @param xReturn the xReturn - * @return the QueryOptions builder - */ - public Builder xReturn(String xReturn) { - this.xReturn = xReturn; - return this; - } - - /** - * Set the offset. - * - * @param offset the offset - * @return the QueryOptions builder - */ - public Builder offset(long offset) { - this.offset = offset; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the QueryOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the highlight. - * - * @param highlight the highlight - * @return the QueryOptions builder - */ - public Builder highlight(Boolean highlight) { - this.highlight = highlight; - return this; - } - - /** - * Set the passagesFields. - * - * @param passagesFields the passagesFields - * @return the QueryOptions builder - */ - public Builder passagesFields(String passagesFields) { - this.passagesFields = passagesFields; - return this; - } - - /** - * Set the passagesCount. - * - * @param passagesCount the passagesCount - * @return the QueryOptions builder - */ - public Builder passagesCount(long passagesCount) { - this.passagesCount = passagesCount; - return this; - } - - /** - * Set the passagesCharacters. - * - * @param passagesCharacters the passagesCharacters - * @return the QueryOptions builder - */ - public Builder passagesCharacters(long passagesCharacters) { - this.passagesCharacters = passagesCharacters; - return this; - } - - /** - * Set the deduplicate. - * - * @param deduplicate the deduplicate - * @return the QueryOptions builder - */ - public Builder deduplicate(Boolean deduplicate) { - this.deduplicate = deduplicate; - return this; - } - - /** - * Set the deduplicateField. - * - * @param deduplicateField the deduplicateField - * @return the QueryOptions builder - */ - public Builder deduplicateField(String deduplicateField) { - this.deduplicateField = deduplicateField; - return this; - } - - /** - * Set the similar. - * - * @param similar the similar - * @return the QueryOptions builder - */ - public Builder similar(Boolean similar) { - this.similar = similar; - return this; - } - - /** - * Set the similarDocumentIds. - * - * @param similarDocumentIds the similarDocumentIds - * @return the QueryOptions builder - */ - public Builder similarDocumentIds(String similarDocumentIds) { - this.similarDocumentIds = similarDocumentIds; - return this; - } - - /** - * Set the similarFields. - * - * @param similarFields the similarFields - * @return the QueryOptions builder - */ - public Builder similarFields(String similarFields) { - this.similarFields = similarFields; - return this; - } - - /** - * Set the bias. - * - * @param bias the bias - * @return the QueryOptions builder - */ - public Builder bias(String bias) { - this.bias = bias; - return this; - } - - /** - * Set the spellingSuggestions. - * - * @param spellingSuggestions the spellingSuggestions - * @return the QueryOptions builder - */ - public Builder spellingSuggestions(Boolean spellingSuggestions) { - this.spellingSuggestions = spellingSuggestions; - return this; - } - - /** - * Set the xWatsonLoggingOptOut. - * - * @param xWatsonLoggingOptOut the xWatsonLoggingOptOut - * @return the QueryOptions builder - */ - public Builder xWatsonLoggingOptOut(Boolean xWatsonLoggingOptOut) { - this.xWatsonLoggingOptOut = xWatsonLoggingOptOut; - return this; - } - } - - protected QueryOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - filter = builder.filter; - query = builder.query; - naturalLanguageQuery = builder.naturalLanguageQuery; - passages = builder.passages; - aggregation = builder.aggregation; - count = builder.count; - xReturn = builder.xReturn; - offset = builder.offset; - sort = builder.sort; - highlight = builder.highlight; - passagesFields = builder.passagesFields; - passagesCount = builder.passagesCount; - passagesCharacters = builder.passagesCharacters; - deduplicate = builder.deduplicate; - deduplicateField = builder.deduplicateField; - similar = builder.similar; - similarDocumentIds = builder.similarDocumentIds; - similarFields = builder.similarFields; - bias = builder.bias; - spellingSuggestions = builder.spellingSuggestions; - xWatsonLoggingOptOut = builder.xWatsonLoggingOptOut; - } - - /** - * New builder. - * - * @return a QueryOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the filter. - * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the query. - * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. Use a query search when you want to find the most relevant search results. - * - * @return the query - */ - public String query() { - return query; - } - - /** - * Gets the naturalLanguageQuery. - * - * A natural language query that returns relevant documents by utilizing training data and natural language - * understanding. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the passages. - * - * A passages query that returns the most relevant passages from the results. - * - * @return the passages - */ - public Boolean passages() { - return passages; - } - - /** - * Gets the aggregation. - * - * An aggregation search that returns an exact answer by combining query search with filters. Useful for applications - * to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of results to return. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the xReturn. - * - * A comma-separated list of the portion of the document hierarchy to return. - * - * @return the xReturn - */ - public String xReturn() { - return xReturn; - } - - /** - * Gets the offset. - * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. - * - * @return the offset - */ - public Long offset() { - return offset; - } - - /** - * Gets the sort. - * - * A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by - * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no - * prefix is specified. This parameter cannot be used in the same query as the **bias** parameter. - * - * @return the sort - */ - public String sort() { - return sort; - } - - /** - * Gets the highlight. - * - * When true, a highlight field is returned for each result which contains the fields which match the query with - * `` tags around the matching query terms. - * - * @return the highlight - */ - public Boolean highlight() { - return highlight; - } - - /** - * Gets the passagesFields. - * - * A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level - * fields are included. - * - * @return the passagesFields - */ - public String passagesFields() { - return passagesFields; - } - - /** - * Gets the passagesCount. - * - * The maximum number of passages to return. The search returns fewer passages if the requested total is not found. - * The default is `10`. The maximum is `100`. - * - * @return the passagesCount - */ - public Long passagesCount() { - return passagesCount; - } - - /** - * Gets the passagesCharacters. - * - * The approximate number of characters that any one passage will have. - * - * @return the passagesCharacters - */ - public Long passagesCharacters() { - return passagesCharacters; - } - - /** - * Gets the deduplicate. - * - * When `true`, and used with a Watson Discovery News collection, duplicate results (based on the contents of the - * **title** field) are removed. Duplicate comparison is limited to the current query only; **offset** is not - * considered. This parameter is currently Beta functionality. - * - * @return the deduplicate - */ - public Boolean deduplicate() { - return deduplicate; - } - - /** - * Gets the deduplicateField. - * - * When specified, duplicate results based on the field specified are removed from the returned results. Duplicate - * comparison is limited to the current query only, **offset** is not considered. This parameter is currently Beta - * functionality. - * - * @return the deduplicateField - */ - public String deduplicateField() { - return deduplicateField; - } - - /** - * Gets the similar. - * - * When `true`, results are returned based on their similarity to the document IDs specified in the - * **similar.document_ids** parameter. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs to find similar documents. - * - * **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search - * with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied - * and reduce the scope. - * - * @return the similarDocumentIds - */ - public String similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not - * specified, the entire document is used for comparison. - * - * @return the similarFields - */ - public String similarFields() { - return similarFields; - } - - /** - * Gets the bias. - * - * Field which the returned results will be biased against. The specified field must be either a **date** or - * **number** format. When a **date** type field is specified returned results are biased towards field values closer - * to the current date. When a **number** type field is specified, returned results are biased towards higher field - * values. This parameter cannot be used in the same query as the **sort** parameter. - * - * @return the bias - */ - public String bias() { - return bias; - } - - /** - * Gets the spellingSuggestions. - * - * When `true` and the **natural_language_query** parameter is used, the **natural_languge_query** parameter is spell - * checked. The most likely correction is retunred in the **suggested_query** field of the response (if one exists). - * - * **Important:** this parameter is only valid when using the Cloud Pak version of Discovery. - * - * @return the spellingSuggestions - */ - public Boolean spellingSuggestions() { - return spellingSuggestions; - } - - /** - * Gets the xWatsonLoggingOptOut. - * - * If `true`, queries are not stored in the Discovery **Logs** endpoint. - * - * @return the xWatsonLoggingOptOut - */ - public Boolean xWatsonLoggingOptOut() { - return xWatsonLoggingOptOut; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java deleted file mode 100644 index e554e7e7578..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A passage query result. - */ -public class QueryPassages extends GenericModel { - - @SerializedName("document_id") - protected String documentId; - @SerializedName("passage_score") - protected Double passageScore; - @SerializedName("passage_text") - protected String passageText; - @SerializedName("start_offset") - protected Long startOffset; - @SerializedName("end_offset") - protected Long endOffset; - protected String field; - - /** - * Gets the documentId. - * - * The unique identifier of the document from which the passage has been extracted. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the passageScore. - * - * The confidence score of the passages's analysis. A higher score indicates greater confidence. - * - * @return the passageScore - */ - public Double getPassageScore() { - return passageScore; - } - - /** - * Gets the passageText. - * - * The content of the extracted passage. - * - * @return the passageText - */ - public String getPassageText() { - return passageText; - } - - /** - * Gets the startOffset. - * - * The position of the first character of the extracted passage in the originating field. - * - * @return the startOffset - */ - public Long getStartOffset() { - return startOffset; - } - - /** - * Gets the endOffset. - * - * The position of the last character of the extracted passage in the originating field. - * - * @return the endOffset - */ - public Long getEndOffset() { - return endOffset; - } - - /** - * Gets the field. - * - * The label of the field from which the passage has been extracted. - * - * @return the field - */ - public String getField() { - return field; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java deleted file mode 100644 index 2fb392e4476..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A response containing the documents and aggregations for the query. - */ -public class QueryResponse extends GenericModel { - - @SerializedName("matching_results") - protected Long matchingResults; - protected List results; - protected List aggregations; - protected List passages; - @SerializedName("duplicates_removed") - protected Long duplicatesRemoved; - @SerializedName("session_token") - protected String sessionToken; - @SerializedName("retrieval_details") - protected RetrievalDetails retrievalDetails; - @SerializedName("suggested_query") - protected String suggestedQuery; - - /** - * Gets the matchingResults. - * - * The number of matching results for the query. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the results. - * - * Array of document results for the query. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * Gets the aggregations. - * - * Array of aggregation results for the query. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } - - /** - * Gets the passages. - * - * Array of passage results for the query. - * - * @return the passages - */ - public List getPassages() { - return passages; - } - - /** - * Gets the duplicatesRemoved. - * - * The number of duplicate results removed. - * - * @return the duplicatesRemoved - */ - public Long getDuplicatesRemoved() { - return duplicatesRemoved; - } - - /** - * Gets the sessionToken. - * - * The session token for this query. The session token can be used to add events associated with this query to the - * query and event log. - * - * **Important:** Session tokens are case sensitive. - * - * @return the sessionToken - */ - public String getSessionToken() { - return sessionToken; - } - - /** - * Gets the retrievalDetails. - * - * An object contain retrieval type information. - * - * @return the retrievalDetails - */ - public RetrievalDetails getRetrievalDetails() { - return retrievalDetails; - } - - /** - * Gets the suggestedQuery. - * - * The suggestions for a misspelled natural language query. - * - * @return the suggestedQuery - */ - public String getSuggestedQuery() { - return suggestedQuery; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java deleted file mode 100644 index 75fcfa83e03..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; - -/** - * Query result object. - */ -public class QueryResult extends DynamicModel { - - @SerializedName("id") - protected String id; - @SerializedName("metadata") - protected Map metadata; - @SerializedName("collection_id") - protected String collectionId; - @SerializedName("result_metadata") - protected QueryResultMetadata resultMetadata; - - public QueryResult() { - super(new TypeToken() { - }); - } - - /** - * Gets the id. - * - * The unique identifier of the document. - * - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * Gets the metadata. - * - * Metadata of the document. - * - * @return the metadata - */ - public Map getMetadata() { - return this.metadata; - } - - /** - * Gets the collectionId. - * - * The collection ID of the collection containing the document for this result. - * - * @return the collectionId - */ - public String getCollectionId() { - return this.collectionId; - } - - /** - * Gets the resultMetadata. - * - * Metadata of a query result. - * - * @return the resultMetadata - */ - public QueryResultMetadata getResultMetadata() { - return this.resultMetadata; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java deleted file mode 100644 index 76cff8804ec..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Metadata of a query result. - */ -public class QueryResultMetadata extends GenericModel { - - protected Double score; - protected Double confidence; - - /** - * Gets the score. - * - * An unbounded measure of the relevance of a particular result, dependent on the query and matching document. A - * higher score indicates a greater match to the query parameters. - * - * @return the score - */ - public Double getScore() { - return score; - } - - /** - * Gets the confidence. - * - * The confidence score for the given result. Calculated based on how relevant the result is estimated to be. - * confidence can range from `0.0` to `1.0`. The higher the number, the more relevant the document. The `confidence` - * value for a result was calculated using the model specified in the `document_retrieval_strategy` field of the - * result set. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java deleted file mode 100644 index 2545f233cab..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object contain retrieval type information. - */ -public class RetrievalDetails extends GenericModel { - - /** - * Indentifies the document retrieval strategy used for this query. `relevancy_training` indicates that the results - * were returned using a relevancy trained model. `continuous_relevancy_training` indicates that the results were - * returned using the continuous relevancy training model created by result feedback analysis. `untrained` means the - * results were returned using the standard untrained model. - * - * **Note**: In the event of trained collections being queried, but the trained model is not used to return results, - * the **document_retrieval_strategy** will be listed as `untrained`. - */ - public interface DocumentRetrievalStrategy { - /** untrained. */ - String UNTRAINED = "untrained"; - /** relevancy_training. */ - String RELEVANCY_TRAINING = "relevancy_training"; - /** continuous_relevancy_training. */ - String CONTINUOUS_RELEVANCY_TRAINING = "continuous_relevancy_training"; - } - - @SerializedName("document_retrieval_strategy") - protected String documentRetrievalStrategy; - - /** - * Gets the documentRetrievalStrategy. - * - * Indentifies the document retrieval strategy used for this query. `relevancy_training` indicates that the results - * were returned using a relevancy trained model. `continuous_relevancy_training` indicates that the results were - * returned using the continuous relevancy training model created by result feedback analysis. `untrained` means the - * results were returned using the standard untrained model. - * - * **Note**: In the event of trained collections being queried, but the trained model is not used to return results, - * the **document_retrieval_strategy** will be listed as `untrained`. - * - * @return the documentRetrievalStrategy - */ - public String getDocumentRetrievalStrategy() { - return documentRetrievalStrategy; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java deleted file mode 100644 index b1c78971341..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing smart document understanding information for this collection. - */ -public class SduStatus extends GenericModel { - - protected Boolean enabled; - @SerializedName("total_annotated_pages") - protected Long totalAnnotatedPages; - @SerializedName("total_pages") - protected Long totalPages; - @SerializedName("total_documents") - protected Long totalDocuments; - @SerializedName("custom_fields") - protected SduStatusCustomFields customFields; - - /** - * Gets the enabled. - * - * When `true`, smart document understanding conversion is enabled for this collection. All collections created with a - * version date after `2019-04-30` have smart document understanding enabled. If `false`, documents added to the - * collection are converted using the **conversion** settings specified in the configuration associated with the - * collection. - * - * @return the enabled - */ - public Boolean isEnabled() { - return enabled; - } - - /** - * Gets the totalAnnotatedPages. - * - * The total number of pages annotated using smart document understanding in this collection. - * - * @return the totalAnnotatedPages - */ - public Long getTotalAnnotatedPages() { - return totalAnnotatedPages; - } - - /** - * Gets the totalPages. - * - * The current number of pages that can be used for training smart document understanding. The `total_pages` number is - * calculated as the total number of pages identified from the documents listed in the **total_documents** field. - * - * @return the totalPages - */ - public Long getTotalPages() { - return totalPages; - } - - /** - * Gets the totalDocuments. - * - * The total number of documents in this collection that can be used to train smart document understanding. For - * **lite** plan collections, the maximum is the first 20 uploaded documents (not including HTML or JSON documents). - * For other plans, the maximum is the first 40 uploaded documents (not including HTML or JSON documents). When the - * maximum is reached, additional documents uploaded to the collection are not considered for training smart document - * understanding. - * - * @return the totalDocuments - */ - public Long getTotalDocuments() { - return totalDocuments; - } - - /** - * Gets the customFields. - * - * Information about custom smart document understanding fields that exist in this collection. - * - * @return the customFields - */ - public SduStatusCustomFields getCustomFields() { - return customFields; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java deleted file mode 100644 index 10d9e05db1e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about custom smart document understanding fields that exist in this collection. - */ -public class SduStatusCustomFields extends GenericModel { - - protected Long defined; - @SerializedName("maximum_allowed") - protected Long maximumAllowed; - - /** - * Gets the defined. - * - * The number of custom fields defined for this collection. - * - * @return the defined - */ - public Long getDefined() { - return defined; - } - - /** - * Gets the maximumAllowed. - * - * The maximum number of custom fields that are allowed in this collection. - * - * @return the maximumAllowed - */ - public Long getMaximumAllowed() { - return maximumAllowed; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java deleted file mode 100644 index 418b33bf4e1..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about the Continuous Relevancy Training for this environment. - */ -public class SearchStatus extends GenericModel { - - /** - * The current status of Continuous Relevancy Training for this environment. - */ - public interface Status { - /** NO_DATA. */ - String NO_DATA = "NO_DATA"; - /** INSUFFICENT_DATA. */ - String INSUFFICENT_DATA = "INSUFFICENT_DATA"; - /** TRAINING. */ - String TRAINING = "TRAINING"; - /** TRAINED. */ - String TRAINED = "TRAINED"; - /** NOT_APPLICABLE. */ - String NOT_APPLICABLE = "NOT_APPLICABLE"; - } - - protected String scope; - protected String status; - @SerializedName("status_description") - protected String statusDescription; - @SerializedName("last_trained") - protected Date lastTrained; - - /** - * Gets the scope. - * - * Current scope of the training. Always returned as `environment`. - * - * @return the scope - */ - public String getScope() { - return scope; - } - - /** - * Gets the status. - * - * The current status of Continuous Relevancy Training for this environment. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the statusDescription. - * - * Long description of the current Continuous Relevancy Training status. - * - * @return the statusDescription - */ - public String getStatusDescription() { - return statusDescription; - } - - /** - * Gets the lastTrained. - * - * The date stamp of the most recent completed training for this environment. - * - * @return the lastTrained - */ - public Date getLastTrained() { - return lastTrained; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java deleted file mode 100644 index d4e1bacabb9..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A list of Document Segmentation settings. - */ -public class SegmentSettings extends GenericModel { - - protected Boolean enabled; - @SerializedName("selector_tags") - protected List selectorTags; - @SerializedName("annotated_fields") - protected List annotatedFields; - - /** - * Builder. - */ - public static class Builder { - private Boolean enabled; - private List selectorTags; - private List annotatedFields; - - private Builder(SegmentSettings segmentSettings) { - this.enabled = segmentSettings.enabled; - this.selectorTags = segmentSettings.selectorTags; - this.annotatedFields = segmentSettings.annotatedFields; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a SegmentSettings. - * - * @return the segmentSettings - */ - public SegmentSettings build() { - return new SegmentSettings(this); - } - - /** - * Adds an selectorTags to selectorTags. - * - * @param selectorTags the new selectorTags - * @return the SegmentSettings builder - */ - public Builder addSelectorTags(String selectorTags) { - com.ibm.cloud.sdk.core.util.Validator.notNull(selectorTags, - "selectorTags cannot be null"); - if (this.selectorTags == null) { - this.selectorTags = new ArrayList(); - } - this.selectorTags.add(selectorTags); - return this; - } - - /** - * Adds an annotatedFields to annotatedFields. - * - * @param annotatedFields the new annotatedFields - * @return the SegmentSettings builder - */ - public Builder addAnnotatedFields(String annotatedFields) { - com.ibm.cloud.sdk.core.util.Validator.notNull(annotatedFields, - "annotatedFields cannot be null"); - if (this.annotatedFields == null) { - this.annotatedFields = new ArrayList(); - } - this.annotatedFields.add(annotatedFields); - return this; - } - - /** - * Set the enabled. - * - * @param enabled the enabled - * @return the SegmentSettings builder - */ - public Builder enabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Set the selectorTags. - * Existing selectorTags will be replaced. - * - * @param selectorTags the selectorTags - * @return the SegmentSettings builder - */ - public Builder selectorTags(List selectorTags) { - this.selectorTags = selectorTags; - return this; - } - - /** - * Set the annotatedFields. - * Existing annotatedFields will be replaced. - * - * @param annotatedFields the annotatedFields - * @return the SegmentSettings builder - */ - public Builder annotatedFields(List annotatedFields) { - this.annotatedFields = annotatedFields; - return this; - } - } - - protected SegmentSettings(Builder builder) { - enabled = builder.enabled; - selectorTags = builder.selectorTags; - annotatedFields = builder.annotatedFields; - } - - /** - * New builder. - * - * @return a SegmentSettings builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the enabled. - * - * Enables/disables the Document Segmentation feature. - * - * @return the enabled - */ - public Boolean enabled() { - return enabled; - } - - /** - * Gets the selectorTags. - * - * Defines the heading level that splits into document segments. Valid values are h1, h2, h3, h4, h5, h6. The content - * of the header field that the segmentation splits at is used as the **title** field for that segmented result. Only - * valid if used with a collection that has **enabled** set to `false` in the **smart_document_understanding** object. - * - * @return the selectorTags - */ - public List selectorTags() { - return selectorTags; - } - - /** - * Gets the annotatedFields. - * - * Defines the annotated smart document understanding fields that the document is split on. The content of the - * annotated field that the segmentation splits at is used as the **title** field for that segmented result. For - * example, if the field `sub-title` is specified, when a document is uploaded each time the smart documement - * understanding conversion encounters a field of type `sub-title` the document is split at that point and the content - * of the field used as the title of the remaining content. Thnis split is performed for all instances of the listed - * fields in the uploaded document. Only valid if used with a collection that has **enabled** set to `true` in the - * **smart_document_understanding** object. - * - * @return the annotatedFields - */ - public List annotatedFields() { - return annotatedFields; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java deleted file mode 100644 index bb04481319c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing source parameters for the configuration. - */ -public class Source extends GenericModel { - - /** - * The type of source to connect to. - * - `box` indicates the configuration is to connect an instance of Enterprise Box. - * - `salesforce` indicates the configuration is to connect to Salesforce. - * - `sharepoint` indicates the configuration is to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the configuration is to perform a web page crawl. - * - `cloud_object_storage` indicates the configuration is to connect to a cloud object store. - */ - public interface Type { - /** box. */ - String BOX = "box"; - /** salesforce. */ - String SALESFORCE = "salesforce"; - /** sharepoint. */ - String SHAREPOINT = "sharepoint"; - /** web_crawl. */ - String WEB_CRAWL = "web_crawl"; - /** cloud_object_storage. */ - String CLOUD_OBJECT_STORAGE = "cloud_object_storage"; - } - - protected String type; - @SerializedName("credential_id") - protected String credentialId; - protected SourceSchedule schedule; - protected SourceOptions options; - - /** - * Builder. - */ - public static class Builder { - private String type; - private String credentialId; - private SourceSchedule schedule; - private SourceOptions options; - - private Builder(Source source) { - this.type = source.type; - this.credentialId = source.credentialId; - this.schedule = source.schedule; - this.options = source.options; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a Source. - * - * @return the source - */ - public Source build() { - return new Source(this); - } - - /** - * Set the type. - * - * @param type the type - * @return the Source builder - */ - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * Set the credentialId. - * - * @param credentialId the credentialId - * @return the Source builder - */ - public Builder credentialId(String credentialId) { - this.credentialId = credentialId; - return this; - } - - /** - * Set the schedule. - * - * @param schedule the schedule - * @return the Source builder - */ - public Builder schedule(SourceSchedule schedule) { - this.schedule = schedule; - return this; - } - - /** - * Set the options. - * - * @param options the options - * @return the Source builder - */ - public Builder options(SourceOptions options) { - this.options = options; - return this; - } - } - - protected Source(Builder builder) { - type = builder.type; - credentialId = builder.credentialId; - schedule = builder.schedule; - options = builder.options; - } - - /** - * New builder. - * - * @return a Source builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the type. - * - * The type of source to connect to. - * - `box` indicates the configuration is to connect an instance of Enterprise Box. - * - `salesforce` indicates the configuration is to connect to Salesforce. - * - `sharepoint` indicates the configuration is to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the configuration is to perform a web page crawl. - * - `cloud_object_storage` indicates the configuration is to connect to a cloud object store. - * - * @return the type - */ - public String type() { - return type; - } - - /** - * Gets the credentialId. - * - * The **credential_id** of the credentials to use to connect to the source. Credentials are defined using the - * **credentials** method. The **source_type** of the credentials used must match the **type** field specified in this - * object. - * - * @return the credentialId - */ - public String credentialId() { - return credentialId; - } - - /** - * Gets the schedule. - * - * Object containing the schedule information for the source. - * - * @return the schedule - */ - public SourceSchedule schedule() { - return schedule; - } - - /** - * Gets the options. - * - * The **options** object defines which items to crawl from the source system. - * - * @return the options - */ - public SourceOptions options() { - return options; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java deleted file mode 100644 index e98666950f2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The **options** object defines which items to crawl from the source system. - */ -public class SourceOptions extends GenericModel { - - protected List folders; - protected List objects; - @SerializedName("site_collections") - protected List siteCollections; - protected List urls; - protected List buckets; - @SerializedName("crawl_all_buckets") - protected Boolean crawlAllBuckets; - - /** - * Builder. - */ - public static class Builder { - private List folders; - private List objects; - private List siteCollections; - private List urls; - private List buckets; - private Boolean crawlAllBuckets; - - private Builder(SourceOptions sourceOptions) { - this.folders = sourceOptions.folders; - this.objects = sourceOptions.objects; - this.siteCollections = sourceOptions.siteCollections; - this.urls = sourceOptions.urls; - this.buckets = sourceOptions.buckets; - this.crawlAllBuckets = sourceOptions.crawlAllBuckets; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a SourceOptions. - * - * @return the sourceOptions - */ - public SourceOptions build() { - return new SourceOptions(this); - } - - /** - * Adds an folders to folders. - * - * @param folders the new folders - * @return the SourceOptions builder - */ - public Builder addFolders(SourceOptionsFolder folders) { - com.ibm.cloud.sdk.core.util.Validator.notNull(folders, - "folders cannot be null"); - if (this.folders == null) { - this.folders = new ArrayList(); - } - this.folders.add(folders); - return this; - } - - /** - * Adds an objects to objects. - * - * @param objects the new objects - * @return the SourceOptions builder - */ - public Builder addObjects(SourceOptionsObject objects) { - com.ibm.cloud.sdk.core.util.Validator.notNull(objects, - "objects cannot be null"); - if (this.objects == null) { - this.objects = new ArrayList(); - } - this.objects.add(objects); - return this; - } - - /** - * Adds an siteCollections to siteCollections. - * - * @param siteCollections the new siteCollections - * @return the SourceOptions builder - */ - public Builder addSiteCollections(SourceOptionsSiteColl siteCollections) { - com.ibm.cloud.sdk.core.util.Validator.notNull(siteCollections, - "siteCollections cannot be null"); - if (this.siteCollections == null) { - this.siteCollections = new ArrayList(); - } - this.siteCollections.add(siteCollections); - return this; - } - - /** - * Adds an urls to urls. - * - * @param urls the new urls - * @return the SourceOptions builder - */ - public Builder addUrls(SourceOptionsWebCrawl urls) { - com.ibm.cloud.sdk.core.util.Validator.notNull(urls, - "urls cannot be null"); - if (this.urls == null) { - this.urls = new ArrayList(); - } - this.urls.add(urls); - return this; - } - - /** - * Adds an buckets to buckets. - * - * @param buckets the new buckets - * @return the SourceOptions builder - */ - public Builder addBuckets(SourceOptionsBuckets buckets) { - com.ibm.cloud.sdk.core.util.Validator.notNull(buckets, - "buckets cannot be null"); - if (this.buckets == null) { - this.buckets = new ArrayList(); - } - this.buckets.add(buckets); - return this; - } - - /** - * Set the folders. - * Existing folders will be replaced. - * - * @param folders the folders - * @return the SourceOptions builder - */ - public Builder folders(List folders) { - this.folders = folders; - return this; - } - - /** - * Set the objects. - * Existing objects will be replaced. - * - * @param objects the objects - * @return the SourceOptions builder - */ - public Builder objects(List objects) { - this.objects = objects; - return this; - } - - /** - * Set the siteCollections. - * Existing siteCollections will be replaced. - * - * @param siteCollections the siteCollections - * @return the SourceOptions builder - */ - public Builder siteCollections(List siteCollections) { - this.siteCollections = siteCollections; - return this; - } - - /** - * Set the urls. - * Existing urls will be replaced. - * - * @param urls the urls - * @return the SourceOptions builder - */ - public Builder urls(List urls) { - this.urls = urls; - return this; - } - - /** - * Set the buckets. - * Existing buckets will be replaced. - * - * @param buckets the buckets - * @return the SourceOptions builder - */ - public Builder buckets(List buckets) { - this.buckets = buckets; - return this; - } - - /** - * Set the crawlAllBuckets. - * - * @param crawlAllBuckets the crawlAllBuckets - * @return the SourceOptions builder - */ - public Builder crawlAllBuckets(Boolean crawlAllBuckets) { - this.crawlAllBuckets = crawlAllBuckets; - return this; - } - } - - protected SourceOptions(Builder builder) { - folders = builder.folders; - objects = builder.objects; - siteCollections = builder.siteCollections; - urls = builder.urls; - buckets = builder.buckets; - crawlAllBuckets = builder.crawlAllBuckets; - } - - /** - * New builder. - * - * @return a SourceOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the folders. - * - * Array of folders to crawl from the Box source. Only valid, and required, when the **type** field of the **source** - * object is set to `box`. - * - * @return the folders - */ - public List folders() { - return folders; - } - - /** - * Gets the objects. - * - * Array of Salesforce document object types to crawl from the Salesforce source. Only valid, and required, when the - * **type** field of the **source** object is set to `salesforce`. - * - * @return the objects - */ - public List objects() { - return objects; - } - - /** - * Gets the siteCollections. - * - * Array of Microsoft SharePointoint Online site collections to crawl from the SharePoint source. Only valid and - * required when the **type** field of the **source** object is set to `sharepoint`. - * - * @return the siteCollections - */ - public List siteCollections() { - return siteCollections; - } - - /** - * Gets the urls. - * - * Array of Web page URLs to begin crawling the web from. Only valid and required when the **type** field of the - * **source** object is set to `web_crawl`. - * - * @return the urls - */ - public List urls() { - return urls; - } - - /** - * Gets the buckets. - * - * Array of cloud object store buckets to begin crawling. Only valid and required when the **type** field of the - * **source** object is set to `cloud_object_store`, and the **crawl_all_buckets** field is `false` or not specified. - * - * @return the buckets - */ - public List buckets() { - return buckets; - } - - /** - * Gets the crawlAllBuckets. - * - * When `true`, all buckets in the specified cloud object store are crawled. If set to `true`, the **buckets** array - * must not be specified. - * - * @return the crawlAllBuckets - */ - public Boolean crawlAllBuckets() { - return crawlAllBuckets; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java deleted file mode 100644 index 489daffe975..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object defining a cloud object store bucket to crawl. - */ -public class SourceOptionsBuckets extends GenericModel { - - protected String name; - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private String name; - private Long limit; - - private Builder(SourceOptionsBuckets sourceOptionsBuckets) { - this.name = sourceOptionsBuckets.name; - this.limit = sourceOptionsBuckets.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this.name = name; - } - - /** - * Builds a SourceOptionsBuckets. - * - * @return the sourceOptionsBuckets - */ - public SourceOptionsBuckets build() { - return new SourceOptionsBuckets(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the SourceOptionsBuckets builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the SourceOptionsBuckets builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected SourceOptionsBuckets(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - name = builder.name; - limit = builder.limit; - } - - /** - * New builder. - * - * @return a SourceOptionsBuckets builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * The name of the cloud object store bucket to crawl. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the limit. - * - * The number of documents to crawl from this cloud object store bucket. If not specified, all documents in the bucket - * are crawled. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java deleted file mode 100644 index 3fa3bd6fdc0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object that defines a box folder to crawl with this configuration. - */ -public class SourceOptionsFolder extends GenericModel { - - @SerializedName("owner_user_id") - protected String ownerUserId; - @SerializedName("folder_id") - protected String folderId; - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private String ownerUserId; - private String folderId; - private Long limit; - - private Builder(SourceOptionsFolder sourceOptionsFolder) { - this.ownerUserId = sourceOptionsFolder.ownerUserId; - this.folderId = sourceOptionsFolder.folderId; - this.limit = sourceOptionsFolder.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param ownerUserId the ownerUserId - * @param folderId the folderId - */ - public Builder(String ownerUserId, String folderId) { - this.ownerUserId = ownerUserId; - this.folderId = folderId; - } - - /** - * Builds a SourceOptionsFolder. - * - * @return the sourceOptionsFolder - */ - public SourceOptionsFolder build() { - return new SourceOptionsFolder(this); - } - - /** - * Set the ownerUserId. - * - * @param ownerUserId the ownerUserId - * @return the SourceOptionsFolder builder - */ - public Builder ownerUserId(String ownerUserId) { - this.ownerUserId = ownerUserId; - return this; - } - - /** - * Set the folderId. - * - * @param folderId the folderId - * @return the SourceOptionsFolder builder - */ - public Builder folderId(String folderId) { - this.folderId = folderId; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the SourceOptionsFolder builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected SourceOptionsFolder(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.ownerUserId, - "ownerUserId cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.folderId, - "folderId cannot be null"); - ownerUserId = builder.ownerUserId; - folderId = builder.folderId; - limit = builder.limit; - } - - /** - * New builder. - * - * @return a SourceOptionsFolder builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the ownerUserId. - * - * The Box user ID of the user who owns the folder to crawl. - * - * @return the ownerUserId - */ - public String ownerUserId() { - return ownerUserId; - } - - /** - * Gets the folderId. - * - * The Box folder ID of the folder to crawl. - * - * @return the folderId - */ - public String folderId() { - return folderId; - } - - /** - * Gets the limit. - * - * The maximum number of documents to crawl for this folder. By default, all documents in the folder are crawled. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java deleted file mode 100644 index f2557ddf976..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object that defines a Salesforce document object type crawl with this configuration. - */ -public class SourceOptionsObject extends GenericModel { - - protected String name; - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private String name; - private Long limit; - - private Builder(SourceOptionsObject sourceOptionsObject) { - this.name = sourceOptionsObject.name; - this.limit = sourceOptionsObject.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this.name = name; - } - - /** - * Builds a SourceOptionsObject. - * - * @return the sourceOptionsObject - */ - public SourceOptionsObject build() { - return new SourceOptionsObject(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the SourceOptionsObject builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the SourceOptionsObject builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected SourceOptionsObject(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - name = builder.name; - limit = builder.limit; - } - - /** - * New builder. - * - * @return a SourceOptionsObject builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * The name of the Salesforce document object to crawl. For example, `case`. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the limit. - * - * The maximum number of documents to crawl for this document object. By default, all documents in the document object - * are crawled. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java deleted file mode 100644 index cb7a41b9fef..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object that defines a Microsoft SharePoint site collection to crawl with this configuration. - */ -public class SourceOptionsSiteColl extends GenericModel { - - @SerializedName("site_collection_path") - protected String siteCollectionPath; - protected Long limit; - - /** - * Builder. - */ - public static class Builder { - private String siteCollectionPath; - private Long limit; - - private Builder(SourceOptionsSiteColl sourceOptionsSiteColl) { - this.siteCollectionPath = sourceOptionsSiteColl.siteCollectionPath; - this.limit = sourceOptionsSiteColl.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param siteCollectionPath the siteCollectionPath - */ - public Builder(String siteCollectionPath) { - this.siteCollectionPath = siteCollectionPath; - } - - /** - * Builds a SourceOptionsSiteColl. - * - * @return the sourceOptionsSiteColl - */ - public SourceOptionsSiteColl build() { - return new SourceOptionsSiteColl(this); - } - - /** - * Set the siteCollectionPath. - * - * @param siteCollectionPath the siteCollectionPath - * @return the SourceOptionsSiteColl builder - */ - public Builder siteCollectionPath(String siteCollectionPath) { - this.siteCollectionPath = siteCollectionPath; - return this; - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the SourceOptionsSiteColl builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - protected SourceOptionsSiteColl(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.siteCollectionPath, - "siteCollectionPath cannot be null"); - siteCollectionPath = builder.siteCollectionPath; - limit = builder.limit; - } - - /** - * New builder. - * - * @return a SourceOptionsSiteColl builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the siteCollectionPath. - * - * The Microsoft SharePoint Online site collection path to crawl. The path must be be relative to the - * **organization_url** that was specified in the credentials associated with this source configuration. - * - * @return the siteCollectionPath - */ - public String siteCollectionPath() { - return siteCollectionPath; - } - - /** - * Gets the limit. - * - * The maximum number of documents to crawl for this site collection. By default, all documents in the site collection - * are crawled. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java deleted file mode 100644 index 18c7170c3ea..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object defining which URL to crawl and how to crawl it. - */ -public class SourceOptionsWebCrawl extends GenericModel { - - /** - * The number of concurrent URLs to fetch. `gentle` means one URL is fetched at a time with a delay between each call. - * `normal` means as many as two URLs are fectched concurrently with a short delay between fetch calls. `aggressive` - * means that up to ten URLs are fetched concurrently with a short delay between fetch calls. - */ - public interface CrawlSpeed { - /** gentle. */ - String GENTLE = "gentle"; - /** normal. */ - String NORMAL = "normal"; - /** aggressive. */ - String AGGRESSIVE = "aggressive"; - } - - protected String url; - @SerializedName("limit_to_starting_hosts") - protected Boolean limitToStartingHosts; - @SerializedName("crawl_speed") - protected String crawlSpeed; - @SerializedName("allow_untrusted_certificate") - protected Boolean allowUntrustedCertificate; - @SerializedName("maximum_hops") - protected Long maximumHops; - @SerializedName("request_timeout") - protected Long requestTimeout; - @SerializedName("override_robots_txt") - protected Boolean overrideRobotsTxt; - protected List blacklist; - - /** - * Builder. - */ - public static class Builder { - private String url; - private Boolean limitToStartingHosts; - private String crawlSpeed; - private Boolean allowUntrustedCertificate; - private Long maximumHops; - private Long requestTimeout; - private Boolean overrideRobotsTxt; - private List blacklist; - - private Builder(SourceOptionsWebCrawl sourceOptionsWebCrawl) { - this.url = sourceOptionsWebCrawl.url; - this.limitToStartingHosts = sourceOptionsWebCrawl.limitToStartingHosts; - this.crawlSpeed = sourceOptionsWebCrawl.crawlSpeed; - this.allowUntrustedCertificate = sourceOptionsWebCrawl.allowUntrustedCertificate; - this.maximumHops = sourceOptionsWebCrawl.maximumHops; - this.requestTimeout = sourceOptionsWebCrawl.requestTimeout; - this.overrideRobotsTxt = sourceOptionsWebCrawl.overrideRobotsTxt; - this.blacklist = sourceOptionsWebCrawl.blacklist; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param url the url - */ - public Builder(String url) { - this.url = url; - } - - /** - * Builds a SourceOptionsWebCrawl. - * - * @return the sourceOptionsWebCrawl - */ - public SourceOptionsWebCrawl build() { - return new SourceOptionsWebCrawl(this); - } - - /** - * Adds an blacklist to blacklist. - * - * @param blacklist the new blacklist - * @return the SourceOptionsWebCrawl builder - */ - public Builder addBlacklist(String blacklist) { - com.ibm.cloud.sdk.core.util.Validator.notNull(blacklist, - "blacklist cannot be null"); - if (this.blacklist == null) { - this.blacklist = new ArrayList(); - } - this.blacklist.add(blacklist); - return this; - } - - /** - * Set the url. - * - * @param url the url - * @return the SourceOptionsWebCrawl builder - */ - public Builder url(String url) { - this.url = url; - return this; - } - - /** - * Set the limitToStartingHosts. - * - * @param limitToStartingHosts the limitToStartingHosts - * @return the SourceOptionsWebCrawl builder - */ - public Builder limitToStartingHosts(Boolean limitToStartingHosts) { - this.limitToStartingHosts = limitToStartingHosts; - return this; - } - - /** - * Set the crawlSpeed. - * - * @param crawlSpeed the crawlSpeed - * @return the SourceOptionsWebCrawl builder - */ - public Builder crawlSpeed(String crawlSpeed) { - this.crawlSpeed = crawlSpeed; - return this; - } - - /** - * Set the allowUntrustedCertificate. - * - * @param allowUntrustedCertificate the allowUntrustedCertificate - * @return the SourceOptionsWebCrawl builder - */ - public Builder allowUntrustedCertificate(Boolean allowUntrustedCertificate) { - this.allowUntrustedCertificate = allowUntrustedCertificate; - return this; - } - - /** - * Set the maximumHops. - * - * @param maximumHops the maximumHops - * @return the SourceOptionsWebCrawl builder - */ - public Builder maximumHops(long maximumHops) { - this.maximumHops = maximumHops; - return this; - } - - /** - * Set the requestTimeout. - * - * @param requestTimeout the requestTimeout - * @return the SourceOptionsWebCrawl builder - */ - public Builder requestTimeout(long requestTimeout) { - this.requestTimeout = requestTimeout; - return this; - } - - /** - * Set the overrideRobotsTxt. - * - * @param overrideRobotsTxt the overrideRobotsTxt - * @return the SourceOptionsWebCrawl builder - */ - public Builder overrideRobotsTxt(Boolean overrideRobotsTxt) { - this.overrideRobotsTxt = overrideRobotsTxt; - return this; - } - - /** - * Set the blacklist. - * Existing blacklist will be replaced. - * - * @param blacklist the blacklist - * @return the SourceOptionsWebCrawl builder - */ - public Builder blacklist(List blacklist) { - this.blacklist = blacklist; - return this; - } - } - - protected SourceOptionsWebCrawl(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.url, - "url cannot be null"); - url = builder.url; - limitToStartingHosts = builder.limitToStartingHosts; - crawlSpeed = builder.crawlSpeed; - allowUntrustedCertificate = builder.allowUntrustedCertificate; - maximumHops = builder.maximumHops; - requestTimeout = builder.requestTimeout; - overrideRobotsTxt = builder.overrideRobotsTxt; - blacklist = builder.blacklist; - } - - /** - * New builder. - * - * @return a SourceOptionsWebCrawl builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the url. - * - * The starting URL to crawl. - * - * @return the url - */ - public String url() { - return url; - } - - /** - * Gets the limitToStartingHosts. - * - * When `true`, crawls of the specified URL are limited to the host part of the **url** field. - * - * @return the limitToStartingHosts - */ - public Boolean limitToStartingHosts() { - return limitToStartingHosts; - } - - /** - * Gets the crawlSpeed. - * - * The number of concurrent URLs to fetch. `gentle` means one URL is fetched at a time with a delay between each call. - * `normal` means as many as two URLs are fectched concurrently with a short delay between fetch calls. `aggressive` - * means that up to ten URLs are fetched concurrently with a short delay between fetch calls. - * - * @return the crawlSpeed - */ - public String crawlSpeed() { - return crawlSpeed; - } - - /** - * Gets the allowUntrustedCertificate. - * - * When `true`, allows the crawl to interact with HTTPS sites with SSL certificates with untrusted signers. - * - * @return the allowUntrustedCertificate - */ - public Boolean allowUntrustedCertificate() { - return allowUntrustedCertificate; - } - - /** - * Gets the maximumHops. - * - * The maximum number of hops to make from the initial URL. When a page is crawled each link on that page will also be - * crawled if it is within the **maximum_hops** from the initial URL. The first page crawled is 0 hops, each link - * crawled from the first page is 1 hop, each link crawled from those pages is 2 hops, and so on. - * - * @return the maximumHops - */ - public Long maximumHops() { - return maximumHops; - } - - /** - * Gets the requestTimeout. - * - * The maximum milliseconds to wait for a response from the web server. - * - * @return the requestTimeout - */ - public Long requestTimeout() { - return requestTimeout; - } - - /** - * Gets the overrideRobotsTxt. - * - * When `true`, the crawler will ignore any `robots.txt` encountered by the crawler. This should only ever be done - * when crawling a web site the user owns. This must be be set to `true` when a **gateway_id** is specied in the - * **credentials**. - * - * @return the overrideRobotsTxt - */ - public Boolean overrideRobotsTxt() { - return overrideRobotsTxt; - } - - /** - * Gets the blacklist. - * - * Array of URL's to be excluded while crawling. The crawler will not follow links which contains this string. For - * example, listing `https://ibm.com/watson` also excludes `https://ibm.com/watson/discovery`. - * - * @return the blacklist - */ - public List blacklist() { - return blacklist; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java deleted file mode 100644 index fe40491c6ec..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing the schedule information for the source. - */ -public class SourceSchedule extends GenericModel { - - /** - * The crawl schedule in the specified **time_zone**. - * - * - `five_minutes`: Runs every five minutes. - * - `hourly`: Runs every hour. - * - `daily`: Runs every day between 00:00 and 06:00. - * - `weekly`: Runs every week on Sunday between 00:00 and 06:00. - * - `monthly`: Runs the on the first Sunday of every month between 00:00 and 06:00. - */ - public interface Frequency { - /** daily. */ - String DAILY = "daily"; - /** weekly. */ - String WEEKLY = "weekly"; - /** monthly. */ - String MONTHLY = "monthly"; - /** five_minutes. */ - String FIVE_MINUTES = "five_minutes"; - /** hourly. */ - String HOURLY = "hourly"; - } - - protected Boolean enabled; - @SerializedName("time_zone") - protected String timeZone; - protected String frequency; - - /** - * Builder. - */ - public static class Builder { - private Boolean enabled; - private String timeZone; - private String frequency; - - private Builder(SourceSchedule sourceSchedule) { - this.enabled = sourceSchedule.enabled; - this.timeZone = sourceSchedule.timeZone; - this.frequency = sourceSchedule.frequency; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a SourceSchedule. - * - * @return the sourceSchedule - */ - public SourceSchedule build() { - return new SourceSchedule(this); - } - - /** - * Set the enabled. - * - * @param enabled the enabled - * @return the SourceSchedule builder - */ - public Builder enabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Set the timeZone. - * - * @param timeZone the timeZone - * @return the SourceSchedule builder - */ - public Builder timeZone(String timeZone) { - this.timeZone = timeZone; - return this; - } - - /** - * Set the frequency. - * - * @param frequency the frequency - * @return the SourceSchedule builder - */ - public Builder frequency(String frequency) { - this.frequency = frequency; - return this; - } - } - - protected SourceSchedule(Builder builder) { - enabled = builder.enabled; - timeZone = builder.timeZone; - frequency = builder.frequency; - } - - /** - * New builder. - * - * @return a SourceSchedule builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the enabled. - * - * When `true`, the source is re-crawled based on the **frequency** field in this object. When `false` the source is - * not re-crawled; When `false` and connecting to Salesforce the source is crawled annually. - * - * @return the enabled - */ - public Boolean enabled() { - return enabled; - } - - /** - * Gets the timeZone. - * - * The time zone to base source crawl times on. Possible values correspond to the IANA (Internet Assigned Numbers - * Authority) time zones list. - * - * @return the timeZone - */ - public String timeZone() { - return timeZone; - } - - /** - * Gets the frequency. - * - * The crawl schedule in the specified **time_zone**. - * - * - `five_minutes`: Runs every five minutes. - * - `hourly`: Runs every hour. - * - `daily`: Runs every day between 00:00 and 06:00. - * - `weekly`: Runs every week on Sunday between 00:00 and 06:00. - * - `monthly`: Runs the on the first Sunday of every month between 00:00 and 06:00. - * - * @return the frequency - */ - public String frequency() { - return frequency; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java deleted file mode 100644 index ea720b3bc50..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing source crawl status information. - */ -public class SourceStatus extends GenericModel { - - /** - * The current status of the source crawl for this collection. This field returns `not_configured` if the default - * configuration for this source does not have a **source** object defined. - * - * - `running` indicates that a crawl to fetch more documents is in progress. - * - `complete` indicates that the crawl has completed with no errors. - * - `queued` indicates that the crawl has been paused by the system and will automatically restart when possible. - * - `unknown` indicates that an unidentified error has occured in the service. - */ - public interface Status { - /** running. */ - String RUNNING = "running"; - /** complete. */ - String COMPLETE = "complete"; - /** not_configured. */ - String NOT_CONFIGURED = "not_configured"; - /** queued. */ - String QUEUED = "queued"; - /** unknown. */ - String UNKNOWN = "unknown"; - } - - protected String status; - @SerializedName("next_crawl") - protected Date nextCrawl; - - /** - * Gets the status. - * - * The current status of the source crawl for this collection. This field returns `not_configured` if the default - * configuration for this source does not have a **source** object defined. - * - * - `running` indicates that a crawl to fetch more documents is in progress. - * - `complete` indicates that the crawl has completed with no errors. - * - `queued` indicates that the crawl has been paused by the system and will automatically restart when possible. - * - `unknown` indicates that an unidentified error has occured in the service. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the nextCrawl. - * - * Date in `RFC 3339` format indicating the time of the next crawl attempt. - * - * @return the nextCrawl - */ - public Date getNextCrawl() { - return nextCrawl; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java deleted file mode 100644 index 27edec32204..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -/** - * Term. - */ -public class Term extends QueryAggregation { - - protected String field; - protected Long count; - - /** - * Gets the field. - * - * The field where the aggregation is located in the document. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the count. - * - * The number of terms identified. - * - * @return the count - */ - public Long getCount() { - return count; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java deleted file mode 100644 index c779e2f70f3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -/** - * Timeslice. - */ -public class Timeslice extends QueryAggregation { - - protected String field; - protected String interval; - protected Boolean anomaly; - - /** - * Gets the field. - * - * The field where the aggregation is located in the document. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the interval. - * - * Interval of the aggregation. Valid date interval values are second/seconds minute/minutes, hour/hours, day/days, - * week/weeks, month/months, and year/years. - * - * @return the interval - */ - public String getInterval() { - return interval; - } - - /** - * Gets the anomaly. - * - * Used to indicate that anomaly detection should be performed. Anomaly detection is used to locate unusual datapoints - * within a time series. - * - * @return the anomaly - */ - public Boolean isAnomaly() { - return anomaly; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java deleted file mode 100644 index 436aa5b093c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An object defining a single tokenizaion rule. - */ -public class TokenDictRule extends GenericModel { - - protected String text; - protected List tokens; - protected List readings; - @SerializedName("part_of_speech") - protected String partOfSpeech; - - /** - * Builder. - */ - public static class Builder { - private String text; - private List tokens; - private List readings; - private String partOfSpeech; - - private Builder(TokenDictRule tokenDictRule) { - this.text = tokenDictRule.text; - this.tokens = tokenDictRule.tokens; - this.readings = tokenDictRule.readings; - this.partOfSpeech = tokenDictRule.partOfSpeech; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param text the text - * @param tokens the tokens - * @param partOfSpeech the partOfSpeech - */ - public Builder(String text, List tokens, String partOfSpeech) { - this.text = text; - this.tokens = tokens; - this.partOfSpeech = partOfSpeech; - } - - /** - * Builds a TokenDictRule. - * - * @return the tokenDictRule - */ - public TokenDictRule build() { - return new TokenDictRule(this); - } - - /** - * Adds an tokens to tokens. - * - * @param tokens the new tokens - * @return the TokenDictRule builder - */ - public Builder addTokens(String tokens) { - com.ibm.cloud.sdk.core.util.Validator.notNull(tokens, - "tokens cannot be null"); - if (this.tokens == null) { - this.tokens = new ArrayList(); - } - this.tokens.add(tokens); - return this; - } - - /** - * Adds an readings to readings. - * - * @param readings the new readings - * @return the TokenDictRule builder - */ - public Builder addReadings(String readings) { - com.ibm.cloud.sdk.core.util.Validator.notNull(readings, - "readings cannot be null"); - if (this.readings == null) { - this.readings = new ArrayList(); - } - this.readings.add(readings); - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the TokenDictRule builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the tokens. - * Existing tokens will be replaced. - * - * @param tokens the tokens - * @return the TokenDictRule builder - */ - public Builder tokens(List tokens) { - this.tokens = tokens; - return this; - } - - /** - * Set the readings. - * Existing readings will be replaced. - * - * @param readings the readings - * @return the TokenDictRule builder - */ - public Builder readings(List readings) { - this.readings = readings; - return this; - } - - /** - * Set the partOfSpeech. - * - * @param partOfSpeech the partOfSpeech - * @return the TokenDictRule builder - */ - public Builder partOfSpeech(String partOfSpeech) { - this.partOfSpeech = partOfSpeech; - return this; - } - } - - protected TokenDictRule(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.tokens, - "tokens cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.partOfSpeech, - "partOfSpeech cannot be null"); - text = builder.text; - tokens = builder.tokens; - readings = builder.readings; - partOfSpeech = builder.partOfSpeech; - } - - /** - * New builder. - * - * @return a TokenDictRule builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * The string to tokenize. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the tokens. - * - * Array of tokens that the `text` field is split into when found. - * - * @return the tokens - */ - public List tokens() { - return tokens; - } - - /** - * Gets the readings. - * - * Array of tokens that represent the content of the `text` field in an alternate character set. - * - * @return the readings - */ - public List readings() { - return readings; - } - - /** - * Gets the partOfSpeech. - * - * The part of speech that the `text` string belongs to. For example `noun`. Custom parts of speech can be specified. - * - * @return the partOfSpeech - */ - public String partOfSpeech() { - return partOfSpeech; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java deleted file mode 100644 index b08c145b88c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object describing the current status of the wordlist. - */ -public class TokenDictStatusResponse extends GenericModel { - - /** - * Current wordlist status for the specified collection. - */ - public interface Status { - /** active. */ - String ACTIVE = "active"; - /** pending. */ - String PENDING = "pending"; - /** not found. */ - String NOT_FOUND = "not found"; - } - - protected String status; - protected String type; - - /** - * Gets the status. - * - * Current wordlist status for the specified collection. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the type. - * - * The type for this wordlist. Can be `tokenization_dictionary` or `stopwords`. - * - * @return the type - */ - public String getType() { - return type; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java deleted file mode 100644 index 4310ad10077..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -/** - * TopHits. - */ -public class TopHits extends QueryAggregation { - - protected Long size; - protected TopHitsResults hits; - - /** - * Gets the size. - * - * Number of top hits returned by the aggregation. - * - * @return the size - */ - public Long getSize() { - return size; - } - - /** - * Gets the hits. - * - * @return the hits - */ - public TopHitsResults getHits() { - return hits; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java deleted file mode 100644 index 89df6f8784a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Top hit information for this query. - */ -public class TopHitsResults extends GenericModel { - - @SerializedName("matching_results") - protected Long matchingResults; - protected List hits; - - /** - * Gets the matchingResults. - * - * Number of matching results. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the hits. - * - * Top results returned by the aggregation. - * - * @return the hits - */ - public List getHits() { - return hits; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java deleted file mode 100644 index 6b4416a391e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training information for a specific collection. - */ -public class TrainingDataSet extends GenericModel { - - @SerializedName("environment_id") - protected String environmentId; - @SerializedName("collection_id") - protected String collectionId; - protected List queries; - - /** - * Gets the environmentId. - * - * The environment id associated with this training data set. - * - * @return the environmentId - */ - public String getEnvironmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The collection id associated with this training data set. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } - - /** - * Gets the queries. - * - * Array of training queries. - * - * @return the queries - */ - public List getQueries() { - return queries; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java deleted file mode 100644 index 2e803b6e13f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training example details. - */ -public class TrainingExample extends GenericModel { - - @SerializedName("document_id") - protected String documentId; - @SerializedName("cross_reference") - protected String crossReference; - protected Long relevance; - - /** - * Builder. - */ - public static class Builder { - private String documentId; - private String crossReference; - private Long relevance; - - private Builder(TrainingExample trainingExample) { - this.documentId = trainingExample.documentId; - this.crossReference = trainingExample.crossReference; - this.relevance = trainingExample.relevance; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a TrainingExample. - * - * @return the trainingExample - */ - public TrainingExample build() { - return new TrainingExample(this); - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the TrainingExample builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - - /** - * Set the crossReference. - * - * @param crossReference the crossReference - * @return the TrainingExample builder - */ - public Builder crossReference(String crossReference) { - this.crossReference = crossReference; - return this; - } - - /** - * Set the relevance. - * - * @param relevance the relevance - * @return the TrainingExample builder - */ - public Builder relevance(long relevance) { - this.relevance = relevance; - return this; - } - } - - protected TrainingExample(Builder builder) { - documentId = builder.documentId; - crossReference = builder.crossReference; - relevance = builder.relevance; - } - - /** - * New builder. - * - * @return a TrainingExample builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the documentId. - * - * The document ID associated with this training example. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } - - /** - * Gets the crossReference. - * - * The cross reference associated with this training example. - * - * @return the crossReference - */ - public String crossReference() { - return crossReference; - } - - /** - * Gets the relevance. - * - * The relevance of the training example. - * - * @return the relevance - */ - public Long relevance() { - return relevance; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java deleted file mode 100644 index e02b9f6ab3d..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing an array of training examples. - */ -public class TrainingExampleList extends GenericModel { - - protected List examples; - - /** - * Gets the examples. - * - * Array of training examples. - * - * @return the examples - */ - public List getExamples() { - return examples; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java deleted file mode 100644 index b1070730df8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training query details. - */ -public class TrainingQuery extends GenericModel { - - @SerializedName("query_id") - protected String queryId; - @SerializedName("natural_language_query") - protected String naturalLanguageQuery; - protected String filter; - protected List examples; - - /** - * Gets the queryId. - * - * The query ID associated with the training query. - * - * @return the queryId - */ - public String getQueryId() { - return queryId; - } - - /** - * Gets the naturalLanguageQuery. - * - * The natural text query for the training query. - * - * @return the naturalLanguageQuery - */ - public String getNaturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the filter. - * - * The filter used on the collection before the **natural_language_query** is applied. - * - * @return the filter - */ - public String getFilter() { - return filter; - } - - /** - * Gets the examples. - * - * Array of training examples. - * - * @return the examples - */ - public List getExamples() { - return examples; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java deleted file mode 100644 index 642fe44cdef..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training status details. - */ -public class TrainingStatus extends GenericModel { - - @SerializedName("total_examples") - protected Long totalExamples; - protected Boolean available; - protected Boolean processing; - @SerializedName("minimum_queries_added") - protected Boolean minimumQueriesAdded; - @SerializedName("minimum_examples_added") - protected Boolean minimumExamplesAdded; - @SerializedName("sufficient_label_diversity") - protected Boolean sufficientLabelDiversity; - protected Long notices; - @SerializedName("successfully_trained") - protected Date successfullyTrained; - @SerializedName("data_updated") - protected Date dataUpdated; - - /** - * Gets the totalExamples. - * - * The total number of training examples uploaded to this collection. - * - * @return the totalExamples - */ - public Long getTotalExamples() { - return totalExamples; - } - - /** - * Gets the available. - * - * When `true`, the collection has been successfully trained. - * - * @return the available - */ - public Boolean isAvailable() { - return available; - } - - /** - * Gets the processing. - * - * When `true`, the collection is currently processing training. - * - * @return the processing - */ - public Boolean isProcessing() { - return processing; - } - - /** - * Gets the minimumQueriesAdded. - * - * When `true`, the collection has a sufficent amount of queries added for training to occur. - * - * @return the minimumQueriesAdded - */ - public Boolean isMinimumQueriesAdded() { - return minimumQueriesAdded; - } - - /** - * Gets the minimumExamplesAdded. - * - * When `true`, the collection has a sufficent amount of examples added for training to occur. - * - * @return the minimumExamplesAdded - */ - public Boolean isMinimumExamplesAdded() { - return minimumExamplesAdded; - } - - /** - * Gets the sufficientLabelDiversity. - * - * When `true`, the collection has a sufficent amount of diversity in labeled results for training to occur. - * - * @return the sufficientLabelDiversity - */ - public Boolean isSufficientLabelDiversity() { - return sufficientLabelDiversity; - } - - /** - * Gets the notices. - * - * The number of notices associated with this data set. - * - * @return the notices - */ - public Long getNotices() { - return notices; - } - - /** - * Gets the successfullyTrained. - * - * The timestamp of when the collection was successfully trained. - * - * @return the successfullyTrained - */ - public Date getSuccessfullyTrained() { - return successfullyTrained; - } - - /** - * Gets the dataUpdated. - * - * The timestamp of when the data was uploaded. - * - * @return the dataUpdated - */ - public Date getDataUpdated() { - return dataUpdated; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java deleted file mode 100644 index 8a9a67bfd50..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateCollection options. - */ -public class UpdateCollectionOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String name; - protected String description; - protected String configurationId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String name; - private String description; - private String configurationId; - - private Builder(UpdateCollectionOptions updateCollectionOptions) { - this.environmentId = updateCollectionOptions.environmentId; - this.collectionId = updateCollectionOptions.collectionId; - this.name = updateCollectionOptions.name; - this.description = updateCollectionOptions.description; - this.configurationId = updateCollectionOptions.configurationId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param name the name - */ - public Builder(String environmentId, String collectionId, String name) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.name = name; - } - - /** - * Builds a UpdateCollectionOptions. - * - * @return the updateCollectionOptions - */ - public UpdateCollectionOptions build() { - return new UpdateCollectionOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the UpdateCollectionOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the UpdateCollectionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateCollectionOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateCollectionOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the UpdateCollectionOptions builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - } - - protected UpdateCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - name = builder.name; - description = builder.description; - configurationId = builder.configurationId; - } - - /** - * New builder. - * - * @return a UpdateCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the name. - * - * The name of the collection. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * A description of the collection. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the configurationId. - * - * The ID of the configuration in which the collection is to be updated. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java deleted file mode 100644 index ad45797cf71..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateConfiguration options. - */ -public class UpdateConfigurationOptions extends GenericModel { - - protected String environmentId; - protected String configurationId; - protected String name; - protected String description; - protected Conversions conversions; - protected List enrichments; - protected List normalizations; - protected Source source; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String configurationId; - private String name; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - private Source source; - - private Builder(UpdateConfigurationOptions updateConfigurationOptions) { - this.environmentId = updateConfigurationOptions.environmentId; - this.configurationId = updateConfigurationOptions.configurationId; - this.name = updateConfigurationOptions.name; - this.description = updateConfigurationOptions.description; - this.conversions = updateConfigurationOptions.conversions; - this.enrichments = updateConfigurationOptions.enrichments; - this.normalizations = updateConfigurationOptions.normalizations; - this.source = updateConfigurationOptions.source; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param configurationId the configurationId - * @param name the name - */ - public Builder(String environmentId, String configurationId, String name) { - this.environmentId = environmentId; - this.configurationId = configurationId; - this.name = name; - } - - /** - * Builds a UpdateConfigurationOptions. - * - * @return the updateConfigurationOptions - */ - public UpdateConfigurationOptions build() { - return new UpdateConfigurationOptions(this); - } - - /** - * Adds an enrichment to enrichments. - * - * @param enrichment the new enrichment - * @return the UpdateConfigurationOptions builder - */ - public Builder addEnrichment(Enrichment enrichment) { - com.ibm.cloud.sdk.core.util.Validator.notNull(enrichment, - "enrichment cannot be null"); - if (this.enrichments == null) { - this.enrichments = new ArrayList(); - } - this.enrichments.add(enrichment); - return this; - } - - /** - * Adds an normalization to normalizations. - * - * @param normalization the new normalization - * @return the UpdateConfigurationOptions builder - */ - public Builder addNormalization(NormalizationOperation normalization) { - com.ibm.cloud.sdk.core.util.Validator.notNull(normalization, - "normalization cannot be null"); - if (this.normalizations == null) { - this.normalizations = new ArrayList(); - } - this.normalizations.add(normalization); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the UpdateConfigurationOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the UpdateConfigurationOptions builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateConfigurationOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateConfigurationOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conversions. - * - * @param conversions the conversions - * @return the UpdateConfigurationOptions builder - */ - public Builder conversions(Conversions conversions) { - this.conversions = conversions; - return this; - } - - /** - * Set the enrichments. - * Existing enrichments will be replaced. - * - * @param enrichments the enrichments - * @return the UpdateConfigurationOptions builder - */ - public Builder enrichments(List enrichments) { - this.enrichments = enrichments; - return this; - } - - /** - * Set the normalizations. - * Existing normalizations will be replaced. - * - * @param normalizations the normalizations - * @return the UpdateConfigurationOptions builder - */ - public Builder normalizations(List normalizations) { - this.normalizations = normalizations; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the UpdateConfigurationOptions builder - */ - public Builder source(Source source) { - this.source = source; - return this; - } - - /** - * Set the configuration. - * - * @param configuration the configuration - * @return the UpdateConfigurationOptions builder - */ - public Builder configuration(Configuration configuration) { - this.name = configuration.name(); - this.description = configuration.description(); - this.conversions = configuration.conversions(); - this.enrichments = configuration.enrichments(); - this.normalizations = configuration.normalizations(); - this.source = configuration.source(); - return this; - } - } - - protected UpdateConfigurationOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.configurationId, - "configurationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - environmentId = builder.environmentId; - configurationId = builder.configurationId; - name = builder.name; - description = builder.description; - conversions = builder.conversions; - enrichments = builder.enrichments; - normalizations = builder.normalizations; - source = builder.source; - } - - /** - * New builder. - * - * @return a UpdateConfigurationOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the configurationId. - * - * The ID of the configuration. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } - - /** - * Gets the name. - * - * The name of the configuration. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * The description of the configuration, if available. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the conversions. - * - * Document conversion settings. - * - * @return the conversions - */ - public Conversions conversions() { - return conversions; - } - - /** - * Gets the enrichments. - * - * An array of document enrichment settings for the configuration. - * - * @return the enrichments - */ - public List enrichments() { - return enrichments; - } - - /** - * Gets the normalizations. - * - * Defines operations that can be used to transform the final output JSON into a normalized form. Operations are - * executed in the order that they appear in the array. - * - * @return the normalizations - */ - public List normalizations() { - return normalizations; - } - - /** - * Gets the source. - * - * Object containing source parameters for the configuration. - * - * @return the source - */ - public Source source() { - return source; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java deleted file mode 100644 index 69870b2ede0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateCredentials options. - */ -public class UpdateCredentialsOptions extends GenericModel { - - /** - * The source that this credentials object connects to. - * - `box` indicates the credentials are used to connect an instance of Enterprise Box. - * - `salesforce` indicates the credentials are used to connect to Salesforce. - * - `sharepoint` indicates the credentials are used to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the credentials are used to perform a web crawl. - * = `cloud_object_storage` indicates the credentials are used to connect to an IBM Cloud Object Store. - */ - public interface SourceType { - /** box. */ - String BOX = "box"; - /** salesforce. */ - String SALESFORCE = "salesforce"; - /** sharepoint. */ - String SHAREPOINT = "sharepoint"; - /** web_crawl. */ - String WEB_CRAWL = "web_crawl"; - /** cloud_object_storage. */ - String CLOUD_OBJECT_STORAGE = "cloud_object_storage"; - } - - /** - * The current status of this set of credentials. `connected` indicates that the credentials are available to use with - * the source configuration of a collection. `invalid` refers to the credentials (for example, the password provided - * has expired) and must be corrected before they can be used with a collection. - */ - public interface Status { - /** connected. */ - String CONNECTED = "connected"; - /** invalid. */ - String INVALID = "invalid"; - } - - protected String environmentId; - protected String credentialId; - protected String sourceType; - protected CredentialDetails credentialDetails; - protected String status; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String credentialId; - private String sourceType; - private CredentialDetails credentialDetails; - private String status; - - private Builder(UpdateCredentialsOptions updateCredentialsOptions) { - this.environmentId = updateCredentialsOptions.environmentId; - this.credentialId = updateCredentialsOptions.credentialId; - this.sourceType = updateCredentialsOptions.sourceType; - this.credentialDetails = updateCredentialsOptions.credentialDetails; - this.status = updateCredentialsOptions.status; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param credentialId the credentialId - */ - public Builder(String environmentId, String credentialId) { - this.environmentId = environmentId; - this.credentialId = credentialId; - } - - /** - * Builds a UpdateCredentialsOptions. - * - * @return the updateCredentialsOptions - */ - public UpdateCredentialsOptions build() { - return new UpdateCredentialsOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the UpdateCredentialsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the credentialId. - * - * @param credentialId the credentialId - * @return the UpdateCredentialsOptions builder - */ - public Builder credentialId(String credentialId) { - this.credentialId = credentialId; - return this; - } - - /** - * Set the sourceType. - * - * @param sourceType the sourceType - * @return the UpdateCredentialsOptions builder - */ - public Builder sourceType(String sourceType) { - this.sourceType = sourceType; - return this; - } - - /** - * Set the credentialDetails. - * - * @param credentialDetails the credentialDetails - * @return the UpdateCredentialsOptions builder - */ - public Builder credentialDetails(CredentialDetails credentialDetails) { - this.credentialDetails = credentialDetails; - return this; - } - - /** - * Set the status. - * - * @param status the status - * @return the UpdateCredentialsOptions builder - */ - public Builder status(String status) { - this.status = status; - return this; - } - - /** - * Set the credentials. - * - * @param credentials the credentials - * @return the UpdateCredentialsOptions builder - */ - public Builder credentials(Credentials credentials) { - this.sourceType = credentials.sourceType(); - this.credentialDetails = credentials.credentialDetails(); - this.status = credentials.status(); - return this; - } - } - - protected UpdateCredentialsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.credentialId, - "credentialId cannot be empty"); - environmentId = builder.environmentId; - credentialId = builder.credentialId; - sourceType = builder.sourceType; - credentialDetails = builder.credentialDetails; - status = builder.status; - } - - /** - * New builder. - * - * @return a UpdateCredentialsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the credentialId. - * - * The unique identifier for a set of source credentials. - * - * @return the credentialId - */ - public String credentialId() { - return credentialId; - } - - /** - * Gets the sourceType. - * - * The source that this credentials object connects to. - * - `box` indicates the credentials are used to connect an instance of Enterprise Box. - * - `salesforce` indicates the credentials are used to connect to Salesforce. - * - `sharepoint` indicates the credentials are used to connect to Microsoft SharePoint Online. - * - `web_crawl` indicates the credentials are used to perform a web crawl. - * = `cloud_object_storage` indicates the credentials are used to connect to an IBM Cloud Object Store. - * - * @return the sourceType - */ - public String sourceType() { - return sourceType; - } - - /** - * Gets the credentialDetails. - * - * Object containing details of the stored credentials. - * - * Obtain credentials for your source from the administrator of the source. - * - * @return the credentialDetails - */ - public CredentialDetails credentialDetails() { - return credentialDetails; - } - - /** - * Gets the status. - * - * The current status of this set of credentials. `connected` indicates that the credentials are available to use with - * the source configuration of a collection. `invalid` refers to the credentials (for example, the password provided - * has expired) and must be corrected before they can be used with a collection. - * - * @return the status - */ - public String status() { - return status; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java deleted file mode 100644 index b0102410f82..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.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 updateDocument options. - */ -public class UpdateDocumentOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String documentId; - protected InputStream file; - protected String filename; - protected String fileContentType; - protected String metadata; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String documentId; - private InputStream file; - private String filename; - private String fileContentType; - private String metadata; - - private Builder(UpdateDocumentOptions updateDocumentOptions) { - this.environmentId = updateDocumentOptions.environmentId; - this.collectionId = updateDocumentOptions.collectionId; - this.documentId = updateDocumentOptions.documentId; - this.file = updateDocumentOptions.file; - this.filename = updateDocumentOptions.filename; - this.fileContentType = updateDocumentOptions.fileContentType; - this.metadata = updateDocumentOptions.metadata; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param documentId the documentId - */ - public Builder(String environmentId, String collectionId, String documentId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.documentId = documentId; - } - - /** - * Builds a UpdateDocumentOptions. - * - * @return the updateDocumentOptions - */ - public UpdateDocumentOptions build() { - return new UpdateDocumentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the UpdateDocumentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the UpdateDocumentOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the UpdateDocumentOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the UpdateDocumentOptions builder - */ - public Builder file(InputStream file) { - this.file = file; - return this; - } - - /** - * Set the filename. - * - * @param filename the filename - * @return the UpdateDocumentOptions builder - */ - public Builder filename(String filename) { - this.filename = filename; - return this; - } - - /** - * Set the fileContentType. - * - * @param fileContentType the fileContentType - * @return the UpdateDocumentOptions builder - */ - public Builder fileContentType(String fileContentType) { - this.fileContentType = fileContentType; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the UpdateDocumentOptions builder - */ - public Builder metadata(String metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the UpdateDocumentOptions 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; - } - } - - protected UpdateDocumentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.documentId, - "documentId 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."); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - documentId = builder.documentId; - file = builder.file; - filename = builder.filename; - fileContentType = builder.fileContentType; - metadata = builder.metadata; - } - - /** - * New builder. - * - * @return a UpdateDocumentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the documentId. - * - * The ID of the document. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } - - /** - * 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 configuration 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java deleted file mode 100644 index e5b2e04270e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateEnvironment options. - */ -public class UpdateEnvironmentOptions extends GenericModel { - - /** - * Size that the environment should be increased to. Environment size cannot be modified when using a Lite plan. - * Environment size can only increased and not decreased. - */ - public interface Size { - /** S. */ - String S = "S"; - /** MS. */ - String MS = "MS"; - /** M. */ - String M = "M"; - /** ML. */ - String ML = "ML"; - /** L. */ - String L = "L"; - /** XL. */ - String XL = "XL"; - /** XXL. */ - String XXL = "XXL"; - /** XXXL. */ - String XXXL = "XXXL"; - } - - protected String environmentId; - protected String name; - protected String description; - protected String size; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - private String description; - private String size; - - private Builder(UpdateEnvironmentOptions updateEnvironmentOptions) { - this.environmentId = updateEnvironmentOptions.environmentId; - this.name = updateEnvironmentOptions.name; - this.description = updateEnvironmentOptions.description; - this.size = updateEnvironmentOptions.size; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - */ - public Builder(String environmentId) { - this.environmentId = environmentId; - } - - /** - * Builds a UpdateEnvironmentOptions. - * - * @return the updateEnvironmentOptions - */ - public UpdateEnvironmentOptions build() { - return new UpdateEnvironmentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the UpdateEnvironmentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateEnvironmentOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateEnvironmentOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the size. - * - * @param size the size - * @return the UpdateEnvironmentOptions builder - */ - public Builder size(String size) { - this.size = size; - return this; - } - } - - protected UpdateEnvironmentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - environmentId = builder.environmentId; - name = builder.name; - description = builder.description; - size = builder.size; - } - - /** - * New builder. - * - * @return a UpdateEnvironmentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the name. - * - * Name that identifies the environment. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * Description of the environment. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the size. - * - * Size that the environment should be increased to. Environment size cannot be modified when using a Lite plan. - * Environment size can only increased and not decreased. - * - * @return the size - */ - public String size() { - return size; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java deleted file mode 100644 index 95c32600658..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateTrainingExample options. - */ -public class UpdateTrainingExampleOptions extends GenericModel { - - protected String environmentId; - protected String collectionId; - protected String queryId; - protected String exampleId; - protected String crossReference; - protected Long relevance; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - private String crossReference; - private Long relevance; - - private Builder(UpdateTrainingExampleOptions updateTrainingExampleOptions) { - this.environmentId = updateTrainingExampleOptions.environmentId; - this.collectionId = updateTrainingExampleOptions.collectionId; - this.queryId = updateTrainingExampleOptions.queryId; - this.exampleId = updateTrainingExampleOptions.exampleId; - this.crossReference = updateTrainingExampleOptions.crossReference; - this.relevance = updateTrainingExampleOptions.relevance; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param environmentId the environmentId - * @param collectionId the collectionId - * @param queryId the queryId - * @param exampleId the exampleId - */ - public Builder(String environmentId, String collectionId, String queryId, String exampleId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.queryId = queryId; - this.exampleId = exampleId; - } - - /** - * Builds a UpdateTrainingExampleOptions. - * - * @return the updateTrainingExampleOptions - */ - public UpdateTrainingExampleOptions build() { - return new UpdateTrainingExampleOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the UpdateTrainingExampleOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the UpdateTrainingExampleOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the UpdateTrainingExampleOptions builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - - /** - * Set the exampleId. - * - * @param exampleId the exampleId - * @return the UpdateTrainingExampleOptions builder - */ - public Builder exampleId(String exampleId) { - this.exampleId = exampleId; - return this; - } - - /** - * Set the crossReference. - * - * @param crossReference the crossReference - * @return the UpdateTrainingExampleOptions builder - */ - public Builder crossReference(String crossReference) { - this.crossReference = crossReference; - return this; - } - - /** - * Set the relevance. - * - * @param relevance the relevance - * @return the UpdateTrainingExampleOptions builder - */ - public Builder relevance(long relevance) { - this.relevance = relevance; - return this; - } - } - - protected UpdateTrainingExampleOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.environmentId, - "environmentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, - "queryId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.exampleId, - "exampleId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - queryId = builder.queryId; - exampleId = builder.exampleId; - crossReference = builder.crossReference; - relevance = builder.relevance; - } - - /** - * New builder. - * - * @return a UpdateTrainingExampleOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the environmentId. - * - * The ID of the environment. - * - * @return the environmentId - */ - public String environmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * The ID of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the queryId. - * - * The ID of the query used for training. - * - * @return the queryId - */ - public String queryId() { - return queryId; - } - - /** - * Gets the exampleId. - * - * The ID of the document as it is indexed. - * - * @return the exampleId - */ - public String exampleId() { - return exampleId; - } - - /** - * Gets the crossReference. - * - * The example to add. - * - * @return the crossReference - */ - public String crossReference() { - return crossReference; - } - - /** - * Gets the relevance. - * - * The relevance value for this example. - * - * @return the relevance - */ - public Long relevance() { - return relevance; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java deleted file mode 100644 index 504ffb2b8f7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing heading detection conversion settings for Microsoft Word documents. - */ -public class WordHeadingDetection extends GenericModel { - - protected List fonts; - protected List styles; - - /** - * Builder. - */ - public static class Builder { - private List fonts; - private List styles; - - private Builder(WordHeadingDetection wordHeadingDetection) { - this.fonts = wordHeadingDetection.fonts; - this.styles = wordHeadingDetection.styles; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a WordHeadingDetection. - * - * @return the wordHeadingDetection - */ - public WordHeadingDetection build() { - return new WordHeadingDetection(this); - } - - /** - * Adds an fontSetting to fonts. - * - * @param fontSetting the new fontSetting - * @return the WordHeadingDetection builder - */ - public Builder addFontSetting(FontSetting fontSetting) { - com.ibm.cloud.sdk.core.util.Validator.notNull(fontSetting, - "fontSetting cannot be null"); - if (this.fonts == null) { - this.fonts = new ArrayList(); - } - this.fonts.add(fontSetting); - return this; - } - - /** - * Adds an wordStyle to styles. - * - * @param wordStyle the new wordStyle - * @return the WordHeadingDetection builder - */ - public Builder addWordStyle(WordStyle wordStyle) { - com.ibm.cloud.sdk.core.util.Validator.notNull(wordStyle, - "wordStyle cannot be null"); - if (this.styles == null) { - this.styles = new ArrayList(); - } - this.styles.add(wordStyle); - return this; - } - - /** - * Set the fonts. - * Existing fonts will be replaced. - * - * @param fonts the fonts - * @return the WordHeadingDetection builder - */ - public Builder fonts(List fonts) { - this.fonts = fonts; - return this; - } - - /** - * Set the styles. - * Existing styles will be replaced. - * - * @param styles the styles - * @return the WordHeadingDetection builder - */ - public Builder styles(List styles) { - this.styles = styles; - return this; - } - } - - protected WordHeadingDetection(Builder builder) { - fonts = builder.fonts; - styles = builder.styles; - } - - /** - * New builder. - * - * @return a WordHeadingDetection builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the fonts. - * - * Array of font matching configurations. - * - * @return the fonts - */ - public List fonts() { - return fonts; - } - - /** - * Gets the styles. - * - * Array of Microsoft Word styles to convert. - * - * @return the styles - */ - public List styles() { - return styles; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java deleted file mode 100644 index 544b4a2899a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A list of Word conversion settings. - */ -public class WordSettings extends GenericModel { - - protected WordHeadingDetection heading; - - /** - * Builder. - */ - public static class Builder { - private WordHeadingDetection heading; - - private Builder(WordSettings wordSettings) { - this.heading = wordSettings.heading; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a WordSettings. - * - * @return the wordSettings - */ - public WordSettings build() { - return new WordSettings(this); - } - - /** - * Set the heading. - * - * @param heading the heading - * @return the WordSettings builder - */ - public Builder heading(WordHeadingDetection heading) { - this.heading = heading; - return this; - } - } - - protected WordSettings(Builder builder) { - heading = builder.heading; - } - - /** - * New builder. - * - * @return a WordSettings builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the heading. - * - * Object containing heading detection conversion settings for Microsoft Word documents. - * - * @return the heading - */ - public WordHeadingDetection heading() { - return heading; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java deleted file mode 100644 index 223f84ad78b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Microsoft Word styles to convert into a specified HTML head level. - */ -public class WordStyle extends GenericModel { - - protected Long level; - protected List names; - - /** - * Builder. - */ - public static class Builder { - private Long level; - private List names; - - private Builder(WordStyle wordStyle) { - this.level = wordStyle.level; - this.names = wordStyle.names; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a WordStyle. - * - * @return the wordStyle - */ - public WordStyle build() { - return new WordStyle(this); - } - - /** - * Adds an names to names. - * - * @param names the new names - * @return the WordStyle builder - */ - public Builder addNames(String names) { - com.ibm.cloud.sdk.core.util.Validator.notNull(names, - "names cannot be null"); - if (this.names == null) { - this.names = new ArrayList(); - } - this.names.add(names); - return this; - } - - /** - * Set the level. - * - * @param level the level - * @return the WordStyle builder - */ - public Builder level(long level) { - this.level = level; - return this; - } - - /** - * Set the names. - * Existing names will be replaced. - * - * @param names the names - * @return the WordStyle builder - */ - public Builder names(List names) { - this.names = names; - return this; - } - } - - protected WordStyle(Builder builder) { - level = builder.level; - names = builder.names; - } - - /** - * New builder. - * - * @return a WordStyle builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the level. - * - * HTML head level that content matching this style is tagged with. - * - * @return the level - */ - public Long level() { - return level; - } - - /** - * Gets the names. - * - * Array of word style names to convert. - * - * @return the names - */ - public List names() { - return names; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java deleted file mode 100644 index c7a4a2c00df..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing an array of XPaths. - */ -public class XPathPatterns extends GenericModel { - - protected List xpaths; - - /** - * Builder. - */ - public static class Builder { - private List xpaths; - - private Builder(XPathPatterns xPathPatterns) { - this.xpaths = xPathPatterns.xpaths; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a XPathPatterns. - * - * @return the xPathPatterns - */ - public XPathPatterns build() { - return new XPathPatterns(this); - } - - /** - * Adds an xpaths to xpaths. - * - * @param xpaths the new xpaths - * @return the XPathPatterns builder - */ - public Builder addXpaths(String xpaths) { - com.ibm.cloud.sdk.core.util.Validator.notNull(xpaths, - "xpaths cannot be null"); - if (this.xpaths == null) { - this.xpaths = new ArrayList(); - } - this.xpaths.add(xpaths); - return this; - } - - /** - * Set the xpaths. - * Existing xpaths will be replaced. - * - * @param xpaths the xpaths - * @return the XPathPatterns builder - */ - public Builder xpaths(List xpaths) { - this.xpaths = xpaths; - return this; - } - } - - protected XPathPatterns(Builder builder) { - xpaths = builder.xpaths; - } - - /** - * New builder. - * - * @return a XPathPatterns builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the xpaths. - * - * An array to XPaths. - * - * @return the xpaths - */ - public List xpaths() { - return xpaths; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java deleted file mode 100644 index 9ec2ce02778..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Discovery v1. - */ -package com.ibm.watson.discovery.v1; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java deleted file mode 100644 index 0deadb28ab3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1.query; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.discovery.v1.model.Calculation; -import com.ibm.watson.discovery.v1.model.Filter; -import com.ibm.watson.discovery.v1.model.Histogram; -import com.ibm.watson.discovery.v1.model.Nested; -import com.ibm.watson.discovery.v1.model.QueryAggregation; -import com.ibm.watson.discovery.v1.model.Term; -import com.ibm.watson.discovery.v1.model.Timeslice; -import com.ibm.watson.discovery.v1.model.TopHits; - -import java.lang.reflect.Type; - -/** - * Deserializer to transform JSON into a {@link QueryAggregation}. - * - * @deprecated This class has been replaced by logic inside of the QueryAggregation class. - */ -public class AggregationDeserializer implements JsonDeserializer { - - private static final String TYPE = "type"; - - /** - * Deserializes JSON and converts it to the appropriate {@link QueryAggregation} subclass. - * - * @param json the JSON data being deserialized - * @param typeOfT the type to deserialize to, which should be {@link QueryAggregation} - * @param context additional information about the deserialization state - * @return the appropriate {@link QueryAggregation} subclass - * @throws JsonParseException signals that there has been an issue parsing the JSON - */ - @Override - public QueryAggregation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - - // get aggregation type from response - JsonObject jsonObject = json.getAsJsonObject(); - String aggregationType = ""; - for (String key : jsonObject.keySet()) { - if (key.equals(TYPE)) { - aggregationType = jsonObject.get(key).getAsString(); - } - } - - QueryAggregation aggregation; - if (aggregationType.equals(AggregationType.HISTOGRAM.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, Histogram.class); - } else if (aggregationType.equals(AggregationType.MAX.getName()) - || aggregationType.equals(AggregationType.MIN.getName()) - || aggregationType.equals(AggregationType.AVERAGE.getName()) - || aggregationType.equals(AggregationType.SUM.getName()) - || aggregationType.equals(AggregationType.UNIQUE_COUNT.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, Calculation.class); - } else if (aggregationType.equals(AggregationType.TERM.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, Term.class); - } else if (aggregationType.equals(AggregationType.FILTER.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, Filter.class); - } else if (aggregationType.equals(AggregationType.NESTED.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, Nested.class); - } else if (aggregationType.equals(AggregationType.TIMESLICE.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, Timeslice.class); - } else if (aggregationType.equals(AggregationType.TOP_HITS.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, TopHits.class); - } else { - aggregation = GsonSingleton.getGson().fromJson(json, GenericQueryAggregation.class); - } - - return aggregation; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationType.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationType.java deleted file mode 100644 index 97adcab72a5..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationType.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.query; - -/** - * Aggregation types. - * - * @deprecated This class has been replaced by the top-level version in com.ibm.watson.discovery.query. - */ -public enum AggregationType { - TERM("term"), FILTER("filter"), NESTED("nested"), HISTOGRAM("histogram"), TIMESLICE("timeslice"), TOP_HITS( - "top_hits"), UNIQUE_COUNT("unique_count"), MAX("max"), MIN("min"), AVERAGE("average"), SUM("sum"); - - private final String name; - - AggregationType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public static AggregationType valueOfIgnoreCase(String value) throws IllegalArgumentException { - for (AggregationType aggregationType : values()) { - if (aggregationType.getName().equalsIgnoreCase(value)) { - return aggregationType; - } - } - throw new IllegalArgumentException(value + " is not a valid Aggregation"); - } - - @Override - public String toString() { - return name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/GenericQueryAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/query/GenericQueryAggregation.java deleted file mode 100644 index c25f8cf5ca7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/GenericQueryAggregation.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ibm.watson.discovery.v1.query; - -import com.ibm.watson.discovery.v1.model.QueryAggregation; - -/** - * Catch-all class for query aggregations which can't be identified and deserialized to a known class. - * - * @deprecated This class is no longer necessary with the built-in deserialization logic in the QueryAggregation class. - */ -public class GenericQueryAggregation extends QueryAggregation { -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/Operator.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/query/Operator.java deleted file mode 100644 index a2b038dde50..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/query/Operator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.v1.query; - -/** - * Query Language Operator Syntax. - * - * @deprecated This class has been replaced by the top-level version in com.ibm.watson.discovery.query. - */ -public enum Operator { - FIELD_SEPARATOR("."), EQUALS("::"), CONTAINS(":"), ESCAPE("\\"), FUZZY("~"), OR("|"), AND(","), NOT( - "!"), NEST_AGGREGATION("."), LESS_THAN("<"), LESS_THAN_OR_EQUAL_TO("<="), GREATER_THAN( - ">"), GREATER_THAN_OR_EQUAL_TO(">="), BOOST("^"), WILDCARD("*", false), OPENING_GROUPING( - "("), CLOSING_GROUPING(")"), OPENING_ARRAY("["), CLOSING_ARRAY("]"), DOUBLE_QUOTE("\""); - - private final String symbol; - private final boolean escape; - - Operator(String symbol) { - this(symbol, true); - } - - Operator(String symbol, boolean escape) { - this.symbol = symbol; - this.escape = escape; - } - - public String getSymbol() { - return symbol; - } - - public boolean shouldEscape() { - return escape; - } - - @Override - public String toString() { - return symbol; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java index e0e88d37428..9d270fc962d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2025. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116 + */ + package com.ibm.watson.discovery.v2; import com.google.gson.JsonObject; @@ -23,384 +28,695 @@ import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; import com.ibm.watson.common.SdkCommon; import com.ibm.watson.discovery.v2.model.AddDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzeDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzedDocument; +import com.ibm.watson.discovery.v2.model.CollectionDetails; import com.ibm.watson.discovery.v2.model.Completions; import com.ibm.watson.discovery.v2.model.ComponentSettingsResponse; +import com.ibm.watson.discovery.v2.model.CreateCollectionOptions; +import com.ibm.watson.discovery.v2.model.CreateDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.CreateDocumentClassifierOptions; +import com.ibm.watson.discovery.v2.model.CreateEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.CreateExpansionsOptions; +import com.ibm.watson.discovery.v2.model.CreateProjectOptions; +import com.ibm.watson.discovery.v2.model.CreateStopwordListOptions; import com.ibm.watson.discovery.v2.model.CreateTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.DeleteCollectionOptions; +import com.ibm.watson.discovery.v2.model.DeleteDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.DeleteDocumentClassifierOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentResponse; +import com.ibm.watson.discovery.v2.model.DeleteEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.DeleteExpansionsOptions; +import com.ibm.watson.discovery.v2.model.DeleteProjectOptions; +import com.ibm.watson.discovery.v2.model.DeleteStopwordListOptions; import com.ibm.watson.discovery.v2.model.DeleteTrainingQueriesOptions; +import com.ibm.watson.discovery.v2.model.DeleteTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.DeleteUserDataOptions; import com.ibm.watson.discovery.v2.model.DocumentAccepted; +import com.ibm.watson.discovery.v2.model.DocumentClassifier; +import com.ibm.watson.discovery.v2.model.DocumentClassifierModel; +import com.ibm.watson.discovery.v2.model.DocumentClassifierModels; +import com.ibm.watson.discovery.v2.model.DocumentClassifiers; +import com.ibm.watson.discovery.v2.model.DocumentDetails; +import com.ibm.watson.discovery.v2.model.Enrichment; +import com.ibm.watson.discovery.v2.model.Enrichments; +import com.ibm.watson.discovery.v2.model.Expansions; import com.ibm.watson.discovery.v2.model.GetAutocompletionOptions; +import com.ibm.watson.discovery.v2.model.GetCollectionOptions; import com.ibm.watson.discovery.v2.model.GetComponentSettingsOptions; +import com.ibm.watson.discovery.v2.model.GetDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.GetDocumentClassifierOptions; +import com.ibm.watson.discovery.v2.model.GetDocumentOptions; +import com.ibm.watson.discovery.v2.model.GetEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.GetProjectOptions; +import com.ibm.watson.discovery.v2.model.GetStopwordListOptions; import com.ibm.watson.discovery.v2.model.GetTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.ListBatchesOptions; +import com.ibm.watson.discovery.v2.model.ListBatchesResponse; import com.ibm.watson.discovery.v2.model.ListCollectionsOptions; import com.ibm.watson.discovery.v2.model.ListCollectionsResponse; +import com.ibm.watson.discovery.v2.model.ListDocumentClassifierModelsOptions; +import com.ibm.watson.discovery.v2.model.ListDocumentClassifiersOptions; +import com.ibm.watson.discovery.v2.model.ListDocumentsOptions; +import com.ibm.watson.discovery.v2.model.ListDocumentsResponse; +import com.ibm.watson.discovery.v2.model.ListEnrichmentsOptions; +import com.ibm.watson.discovery.v2.model.ListExpansionsOptions; import com.ibm.watson.discovery.v2.model.ListFieldsOptions; import com.ibm.watson.discovery.v2.model.ListFieldsResponse; +import com.ibm.watson.discovery.v2.model.ListProjectsOptions; +import com.ibm.watson.discovery.v2.model.ListProjectsResponse; import com.ibm.watson.discovery.v2.model.ListTrainingQueriesOptions; +import com.ibm.watson.discovery.v2.model.ProjectDetails; +import com.ibm.watson.discovery.v2.model.PullBatchesOptions; +import com.ibm.watson.discovery.v2.model.PullBatchesResponse; +import com.ibm.watson.discovery.v2.model.PushBatchesOptions; +import com.ibm.watson.discovery.v2.model.QueryCollectionNoticesOptions; import com.ibm.watson.discovery.v2.model.QueryNoticesOptions; import com.ibm.watson.discovery.v2.model.QueryNoticesResponse; import com.ibm.watson.discovery.v2.model.QueryOptions; import com.ibm.watson.discovery.v2.model.QueryResponse; +import com.ibm.watson.discovery.v2.model.StopWordList; import com.ibm.watson.discovery.v2.model.TrainingQuery; import com.ibm.watson.discovery.v2.model.TrainingQuerySet; +import com.ibm.watson.discovery.v2.model.UpdateCollectionOptions; +import com.ibm.watson.discovery.v2.model.UpdateDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.UpdateDocumentClassifierOptions; import com.ibm.watson.discovery.v2.model.UpdateDocumentOptions; +import com.ibm.watson.discovery.v2.model.UpdateEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.UpdateProjectOptions; import com.ibm.watson.discovery.v2.model.UpdateTrainingQueryOptions; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * IBM Watson™ Discovery for IBM Cloud Pak for Data 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. + * IBM Watson&reg; 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. * - * @version v2 - * @see Discovery + *

API Version: 2.0 See: https://cloud.ibm.com/docs/discovery-data */ public class Discovery extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "discovery"; + /** Default service name used when configuring the `Discovery` client. */ + public static final String DEFAULT_SERVICE_NAME = "discovery"; - private String versionDate; + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.discovery.watson.cloud.ibm.com"; + + private String version; /** - * Constructs a new `Discovery` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Discovery` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2023-03-31`. */ - public Discovery(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + public Discovery(String version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Discovery` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. + * Constructs an instance of the `Discovery` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2023-03-31`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Discovery(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Discovery(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Discovery` client with the specified serviceName. + * Constructs an instance of the `Discovery` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2023-03-31`. + * @param serviceName the service name to be used when configuring the client instance */ - public Discovery(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Discovery(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Discovery` client with the specified Authenticator - * and serviceName. + * Constructs an instance of the `Discovery` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2023-03-31`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Discovery(String versionDate, String serviceName, Authenticator authenticator) { + public Discovery(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; + setServiceUrl(DEFAULT_SERVICE_URL); + setVersion(version); this.configureService(serviceName); } /** - * List collections. + * Gets the version. * - * Lists existing collections for the specified project. + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2023-03-31`. * - * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionsResponse} + * @return the version */ - public ServiceCall listCollections(ListCollectionsOptions listCollectionsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listCollectionsOptions, - "listCollectionsOptions cannot be null"); - String[] pathSegments = { "v2/projects", "collections" }; - String[] pathParameters = { listCollectionsOptions.projectId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listCollections"); + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + + /** + * List projects. + * + *

Lists existing projects for this instance. + * + * @param listProjectsOptions the {@link ListProjectsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListProjectsResponse} + */ + public ServiceCall listProjects(ListProjectsOptions listProjectsOptions) { + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects")); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listProjects"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a project. + * List projects. * - * By using this method, you can construct queries. For details, see the [Discovery - * documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-concepts). + *

Lists existing projects for this instance. * - * @param queryOptions the {@link QueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryResponse} + * @return a {@link ServiceCall} with a result of type {@link ListProjectsResponse} */ - public ServiceCall query(QueryOptions queryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(queryOptions, - "queryOptions cannot be null"); - String[] pathSegments = { "v2/projects", "query" }; - String[] pathParameters = { queryOptions.projectId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "query"); + public ServiceCall listProjects() { + return listProjects(null); + } + + /** + * Create a project. + * + *

Create a new project for this instance. + * + * @param createProjectOptions the {@link CreateProjectOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ProjectDetails} + */ + public ServiceCall createProject(CreateProjectOptions createProjectOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createProjectOptions, "createProjectOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects")); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createProject"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); - if (queryOptions.collectionIds() != null) { - contentJson.add("collection_ids", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions - .collectionIds())); - } - if (queryOptions.filter() != null) { - contentJson.addProperty("filter", queryOptions.filter()); + contentJson.addProperty("name", createProjectOptions.name()); + contentJson.addProperty("type", createProjectOptions.type()); + if (createProjectOptions.defaultQueryParameters() != null) { + contentJson.add( + "default_query_parameters", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createProjectOptions.defaultQueryParameters())); } - if (queryOptions.query() != null) { - contentJson.addProperty("query", queryOptions.query()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get project. + * + *

Get details on the specified project. + * + * @param getProjectOptions the {@link GetProjectOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ProjectDetails} + */ + public ServiceCall getProject(GetProjectOptions getProjectOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getProjectOptions, "getProjectOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getProjectOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getProject"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (queryOptions.naturalLanguageQuery() != null) { - contentJson.addProperty("natural_language_query", queryOptions.naturalLanguageQuery()); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a project. + * + *

Update the specified project's name. + * + * @param updateProjectOptions the {@link UpdateProjectOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ProjectDetails} + */ + public ServiceCall updateProject(UpdateProjectOptions updateProjectOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateProjectOptions, "updateProjectOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateProjectOptions.projectId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateProject"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (queryOptions.aggregation() != null) { - contentJson.addProperty("aggregation", queryOptions.aggregation()); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (updateProjectOptions.name() != null) { + contentJson.addProperty("name", updateProjectOptions.name()); } - if (queryOptions.count() != null) { - contentJson.addProperty("count", queryOptions.count()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a project. + * + *

Deletes the specified project. + * + *

**Important:** Deleting a project deletes everything that is part of the specified project, + * including all collections. + * + * @param deleteProjectOptions the {@link DeleteProjectOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteProject(DeleteProjectOptions deleteProjectOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteProjectOptions, "deleteProjectOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteProjectOptions.projectId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteProject"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (queryOptions.xReturn() != null) { - contentJson.add("return", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions.xReturn())); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List fields. + * + *

Gets a list of the unique fields (and their types) stored in the specified collections. + * + * @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListFieldsResponse} + */ + public ServiceCall listFields(ListFieldsOptions listFieldsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listFieldsOptions, "listFieldsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listFieldsOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/fields", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listFields"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (queryOptions.offset() != null) { - contentJson.addProperty("offset", queryOptions.offset()); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listFieldsOptions.collectionIds() != null) { + builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); } - if (queryOptions.sort() != null) { - contentJson.addProperty("sort", queryOptions.sort()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List collections. + * + *

Lists existing collections for the specified project. + * + * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ListCollectionsResponse} + */ + public ServiceCall listCollections( + ListCollectionsOptions listCollectionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listCollectionsOptions, "listCollectionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listCollectionsOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/collections", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listCollections"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (queryOptions.highlight() != null) { - contentJson.addProperty("highlight", queryOptions.highlight()); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a collection. + * + *

Create a new collection in the specified project. + * + * @param createCollectionOptions the {@link CreateCollectionOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} + */ + public ServiceCall createCollection( + CreateCollectionOptions createCollectionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createCollectionOptions, "createCollectionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createCollectionOptions.projectId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/collections", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createCollection"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); } - if (queryOptions.spellingSuggestions() != null) { - contentJson.addProperty("spelling_suggestions", queryOptions.spellingSuggestions()); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", createCollectionOptions.name()); + if (createCollectionOptions.description() != null) { + contentJson.addProperty("description", createCollectionOptions.description()); } - if (queryOptions.tableResults() != null) { - contentJson.add("table_results", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions - .tableResults())); + if (createCollectionOptions.language() != null) { + contentJson.addProperty("language", createCollectionOptions.language()); } - if (queryOptions.suggestedRefinements() != null) { - contentJson.add("suggested_refinements", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - queryOptions.suggestedRefinements())); + if (createCollectionOptions.ocrEnabled() != null) { + contentJson.addProperty("ocr_enabled", createCollectionOptions.ocrEnabled()); } - if (queryOptions.passages() != null) { - contentJson.add("passages", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions - .passages())); + if (createCollectionOptions.enrichments() != null) { + contentJson.add( + "enrichments", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createCollectionOptions.enrichments())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Get Autocomplete Suggestions. + * Get collection details. * - * Returns completion query suggestions for the specified prefix. + *

Get details about the specified collection. * - * @param getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Completions} + * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} */ - public ServiceCall getAutocompletion(GetAutocompletionOptions getAutocompletionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getAutocompletionOptions, - "getAutocompletionOptions cannot be null"); - String[] pathSegments = { "v2/projects", "autocompletion" }; - String[] pathParameters = { getAutocompletionOptions.projectId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getAutocompletion"); + public ServiceCall getCollection(GetCollectionOptions getCollectionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getCollectionOptions, "getCollectionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getCollectionOptions.projectId()); + pathParamsMap.put("collection_id", getCollectionOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("prefix", getAutocompletionOptions.prefix()); - if (getAutocompletionOptions.collectionIds() != null) { - builder.query("collection_ids", RequestUtils.join(getAutocompletionOptions.collectionIds(), ",")); - } - if (getAutocompletionOptions.field() != null) { - builder.query("field", getAutocompletionOptions.field()); - } - if (getAutocompletionOptions.count() != null) { - builder.query("count", String.valueOf(getAutocompletionOptions.count())); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query system notices. + * Update a collection. * - * Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when - * ingesting documents and performing relevance training. + *

Updates the specified collection's name, description, enrichments, and configuration. * - * @param queryNoticesOptions the {@link QueryNoticesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse} + *

If you apply normalization rules to data in an existing collection, you must initiate + * reprocessing of the collection. To do so, from the *Manage fields* page in the product user + * interface, temporarily change the data type of a field to enable the reprocess button. Change + * the data type of the field back to its original value, and then click **Apply changes and + * reprocess**. + * + *

To remove a configuration that applies JSON normalization operations as part of the + * conversion phase of ingestion, specify an empty `json_normalizations` object (`[]`) in the + * request. + * + *

To remove a configuration that applies JSON normalization operations after enrichments are + * applied, specify an empty `normalizations` object (`[]`) in the request. + * + * @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} */ - public ServiceCall queryNotices(QueryNoticesOptions queryNoticesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(queryNoticesOptions, - "queryNoticesOptions cannot be null"); - String[] pathSegments = { "v2/projects", "notices" }; - String[] pathParameters = { queryNoticesOptions.projectId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "queryNotices"); + public ServiceCall updateCollection( + UpdateCollectionOptions updateCollectionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateCollectionOptions, "updateCollectionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateCollectionOptions.projectId()); + pathParamsMap.put("collection_id", updateCollectionOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (queryNoticesOptions.filter() != null) { - builder.query("filter", queryNoticesOptions.filter()); - } - if (queryNoticesOptions.query() != null) { - builder.query("query", queryNoticesOptions.query()); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (updateCollectionOptions.name() != null) { + contentJson.addProperty("name", updateCollectionOptions.name()); } - if (queryNoticesOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", queryNoticesOptions.naturalLanguageQuery()); + if (updateCollectionOptions.description() != null) { + contentJson.addProperty("description", updateCollectionOptions.description()); } - if (queryNoticesOptions.count() != null) { - builder.query("count", String.valueOf(queryNoticesOptions.count())); + if (updateCollectionOptions.ocrEnabled() != null) { + contentJson.addProperty("ocr_enabled", updateCollectionOptions.ocrEnabled()); } - if (queryNoticesOptions.offset() != null) { - builder.query("offset", String.valueOf(queryNoticesOptions.offset())); + if (updateCollectionOptions.enrichments() != null) { + contentJson.add( + "enrichments", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateCollectionOptions.enrichments())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * List fields. + * Delete a collection. * - * Gets a list of the unique fields (and their types) stored in the the specified collections. + *

Deletes the specified collection from the project. All documents stored in the specified + * collection and not shared is also deleted. * - * @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListFieldsResponse} + * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall listFields(ListFieldsOptions listFieldsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listFieldsOptions, - "listFieldsOptions cannot be null"); - String[] pathSegments = { "v2/projects", "fields" }; - String[] pathParameters = { listFieldsOptions.projectId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listFields"); + public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollectionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteCollectionOptions, "deleteCollectionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteCollectionOptions.projectId()); + pathParamsMap.put("collection_id", deleteCollectionOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.header("Accept", "application/json"); - if (listFieldsOptions.collectionIds() != null) { - builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } /** - * Configuration settings for components. + * List documents. + * + *

Lists the documents in the specified collection. The list includes only the document ID of + * each document and returns information for up to 10,000 documents. * - * Returns default configuration settings for components. + *

**Note**: This method is available only from Cloud Pak for Data version 4.0.9 and later + * installed instances, and from IBM Cloud-managed instances. * - * @param getComponentSettingsOptions the {@link GetComponentSettingsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ComponentSettingsResponse} + * @param listDocumentsOptions the {@link ListDocumentsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ListDocumentsResponse} */ - public ServiceCall getComponentSettings( - GetComponentSettingsOptions getComponentSettingsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getComponentSettingsOptions, - "getComponentSettingsOptions cannot be null"); - String[] pathSegments = { "v2/projects", "component_settings" }; - String[] pathParameters = { getComponentSettingsOptions.projectId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getComponentSettings"); + public ServiceCall listDocuments( + ListDocumentsOptions listDocumentsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listDocumentsOptions, "listDocumentsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listDocumentsOptions.projectId()); + pathParamsMap.put("collection_id", listDocumentsOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listDocuments"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + if (listDocumentsOptions.count() != null) { + builder.query("count", String.valueOf(listDocumentsOptions.count())); + } + if (listDocumentsOptions.status() != null) { + builder.query("status", String.valueOf(listDocumentsOptions.status())); + } + if (listDocumentsOptions.hasNotices() != null) { + builder.query("has_notices", String.valueOf(listDocumentsOptions.hasNotices())); + } + if (listDocumentsOptions.isParent() != null) { + builder.query("is_parent", String.valueOf(listDocumentsOptions.isParent())); + } + if (listDocumentsOptions.parentDocumentId() != null) { + builder.query("parent_document_id", String.valueOf(listDocumentsOptions.parentDocumentId())); + } + if (listDocumentsOptions.sha256() != null) { + builder.query("sha256", String.valueOf(listDocumentsOptions.sha256())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Add a document. * - * Add a document to a collection with optional metadata. - * - * Returns immediately after the system has accepted the document for processing. + *

Add a document to a collection with optional metadata. * - * * The user must provide document content, metadata, or both. If the request is missing both document content and - * metadata, it is rejected. + *

Returns immediately after the system has accepted the document for processing. * - * * The user can set the **Content-Type** parameter on the **file** part to indicate the media type of the - * document. If the **Content-Type** parameter is missing or is one of the generic media types (for example, - * `application/octet-stream`), then the service attempts to automatically detect the document's media type. + *

Use this method to upload a file to the collection. You cannot use this method to crawl an + * external data source. * - * * The following field names are reserved and will be filtered out if present after normalization: `id`, `score`, - * `highlight`, and any field with the prefix of: `_`, `+`, or `-` + *

* For a list of supported file types, see the [product + * documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes). * - * * Fields with empty name values after normalization are filtered out before indexing. + *

* You must provide document content, metadata, or both. If the request is missing both + * document content and metadata, it is rejected. * - * * Fields containing the following characters after normalization are filtered out before indexing: `#` and `,` + *

* You can set the **Content-Type** parameter on the **file** part to indicate the media type + * of the document. If the **Content-Type** parameter is missing or is one of the generic media + * types (for example, `application/octet-stream`), then the service attempts to automatically + * detect the document's media type. * - * If the document is uploaded to a collection that has it's data shared with another collection, the - * **X-Watson-Discovery-Force** header must be set to `true`. + *

* 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`. * - * **Note:** Documents can be added with a specific **document_id** by using the - * **_/v2/projects/{project_id}/collections/{collection_id}/documents** method. + *

* In curl requests only, you can assign an ID to a document that you add by appending the ID + * to the endpoint + * (`/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}`). If a + * document already exists with the specified ID, it is replaced. * - * **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. + *

For more information about how certain file types and field names are handled when a file is + * added to a collection, see the [product + * documentation](/docs/discovery-data?topic=discovery-data-index-overview#field-name-limits). * * @param addDocumentOptions the {@link AddDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} + * @return a {@link ServiceCall} with a result of type {@link DocumentAccepted} */ public ServiceCall addDocument(AddDocumentOptions addDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addDocumentOptions, - "addDocumentOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((addDocumentOptions.file() != null) || (addDocumentOptions - .metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = { "v2/projects", "collections", "documents" }; - String[] pathParameters = { addDocumentOptions.projectId(), addDocumentOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + addDocumentOptions, "addDocumentOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.isTrue( + (addDocumentOptions.file() != null) || (addDocumentOptions.metadata() != null), + "At least one of file or metadata must be supplied."); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", addDocumentOptions.projectId()); + pathParamsMap.put("collection_id", addDocumentOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "addDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -409,52 +725,103 @@ public ServiceCall addDocument(AddDocumentOptions addDocumentO if (addDocumentOptions.xWatsonDiscoveryForce() != null) { builder.header("X-Watson-Discovery-Force", addDocumentOptions.xWatsonDiscoveryForce()); } + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (addDocumentOptions.file() != null) { - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(addDocumentOptions.file(), addDocumentOptions - .fileContentType()); + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody( + addDocumentOptions.file(), addDocumentOptions.fileContentType()); multipartBuilder.addFormDataPart("file", addDocumentOptions.filename(), fileBody); } if (addDocumentOptions.metadata() != null) { multipartBuilder.addFormDataPart("metadata", addDocumentOptions.metadata()); } builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get document details. + * + *

Get details about a specific document, whether the document is added by uploading a file or + * by crawling an external data source. + * + *

**Note**: This method is available only from Cloud Pak for Data version 4.0.9 and later + * installed instances, and from IBM Cloud-managed instances. + * + * @param getDocumentOptions the {@link GetDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentDetails} + */ + public ServiceCall getDocument(GetDocumentOptions getDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getDocumentOptions, "getDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getDocumentOptions.projectId()); + pathParamsMap.put("collection_id", getDocumentOptions.collectionId()); + pathParamsMap.put("document_id", getDocumentOptions.documentId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getDocument"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update a document. * - * Replace an existing document or add a document with a specified **document_id**. Starts ingesting a document with - * optional metadata. + *

Replace an existing document or add a document with a specified document ID. Starts + * ingesting a document with optional metadata. + * + *

Use this method to upload a file to a collection. You cannot use this method to crawl an + * external data source. + * + *

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`. * - * If the document is uploaded to a collection that has it's data shared with another collection, the - * **X-Watson-Discovery-Force** header must be set to `true`. + *

**Notes:** * - * **Note:** When uploading a new document with this method it automatically replaces any document stored with the - * same **document_id** if it exists. + *

* Uploading a new document with this method automatically replaces any existing document + * stored with the same document ID. * - * **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. + *

* If an uploaded document is split into child documents during ingestion, all existing child + * documents are overwritten, even if the updated version of the document has fewer child + * documents. * - * @param updateDocumentOptions the {@link UpdateDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} + * @param updateDocumentOptions the {@link UpdateDocumentOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link DocumentAccepted} */ public ServiceCall updateDocument(UpdateDocumentOptions updateDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateDocumentOptions, - "updateDocumentOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((updateDocumentOptions.file() != null) || (updateDocumentOptions - .metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = { "v2/projects", "collections", "documents" }; - String[] pathParameters = { updateDocumentOptions.projectId(), updateDocumentOptions.collectionId(), - updateDocumentOptions.documentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateDocumentOptions, "updateDocumentOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.isTrue( + (updateDocumentOptions.file() != null) || (updateDocumentOptions.metadata() != null), + "At least one of file or metadata must be supplied."); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateDocumentOptions.projectId()); + pathParamsMap.put("collection_id", updateDocumentOptions.collectionId()); + pathParamsMap.put("document_id", updateDocumentOptions.documentId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -463,44 +830,77 @@ public ServiceCall updateDocument(UpdateDocumentOptions update if (updateDocumentOptions.xWatsonDiscoveryForce() != null) { builder.header("X-Watson-Discovery-Force", updateDocumentOptions.xWatsonDiscoveryForce()); } + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (updateDocumentOptions.file() != null) { - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(updateDocumentOptions.file(), updateDocumentOptions - .fileContentType()); + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody( + updateDocumentOptions.file(), updateDocumentOptions.fileContentType()); multipartBuilder.addFormDataPart("file", updateDocumentOptions.filename(), fileBody); } if (updateDocumentOptions.metadata() != null) { multipartBuilder.addFormDataPart("metadata", updateDocumentOptions.metadata()); } builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a document. * - * 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'. + *

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. * - * **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. + *

**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 - * @return a {@link ServiceCall} with a response type of {@link DeleteDocumentResponse} + *

If the document with the given document ID exists, Watson Discovery first marks or tags the + * document as deleted when it sends the 200 response code. At a later time (within a couple of + * minutes unless the document has many child documents), it removes the document from the + * collection. + * + *

There is no bulk document delete API. Documents must be deleted one at a time using this + * API. However, you can delete a collection, and all the documents from the collection are + * removed along with the collection. + * + *

The document will be deleted from the given collection only, not from the corresponding data + * source. Wherever relevant, an incremental crawl will not bring back the document into Watson + * Discovery from the data source. Only a full crawl will retrieve the deleted document back from + * the data source provided it is still present in the same data source. + * + *

Finally, if multiple collections share the same dataset, deleting a document from a + * collection will remove it from that collection only (in other remaining collections the + * document will still exist). The document will be removed from the dataset, if this document is + * deleted from all the collections that share the same dataset. + * + * @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link DeleteDocumentResponse} */ - public ServiceCall deleteDocument(DeleteDocumentOptions deleteDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDocumentOptions, - "deleteDocumentOptions cannot be null"); - String[] pathSegments = { "v2/projects", "collections", "documents" }; - String[] pathParameters = { deleteDocumentOptions.projectId(), deleteDocumentOptions.collectionId(), - deleteDocumentOptions.documentId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + public ServiceCall deleteDocument( + DeleteDocumentOptions deleteDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteDocumentOptions, "deleteDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteDocumentOptions.projectId()); + pathParamsMap.put("collection_id", deleteDocumentOptions.collectionId()); + pathParamsMap.put("document_id", deleteDocumentOptions.documentId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -509,161 +909,1553 @@ public ServiceCall deleteDocument(DeleteDocumentOptions if (deleteDocumentOptions.xWatsonDiscoveryForce() != null) { builder.header("X-Watson-Discovery-Force", deleteDocumentOptions.xWatsonDiscoveryForce()); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * List training queries. + * Query a project. * - * List the training queries for the specified project. + *

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](/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. * - * @param listTrainingQueriesOptions the {@link ListTrainingQueriesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuerySet} + *

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. + * + * @param queryOptions the {@link QueryOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link QueryResponse} */ - public ServiceCall listTrainingQueries(ListTrainingQueriesOptions listTrainingQueriesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listTrainingQueriesOptions, - "listTrainingQueriesOptions cannot be null"); - String[] pathSegments = { "v2/projects", "training_data/queries" }; - String[] pathParameters = { listTrainingQueriesOptions.projectId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listTrainingQueries"); + public ServiceCall query(QueryOptions queryOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(queryOptions, "queryOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", queryOptions.projectId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/query", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "query"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (queryOptions.collectionIds() != null) { + contentJson.add( + "collection_ids", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(queryOptions.collectionIds())); + } + if (queryOptions.filter() != null) { + contentJson.addProperty("filter", queryOptions.filter()); + } + if (queryOptions.query() != null) { + contentJson.addProperty("query", queryOptions.query()); + } + if (queryOptions.naturalLanguageQuery() != null) { + contentJson.addProperty("natural_language_query", queryOptions.naturalLanguageQuery()); + } + if (queryOptions.aggregation() != null) { + contentJson.addProperty("aggregation", queryOptions.aggregation()); + } + if (queryOptions.count() != null) { + contentJson.addProperty("count", queryOptions.count()); + } + if (queryOptions.xReturn() != null) { + contentJson.add( + "return", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions.xReturn())); + } + if (queryOptions.offset() != null) { + contentJson.addProperty("offset", queryOptions.offset()); + } + if (queryOptions.sort() != null) { + contentJson.addProperty("sort", queryOptions.sort()); + } + if (queryOptions.highlight() != null) { + contentJson.addProperty("highlight", queryOptions.highlight()); + } + if (queryOptions.spellingSuggestions() != null) { + contentJson.addProperty("spelling_suggestions", queryOptions.spellingSuggestions()); + } + if (queryOptions.tableResults() != null) { + contentJson.add( + "table_results", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(queryOptions.tableResults())); + } + if (queryOptions.suggestedRefinements() != null) { + contentJson.add( + "suggested_refinements", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(queryOptions.suggestedRefinements())); + } + if (queryOptions.passages() != null) { + contentJson.add( + "passages", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions.passages())); + } + if (queryOptions.similar() != null) { + contentJson.add( + "similar", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(queryOptions.similar())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Delete training queries. + * Get Autocomplete Suggestions. + * + *

Returns completion query suggestions for the specified prefix. * - * Removes all training queries for the specified project. + *

Suggested words are based on terms from the project documents. Suggestions are not based on + * terms from the project's search history, and the project does not learn from previous user + * choices. * - * @param deleteTrainingQueriesOptions the {@link DeleteTrainingQueriesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Completions} */ - public ServiceCall deleteTrainingQueries(DeleteTrainingQueriesOptions deleteTrainingQueriesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteTrainingQueriesOptions, - "deleteTrainingQueriesOptions cannot be null"); - String[] pathSegments = { "v2/projects", "training_data/queries" }; - String[] pathParameters = { deleteTrainingQueriesOptions.projectId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteTrainingQueries"); + public ServiceCall getAutocompletion( + GetAutocompletionOptions getAutocompletionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getAutocompletionOptions, "getAutocompletionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getAutocompletionOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/autocompletion", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "getAutocompletion"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + builder.query("prefix", String.valueOf(getAutocompletionOptions.prefix())); + if (getAutocompletionOptions.collectionIds() != null) { + builder.query( + "collection_ids", RequestUtils.join(getAutocompletionOptions.collectionIds(), ",")); + } + if (getAutocompletionOptions.field() != null) { + builder.query("field", String.valueOf(getAutocompletionOptions.field())); + } + if (getAutocompletionOptions.count() != null) { + builder.query("count", String.valueOf(getAutocompletionOptions.count())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Create training query. + * Query collection notices. * - * Add a query to the training data for this project. The query can contain a filter and natural language query. + *

Finds collection-level notices (errors and warnings) that are generated when documents are + * ingested. * - * @param createTrainingQueryOptions the {@link CreateTrainingQueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @param queryCollectionNoticesOptions the {@link QueryCollectionNoticesOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link QueryNoticesResponse} */ - public ServiceCall createTrainingQuery(CreateTrainingQueryOptions createTrainingQueryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createTrainingQueryOptions, - "createTrainingQueryOptions cannot be null"); - String[] pathSegments = { "v2/projects", "training_data/queries" }; - String[] pathParameters = { createTrainingQueryOptions.projectId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createTrainingQuery"); + public ServiceCall queryCollectionNotices( + QueryCollectionNoticesOptions queryCollectionNoticesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + queryCollectionNoticesOptions, "queryCollectionNoticesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", queryCollectionNoticesOptions.projectId()); + pathParamsMap.put("collection_id", queryCollectionNoticesOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/notices", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "queryCollectionNotices"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("natural_language_query", createTrainingQueryOptions.naturalLanguageQuery()); - contentJson.add("examples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - createTrainingQueryOptions.examples())); - if (createTrainingQueryOptions.filter() != null) { - contentJson.addProperty("filter", createTrainingQueryOptions.filter()); + builder.query("version", String.valueOf(this.version)); + if (queryCollectionNoticesOptions.filter() != null) { + builder.query("filter", String.valueOf(queryCollectionNoticesOptions.filter())); } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + if (queryCollectionNoticesOptions.query() != null) { + builder.query("query", String.valueOf(queryCollectionNoticesOptions.query())); + } + if (queryCollectionNoticesOptions.naturalLanguageQuery() != null) { + builder.query( + "natural_language_query", + String.valueOf(queryCollectionNoticesOptions.naturalLanguageQuery())); + } + if (queryCollectionNoticesOptions.count() != null) { + builder.query("count", String.valueOf(queryCollectionNoticesOptions.count())); + } + if (queryCollectionNoticesOptions.offset() != null) { + builder.query("offset", String.valueOf(queryCollectionNoticesOptions.offset())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Query project notices. + * + *

Finds project-level notices (errors and warnings). Currently, project-level notices are + * generated by relevancy training. + * + * @param queryNoticesOptions the {@link QueryNoticesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link QueryNoticesResponse} + */ + public ServiceCall queryNotices(QueryNoticesOptions queryNoticesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + queryNoticesOptions, "queryNoticesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", queryNoticesOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/notices", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "queryNotices"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (queryNoticesOptions.filter() != null) { + builder.query("filter", String.valueOf(queryNoticesOptions.filter())); + } + if (queryNoticesOptions.query() != null) { + builder.query("query", String.valueOf(queryNoticesOptions.query())); + } + if (queryNoticesOptions.naturalLanguageQuery() != null) { + builder.query( + "natural_language_query", String.valueOf(queryNoticesOptions.naturalLanguageQuery())); + } + if (queryNoticesOptions.count() != null) { + builder.query("count", String.valueOf(queryNoticesOptions.count())); + } + if (queryNoticesOptions.offset() != null) { + builder.query("offset", String.valueOf(queryNoticesOptions.offset())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a custom stop words list. + * + *

Returns the custom stop words list that is used by the collection. For information about the + * default stop words lists that are applied to queries, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-stopwords). + * + * @param getStopwordListOptions the {@link GetStopwordListOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link StopWordList} + */ + public ServiceCall getStopwordList(GetStopwordListOptions getStopwordListOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getStopwordListOptions, "getStopwordListOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getStopwordListOptions.projectId()); + pathParamsMap.put("collection_id", getStopwordListOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/stopwords", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getStopwordList"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a custom stop words list. + * + *

Adds a list of custom stop words. Stop words are words that you want the service to ignore + * when they occur in a query because they're not useful in distinguishing the semantic meaning of + * the query. The stop words list cannot contain more than 1 million characters. + * + *

A default stop words list is used by all collections. The default list is applied both at + * indexing time and at query time. A custom stop words list that you add is used at query time + * only. + * + *

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 + * for the call + * @return a {@link ServiceCall} with a result of type {@link StopWordList} + */ + public ServiceCall createStopwordList( + CreateStopwordListOptions createStopwordListOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createStopwordListOptions, "createStopwordListOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createStopwordListOptions.projectId()); + pathParamsMap.put("collection_id", createStopwordListOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/stopwords", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "createStopwordList"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (createStopwordListOptions.stopwords() != null) { + contentJson.add( + "stopwords", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createStopwordListOptions.stopwords())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a custom stop words list. + * + *

Deletes a custom stop words list to stop using it in queries against the collection. After a + * custom stop words list is deleted, the default stop words list is used. + * + * @param deleteStopwordListOptions the {@link DeleteStopwordListOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteStopwordList(DeleteStopwordListOptions deleteStopwordListOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteStopwordListOptions, "deleteStopwordListOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteStopwordListOptions.projectId()); + pathParamsMap.put("collection_id", deleteStopwordListOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/stopwords", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "deleteStopwordList"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get the expansion list. + * + *

Returns the current expansion list for the specified collection. If an expansion list is not + * specified, an empty expansions array is returned. + * + * @param listExpansionsOptions the {@link ListExpansionsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Expansions} + */ + public ServiceCall listExpansions(ListExpansionsOptions listExpansionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listExpansionsOptions, "listExpansionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listExpansionsOptions.projectId()); + pathParamsMap.put("collection_id", listExpansionsOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/expansions", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listExpansions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create or update an expansion list. + * + *

Creates or replaces the expansion list for this collection. An expansion list introduces + * alternative wording for key terms that are mentioned in your collection. By identifying + * synonyms or common misspellings, you expand the scope of a query beyond exact matches. The + * maximum number of expanded terms allowed per collection is 5,000. + * + * @param createExpansionsOptions the {@link CreateExpansionsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Expansions} + */ + public ServiceCall createExpansions(CreateExpansionsOptions createExpansionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createExpansionsOptions, "createExpansionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createExpansionsOptions.projectId()); + pathParamsMap.put("collection_id", createExpansionsOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/expansions", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createExpansions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.add( + "expansions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createExpansionsOptions.expansions())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete the expansion list. + * + *

Removes the expansion information for this collection. To disable query expansion for a + * collection, delete the expansion list. + * + * @param deleteExpansionsOptions the {@link DeleteExpansionsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteExpansions(DeleteExpansionsOptions deleteExpansionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteExpansionsOptions, "deleteExpansionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteExpansionsOptions.projectId()); + pathParamsMap.put("collection_id", deleteExpansionsOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/expansions", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteExpansions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List component settings. + * + *

Returns default configuration settings for components. + * + * @param getComponentSettingsOptions the {@link GetComponentSettingsOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link ComponentSettingsResponse} + */ + public ServiceCall getComponentSettings( + GetComponentSettingsOptions getComponentSettingsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getComponentSettingsOptions, "getComponentSettingsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getComponentSettingsOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/component_settings", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "getComponentSettings"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List training queries. + * + *

List the training queries for the specified project. + * + * @param listTrainingQueriesOptions the {@link ListTrainingQueriesOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link TrainingQuerySet} + */ + public ServiceCall listTrainingQueries( + ListTrainingQueriesOptions listTrainingQueriesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listTrainingQueriesOptions, "listTrainingQueriesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listTrainingQueriesOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/training_data/queries", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "listTrainingQueries"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete training queries. + * + *

Removes all training queries for the specified project. + * + * @param deleteTrainingQueriesOptions the {@link DeleteTrainingQueriesOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteTrainingQueries( + DeleteTrainingQueriesOptions deleteTrainingQueriesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteTrainingQueriesOptions, "deleteTrainingQueriesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteTrainingQueriesOptions.projectId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/training_data/queries", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "deleteTrainingQueries"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a training query. + * + *

Add a query to the training data for this project. The query can contain a filter and + * natural language query. + * + *

**Note**: You cannot apply relevancy training to a `content_mining` project type. + * + * @param createTrainingQueryOptions the {@link CreateTrainingQueryOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} + */ + public ServiceCall createTrainingQuery( + CreateTrainingQueryOptions createTrainingQueryOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createTrainingQueryOptions, "createTrainingQueryOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createTrainingQueryOptions.projectId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/training_data/queries", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "createTrainingQuery"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty( + "natural_language_query", createTrainingQueryOptions.naturalLanguageQuery()); + contentJson.add( + "examples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createTrainingQueryOptions.examples())); + if (createTrainingQueryOptions.filter() != null) { + contentJson.addProperty("filter", createTrainingQueryOptions.filter()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Get a training data query. * - * Get details for a specific training data query, including the query string and all examples. + *

Get details for a specific training data query, including the query string and all examples. * - * @param getTrainingQueryOptions the {@link GetTrainingQueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @param getTrainingQueryOptions the {@link GetTrainingQueryOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ - public ServiceCall getTrainingQuery(GetTrainingQueryOptions getTrainingQueryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getTrainingQueryOptions, - "getTrainingQueryOptions cannot be null"); - String[] pathSegments = { "v2/projects", "training_data/queries" }; - String[] pathParameters = { getTrainingQueryOptions.projectId(), getTrainingQueryOptions.queryId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); + public ServiceCall getTrainingQuery( + GetTrainingQueryOptions getTrainingQueryOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getTrainingQueryOptions, "getTrainingQueryOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getTrainingQueryOptions.projectId()); + pathParamsMap.put("query_id", getTrainingQueryOptions.queryId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/training_data/queries/{query_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getTrainingQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Update a training query. * - * Updates an existing training query and it's examples. + *

Updates an existing training query and its examples. You must resubmit all of the examples + * with the update request. * - * @param updateTrainingQueryOptions the {@link UpdateTrainingQueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @param updateTrainingQueryOptions the {@link UpdateTrainingQueryOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ - public ServiceCall updateTrainingQuery(UpdateTrainingQueryOptions updateTrainingQueryOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateTrainingQueryOptions, - "updateTrainingQueryOptions cannot be null"); - String[] pathSegments = { "v2/projects", "training_data/queries" }; - String[] pathParameters = { updateTrainingQueryOptions.projectId(), updateTrainingQueryOptions.queryId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateTrainingQuery"); + public ServiceCall updateTrainingQuery( + UpdateTrainingQueryOptions updateTrainingQueryOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateTrainingQueryOptions, "updateTrainingQueryOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateTrainingQueryOptions.projectId()); + pathParamsMap.put("query_id", updateTrainingQueryOptions.queryId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/training_data/queries/{query_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "updateTrainingQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("natural_language_query", updateTrainingQueryOptions.naturalLanguageQuery()); - contentJson.add("examples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - updateTrainingQueryOptions.examples())); + contentJson.addProperty( + "natural_language_query", updateTrainingQueryOptions.naturalLanguageQuery()); + contentJson.add( + "examples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateTrainingQueryOptions.examples())); if (updateTrainingQueryOptions.filter() != null) { contentJson.addProperty("filter", updateTrainingQueryOptions.filter()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a training data query. + * + *

Removes details from a training data query, including the query string and all examples. + * + *

To delete an example, use the *Update a training query* method and omit the example that you + * want to delete from the example set. + * + * @param deleteTrainingQueryOptions the {@link DeleteTrainingQueryOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteTrainingQuery( + DeleteTrainingQueryOptions deleteTrainingQueryOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteTrainingQueryOptions, "deleteTrainingQueryOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteTrainingQueryOptions.projectId()); + pathParamsMap.put("query_id", deleteTrainingQueryOptions.queryId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/training_data/queries/{query_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "deleteTrainingQuery"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List enrichments. + * + *

Lists the enrichments available to this project. The *Part of Speech* and *Sentiment of + * Phrases* enrichments might be listed, but are reserved for internal use only. + * + * @param listEnrichmentsOptions the {@link ListEnrichmentsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Enrichments} + */ + public ServiceCall listEnrichments(ListEnrichmentsOptions listEnrichmentsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listEnrichmentsOptions, "listEnrichmentsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listEnrichmentsOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/enrichments", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listEnrichments"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create an enrichment. + * + *

Create an enrichment for use with the specified project. To apply the enrichment to a + * collection in the project, use the [Collections API](/apidocs/discovery-data#createcollection). + * + * @param createEnrichmentOptions the {@link CreateEnrichmentOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Enrichment} + */ + public ServiceCall createEnrichment(CreateEnrichmentOptions createEnrichmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createEnrichmentOptions, "createEnrichmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createEnrichmentOptions.projectId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/enrichments", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createEnrichment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart("enrichment", createEnrichmentOptions.enrichment().toString()); + if (createEnrichmentOptions.file() != null) { + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody(createEnrichmentOptions.file(), "application/octet-stream"); + multipartBuilder.addFormDataPart("file", "filename", fileBody); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get enrichment. + * + *

Get details about a specific enrichment. + * + * @param getEnrichmentOptions the {@link GetEnrichmentOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Enrichment} + */ + public ServiceCall getEnrichment(GetEnrichmentOptions getEnrichmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getEnrichmentOptions, "getEnrichmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getEnrichmentOptions.projectId()); + pathParamsMap.put("enrichment_id", getEnrichmentOptions.enrichmentId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/enrichments/{enrichment_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getEnrichment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update an enrichment. + * + *

Updates an existing enrichment's name and description. + * + * @param updateEnrichmentOptions the {@link UpdateEnrichmentOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Enrichment} + */ + public ServiceCall updateEnrichment(UpdateEnrichmentOptions updateEnrichmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateEnrichmentOptions, "updateEnrichmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateEnrichmentOptions.projectId()); + pathParamsMap.put("enrichment_id", updateEnrichmentOptions.enrichmentId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/enrichments/{enrichment_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateEnrichment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", updateEnrichmentOptions.name()); + if (updateEnrichmentOptions.description() != null) { + contentJson.addProperty("description", updateEnrichmentOptions.description()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } + /** + * Delete an enrichment. + * + *

Deletes an existing enrichment from the specified project. + * + *

**Note:** Only enrichments that have been manually created can be deleted. + * + * @param deleteEnrichmentOptions the {@link DeleteEnrichmentOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteEnrichment(DeleteEnrichmentOptions deleteEnrichmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteEnrichmentOptions, "deleteEnrichmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteEnrichmentOptions.projectId()); + pathParamsMap.put("enrichment_id", deleteEnrichmentOptions.enrichmentId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/enrichments/{enrichment_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteEnrichment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List batches. + * + *

A batch is a set of documents that are ready for enrichment by an external application. + * After you apply a webhook enrichment to a collection, and then process or upload documents to + * the collection, Discovery creates a batch with a unique **batch_id**. + * + *

To start, you must register your external application as a **webhook** type by using the + * [Create enrichment API](/apidocs/discovery-data#createenrichment) method. + * + *

Use the List batches API to get the following: + * + *

* Notified batches that are not yet pulled by the external enrichment application. + * + *

* Batches that are pulled, but not yet pushed to Discovery by the external enrichment + * application. + * + * @param listBatchesOptions the {@link ListBatchesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListBatchesResponse} + */ + public ServiceCall listBatches(ListBatchesOptions listBatchesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listBatchesOptions, "listBatchesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listBatchesOptions.projectId()); + pathParamsMap.put("collection_id", listBatchesOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/batches", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listBatches"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Pull batches. + * + *

Pull a batch of documents from Discovery for enrichment by an external application. Ensure + * to include the `Accept-Encoding: gzip` header in this method to get the file. You can also + * implement retry logic when calling this method to avoid any network errors. + * + * @param pullBatchesOptions the {@link PullBatchesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PullBatchesResponse} + */ + public ServiceCall pullBatches(PullBatchesOptions pullBatchesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + pullBatchesOptions, "pullBatchesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", pullBatchesOptions.projectId()); + pathParamsMap.put("collection_id", pullBatchesOptions.collectionId()); + pathParamsMap.put("batch_id", pullBatchesOptions.batchId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/batches/{batch_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "pullBatches"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Push batches. + * + *

Push a batch of documents to Discovery after annotation by an external application. You can + * implement retry logic when calling this method to avoid any network errors. + * + * @param pushBatchesOptions the {@link PushBatchesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Boolean} + */ + public ServiceCall pushBatches(PushBatchesOptions pushBatchesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + pushBatchesOptions, "pushBatchesOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.isTrue( + (pushBatchesOptions.file() != null), "At least one of or file must be supplied."); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", pushBatchesOptions.projectId()); + pathParamsMap.put("collection_id", pushBatchesOptions.collectionId()); + pathParamsMap.put("batch_id", pushBatchesOptions.batchId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/batches/{batch_id}", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "pushBatches"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + if (pushBatchesOptions.file() != null) { + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody(pushBatchesOptions.file(), "application/octet-stream"); + multipartBuilder.addFormDataPart("file", pushBatchesOptions.filename(), fileBody); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List document classifiers. + * + *

Get a list of the document classifiers in a project. Returns only the name and classifier ID + * of each document classifier. + * + * @param listDocumentClassifiersOptions the {@link ListDocumentClassifiersOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifiers} + */ + public ServiceCall listDocumentClassifiers( + ListDocumentClassifiersOptions listDocumentClassifiersOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listDocumentClassifiersOptions, "listDocumentClassifiersOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listDocumentClassifiersOptions.projectId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/document_classifiers", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "listDocumentClassifiers"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a document classifier. + * + *

Create a document classifier. You can use the API to create a document classifier in any + * project type. After you create a document classifier, you can use the Enrichments API to create + * a classifier enrichment, and then the Collections API to apply the enrichment to a collection + * in the project. + * + *

**Note:** This method is supported on installed instances (IBM Cloud Pak for Data) or IBM + * Cloud-managed Premium or Enterprise plan instances. + * + * @param createDocumentClassifierOptions the {@link CreateDocumentClassifierOptions} containing + * the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifier} + */ + public ServiceCall createDocumentClassifier( + CreateDocumentClassifierOptions createDocumentClassifierOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createDocumentClassifierOptions, "createDocumentClassifierOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createDocumentClassifierOptions.projectId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/document_classifiers", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "createDocumentClassifier"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + okhttp3.RequestBody trainingDataBody = + RequestUtils.inputStreamBody(createDocumentClassifierOptions.trainingData(), "text/csv"); + multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); + multipartBuilder.addFormDataPart( + "classifier", createDocumentClassifierOptions.classifier().toString()); + if (createDocumentClassifierOptions.testData() != null) { + okhttp3.RequestBody testDataBody = + RequestUtils.inputStreamBody(createDocumentClassifierOptions.testData(), "text/csv"); + multipartBuilder.addFormDataPart("test_data", "filename", testDataBody); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a document classifier. + * + *

Get details about a specific document classifier. + * + * @param getDocumentClassifierOptions the {@link GetDocumentClassifierOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifier} + */ + public ServiceCall getDocumentClassifier( + GetDocumentClassifierOptions getDocumentClassifierOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getDocumentClassifierOptions, "getDocumentClassifierOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getDocumentClassifierOptions.projectId()); + pathParamsMap.put("classifier_id", getDocumentClassifierOptions.classifierId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "getDocumentClassifier"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a document classifier. + * + *

Update the document classifier name or description, update the training data, or add or + * update the test data. + * + * @param updateDocumentClassifierOptions the {@link UpdateDocumentClassifierOptions} containing + * the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifier} + */ + public ServiceCall updateDocumentClassifier( + UpdateDocumentClassifierOptions updateDocumentClassifierOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateDocumentClassifierOptions, "updateDocumentClassifierOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateDocumentClassifierOptions.projectId()); + pathParamsMap.put("classifier_id", updateDocumentClassifierOptions.classifierId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "updateDocumentClassifier"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart( + "classifier", updateDocumentClassifierOptions.classifier().toString()); + if (updateDocumentClassifierOptions.trainingData() != null) { + okhttp3.RequestBody trainingDataBody = + RequestUtils.inputStreamBody(updateDocumentClassifierOptions.trainingData(), "text/csv"); + multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); + } + if (updateDocumentClassifierOptions.testData() != null) { + okhttp3.RequestBody testDataBody = + RequestUtils.inputStreamBody(updateDocumentClassifierOptions.testData(), "text/csv"); + multipartBuilder.addFormDataPart("test_data", "filename", testDataBody); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a document classifier. + * + *

Deletes an existing document classifier from the specified project. + * + * @param deleteDocumentClassifierOptions the {@link DeleteDocumentClassifierOptions} containing + * the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteDocumentClassifier( + DeleteDocumentClassifierOptions deleteDocumentClassifierOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteDocumentClassifierOptions, "deleteDocumentClassifierOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteDocumentClassifierOptions.projectId()); + pathParamsMap.put("classifier_id", deleteDocumentClassifierOptions.classifierId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "deleteDocumentClassifier"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List document classifier models. + * + *

Get a list of the document classifier models in a project. Returns only the name and model + * ID of each document classifier model. + * + * @param listDocumentClassifierModelsOptions the {@link ListDocumentClassifierModelsOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifierModels} + */ + public ServiceCall listDocumentClassifierModels( + ListDocumentClassifierModelsOptions listDocumentClassifierModelsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listDocumentClassifierModelsOptions, "listDocumentClassifierModelsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listDocumentClassifierModelsOptions.projectId()); + pathParamsMap.put("classifier_id", listDocumentClassifierModelsOptions.classifierId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}/models", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "listDocumentClassifierModels"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a document classifier model. + * + *

Create a document classifier model by training a model that uses the data and classifier + * settings defined in the specified document classifier. + * + *

**Note:** This method is supported on installed intances (IBM Cloud Pak for Data) or IBM + * Cloud-managed Premium or Enterprise plan instances. + * + * @param createDocumentClassifierModelOptions the {@link CreateDocumentClassifierModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifierModel} + */ + public ServiceCall createDocumentClassifierModel( + CreateDocumentClassifierModelOptions createDocumentClassifierModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createDocumentClassifierModelOptions, + "createDocumentClassifierModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createDocumentClassifierModelOptions.projectId()); + pathParamsMap.put("classifier_id", createDocumentClassifierModelOptions.classifierId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}/models", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "createDocumentClassifierModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", createDocumentClassifierModelOptions.name()); + if (createDocumentClassifierModelOptions.description() != null) { + contentJson.addProperty("description", createDocumentClassifierModelOptions.description()); + } + if (createDocumentClassifierModelOptions.learningRate() != null) { + contentJson.addProperty("learning_rate", createDocumentClassifierModelOptions.learningRate()); + } + if (createDocumentClassifierModelOptions.l1RegularizationStrengths() != null) { + contentJson.add( + "l1_regularization_strengths", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDocumentClassifierModelOptions.l1RegularizationStrengths())); + } + if (createDocumentClassifierModelOptions.l2RegularizationStrengths() != null) { + contentJson.add( + "l2_regularization_strengths", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDocumentClassifierModelOptions.l2RegularizationStrengths())); + } + if (createDocumentClassifierModelOptions.trainingMaxSteps() != null) { + contentJson.addProperty( + "training_max_steps", createDocumentClassifierModelOptions.trainingMaxSteps()); + } + if (createDocumentClassifierModelOptions.improvementRatio() != null) { + contentJson.addProperty( + "improvement_ratio", createDocumentClassifierModelOptions.improvementRatio()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a document classifier model. + * + *

Get details about a specific document classifier model. + * + * @param getDocumentClassifierModelOptions the {@link GetDocumentClassifierModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifierModel} + */ + public ServiceCall getDocumentClassifierModel( + GetDocumentClassifierModelOptions getDocumentClassifierModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getDocumentClassifierModelOptions, "getDocumentClassifierModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getDocumentClassifierModelOptions.projectId()); + pathParamsMap.put("classifier_id", getDocumentClassifierModelOptions.classifierId()); + pathParamsMap.put("model_id", getDocumentClassifierModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}/models/{model_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "getDocumentClassifierModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a document classifier model. + * + *

Update the document classifier model name or description. + * + * @param updateDocumentClassifierModelOptions the {@link UpdateDocumentClassifierModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentClassifierModel} + */ + public ServiceCall updateDocumentClassifierModel( + UpdateDocumentClassifierModelOptions updateDocumentClassifierModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateDocumentClassifierModelOptions, + "updateDocumentClassifierModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateDocumentClassifierModelOptions.projectId()); + pathParamsMap.put("classifier_id", updateDocumentClassifierModelOptions.classifierId()); + pathParamsMap.put("model_id", updateDocumentClassifierModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}/models/{model_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "updateDocumentClassifierModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (updateDocumentClassifierModelOptions.name() != null) { + contentJson.addProperty("name", updateDocumentClassifierModelOptions.name()); + } + if (updateDocumentClassifierModelOptions.description() != null) { + contentJson.addProperty("description", updateDocumentClassifierModelOptions.description()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a document classifier model. + * + *

Deletes an existing document classifier model from the specified project. + * + * @param deleteDocumentClassifierModelOptions the {@link DeleteDocumentClassifierModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteDocumentClassifierModel( + DeleteDocumentClassifierModelOptions deleteDocumentClassifierModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteDocumentClassifierModelOptions, + "deleteDocumentClassifierModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteDocumentClassifierModelOptions.projectId()); + pathParamsMap.put("classifier_id", deleteDocumentClassifierModelOptions.classifierId()); + pathParamsMap.put("model_id", deleteDocumentClassifierModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/document_classifiers/{classifier_id}/models/{model_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("discovery", "v2", "deleteDocumentClassifierModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Analyze a document. + * + *

Process a document and return it for realtime use. Supports JSON files only. + * + *

The file is not stored in the collection, but is processed according to the collection's + * configuration settings. To get results, enrichments must be applied to a field in the + * collection that also exists in the file that you want to analyze. For example, to analyze text + * in a `Quote` field, you must apply enrichments to the `Quote` field in the collection + * configuration. Then, when you analyze the file, the text in the `Quote` field is analyzed and + * results are written to a field named `enriched_Quote`. + * + *

Submit a request against only one collection at a time. Remember, the documents in the + * collection are not significant. It is the enrichments that are defined for the collection that + * matter. If you submit requests to several collections, then several models are initiated at the + * same time, which can cause request failures. + * + *

**Note:** This method is supported with Enterprise plan deployments and installed + * deployments only. + * + * @param analyzeDocumentOptions the {@link AnalyzeDocumentOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link AnalyzedDocument} + */ + public ServiceCall analyzeDocument( + AnalyzeDocumentOptions analyzeDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + analyzeDocumentOptions, "analyzeDocumentOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.isTrue( + (analyzeDocumentOptions.file() != null) || (analyzeDocumentOptions.metadata() != null), + "At least one of file or metadata must be supplied."); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", analyzeDocumentOptions.projectId()); + pathParamsMap.put("collection_id", analyzeDocumentOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/analyze", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "analyzeDocument"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + if (analyzeDocumentOptions.file() != null) { + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody( + analyzeDocumentOptions.file(), analyzeDocumentOptions.fileContentType()); + multipartBuilder.addFormDataPart("file", analyzeDocumentOptions.filename(), fileBody); + } + if (analyzeDocumentOptions.metadata() != null) { + multipartBuilder.addFormDataPart("metadata", analyzeDocumentOptions.metadata()); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete labeled data. + * + *

Deletes all data associated with a specified customer ID. The method has no effect if no + * data is associated with the customer ID. + * + *

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](/docs/discovery-data?topic=discovery-data-information-security#information-security). + * + *

**Note:** This method is only supported on IBM Cloud instances of Discovery. + * + * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteUserDataOptions, "deleteUserDataOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/user_data")); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteUserData"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java index eaa324a8b91..82086ad0529 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,18 +10,16 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; 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. - */ +/** The addDocument options. */ public class AddDocumentOptions extends GenericModel { protected String projectId; @@ -32,9 +30,7 @@ public class AddDocumentOptions extends GenericModel { protected String metadata; protected Boolean xWatsonDiscoveryForce; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String collectionId; @@ -44,6 +40,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; @@ -54,11 +55,8 @@ private Builder(AddDocumentOptions addDocumentOptions) { this.xWatsonDiscoveryForce = addDocumentOptions.xWatsonDiscoveryForce; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -74,7 +72,7 @@ public Builder(String projectId, String collectionId) { /** * Builds a AddDocumentOptions. * - * @return the addDocumentOptions + * @return the new AddDocumentOptions instance */ public AddDocumentOptions build() { return new AddDocumentOptions(this); @@ -162,7 +160,6 @@ public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { * * @param file the file * @return the AddDocumentOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder file(File file) throws FileNotFoundException { @@ -172,12 +169,14 @@ public Builder file(File file) throws FileNotFoundException { } } + protected AddDocumentOptions() {} + protected 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), + 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; @@ -200,7 +199,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -211,7 +211,7 @@ public String projectId() { /** * Gets the collectionId. * - * The ID of the collection. + *

The Universally Unique Identifier (UUID) of the collection. * * @return the collectionId */ @@ -222,9 +222,14 @@ public String 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 configuration is 1 megabyte. Files larger than the - * supported size are rejected. + *

**Add a document**: The content of the document to ingest. For the supported file types and + * maximum supported file size limits when adding a document, see [the + * documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes). + * + *

**Analyze a document**: The content of the document to analyze but not ingest. Only the + * `application/json` content type is supported by the Analyze API. For maximum supported file + * size limits, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-analyzeapi#analyzeapi-limits). * * @return the file */ @@ -235,7 +240,7 @@ public InputStream file() { /** * Gets the filename. * - * The filename for file. + *

The filename for file. * * @return the filename */ @@ -246,7 +251,8 @@ public String filename() { /** * Gets the fileContentType. * - * The content type of file. Values for this parameter can be obtained from the HttpMediaType class. + *

The content type of file. Values for this parameter can be obtained from the HttpMediaType + * class. * * @return the fileContentType */ @@ -257,10 +263,14 @@ public String 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" - * } ```. + *

Add information about the file that you want to include in the response. + * + *

The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are + * rejected. + * + *

Example: + * + *

``` { "filename": "favorites2.json", "file_type": "json" }. * * @return the metadata */ @@ -271,8 +281,8 @@ public String 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. + *

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 */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptions.java new file mode 100644 index 00000000000..afcb38314b6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptions.java @@ -0,0 +1,265 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The analyzeDocument options. */ +public class AnalyzeDocumentOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected InputStream file; + protected String filename; + protected String fileContentType; + protected String metadata; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private InputStream file; + private String filename; + 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; + this.file = analyzeDocumentOptions.file; + this.filename = analyzeDocumentOptions.filename; + this.fileContentType = analyzeDocumentOptions.fileContentType; + this.metadata = analyzeDocumentOptions.metadata; + } + + /** 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 AnalyzeDocumentOptions. + * + * @return the new AnalyzeDocumentOptions instance + */ + public AnalyzeDocumentOptions build() { + return new AnalyzeDocumentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the AnalyzeDocumentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the AnalyzeDocumentOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AnalyzeDocumentOptions builder + */ + public Builder file(InputStream file) { + this.file = file; + return this; + } + + /** + * Set the filename. + * + * @param filename the filename + * @return the AnalyzeDocumentOptions builder + */ + public Builder filename(String filename) { + this.filename = filename; + return this; + } + + /** + * Set the fileContentType. + * + * @param fileContentType the fileContentType + * @return the AnalyzeDocumentOptions builder + */ + public Builder fileContentType(String fileContentType) { + this.fileContentType = fileContentType; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the AnalyzeDocumentOptions builder + */ + public Builder metadata(String metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AnalyzeDocumentOptions 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; + } + } + + protected AnalyzeDocumentOptions() {} + + protected AnalyzeDocumentOptions(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; + } + + /** + * New builder. + * + * @return a AnalyzeDocumentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the file. + * + *

**Add a document**: The content of the document to ingest. For the supported file types and + * maximum supported file size limits when adding a document, see [the + * documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes). + * + *

**Analyze a document**: The content of the document to analyze but not ingest. Only the + * `application/json` content type is supported by the Analyze API. For maximum supported file + * size limits, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-analyzeapi#analyzeapi-limits). + * + * @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. + * + *

Add information about the file that you want to include in the response. + * + *

The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are + * rejected. + * + *

Example: + * + *

``` { "filename": "favorites2.json", "file_type": "json" }. + * + * @return the metadata + */ + public String metadata() { + return metadata; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedDocument.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedDocument.java new file mode 100644 index 00000000000..4521bf9b87e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedDocument.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** + * An object that contains the converted document and any identified enrichments. Root-level fields + * from the original file are returned also. + */ +public class AnalyzedDocument extends GenericModel { + + protected List notices; + protected AnalyzedResult result; + + protected AnalyzedDocument() {} + + /** + * Gets the notices. + * + *

Array of notices that are triggered when the files are processed. + * + * @return the notices + */ + public List getNotices() { + return notices; + } + + /** + * Gets the result. + * + *

Result of the document analysis. + * + * @return the result + */ + public AnalyzedResult getResult() { + return result; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedResult.java new file mode 100644 index 00000000000..b3fa0c2a062 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedResult.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.google.gson.reflect.TypeToken; +import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.Map; + +/** + * Result of the document analysis. + * + *

This type supports additional properties of type Object. The remaining key-value pairs. + */ +public class AnalyzedResult extends DynamicModel { + + @SerializedName("metadata") + protected Map metadata; + + public AnalyzedResult() { + super(new TypeToken() {}); + } + + /** + * Gets the metadata. + * + *

Metadata that was specified with the request. + * + * @return the metadata + */ + public Map getMetadata() { + return this.metadata; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/BatchDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/BatchDetails.java new file mode 100644 index 00000000000..a193a9b4fb9 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/BatchDetails.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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; +import java.util.Date; + +/** + * A batch is a set of documents that are ready for enrichment by an external application. After you + * apply a webhook enrichment to a collection, and then process or upload documents to the + * collection, Discovery creates a batch with a unique **batch_id**. + */ +public class BatchDetails extends GenericModel { + + @SerializedName("batch_id") + protected String batchId; + + protected Date created; + + @SerializedName("enrichment_id") + protected String enrichmentId; + + protected BatchDetails() {} + + /** + * Gets the batchId. + * + *

The Universally Unique Identifier (UUID) for a batch of documents. + * + * @return the batchId + */ + public String getBatchId() { + return batchId; + } + + /** + * Gets the created. + * + *

The date and time (RFC3339) that the batch was created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) for the external enrichment. + * + * @return the enrichmentId + */ + public String getEnrichmentId() { + return enrichmentId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ClassifierFederatedModel.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ClassifierFederatedModel.java new file mode 100644 index 00000000000..453556352cd --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ClassifierFederatedModel.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object with details for creating federated document classifier models. */ +public class ClassifierFederatedModel extends GenericModel { + + protected String field; + + /** Builder. */ + 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; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param field the field + */ + public Builder(String field) { + this.field = field; + } + + /** + * Builds a ClassifierFederatedModel. + * + * @return the new ClassifierFederatedModel instance + */ + public ClassifierFederatedModel build() { + return new ClassifierFederatedModel(this); + } + + /** + * Set the field. + * + * @param field the field + * @return the ClassifierFederatedModel builder + */ + public Builder field(String field) { + this.field = field; + return this; + } + } + + protected ClassifierFederatedModel() {} + + protected ClassifierFederatedModel(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.field, "field cannot be null"); + field = builder.field; + } + + /** + * New builder. + * + * @return a ClassifierFederatedModel builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the field. + * + *

Name of the field that contains the values from which multiple classifier models are + * defined. For example, you can specify a field that lists product lines to create a separate + * model per product line. + * + * @return the field + */ + public String field() { + return field; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ClassifierModelEvaluation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ClassifierModelEvaluation.java new file mode 100644 index 00000000000..7ac681b28f7 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ClassifierModelEvaluation.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.List; + +/** An object that contains information about a trained document classifier model. */ +public class ClassifierModelEvaluation extends GenericModel { + + @SerializedName("micro_average") + protected ModelEvaluationMicroAverage microAverage; + + @SerializedName("macro_average") + protected ModelEvaluationMacroAverage macroAverage; + + @SerializedName("per_class") + protected List perClass; + + protected ClassifierModelEvaluation() {} + + /** + * Gets the microAverage. + * + *

A micro-average aggregates the contributions of all classes to compute the average metric. + * Classes refers to the classification labels that are specified in the **answer_field**. + * + * @return the microAverage + */ + public ModelEvaluationMicroAverage getMicroAverage() { + return microAverage; + } + + /** + * Gets the macroAverage. + * + *

A macro-average computes metric independently for each class and then takes the average. + * Class refers to the classification label that is specified in the **answer_field**. + * + * @return the macroAverage + */ + public ModelEvaluationMacroAverage getMacroAverage() { + return macroAverage; + } + + /** + * Gets the perClass. + * + *

An array of evaluation metrics, one set of metrics for each class, where class refers to the + * classification label that is specified in the **answer_field**. + * + * @return the perClass + */ + public List getPerClass() { + return perClass; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java index 51713ee8a1b..e437c863f71 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,26 @@ * 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. - */ +/** A collection for storing documents. */ public class Collection extends GenericModel { @SerializedName("collection_id") protected String collectionId; + protected String name; + protected Collection() {} + /** * Gets the collectionId. * - * The unique identifier of the collection. + *

The Universally Unique Identifier (UUID) of the collection. * * @return the collectionId */ @@ -38,7 +40,7 @@ public String getCollectionId() { /** * Gets the name. * - * The name of the collection. + *

The name of the collection. * * @return the name */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java new file mode 100644 index 00000000000..a3a7936f907 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java @@ -0,0 +1,268 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** A collection for storing documents. */ +public class CollectionDetails extends GenericModel { + + @SerializedName("collection_id") + protected String collectionId; + + protected String name; + protected String description; + protected Date created; + protected String language; + + @SerializedName("ocr_enabled") + protected Boolean ocrEnabled; + + protected List enrichments; + + @SerializedName("smart_document_understanding") + protected CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private String language; + private Boolean ocrEnabled; + private List enrichments; + + /** + * 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.ocrEnabled = collectionDetails.ocrEnabled; + this.enrichments = collectionDetails.enrichments; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + */ + public Builder(String name) { + this.name = name; + } + + /** + * Builds a CollectionDetails. + * + * @return the new CollectionDetails instance + */ + public CollectionDetails build() { + return new CollectionDetails(this); + } + + /** + * Adds a new element to enrichments. + * + * @param enrichments the new element to be added + * @return the CollectionDetails builder + */ + public Builder addEnrichments(CollectionEnrichment enrichments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(enrichments, "enrichments cannot be null"); + if (this.enrichments == null) { + this.enrichments = new ArrayList(); + } + this.enrichments.add(enrichments); + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CollectionDetails builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CollectionDetails builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CollectionDetails builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the ocrEnabled. + * + * @param ocrEnabled the ocrEnabled + * @return the CollectionDetails builder + */ + public Builder ocrEnabled(Boolean ocrEnabled) { + this.ocrEnabled = ocrEnabled; + return this; + } + + /** + * Set the enrichments. Existing enrichments will be replaced. + * + * @param enrichments the enrichments + * @return the CollectionDetails builder + */ + public Builder enrichments(List enrichments) { + this.enrichments = enrichments; + return this; + } + } + + protected CollectionDetails() {} + + protected CollectionDetails(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + name = builder.name; + description = builder.description; + language = builder.language; + ocrEnabled = builder.ocrEnabled; + enrichments = builder.enrichments; + } + + /** + * New builder. + * + * @return a CollectionDetails builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the name. + * + *

The name of the collection. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A description of the collection. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the created. + * + *

The date that the collection was created. + * + * @return the created + */ + public Date created() { + return created; + } + + /** + * Gets the language. + * + *

The language of the collection. For a list of supported languages, see the [product + * documentation](/docs/discovery-data?topic=discovery-data-language-support). + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the ocrEnabled. + * + *

If set to `true`, optical character recognition (OCR) is enabled. For more information, see + * [Optical character recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). + * + * @return the ocrEnabled + */ + public Boolean ocrEnabled() { + return ocrEnabled; + } + + /** + * Gets the enrichments. + * + *

An array of enrichments that are applied to this collection. To get a list of enrichments + * that are available for a project, use the [List enrichments](#listenrichments) method. + * + *

If no enrichments are specified when the collection is created, the default enrichments for + * the project type are applied. For more information about project default settings, see the + * [product documentation](/docs/discovery-data?topic=discovery-data-project-defaults). + * + * @return the enrichments + */ + public List enrichments() { + return enrichments; + } + + /** + * Gets the smartDocumentUnderstanding. + * + *

An object that describes the Smart Document Understanding model for a collection. + * + * @return the smartDocumentUnderstanding + */ + public CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding() { + return smartDocumentUnderstanding; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetailsSmartDocumentUnderstanding.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetailsSmartDocumentUnderstanding.java new file mode 100644 index 00000000000..41b497b4158 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetailsSmartDocumentUnderstanding.java @@ -0,0 +1,154 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** An object that describes the Smart Document Understanding model for a collection. */ +public class CollectionDetailsSmartDocumentUnderstanding extends GenericModel { + + /** + * Specifies the type of Smart Document Understanding (SDU) model that is enabled for the + * collection. The following types of models are supported: + * + *

* `custom`: A user-trained model is applied. + * + *

* `pre_trained`: A pretrained model is applied. This type of model is applied automatically + * to *Document Retrieval for Contracts* projects. + * + *

* `text_extraction`: An SDU model that extracts text and metadata from the content. This + * model is enabled in collections by default regardless of the types of documents in the + * collection (as long as the service plan supports SDU models). + * + *

You can apply user-trained or pretrained models to collections from the *Identify fields* + * page of the product user interface. For more information, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-configuring-fields). + */ + public interface Model { + /** custom. */ + String CUSTOM = "custom"; + /** pre_trained. */ + String PRE_TRAINED = "pre_trained"; + /** text_extraction. */ + String TEXT_EXTRACTION = "text_extraction"; + } + + protected Boolean enabled; + protected String model; + + /** Builder. */ + 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; + this.model = collectionDetailsSmartDocumentUnderstanding.model; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a CollectionDetailsSmartDocumentUnderstanding. + * + * @return the new CollectionDetailsSmartDocumentUnderstanding instance + */ + public CollectionDetailsSmartDocumentUnderstanding build() { + return new CollectionDetailsSmartDocumentUnderstanding(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the CollectionDetailsSmartDocumentUnderstanding builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the model. + * + * @param model the model + * @return the CollectionDetailsSmartDocumentUnderstanding builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + protected CollectionDetailsSmartDocumentUnderstanding() {} + + protected CollectionDetailsSmartDocumentUnderstanding(Builder builder) { + enabled = builder.enabled; + model = builder.model; + } + + /** + * New builder. + * + * @return a CollectionDetailsSmartDocumentUnderstanding builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

When `true`, smart document understanding conversion is enabled for the collection. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the model. + * + *

Specifies the type of Smart Document Understanding (SDU) model that is enabled for the + * collection. The following types of models are supported: + * + *

* `custom`: A user-trained model is applied. + * + *

* `pre_trained`: A pretrained model is applied. This type of model is applied automatically + * to *Document Retrieval for Contracts* projects. + * + *

* `text_extraction`: An SDU model that extracts text and metadata from the content. This + * model is enabled in collections by default regardless of the types of documents in the + * collection (as long as the service plan supports SDU models). + * + *

You can apply user-trained or pretrained models to collections from the *Identify fields* + * page of the product user interface. For more information, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-configuring-fields). + * + * @return the model + */ + public String model() { + return model; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java new file mode 100644 index 00000000000..d7ec6be5a9f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java @@ -0,0 +1,136 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** An object describing an enrichment for a collection. */ +public class CollectionEnrichment extends GenericModel { + + @SerializedName("enrichment_id") + protected String enrichmentId; + + protected List fields; + + /** Builder. */ + public static class Builder { + private String enrichmentId; + private List 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; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a CollectionEnrichment. + * + * @return the new CollectionEnrichment instance + */ + public CollectionEnrichment build() { + return new CollectionEnrichment(this); + } + + /** + * Adds a new element to fields. + * + * @param fields the new element to be added + * @return the CollectionEnrichment builder + */ + public Builder addFields(String fields) { + com.ibm.cloud.sdk.core.util.Validator.notNull(fields, "fields cannot be null"); + if (this.fields == null) { + this.fields = new ArrayList(); + } + this.fields.add(fields); + return this; + } + + /** + * Set the enrichmentId. + * + * @param enrichmentId the enrichmentId + * @return the CollectionEnrichment builder + */ + public Builder enrichmentId(String enrichmentId) { + this.enrichmentId = enrichmentId; + return this; + } + + /** + * Set the fields. Existing fields will be replaced. + * + * @param fields the fields + * @return the CollectionEnrichment builder + */ + public Builder fields(List fields) { + this.fields = fields; + return this; + } + } + + protected CollectionEnrichment() {} + + protected CollectionEnrichment(Builder builder) { + enrichmentId = builder.enrichmentId; + fields = builder.fields; + } + + /** + * New builder. + * + * @return a CollectionEnrichment builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enrichmentId. + * + *

The unique identifier of this enrichment. For more information about how to determine the ID + * of an enrichment, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-manage-enrichments#enrichments-ids). + * + * @return the enrichmentId + */ + public String enrichmentId() { + return enrichmentId; + } + + /** + * Gets the fields. + * + *

An array of field names that the enrichment is applied to. + * + *

If you apply an enrichment to a field from a JSON file, the data is converted to an array + * automatically, even if the field contains a single value. + * + * @return the fields + */ + public List fields() { + return fields; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java index da8e294c106..0e1594f5989 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,23 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * An object containing an array of autocompletion suggestions. - */ +/** An object that contains an array of autocompletion suggestions. */ public class Completions extends GenericModel { protected List completions; + protected Completions() {} + /** * Gets the completions. * - * Array of autcomplete suggestion based on the provided prefix. + *

Array of autocomplete suggestion based on the provided prefix. * * @return the completions */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java index 289075a7cdf..02b08751108 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,19 +10,16 @@ * 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; -/** - * Display settings for aggregations. - */ +/** Display settings for aggregations. */ public class ComponentSettingsAggregation extends GenericModel { - /** - * Type of visualization to use when rendering the aggregation. - */ + /** Type of visualization to use when rendering the aggregation. */ public interface VisualizationType { /** auto. */ String AUTO = "auto"; @@ -36,15 +33,19 @@ public interface VisualizationType { protected String name; protected String label; + @SerializedName("multiple_selections_allowed") protected Boolean multipleSelectionsAllowed; + @SerializedName("visualization_type") protected String visualizationType; + protected ComponentSettingsAggregation() {} + /** * Gets the name. * - * Identifier used to map aggregation settings to aggregation configuration. + *

Identifier used to map aggregation settings to aggregation configuration. * * @return the name */ @@ -55,7 +56,7 @@ public String getName() { /** * Gets the label. * - * User-friendly alias for the aggregation. + *

User-friendly alias for the aggregation. * * @return the label */ @@ -66,7 +67,7 @@ public String getLabel() { /** * Gets the multipleSelectionsAllowed. * - * Whether users is allowed to select more than one of the aggregation terms. + *

Whether users is allowed to select more than one of the aggregation terms. * * @return the multipleSelectionsAllowed */ @@ -77,7 +78,7 @@ public Boolean isMultipleSelectionsAllowed() { /** * Gets the visualizationType. * - * Type of visualization to use when rendering the aggregation. + *

Type of visualization to use when rendering the aggregation. * * @return the visualizationType */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java index 4f4384ddd3b..ffda748e931 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,22 +10,23 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Fields shown in the results section of the UI. - */ +/** Fields shown in the results section of the UI. */ public class ComponentSettingsFieldsShown extends GenericModel { protected ComponentSettingsFieldsShownBody body; protected ComponentSettingsFieldsShownTitle title; + protected ComponentSettingsFieldsShown() {} + /** * Gets the body. * - * Body label. + *

Body label. * * @return the body */ @@ -36,7 +37,7 @@ public ComponentSettingsFieldsShownBody getBody() { /** * Gets the title. * - * Title label. + *

Title label. * * @return the title */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java index 9acc125076a..b9378decc55 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,26 @@ * 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; -/** - * Body label. - */ +/** Body label. */ public class ComponentSettingsFieldsShownBody extends GenericModel { @SerializedName("use_passage") protected Boolean usePassage; + protected String field; + protected ComponentSettingsFieldsShownBody() {} + /** * Gets the usePassage. * - * Use the whole passage as the body. + *

Use the whole passage as the body. * * @return the usePassage */ @@ -38,7 +40,7 @@ public Boolean isUsePassage() { /** * Gets the field. * - * Use a specific field as the title. + *

Use a specific field as the title. * * @return the field */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java index 680b2d2e3a5..5a682eaca6d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,21 +10,22 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Title label. - */ +/** Title label. */ public class ComponentSettingsFieldsShownTitle extends GenericModel { protected String field; + protected ComponentSettingsFieldsShownTitle() {} + /** * Gets the field. * - * Use a specific field as the title. + *

Use a specific field as the title. * * @return the field */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java index a15c8310639..420e7c446a2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,31 +10,35 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * A response containing the default component settings. - */ +/** The default component settings for this project. */ public class ComponentSettingsResponse extends GenericModel { @SerializedName("fields_shown") protected ComponentSettingsFieldsShown fieldsShown; + protected Boolean autocomplete; + @SerializedName("structured_search") protected Boolean structuredSearch; + @SerializedName("results_per_page") protected Long resultsPerPage; + protected List aggregations; + protected ComponentSettingsResponse() {} + /** * Gets the fieldsShown. * - * Fields shown in the results section of the UI. + *

Fields shown in the results section of the UI. * * @return the fieldsShown */ @@ -45,7 +49,7 @@ public ComponentSettingsFieldsShown getFieldsShown() { /** * Gets the autocomplete. * - * Whether or not autocomplete is enabled. + *

Whether or not autocomplete is enabled. * * @return the autocomplete */ @@ -56,7 +60,7 @@ public Boolean isAutocomplete() { /** * Gets the structuredSearch. * - * Whether or not structured search is enabled. + *

Whether or not structured search is enabled. * * @return the structuredSearch */ @@ -67,7 +71,7 @@ public Boolean isStructuredSearch() { /** * Gets the resultsPerPage. * - * Number or results shown per page. + *

Number or results shown per page. * * @return the resultsPerPage */ @@ -78,7 +82,7 @@ public Long getResultsPerPage() { /** * Gets the aggregations. * - * a list of component setting aggregations. + *

a list of component setting aggregations. * * @return the aggregations */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java new file mode 100644 index 00000000000..534b99a2646 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java @@ -0,0 +1,268 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The createCollection options. */ +public class CreateCollectionOptions extends GenericModel { + + protected String projectId; + protected String name; + protected String description; + protected String language; + protected Boolean ocrEnabled; + protected List enrichments; + + /** Builder. */ + public static class Builder { + private String projectId; + private String name; + private String description; + private String language; + private Boolean ocrEnabled; + private List enrichments; + + /** + * Instantiates a new Builder from an existing CreateCollectionOptions instance. + * + * @param createCollectionOptions the instance to initialize the Builder with + */ + private Builder(CreateCollectionOptions createCollectionOptions) { + this.projectId = createCollectionOptions.projectId; + this.name = createCollectionOptions.name; + this.description = createCollectionOptions.description; + this.language = createCollectionOptions.language; + this.ocrEnabled = createCollectionOptions.ocrEnabled; + this.enrichments = createCollectionOptions.enrichments; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param name the name + */ + public Builder(String projectId, String name) { + this.projectId = projectId; + this.name = name; + } + + /** + * Builds a CreateCollectionOptions. + * + * @return the new CreateCollectionOptions instance + */ + public CreateCollectionOptions build() { + return new CreateCollectionOptions(this); + } + + /** + * Adds a new element to enrichments. + * + * @param enrichments the new element to be added + * @return the CreateCollectionOptions builder + */ + public Builder addEnrichments(CollectionEnrichment enrichments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(enrichments, "enrichments cannot be null"); + if (this.enrichments == null) { + this.enrichments = new ArrayList(); + } + this.enrichments.add(enrichments); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the CreateCollectionOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateCollectionOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateCollectionOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateCollectionOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the ocrEnabled. + * + * @param ocrEnabled the ocrEnabled + * @return the CreateCollectionOptions builder + */ + public Builder ocrEnabled(Boolean ocrEnabled) { + this.ocrEnabled = ocrEnabled; + return this; + } + + /** + * Set the enrichments. Existing enrichments will be replaced. + * + * @param enrichments the enrichments + * @return the CreateCollectionOptions builder + */ + public Builder enrichments(List enrichments) { + this.enrichments = enrichments; + return this; + } + + /** + * Set the collectionDetails. + * + * @param collectionDetails the collectionDetails + * @return the CreateCollectionOptions builder + */ + public Builder collectionDetails(CollectionDetails collectionDetails) { + this.name = collectionDetails.name(); + this.description = collectionDetails.description(); + this.language = collectionDetails.language(); + this.ocrEnabled = collectionDetails.ocrEnabled(); + this.enrichments = collectionDetails.enrichments(); + return this; + } + } + + protected CreateCollectionOptions() {} + + protected CreateCollectionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + projectId = builder.projectId; + name = builder.name; + description = builder.description; + language = builder.language; + ocrEnabled = builder.ocrEnabled; + enrichments = builder.enrichments; + } + + /** + * New builder. + * + * @return a CreateCollectionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the name. + * + *

The name of the collection. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A description of the collection. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the language. + * + *

The language of the collection. For a list of supported languages, see the [product + * documentation](/docs/discovery-data?topic=discovery-data-language-support). + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the ocrEnabled. + * + *

If set to `true`, optical character recognition (OCR) is enabled. For more information, see + * [Optical character recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). + * + * @return the ocrEnabled + */ + public Boolean ocrEnabled() { + return ocrEnabled; + } + + /** + * Gets the enrichments. + * + *

An array of enrichments that are applied to this collection. To get a list of enrichments + * that are available for a project, use the [List enrichments](#listenrichments) method. + * + *

If no enrichments are specified when the collection is created, the default enrichments for + * the project type are applied. For more information about project default settings, see the + * [product documentation](/docs/discovery-data?topic=discovery-data-project-defaults). + * + * @return the enrichments + */ + public List enrichments() { + return enrichments; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifier.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifier.java new file mode 100644 index 00000000000..73da104b1d3 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifier.java @@ -0,0 +1,263 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * An object that manages the settings and data that is required to train a document classification + * model. + */ +public class CreateDocumentClassifier extends GenericModel { + + protected String name; + protected String description; + protected String language; + + @SerializedName("answer_field") + protected String answerField; + + protected List enrichments; + + @SerializedName("federated_classification") + protected ClassifierFederatedModel federatedClassification; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private String language; + private String answerField; + private List enrichments; + private ClassifierFederatedModel federatedClassification; + + /** + * Instantiates a new Builder from an existing CreateDocumentClassifier instance. + * + * @param createDocumentClassifier the instance to initialize the Builder with + */ + private Builder(CreateDocumentClassifier createDocumentClassifier) { + this.name = createDocumentClassifier.name; + this.description = createDocumentClassifier.description; + this.language = createDocumentClassifier.language; + this.answerField = createDocumentClassifier.answerField; + this.enrichments = createDocumentClassifier.enrichments; + this.federatedClassification = createDocumentClassifier.federatedClassification; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param language the language + * @param answerField the answerField + */ + public Builder(String name, String language, String answerField) { + this.name = name; + this.language = language; + this.answerField = answerField; + } + + /** + * Builds a CreateDocumentClassifier. + * + * @return the new CreateDocumentClassifier instance + */ + public CreateDocumentClassifier build() { + return new CreateDocumentClassifier(this); + } + + /** + * Adds a new element to enrichments. + * + * @param enrichments the new element to be added + * @return the CreateDocumentClassifier builder + */ + public Builder addEnrichments(DocumentClassifierEnrichment enrichments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(enrichments, "enrichments cannot be null"); + if (this.enrichments == null) { + this.enrichments = new ArrayList(); + } + this.enrichments.add(enrichments); + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateDocumentClassifier builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateDocumentClassifier builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateDocumentClassifier builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the answerField. + * + * @param answerField the answerField + * @return the CreateDocumentClassifier builder + */ + public Builder answerField(String answerField) { + this.answerField = answerField; + return this; + } + + /** + * Set the enrichments. Existing enrichments will be replaced. + * + * @param enrichments the enrichments + * @return the CreateDocumentClassifier builder + */ + public Builder enrichments(List enrichments) { + this.enrichments = enrichments; + return this; + } + + /** + * Set the federatedClassification. + * + * @param federatedClassification the federatedClassification + * @return the CreateDocumentClassifier builder + */ + public Builder federatedClassification(ClassifierFederatedModel federatedClassification) { + this.federatedClassification = federatedClassification; + return this; + } + } + + protected CreateDocumentClassifier() {} + + protected CreateDocumentClassifier(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.answerField, "answerField cannot be null"); + name = builder.name; + description = builder.description; + language = builder.language; + answerField = builder.answerField; + enrichments = builder.enrichments; + federatedClassification = builder.federatedClassification; + } + + /** + * New builder. + * + * @return a CreateDocumentClassifier builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

A human-readable name of the document classifier. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A description of the document classifier. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the language. + * + *

The language of the training data that is associated with the document classifier. Language + * is specified by using the ISO 639-1 language code, such as `en` for English or `ja` for + * Japanese. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the answerField. + * + *

The name of the field from the training and test data that contains the classification + * labels. + * + * @return the answerField + */ + public String answerField() { + return answerField; + } + + /** + * Gets the enrichments. + * + *

An array of enrichments to apply to the data that is used to train and test the document + * classifier. The output from the enrichments is used as features by the classifier to classify + * the document content both during training and at run time. + * + * @return the enrichments + */ + public List enrichments() { + return enrichments; + } + + /** + * Gets the federatedClassification. + * + *

An object with details for creating federated document classifier models. + * + * @return the federatedClassification + */ + public ClassifierFederatedModel federatedClassification() { + return federatedClassification; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierModelOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierModelOptions.java new file mode 100644 index 00000000000..ee89ce5dc80 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierModelOptions.java @@ -0,0 +1,356 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The createDocumentClassifierModel options. */ +public class CreateDocumentClassifierModelOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + protected String name; + protected String description; + protected Double learningRate; + protected List l1RegularizationStrengths; + protected List l2RegularizationStrengths; + protected Long trainingMaxSteps; + protected Double improvementRatio; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + private String name; + private String description; + private Double learningRate; + private List l1RegularizationStrengths; + private List l2RegularizationStrengths; + private Long trainingMaxSteps; + private Double improvementRatio; + + /** + * Instantiates a new Builder from an existing CreateDocumentClassifierModelOptions instance. + * + * @param createDocumentClassifierModelOptions the instance to initialize the Builder with + */ + private Builder(CreateDocumentClassifierModelOptions createDocumentClassifierModelOptions) { + this.projectId = createDocumentClassifierModelOptions.projectId; + this.classifierId = createDocumentClassifierModelOptions.classifierId; + this.name = createDocumentClassifierModelOptions.name; + this.description = createDocumentClassifierModelOptions.description; + this.learningRate = createDocumentClassifierModelOptions.learningRate; + this.l1RegularizationStrengths = + createDocumentClassifierModelOptions.l1RegularizationStrengths; + this.l2RegularizationStrengths = + createDocumentClassifierModelOptions.l2RegularizationStrengths; + this.trainingMaxSteps = createDocumentClassifierModelOptions.trainingMaxSteps; + this.improvementRatio = createDocumentClassifierModelOptions.improvementRatio; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + * @param name the name + */ + public Builder(String projectId, String classifierId, String name) { + this.projectId = projectId; + this.classifierId = classifierId; + this.name = name; + } + + /** + * Builds a CreateDocumentClassifierModelOptions. + * + * @return the new CreateDocumentClassifierModelOptions instance + */ + public CreateDocumentClassifierModelOptions build() { + return new CreateDocumentClassifierModelOptions(this); + } + + /** + * Adds a new element to l1RegularizationStrengths. + * + * @param l1RegularizationStrengths the new element to be added + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder addL1RegularizationStrengths(Double l1RegularizationStrengths) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + l1RegularizationStrengths, "l1RegularizationStrengths cannot be null"); + if (this.l1RegularizationStrengths == null) { + this.l1RegularizationStrengths = new ArrayList(); + } + this.l1RegularizationStrengths.add(l1RegularizationStrengths); + return this; + } + + /** + * Adds a new element to l2RegularizationStrengths. + * + * @param l2RegularizationStrengths the new element to be added + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder addL2RegularizationStrengths(Double l2RegularizationStrengths) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + l2RegularizationStrengths, "l2RegularizationStrengths cannot be null"); + if (this.l2RegularizationStrengths == null) { + this.l2RegularizationStrengths = new ArrayList(); + } + this.l2RegularizationStrengths.add(l2RegularizationStrengths); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the learningRate. + * + * @param learningRate the learningRate + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder learningRate(Double learningRate) { + this.learningRate = learningRate; + return this; + } + + /** + * Set the l1RegularizationStrengths. Existing l1RegularizationStrengths will be replaced. + * + * @param l1RegularizationStrengths the l1RegularizationStrengths + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder l1RegularizationStrengths(List l1RegularizationStrengths) { + this.l1RegularizationStrengths = l1RegularizationStrengths; + return this; + } + + /** + * Set the l2RegularizationStrengths. Existing l2RegularizationStrengths will be replaced. + * + * @param l2RegularizationStrengths the l2RegularizationStrengths + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder l2RegularizationStrengths(List l2RegularizationStrengths) { + this.l2RegularizationStrengths = l2RegularizationStrengths; + return this; + } + + /** + * Set the trainingMaxSteps. + * + * @param trainingMaxSteps the trainingMaxSteps + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder trainingMaxSteps(long trainingMaxSteps) { + this.trainingMaxSteps = trainingMaxSteps; + return this; + } + + /** + * Set the improvementRatio. + * + * @param improvementRatio the improvementRatio + * @return the CreateDocumentClassifierModelOptions builder + */ + public Builder improvementRatio(Double improvementRatio) { + this.improvementRatio = improvementRatio; + return this; + } + } + + protected CreateDocumentClassifierModelOptions() {} + + protected CreateDocumentClassifierModelOptions(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.classifierId, "classifierId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + projectId = builder.projectId; + classifierId = builder.classifierId; + name = builder.name; + description = builder.description; + learningRate = builder.learningRate; + l1RegularizationStrengths = builder.l1RegularizationStrengths; + l2RegularizationStrengths = builder.l2RegularizationStrengths; + trainingMaxSteps = builder.trainingMaxSteps; + improvementRatio = builder.improvementRatio; + } + + /** + * New builder. + * + * @return a CreateDocumentClassifierModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } + + /** + * Gets the name. + * + *

The name of the document classifier model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A description of the document classifier model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the learningRate. + * + *

A tuning parameter in an optimization algorithm that determines the step size at each + * iteration of the training process. It influences how much of any newly acquired information + * overrides the existing information, and therefore is said to represent the speed at which a + * machine learning model learns. The default value is `0.1`. + * + * @return the learningRate + */ + public Double learningRate() { + return learningRate; + } + + /** + * Gets the l1RegularizationStrengths. + * + *

Avoids overfitting by shrinking the coefficient of less important features to zero, which + * removes some features altogether. You can specify many values for hyper-parameter optimization. + * The default value is `[0.000001]`. + * + * @return the l1RegularizationStrengths + */ + public List l1RegularizationStrengths() { + return l1RegularizationStrengths; + } + + /** + * Gets the l2RegularizationStrengths. + * + *

A method you can apply to avoid overfitting your model on the training data. You can specify + * many values for hyper-parameter optimization. The default value is `[0.000001]`. + * + * @return the l2RegularizationStrengths + */ + public List l2RegularizationStrengths() { + return l2RegularizationStrengths; + } + + /** + * Gets the trainingMaxSteps. + * + *

Maximum number of training steps to complete. This setting is useful if you need the + * training process to finish in a specific time frame to fit into an automated process. The + * default value is ten million. + * + * @return the trainingMaxSteps + */ + public Long trainingMaxSteps() { + return trainingMaxSteps; + } + + /** + * Gets the improvementRatio. + * + *

Stops the training run early if the improvement ratio is not met by the time the process + * reaches a certain point. The default value is `0.00001`. + * + * @return the improvementRatio + */ + public Double improvementRatio() { + return improvementRatio; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierOptions.java new file mode 100644 index 00000000000..92b28a99d65 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierOptions.java @@ -0,0 +1,217 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The createDocumentClassifier options. */ +public class CreateDocumentClassifierOptions extends GenericModel { + + protected String projectId; + protected InputStream trainingData; + protected CreateDocumentClassifier classifier; + protected InputStream testData; + + /** Builder. */ + public static class Builder { + private String projectId; + private InputStream trainingData; + private CreateDocumentClassifier classifier; + private InputStream testData; + + /** + * Instantiates a new Builder from an existing CreateDocumentClassifierOptions instance. + * + * @param createDocumentClassifierOptions the instance to initialize the Builder with + */ + private Builder(CreateDocumentClassifierOptions createDocumentClassifierOptions) { + this.projectId = createDocumentClassifierOptions.projectId; + this.trainingData = createDocumentClassifierOptions.trainingData; + this.classifier = createDocumentClassifierOptions.classifier; + this.testData = createDocumentClassifierOptions.testData; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param trainingData the trainingData + * @param classifier the classifier + */ + public Builder( + String projectId, InputStream trainingData, CreateDocumentClassifier classifier) { + this.projectId = projectId; + this.trainingData = trainingData; + this.classifier = classifier; + } + + /** + * Builds a CreateDocumentClassifierOptions. + * + * @return the new CreateDocumentClassifierOptions instance + */ + public CreateDocumentClassifierOptions build() { + return new CreateDocumentClassifierOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the CreateDocumentClassifierOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateDocumentClassifierOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the classifier. + * + * @param classifier the classifier + * @return the CreateDocumentClassifierOptions builder + */ + public Builder classifier(CreateDocumentClassifier classifier) { + this.classifier = classifier; + return this; + } + + /** + * Set the testData. + * + * @param testData the testData + * @return the CreateDocumentClassifierOptions builder + */ + public Builder testData(InputStream testData) { + this.testData = testData; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateDocumentClassifierOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + + /** + * Set the testData. + * + * @param testData the testData + * @return the CreateDocumentClassifierOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder testData(File testData) throws FileNotFoundException { + this.testData = new FileInputStream(testData); + return this; + } + } + + protected CreateDocumentClassifierOptions() {} + + protected CreateDocumentClassifierOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.classifier, "classifier cannot be null"); + projectId = builder.projectId; + trainingData = builder.trainingData; + classifier = builder.classifier; + testData = builder.testData; + } + + /** + * New builder. + * + * @return a CreateDocumentClassifierOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the trainingData. + * + *

The training data CSV file to upload. The CSV file must have headers. The file must include + * a field that contains the text you want to classify and a field that contains the + * classification labels that you want to use to classify your data. If you want to specify + * multiple values in a single field, use a semicolon as the value separator. For a sample file, + * see [the product documentation](/docs/discovery-data?topic=discovery-data-cm-doc-classifier). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the classifier. + * + *

An object that manages the settings and data that is required to train a document + * classification model. + * + * @return the classifier + */ + public CreateDocumentClassifier classifier() { + return classifier; + } + + /** + * Gets the testData. + * + *

The CSV with test data to upload. The column values in the test file must be the same as the + * column values in the training data file. If no test data is provided, the training data is + * split into two separate groups of training and test data. + * + * @return the testData + */ + public InputStream testData() { + return testData; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java new file mode 100644 index 00000000000..be014028089 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java @@ -0,0 +1,247 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information about a specific enrichment. */ +public class CreateEnrichment extends GenericModel { + + /** + * The type of this enrichment. The following types are supported: + * + *

* `classifier`: Creates a document classifier enrichment from a document classifier model + * that you create by using the [Document classifier + * API](/apidocs/discovery-data#createdocumentclassifier). **Note**: A text classifier enrichment + * can be created only from the product user interface. + * + *

* `dictionary`: Creates a custom dictionary enrichment that you define in a CSV file. + * + *

* `regular_expression`: Creates a custom regular expression enrichment from regex syntax + * that you specify in the request. + * + *

* `rule_based`: Creates an enrichment from an advanced rules model that is created and + * exported as a ZIP file from Watson Knowledge Studio. + * + *

* `uima_annotator`: Creates an enrichment from a custom UIMA text analysis model that is + * defined in a PEAR file created in one of the following ways: + * + *

* Watson Explorer Content Analytics Studio. **Note**: Supported in IBM Cloud Pak for Data + * instances only. + * + *

* Rule-based model that is created in Watson Knowledge Studio. + * + *

* `watson_knowledge_studio_model`: Creates an enrichment from a Watson Knowledge Studio + * machine learning model that is defined in a ZIP file. + * + *

* `webhook`: Connects to an external enrichment application by using a webhook. + * + *

* `sentence_classifier`: Use sentence classifier to classify sentences in your documents. + * This feature is available in IBM Cloud-managed instances only. The sentence classifier feature + * is beta functionality. Beta features are not supported by the SDKs. + */ + public interface Type { + /** classifier. */ + String CLASSIFIER = "classifier"; + /** dictionary. */ + String DICTIONARY = "dictionary"; + /** regular_expression. */ + String REGULAR_EXPRESSION = "regular_expression"; + /** uima_annotator. */ + String UIMA_ANNOTATOR = "uima_annotator"; + /** rule_based. */ + String RULE_BASED = "rule_based"; + /** watson_knowledge_studio_model. */ + String WATSON_KNOWLEDGE_STUDIO_MODEL = "watson_knowledge_studio_model"; + /** webhook. */ + String WEBHOOK = "webhook"; + /** sentence_classifier. */ + String SENTENCE_CLASSIFIER = "sentence_classifier"; + } + + protected String name; + protected String description; + protected String type; + protected EnrichmentOptions options; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + private String type; + private EnrichmentOptions options; + + /** + * Instantiates a new Builder from an existing CreateEnrichment instance. + * + * @param createEnrichment the instance to initialize the Builder with + */ + private Builder(CreateEnrichment createEnrichment) { + this.name = createEnrichment.name; + this.description = createEnrichment.description; + this.type = createEnrichment.type; + this.options = createEnrichment.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a CreateEnrichment. + * + * @return the new CreateEnrichment instance + */ + public CreateEnrichment build() { + return new CreateEnrichment(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateEnrichment builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateEnrichment builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the CreateEnrichment builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the options. + * + * @param options the options + * @return the CreateEnrichment builder + */ + public Builder options(EnrichmentOptions options) { + this.options = options; + return this; + } + } + + protected CreateEnrichment() {} + + protected CreateEnrichment(Builder builder) { + name = builder.name; + description = builder.description; + type = builder.type; + options = builder.options; + } + + /** + * New builder. + * + * @return a CreateEnrichment builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The human readable name for this enrichment. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The description of this enrichment. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the type. + * + *

The type of this enrichment. The following types are supported: + * + *

* `classifier`: Creates a document classifier enrichment from a document classifier model + * that you create by using the [Document classifier + * API](/apidocs/discovery-data#createdocumentclassifier). **Note**: A text classifier enrichment + * can be created only from the product user interface. + * + *

* `dictionary`: Creates a custom dictionary enrichment that you define in a CSV file. + * + *

* `regular_expression`: Creates a custom regular expression enrichment from regex syntax + * that you specify in the request. + * + *

* `rule_based`: Creates an enrichment from an advanced rules model that is created and + * exported as a ZIP file from Watson Knowledge Studio. + * + *

* `uima_annotator`: Creates an enrichment from a custom UIMA text analysis model that is + * defined in a PEAR file created in one of the following ways: + * + *

* Watson Explorer Content Analytics Studio. **Note**: Supported in IBM Cloud Pak for Data + * instances only. + * + *

* Rule-based model that is created in Watson Knowledge Studio. + * + *

* `watson_knowledge_studio_model`: Creates an enrichment from a Watson Knowledge Studio + * machine learning model that is defined in a ZIP file. + * + *

* `webhook`: Connects to an external enrichment application by using a webhook. + * + *

* `sentence_classifier`: Use sentence classifier to classify sentences in your documents. + * This feature is available in IBM Cloud-managed instances only. The sentence classifier feature + * is beta functionality. Beta features are not supported by the SDKs. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the options. + * + *

An object that contains options for the current enrichment. Starting with version + * `2020-08-30`, the enrichment options are not included in responses from the List Enrichments + * method. + * + * @return the options + */ + public EnrichmentOptions options() { + return options; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java new file mode 100644 index 00000000000..976db595169 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java @@ -0,0 +1,173 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The createEnrichment options. */ +public class CreateEnrichmentOptions extends GenericModel { + + protected String projectId; + protected CreateEnrichment enrichment; + protected InputStream file; + + /** Builder. */ + public static class Builder { + private String projectId; + private CreateEnrichment enrichment; + private InputStream file; + + /** + * Instantiates a new Builder from an existing CreateEnrichmentOptions instance. + * + * @param createEnrichmentOptions the instance to initialize the Builder with + */ + private Builder(CreateEnrichmentOptions createEnrichmentOptions) { + this.projectId = createEnrichmentOptions.projectId; + this.enrichment = createEnrichmentOptions.enrichment; + this.file = createEnrichmentOptions.file; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param enrichment the enrichment + */ + public Builder(String projectId, CreateEnrichment enrichment) { + this.projectId = projectId; + this.enrichment = enrichment; + } + + /** + * Builds a CreateEnrichmentOptions. + * + * @return the new CreateEnrichmentOptions instance + */ + public CreateEnrichmentOptions build() { + return new CreateEnrichmentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the CreateEnrichmentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the enrichment. + * + * @param enrichment the enrichment + * @return the CreateEnrichmentOptions builder + */ + public Builder enrichment(CreateEnrichment enrichment) { + this.enrichment = enrichment; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the CreateEnrichmentOptions builder + */ + public Builder file(InputStream file) { + this.file = file; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the CreateEnrichmentOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder file(File file) throws FileNotFoundException { + this.file = new FileInputStream(file); + return this; + } + } + + protected CreateEnrichmentOptions() {} + + protected CreateEnrichmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.enrichment, "enrichment cannot be null"); + projectId = builder.projectId; + enrichment = builder.enrichment; + file = builder.file; + } + + /** + * New builder. + * + * @return a CreateEnrichmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the enrichment. + * + *

Information about a specific enrichment. + * + * @return the enrichment + */ + public CreateEnrichment enrichment() { + return enrichment; + } + + /** + * Gets the file. + * + *

The enrichment file to upload. Expected file types per enrichment are as follows: + * + *

* CSV for `dictionary` and `sentence_classifier` (the training data CSV file to upload). + * + *

* PEAR for `uima_annotator` and `rule_based` (Explorer) + * + *

* ZIP for `watson_knowledge_studio_model` and `rule_based` (Studio Advanced Rule Editor). + * + * @return the file + */ + public InputStream file() { + return file; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateExpansionsOptions.java new file mode 100644 index 00000000000..83174d4842f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateExpansionsOptions.java @@ -0,0 +1,196 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The createExpansions options. */ +public class CreateExpansionsOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected List expansions; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private List expansions; + + /** + * Instantiates a new Builder from an existing CreateExpansionsOptions instance. + * + * @param createExpansionsOptions the instance to initialize the Builder with + */ + private Builder(CreateExpansionsOptions createExpansionsOptions) { + this.projectId = createExpansionsOptions.projectId; + this.collectionId = createExpansionsOptions.collectionId; + this.expansions = createExpansionsOptions.expansions; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param collectionId the collectionId + * @param expansions the expansions + */ + public Builder(String projectId, String collectionId, List expansions) { + this.projectId = projectId; + this.collectionId = collectionId; + this.expansions = expansions; + } + + /** + * Builds a CreateExpansionsOptions. + * + * @return the new CreateExpansionsOptions instance + */ + public CreateExpansionsOptions build() { + return new CreateExpansionsOptions(this); + } + + /** + * Adds a new element to expansions. + * + * @param expansions the new element to be added + * @return the CreateExpansionsOptions builder + */ + public Builder addExpansions(Expansion expansions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(expansions, "expansions cannot be null"); + if (this.expansions == null) { + this.expansions = new ArrayList(); + } + this.expansions.add(expansions); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the CreateExpansionsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the CreateExpansionsOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the expansions. Existing expansions will be replaced. + * + * @param expansions the expansions + * @return the CreateExpansionsOptions builder + */ + public Builder expansions(List expansions) { + this.expansions = expansions; + return this; + } + + /** + * Set the expansions. + * + * @param expansions the expansions + * @return the CreateExpansionsOptions builder + */ + public Builder expansions(Expansions expansions) { + this.expansions = expansions.expansions(); + return this; + } + } + + protected CreateExpansionsOptions() {} + + protected CreateExpansionsOptions(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.notNull(builder.expansions, "expansions cannot be null"); + projectId = builder.projectId; + collectionId = builder.collectionId; + expansions = builder.expansions; + } + + /** + * New builder. + * + * @return a CreateExpansionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the expansions. + * + *

An array of query expansion definitions. + * + *

Each object in the **expansions** array represents a term or set of terms that will be + * expanded into other terms. Each expansion object can be configured as `bidirectional` or + * `unidirectional`. + * + *

* **Bidirectional**: Each entry in the `expanded_terms` list expands to include all expanded + * terms. For example, a query for `ibm` expands to `ibm OR international business machines OR big + * blue`. + * + *

* **Unidirectional**: The terms in `input_terms` in the query are replaced by the terms in + * `expanded_terms`. For example, a query for the often misused term `on premise` is converted to + * `on premises OR on-premises` and does not contain the original term. If you want an input term + * to be included in the query, then repeat the input term in the expanded terms list. + * + * @return the expansions + */ + public List expansions() { + return expansions; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java new file mode 100644 index 00000000000..b35a2a8f391 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java @@ -0,0 +1,186 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The createProject options. */ +public class CreateProjectOptions extends GenericModel { + + /** + * The type of project. + * + *

The `content_intelligence` type is a *Document Retrieval for Contracts* project and the + * `other` type is a *Custom* project. + * + *

The `content_mining` and `content_intelligence` types are available with Premium plan + * managed deployments and installed deployments only. + * + *

The Intelligent Document Processing (IDP) project type is available from IBM Cloud-managed + * instances only. + */ + public interface Type { + /** intelligent_document_processing. */ + String INTELLIGENT_DOCUMENT_PROCESSING = "intelligent_document_processing"; + /** document_retrieval. */ + String DOCUMENT_RETRIEVAL = "document_retrieval"; + /** conversational_search. */ + String CONVERSATIONAL_SEARCH = "conversational_search"; + /** content_intelligence. */ + String CONTENT_INTELLIGENCE = "content_intelligence"; + /** content_mining. */ + String CONTENT_MINING = "content_mining"; + /** other. */ + String OTHER = "other"; + } + + protected String name; + protected String type; + protected DefaultQueryParams defaultQueryParameters; + + /** Builder. */ + public static class Builder { + private String name; + private String type; + private DefaultQueryParams defaultQueryParameters; + + /** + * Instantiates a new Builder from an existing CreateProjectOptions instance. + * + * @param createProjectOptions the instance to initialize the Builder with + */ + private Builder(CreateProjectOptions createProjectOptions) { + this.name = createProjectOptions.name; + this.type = createProjectOptions.type; + this.defaultQueryParameters = createProjectOptions.defaultQueryParameters; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param type the type + */ + public Builder(String name, String type) { + this.name = name; + this.type = type; + } + + /** + * Builds a CreateProjectOptions. + * + * @return the new CreateProjectOptions instance + */ + public CreateProjectOptions build() { + return new CreateProjectOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateProjectOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the CreateProjectOptions builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the defaultQueryParameters. + * + * @param defaultQueryParameters the defaultQueryParameters + * @return the CreateProjectOptions builder + */ + public Builder defaultQueryParameters(DefaultQueryParams defaultQueryParameters) { + this.defaultQueryParameters = defaultQueryParameters; + return this; + } + } + + protected CreateProjectOptions() {} + + protected CreateProjectOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, "type cannot be null"); + name = builder.name; + type = builder.type; + defaultQueryParameters = builder.defaultQueryParameters; + } + + /** + * New builder. + * + * @return a CreateProjectOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The human readable name of this project. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the type. + * + *

The type of project. + * + *

The `content_intelligence` type is a *Document Retrieval for Contracts* project and the + * `other` type is a *Custom* project. + * + *

The `content_mining` and `content_intelligence` types are available with Premium plan + * managed deployments and installed deployments only. + * + *

The Intelligent Document Processing (IDP) project type is available from IBM Cloud-managed + * instances only. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the defaultQueryParameters. + * + *

Default query parameters for this project. + * + * @return the defaultQueryParameters + */ + public DefaultQueryParams defaultQueryParameters() { + return defaultQueryParameters; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateStopwordListOptions.java new file mode 100644 index 00000000000..0dd0b2009b7 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateStopwordListOptions.java @@ -0,0 +1,180 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The createStopwordList options. */ +public class CreateStopwordListOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected List stopwords; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private List stopwords; + + /** + * Instantiates a new Builder from an existing CreateStopwordListOptions instance. + * + * @param createStopwordListOptions the instance to initialize the Builder with + */ + private Builder(CreateStopwordListOptions createStopwordListOptions) { + this.projectId = createStopwordListOptions.projectId; + this.collectionId = createStopwordListOptions.collectionId; + this.stopwords = createStopwordListOptions.stopwords; + } + + /** 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 CreateStopwordListOptions. + * + * @return the new CreateStopwordListOptions instance + */ + public CreateStopwordListOptions build() { + return new CreateStopwordListOptions(this); + } + + /** + * Adds a new element to stopwords. + * + * @param stopwords the new element to be added + * @return the CreateStopwordListOptions builder + */ + public Builder addStopwords(String stopwords) { + com.ibm.cloud.sdk.core.util.Validator.notNull(stopwords, "stopwords cannot be null"); + if (this.stopwords == null) { + this.stopwords = new ArrayList(); + } + this.stopwords.add(stopwords); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the CreateStopwordListOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the CreateStopwordListOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the stopwords. Existing stopwords will be replaced. + * + * @param stopwords the stopwords + * @return the CreateStopwordListOptions builder + */ + public Builder stopwords(List stopwords) { + this.stopwords = stopwords; + return this; + } + + /** + * Set the stopWordList. + * + * @param stopWordList the stopWordList + * @return the CreateStopwordListOptions builder + */ + public Builder stopWordList(StopWordList stopWordList) { + this.stopwords = stopWordList.stopwords(); + return this; + } + } + + protected CreateStopwordListOptions() {} + + protected CreateStopwordListOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + stopwords = builder.stopwords; + } + + /** + * New builder. + * + * @return a CreateStopwordListOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the stopwords. + * + *

List of stop words. + * + * @return the stopwords + */ + public List stopwords() { + return stopwords; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java index a5c91e76cf8..92ee165a1a5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createTrainingQuery options. - */ +/** The createTrainingQuery options. */ public class CreateTrainingQueryOptions extends GenericModel { protected String projectId; @@ -27,15 +25,18 @@ public class CreateTrainingQueryOptions extends GenericModel { protected List examples; protected String filter; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String naturalLanguageQuery; private List examples; private String filter; + /** + * Instantiates a new Builder from an existing CreateTrainingQueryOptions instance. + * + * @param createTrainingQueryOptions the instance to initialize the Builder with + */ private Builder(CreateTrainingQueryOptions createTrainingQueryOptions) { this.projectId = createTrainingQueryOptions.projectId; this.naturalLanguageQuery = createTrainingQueryOptions.naturalLanguageQuery; @@ -43,11 +44,8 @@ private Builder(CreateTrainingQueryOptions createTrainingQueryOptions) { this.filter = createTrainingQueryOptions.filter; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -65,21 +63,20 @@ public Builder(String projectId, String naturalLanguageQuery, List(); } @@ -110,8 +107,7 @@ public Builder naturalLanguageQuery(String naturalLanguageQuery) { } /** - * Set the examples. - * Existing examples will be replaced. + * Set the examples. Existing examples will be replaced. * * @param examples the examples * @return the CreateTrainingQueryOptions builder @@ -146,13 +142,13 @@ public Builder trainingQuery(TrainingQuery trainingQuery) { } } + protected CreateTrainingQueryOptions() {} + protected CreateTrainingQueryOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, - "projectId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.naturalLanguageQuery, - "naturalLanguageQuery cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, - "examples cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.naturalLanguageQuery, "naturalLanguageQuery cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, "examples cannot be null"); projectId = builder.projectId; naturalLanguageQuery = builder.naturalLanguageQuery; examples = builder.examples; @@ -171,7 +167,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -182,7 +179,7 @@ public String projectId() { /** * Gets the naturalLanguageQuery. * - * The natural text query for the training query. + *

The natural text query that is used as the training query. * * @return the naturalLanguageQuery */ @@ -193,7 +190,7 @@ public String naturalLanguageQuery() { /** * Gets the examples. * - * Array of training examples. + *

Array of training examples. * * @return the examples */ @@ -204,7 +201,10 @@ public List examples() { /** * Gets the filter. * - * The filter used on the collection before the **natural_language_query** is applied. + *

The filter used on the collection before the **natural_language_query** is applied. Only + * specify a filter if the documents that you consider to be most relevant are not included in the + * top 100 results when you submit test queries. If you specify a filter during training, apply + * the same filter to queries that are submitted at runtime for optimal ranking results. * * @return the filter */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParams.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParams.java new file mode 100644 index 00000000000..fe478dd98a9 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParams.java @@ -0,0 +1,369 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** Default query parameters for this project. */ +public class DefaultQueryParams extends GenericModel { + + @SerializedName("collection_ids") + protected List collectionIds; + + protected DefaultQueryParamsPassages passages; + + @SerializedName("table_results") + protected DefaultQueryParamsTableResults tableResults; + + protected String aggregation; + + @SerializedName("suggested_refinements") + protected DefaultQueryParamsSuggestedRefinements suggestedRefinements; + + @SerializedName("spelling_suggestions") + protected Boolean spellingSuggestions; + + protected Boolean highlight; + protected Long count; + protected String sort; + + @SerializedName("return") + protected List xReturn; + + /** Builder. */ + public static class Builder { + private List collectionIds; + private DefaultQueryParamsPassages passages; + private DefaultQueryParamsTableResults tableResults; + private String aggregation; + private DefaultQueryParamsSuggestedRefinements suggestedRefinements; + private Boolean spellingSuggestions; + private Boolean highlight; + private Long count; + private String sort; + private List xReturn; + + /** + * Instantiates a new Builder from an existing DefaultQueryParams instance. + * + * @param defaultQueryParams the instance to initialize the Builder with + */ + private Builder(DefaultQueryParams defaultQueryParams) { + this.collectionIds = defaultQueryParams.collectionIds; + this.passages = defaultQueryParams.passages; + this.tableResults = defaultQueryParams.tableResults; + this.aggregation = defaultQueryParams.aggregation; + this.suggestedRefinements = defaultQueryParams.suggestedRefinements; + this.spellingSuggestions = defaultQueryParams.spellingSuggestions; + this.highlight = defaultQueryParams.highlight; + this.count = defaultQueryParams.count; + this.sort = defaultQueryParams.sort; + this.xReturn = defaultQueryParams.xReturn; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DefaultQueryParams. + * + * @return the new DefaultQueryParams instance + */ + public DefaultQueryParams build() { + return new DefaultQueryParams(this); + } + + /** + * Adds a new element to collectionIds. + * + * @param collectionIds the new element to be added + * @return the DefaultQueryParams builder + */ + public Builder addCollectionIds(String collectionIds) { + com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, "collectionIds cannot be null"); + if (this.collectionIds == null) { + this.collectionIds = new ArrayList(); + } + this.collectionIds.add(collectionIds); + return this; + } + + /** + * Adds a new element to xReturn. + * + * @param xReturn the new element to be added + * @return the DefaultQueryParams builder + */ + public Builder addXReturn(String xReturn) { + com.ibm.cloud.sdk.core.util.Validator.notNull(xReturn, "xReturn cannot be null"); + if (this.xReturn == null) { + this.xReturn = new ArrayList(); + } + this.xReturn.add(xReturn); + return this; + } + + /** + * Set the collectionIds. Existing collectionIds will be replaced. + * + * @param collectionIds the collectionIds + * @return the DefaultQueryParams builder + */ + public Builder collectionIds(List collectionIds) { + this.collectionIds = collectionIds; + return this; + } + + /** + * Set the passages. + * + * @param passages the passages + * @return the DefaultQueryParams builder + */ + public Builder passages(DefaultQueryParamsPassages passages) { + this.passages = passages; + return this; + } + + /** + * Set the tableResults. + * + * @param tableResults the tableResults + * @return the DefaultQueryParams builder + */ + public Builder tableResults(DefaultQueryParamsTableResults tableResults) { + this.tableResults = tableResults; + return this; + } + + /** + * Set the aggregation. + * + * @param aggregation the aggregation + * @return the DefaultQueryParams builder + */ + public Builder aggregation(String aggregation) { + this.aggregation = aggregation; + return this; + } + + /** + * Set the suggestedRefinements. + * + * @param suggestedRefinements the suggestedRefinements + * @return the DefaultQueryParams builder + */ + public Builder suggestedRefinements( + DefaultQueryParamsSuggestedRefinements suggestedRefinements) { + this.suggestedRefinements = suggestedRefinements; + return this; + } + + /** + * Set the spellingSuggestions. + * + * @param spellingSuggestions the spellingSuggestions + * @return the DefaultQueryParams builder + */ + public Builder spellingSuggestions(Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + return this; + } + + /** + * Set the highlight. + * + * @param highlight the highlight + * @return the DefaultQueryParams builder + */ + public Builder highlight(Boolean highlight) { + this.highlight = highlight; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the DefaultQueryParams builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the DefaultQueryParams builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the xReturn. Existing xReturn will be replaced. + * + * @param xReturn the xReturn + * @return the DefaultQueryParams builder + */ + public Builder xReturn(List xReturn) { + this.xReturn = xReturn; + return this; + } + } + + protected DefaultQueryParams() {} + + protected DefaultQueryParams(Builder builder) { + collectionIds = builder.collectionIds; + passages = builder.passages; + tableResults = builder.tableResults; + aggregation = builder.aggregation; + suggestedRefinements = builder.suggestedRefinements; + spellingSuggestions = builder.spellingSuggestions; + highlight = builder.highlight; + count = builder.count; + sort = builder.sort; + xReturn = builder.xReturn; + } + + /** + * New builder. + * + * @return a DefaultQueryParams builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the collectionIds. + * + *

An array of collection identifiers to query. If empty or omitted all collections in the + * project are queried. + * + * @return the collectionIds + */ + public List collectionIds() { + return collectionIds; + } + + /** + * Gets the passages. + * + *

Default settings configuration for passage search options. + * + * @return the passages + */ + public DefaultQueryParamsPassages passages() { + return passages; + } + + /** + * Gets the tableResults. + * + *

Default project query settings for table results. + * + * @return the tableResults + */ + public DefaultQueryParamsTableResults tableResults() { + return tableResults; + } + + /** + * Gets the aggregation. + * + *

A string representing the default aggregation query for the project. + * + * @return the aggregation + */ + public String aggregation() { + return aggregation; + } + + /** + * Gets the suggestedRefinements. + * + *

Object that contains suggested refinement settings. + * + *

**Note**: The `suggested_refinements` parameter that identified dynamic facets from the data + * is deprecated. + * + * @return the suggestedRefinements + */ + public DefaultQueryParamsSuggestedRefinements suggestedRefinements() { + return suggestedRefinements; + } + + /** + * Gets the spellingSuggestions. + * + *

When `true`, a spelling suggestions for the query are returned by default. + * + * @return the spellingSuggestions + */ + public Boolean spellingSuggestions() { + return spellingSuggestions; + } + + /** + * Gets the highlight. + * + *

When `true`, highlights for the query are returned by default. + * + * @return the highlight + */ + public Boolean highlight() { + return highlight; + } + + /** + * Gets the count. + * + *

The number of document results returned by default. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the sort. + * + *

A comma separated list of document fields to sort results by default. + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the xReturn. + * + *

An array of field names to return in document results if present by default. + * + * @return the xReturn + */ + public List xReturn() { + return xReturn; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java new file mode 100644 index 00000000000..806a5a782e6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java @@ -0,0 +1,239 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** Default settings configuration for passage search options. */ +public class DefaultQueryParamsPassages extends GenericModel { + + protected Boolean enabled; + protected Long count; + protected List fields; + protected Long characters; + + @SerializedName("per_document") + protected Boolean perDocument; + + @SerializedName("max_per_document") + protected Long maxPerDocument; + + /** Builder. */ + public static class Builder { + private Boolean enabled; + private Long count; + private List fields; + private Long characters; + private Boolean perDocument; + private Long maxPerDocument; + + /** + * Instantiates a new Builder from an existing DefaultQueryParamsPassages instance. + * + * @param defaultQueryParamsPassages the instance to initialize the Builder with + */ + private Builder(DefaultQueryParamsPassages defaultQueryParamsPassages) { + this.enabled = defaultQueryParamsPassages.enabled; + this.count = defaultQueryParamsPassages.count; + this.fields = defaultQueryParamsPassages.fields; + this.characters = defaultQueryParamsPassages.characters; + this.perDocument = defaultQueryParamsPassages.perDocument; + this.maxPerDocument = defaultQueryParamsPassages.maxPerDocument; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DefaultQueryParamsPassages. + * + * @return the new DefaultQueryParamsPassages instance + */ + public DefaultQueryParamsPassages build() { + return new DefaultQueryParamsPassages(this); + } + + /** + * Adds a new element to fields. + * + * @param fields the new element to be added + * @return the DefaultQueryParamsPassages builder + */ + public Builder addFields(String fields) { + com.ibm.cloud.sdk.core.util.Validator.notNull(fields, "fields cannot be null"); + if (this.fields == null) { + this.fields = new ArrayList(); + } + this.fields.add(fields); + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the DefaultQueryParamsPassages builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the DefaultQueryParamsPassages builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the fields. Existing fields will be replaced. + * + * @param fields the fields + * @return the DefaultQueryParamsPassages builder + */ + public Builder fields(List fields) { + this.fields = fields; + return this; + } + + /** + * Set the characters. + * + * @param characters the characters + * @return the DefaultQueryParamsPassages builder + */ + public Builder characters(long characters) { + this.characters = characters; + return this; + } + + /** + * Set the perDocument. + * + * @param perDocument the perDocument + * @return the DefaultQueryParamsPassages builder + */ + public Builder perDocument(Boolean perDocument) { + this.perDocument = perDocument; + return this; + } + + /** + * Set the maxPerDocument. + * + * @param maxPerDocument the maxPerDocument + * @return the DefaultQueryParamsPassages builder + */ + public Builder maxPerDocument(long maxPerDocument) { + this.maxPerDocument = maxPerDocument; + return this; + } + } + + protected DefaultQueryParamsPassages() {} + + protected DefaultQueryParamsPassages(Builder builder) { + enabled = builder.enabled; + count = builder.count; + fields = builder.fields; + characters = builder.characters; + perDocument = builder.perDocument; + maxPerDocument = builder.maxPerDocument; + } + + /** + * New builder. + * + * @return a DefaultQueryParamsPassages builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

When `true`, a passage search is performed by default. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the count. + * + *

The number of passages to return. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the fields. + * + *

An array of field names to perform the passage search on. + * + * @return the fields + */ + public List fields() { + return fields; + } + + /** + * Gets the characters. + * + *

The approximate number of characters that each returned passage will contain. + * + * @return the characters + */ + public Long characters() { + return characters; + } + + /** + * Gets the perDocument. + * + *

When `true` the number of passages that can be returned from a single document is restricted + * to the *max_per_document* value. + * + * @return the perDocument + */ + public Boolean perDocument() { + return perDocument; + } + + /** + * Gets the maxPerDocument. + * + *

The default maximum number of passages that can be taken from a single document as the + * result of a passage query. + * + * @return the maxPerDocument + */ + public Long maxPerDocument() { + return maxPerDocument; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java new file mode 100644 index 00000000000..955824fffeb --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java @@ -0,0 +1,116 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Object that contains suggested refinement settings. + * + *

**Note**: The `suggested_refinements` parameter that identified dynamic facets from the data + * is deprecated. + */ +public class DefaultQueryParamsSuggestedRefinements extends GenericModel { + + protected Boolean enabled; + protected Long count; + + /** Builder. */ + public static class Builder { + private Boolean enabled; + private Long count; + + /** + * Instantiates a new Builder from an existing DefaultQueryParamsSuggestedRefinements instance. + * + * @param defaultQueryParamsSuggestedRefinements the instance to initialize the Builder with + */ + private Builder(DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinements) { + this.enabled = defaultQueryParamsSuggestedRefinements.enabled; + this.count = defaultQueryParamsSuggestedRefinements.count; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DefaultQueryParamsSuggestedRefinements. + * + * @return the new DefaultQueryParamsSuggestedRefinements instance + */ + public DefaultQueryParamsSuggestedRefinements build() { + return new DefaultQueryParamsSuggestedRefinements(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the DefaultQueryParamsSuggestedRefinements builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the DefaultQueryParamsSuggestedRefinements builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + } + + protected DefaultQueryParamsSuggestedRefinements() {} + + protected DefaultQueryParamsSuggestedRefinements(Builder builder) { + enabled = builder.enabled; + count = builder.count; + } + + /** + * New builder. + * + * @return a DefaultQueryParamsSuggestedRefinements builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

When `true`, suggested refinements for the query are returned by default. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the count. + * + *

The number of suggested refinements to return by default. + * + * @return the count + */ + public Long count() { + return count; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java new file mode 100644 index 00000000000..30e48c9cf6c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; + +/** Default project query settings for table results. */ +public class DefaultQueryParamsTableResults extends GenericModel { + + protected Boolean enabled; + protected Long count; + + @SerializedName("per_document") + protected Long perDocument; + + /** Builder. */ + public static class Builder { + private Boolean enabled; + private Long count; + private Long perDocument; + + /** + * Instantiates a new Builder from an existing DefaultQueryParamsTableResults instance. + * + * @param defaultQueryParamsTableResults the instance to initialize the Builder with + */ + private Builder(DefaultQueryParamsTableResults defaultQueryParamsTableResults) { + this.enabled = defaultQueryParamsTableResults.enabled; + this.count = defaultQueryParamsTableResults.count; + this.perDocument = defaultQueryParamsTableResults.perDocument; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DefaultQueryParamsTableResults. + * + * @return the new DefaultQueryParamsTableResults instance + */ + public DefaultQueryParamsTableResults build() { + return new DefaultQueryParamsTableResults(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the DefaultQueryParamsTableResults builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the DefaultQueryParamsTableResults builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the perDocument. + * + * @param perDocument the perDocument + * @return the DefaultQueryParamsTableResults builder + */ + public Builder perDocument(long perDocument) { + this.perDocument = perDocument; + return this; + } + } + + protected DefaultQueryParamsTableResults() {} + + protected DefaultQueryParamsTableResults(Builder builder) { + enabled = builder.enabled; + count = builder.count; + perDocument = builder.perDocument; + } + + /** + * New builder. + * + * @return a DefaultQueryParamsTableResults builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

When `true`, a table results for the query are returned by default. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the count. + * + *

The number of table results to return by default. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the perDocument. + * + *

The number of table results to include in each result document. + * + * @return the perDocument + */ + public Long perDocument() { + return perDocument; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java new file mode 100644 index 00000000000..b3bfcb785a6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteCollection options. */ +public class DeleteCollectionOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing DeleteCollectionOptions instance. + * + * @param deleteCollectionOptions the instance to initialize the Builder with + */ + private Builder(DeleteCollectionOptions deleteCollectionOptions) { + this.projectId = deleteCollectionOptions.projectId; + this.collectionId = deleteCollectionOptions.collectionId; + } + + /** 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 DeleteCollectionOptions. + * + * @return the new DeleteCollectionOptions instance + */ + public DeleteCollectionOptions build() { + return new DeleteCollectionOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteCollectionOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the DeleteCollectionOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected DeleteCollectionOptions() {} + + protected DeleteCollectionOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a DeleteCollectionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierModelOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierModelOptions.java new file mode 100644 index 00000000000..39a6887050e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierModelOptions.java @@ -0,0 +1,155 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteDocumentClassifierModel options. */ +public class DeleteDocumentClassifierModelOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + protected String modelId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + private String modelId; + + /** + * Instantiates a new Builder from an existing DeleteDocumentClassifierModelOptions instance. + * + * @param deleteDocumentClassifierModelOptions the instance to initialize the Builder with + */ + private Builder(DeleteDocumentClassifierModelOptions deleteDocumentClassifierModelOptions) { + this.projectId = deleteDocumentClassifierModelOptions.projectId; + this.classifierId = deleteDocumentClassifierModelOptions.classifierId; + this.modelId = deleteDocumentClassifierModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + * @param modelId the modelId + */ + public Builder(String projectId, String classifierId, String modelId) { + this.projectId = projectId; + this.classifierId = classifierId; + this.modelId = modelId; + } + + /** + * Builds a DeleteDocumentClassifierModelOptions. + * + * @return the new DeleteDocumentClassifierModelOptions instance + */ + public DeleteDocumentClassifierModelOptions build() { + return new DeleteDocumentClassifierModelOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteDocumentClassifierModelOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the DeleteDocumentClassifierModelOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the DeleteDocumentClassifierModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected DeleteDocumentClassifierModelOptions() {} + + protected DeleteDocumentClassifierModelOptions(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.classifierId, "classifierId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + projectId = builder.projectId; + classifierId = builder.classifierId; + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a DeleteDocumentClassifierModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } + + /** + * Gets the modelId. + * + *

The Universally Unique Identifier (UUID) of the classifier model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierOptions.java new file mode 100644 index 00000000000..f5f5ff19fa5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteDocumentClassifier options. */ +public class DeleteDocumentClassifierOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + + /** + * Instantiates a new Builder from an existing DeleteDocumentClassifierOptions instance. + * + * @param deleteDocumentClassifierOptions the instance to initialize the Builder with + */ + private Builder(DeleteDocumentClassifierOptions deleteDocumentClassifierOptions) { + this.projectId = deleteDocumentClassifierOptions.projectId; + this.classifierId = deleteDocumentClassifierOptions.classifierId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + */ + public Builder(String projectId, String classifierId) { + this.projectId = projectId; + this.classifierId = classifierId; + } + + /** + * Builds a DeleteDocumentClassifierOptions. + * + * @return the new DeleteDocumentClassifierOptions instance + */ + public DeleteDocumentClassifierOptions build() { + return new DeleteDocumentClassifierOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteDocumentClassifierOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the DeleteDocumentClassifierOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + } + + protected DeleteDocumentClassifierOptions() {} + + protected DeleteDocumentClassifierOptions(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.classifierId, "classifierId cannot be empty"); + projectId = builder.projectId; + classifierId = builder.classifierId; + } + + /** + * New builder. + * + * @return a DeleteDocumentClassifierOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java index dea74bc9095..c4b6dc0380a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteDocument options. - */ +/** The deleteDocument options. */ public class DeleteDocumentOptions extends GenericModel { protected String projectId; @@ -24,15 +23,18 @@ public class DeleteDocumentOptions extends GenericModel { protected String documentId; protected Boolean xWatsonDiscoveryForce; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String collectionId; private String documentId; private Boolean xWatsonDiscoveryForce; + /** + * Instantiates a new Builder from an existing DeleteDocumentOptions instance. + * + * @param deleteDocumentOptions the instance to initialize the Builder with + */ private Builder(DeleteDocumentOptions deleteDocumentOptions) { this.projectId = deleteDocumentOptions.projectId; this.collectionId = deleteDocumentOptions.collectionId; @@ -40,11 +42,8 @@ private Builder(DeleteDocumentOptions deleteDocumentOptions) { this.xWatsonDiscoveryForce = deleteDocumentOptions.xWatsonDiscoveryForce; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -62,7 +61,7 @@ public Builder(String projectId, String collectionId, String documentId) { /** * Builds a DeleteDocumentOptions. * - * @return the deleteDocumentOptions + * @return the new DeleteDocumentOptions instance */ public DeleteDocumentOptions build() { return new DeleteDocumentOptions(this); @@ -113,13 +112,14 @@ public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { } } + protected DeleteDocumentOptions() {} + protected DeleteDocumentOptions(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.notEmpty(builder.documentId, - "documentId cannot be empty"); + 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.notEmpty( + builder.documentId, "documentId cannot be empty"); projectId = builder.projectId; collectionId = builder.collectionId; documentId = builder.documentId; @@ -138,7 +138,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -149,7 +150,7 @@ public String projectId() { /** * Gets the collectionId. * - * The ID of the collection. + *

The Universally Unique Identifier (UUID) of the collection. * * @return the collectionId */ @@ -160,7 +161,7 @@ public String collectionId() { /** * Gets the documentId. * - * The ID of the document. + *

The ID of the document. * * @return the documentId */ @@ -171,8 +172,8 @@ public String documentId() { /** * 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. + *

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 */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java index beec47e8e24..dc658ceb97e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,19 +10,16 @@ * 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; -/** - * Information returned when a document is deleted. - */ +/** Information returned when a document is deleted. */ public class DeleteDocumentResponse extends GenericModel { - /** - * Status of the document. A deleted document has the status deleted. - */ + /** Status of the document. A deleted document has the status deleted. */ public interface Status { /** deleted. */ String DELETED = "deleted"; @@ -30,12 +27,15 @@ public interface Status { @SerializedName("document_id") protected String documentId; + protected String status; + protected DeleteDocumentResponse() {} + /** * Gets the documentId. * - * The unique identifier of the document. + *

The unique identifier of the document. * * @return the documentId */ @@ -46,7 +46,7 @@ public String getDocumentId() { /** * Gets the status. * - * Status of the document. A deleted document has the status deleted. + *

Status of the document. A deleted document has the status deleted. * * @return the status */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java new file mode 100644 index 00000000000..2173a907a5e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteEnrichment options. */ +public class DeleteEnrichmentOptions extends GenericModel { + + protected String projectId; + protected String enrichmentId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String enrichmentId; + + /** + * Instantiates a new Builder from an existing DeleteEnrichmentOptions instance. + * + * @param deleteEnrichmentOptions the instance to initialize the Builder with + */ + private Builder(DeleteEnrichmentOptions deleteEnrichmentOptions) { + this.projectId = deleteEnrichmentOptions.projectId; + this.enrichmentId = deleteEnrichmentOptions.enrichmentId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param enrichmentId the enrichmentId + */ + public Builder(String projectId, String enrichmentId) { + this.projectId = projectId; + this.enrichmentId = enrichmentId; + } + + /** + * Builds a DeleteEnrichmentOptions. + * + * @return the new DeleteEnrichmentOptions instance + */ + public DeleteEnrichmentOptions build() { + return new DeleteEnrichmentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteEnrichmentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the enrichmentId. + * + * @param enrichmentId the enrichmentId + * @return the DeleteEnrichmentOptions builder + */ + public Builder enrichmentId(String enrichmentId) { + this.enrichmentId = enrichmentId; + return this; + } + } + + protected DeleteEnrichmentOptions() {} + + protected DeleteEnrichmentOptions(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.enrichmentId, "enrichmentId cannot be empty"); + projectId = builder.projectId; + enrichmentId = builder.enrichmentId; + } + + /** + * New builder. + * + * @return a DeleteEnrichmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) of the enrichment. + * + * @return the enrichmentId + */ + public String enrichmentId() { + return enrichmentId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteExpansionsOptions.java new file mode 100644 index 00000000000..c9fd4638d12 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteExpansionsOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteExpansions options. */ +public class DeleteExpansionsOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing DeleteExpansionsOptions instance. + * + * @param deleteExpansionsOptions the instance to initialize the Builder with + */ + private Builder(DeleteExpansionsOptions deleteExpansionsOptions) { + this.projectId = deleteExpansionsOptions.projectId; + this.collectionId = deleteExpansionsOptions.collectionId; + } + + /** 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 DeleteExpansionsOptions. + * + * @return the new DeleteExpansionsOptions instance + */ + public DeleteExpansionsOptions build() { + return new DeleteExpansionsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteExpansionsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the DeleteExpansionsOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected DeleteExpansionsOptions() {} + + protected DeleteExpansionsOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a DeleteExpansionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java new file mode 100644 index 00000000000..d108f655ff6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteProject options. */ +public class DeleteProjectOptions extends GenericModel { + + protected String projectId; + + /** Builder. */ + public static class Builder { + private String projectId; + + /** + * Instantiates a new Builder from an existing DeleteProjectOptions instance. + * + * @param deleteProjectOptions the instance to initialize the Builder with + */ + private Builder(DeleteProjectOptions deleteProjectOptions) { + this.projectId = deleteProjectOptions.projectId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a DeleteProjectOptions. + * + * @return the new DeleteProjectOptions instance + */ + public DeleteProjectOptions build() { + return new DeleteProjectOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteProjectOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected DeleteProjectOptions() {} + + protected DeleteProjectOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a DeleteProjectOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteStopwordListOptions.java new file mode 100644 index 00000000000..ffe8b80813b --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteStopwordListOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteStopwordList options. */ +public class DeleteStopwordListOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing DeleteStopwordListOptions instance. + * + * @param deleteStopwordListOptions the instance to initialize the Builder with + */ + private Builder(DeleteStopwordListOptions deleteStopwordListOptions) { + this.projectId = deleteStopwordListOptions.projectId; + this.collectionId = deleteStopwordListOptions.collectionId; + } + + /** 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 DeleteStopwordListOptions. + * + * @return the new DeleteStopwordListOptions instance + */ + public DeleteStopwordListOptions build() { + return new DeleteStopwordListOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteStopwordListOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the DeleteStopwordListOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected DeleteStopwordListOptions() {} + + protected DeleteStopwordListOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a DeleteStopwordListOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java index 41f7cedfbf2..a7c9d4098e0 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteTrainingQueries options. - */ +/** The deleteTrainingQueries options. */ public class DeleteTrainingQueriesOptions extends GenericModel { protected String projectId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; + /** + * Instantiates a new Builder from an existing DeleteTrainingQueriesOptions instance. + * + * @param deleteTrainingQueriesOptions the instance to initialize the Builder with + */ private Builder(DeleteTrainingQueriesOptions deleteTrainingQueriesOptions) { this.projectId = deleteTrainingQueriesOptions.projectId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String projectId) { /** * Builds a DeleteTrainingQueriesOptions. * - * @return the deleteTrainingQueriesOptions + * @return the new DeleteTrainingQueriesOptions instance */ public DeleteTrainingQueriesOptions build() { return new DeleteTrainingQueriesOptions(this); @@ -67,9 +66,10 @@ public Builder projectId(String projectId) { } } + protected DeleteTrainingQueriesOptions() {} + protected DeleteTrainingQueriesOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; } @@ -85,7 +85,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueryOptions.java new file mode 100644 index 00000000000..56574dda1c0 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueryOptions.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteTrainingQuery options. */ +public class DeleteTrainingQueryOptions extends GenericModel { + + protected String projectId; + protected String queryId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String queryId; + + /** + * Instantiates a new Builder from an existing DeleteTrainingQueryOptions instance. + * + * @param deleteTrainingQueryOptions the instance to initialize the Builder with + */ + private Builder(DeleteTrainingQueryOptions deleteTrainingQueryOptions) { + this.projectId = deleteTrainingQueryOptions.projectId; + this.queryId = deleteTrainingQueryOptions.queryId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param queryId the queryId + */ + public Builder(String projectId, String queryId) { + this.projectId = projectId; + this.queryId = queryId; + } + + /** + * Builds a DeleteTrainingQueryOptions. + * + * @return the new DeleteTrainingQueryOptions instance + */ + public DeleteTrainingQueryOptions build() { + return new DeleteTrainingQueryOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteTrainingQueryOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the queryId. + * + * @param queryId the queryId + * @return the DeleteTrainingQueryOptions builder + */ + public Builder queryId(String queryId) { + this.queryId = queryId; + return this; + } + } + + protected DeleteTrainingQueryOptions() {} + + protected DeleteTrainingQueryOptions(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.queryId, "queryId cannot be empty"); + projectId = builder.projectId; + queryId = builder.queryId; + } + + /** + * New builder. + * + * @return a DeleteTrainingQueryOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the queryId. + * + *

The ID of the query used for training. + * + * @return the queryId + */ + public String queryId() { + return queryId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java new file mode 100644 index 00000000000..cc0520b7466 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java @@ -0,0 +1,95 @@ +/* + * (C) Copyright IBM Corp. 2018, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteUserData options. */ +public class DeleteUserDataOptions extends GenericModel { + + protected String customerId; + + /** Builder. */ + public static class Builder { + private String customerId; + + /** + * Instantiates a new Builder from an existing DeleteUserDataOptions instance. + * + * @param deleteUserDataOptions the instance to initialize the Builder with + */ + private Builder(DeleteUserDataOptions deleteUserDataOptions) { + this.customerId = deleteUserDataOptions.customerId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customerId the customerId + */ + public Builder(String customerId) { + this.customerId = customerId; + } + + /** + * Builds a DeleteUserDataOptions. + * + * @return the new DeleteUserDataOptions instance + */ + public DeleteUserDataOptions build() { + return new DeleteUserDataOptions(this); + } + + /** + * Set the customerId. + * + * @param customerId the customerId + * @return the DeleteUserDataOptions builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + } + + protected DeleteUserDataOptions() {} + + protected DeleteUserDataOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, "customerId cannot be null"); + customerId = builder.customerId; + } + + /** + * New builder. + * + * @return a DeleteUserDataOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customerId. + * + *

The customer ID for which all data is to be deleted. + * + * @return the customerId + */ + public String customerId() { + return customerId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java index 1682d1ce1ff..6561cc79058 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,19 +10,19 @@ * 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; -/** - * Information returned after an uploaded document is accepted. - */ +/** Information returned after an uploaded document is accepted. */ public class DocumentAccepted extends GenericModel { /** - * Status of the document in the ingestion process. A status of `processing` is returned for documents that are - * ingested with a *version* date before `2019-01-01`. The `pending` status is returned for all others. + * Status of the document in the ingestion process. A status of `processing` is returned for + * documents that are ingested with a *version* date before `2019-01-01`. The `pending` status is + * returned for all others. */ public interface Status { /** processing. */ @@ -33,12 +33,15 @@ public interface Status { @SerializedName("document_id") protected String documentId; + protected String status; + protected DocumentAccepted() {} + /** * Gets the documentId. * - * The unique identifier of the ingested document. + *

The unique identifier of the ingested document. * * @return the documentId */ @@ -49,8 +52,9 @@ public String getDocumentId() { /** * Gets the status. * - * Status of the document in the ingestion process. A status of `processing` is returned for documents that are - * ingested with a *version* date before `2019-01-01`. The `pending` status is returned for all others. + *

Status of the document in the ingestion process. A status of `processing` is returned for + * documents that are ingested with a *version* date before `2019-01-01`. The `pending` status is + * returned for all others. * * @return the status */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java index f1dd868a1de..5e0ce17672a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,24 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * List of document attributes. - */ +/** List of document attributes. */ public class DocumentAttribute extends GenericModel { protected String type; protected String text; protected TableElementLocation location; + protected DocumentAttribute() {} + /** * Gets the type. * - * The type of attribute. + *

The type of attribute. * * @return the type */ @@ -37,7 +38,7 @@ public String getType() { /** * Gets the text. * - * The text associated with the attribute. + *

The text associated with the attribute. * * @return the text */ @@ -48,8 +49,8 @@ public String getText() { /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifier.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifier.java new file mode 100644 index 00000000000..db50d4be524 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifier.java @@ -0,0 +1,178 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.Date; +import java.util.List; + +/** Information about a document classifier. */ +public class DocumentClassifier extends GenericModel { + + @SerializedName("classifier_id") + protected String classifierId; + + protected String name; + protected String description; + protected Date created; + protected String language; + protected List enrichments; + + @SerializedName("recognized_fields") + protected List recognizedFields; + + @SerializedName("answer_field") + protected String answerField; + + @SerializedName("training_data_file") + protected String trainingDataFile; + + @SerializedName("test_data_file") + protected String testDataFile; + + @SerializedName("federated_classification") + protected ClassifierFederatedModel federatedClassification; + + protected DocumentClassifier() {} + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the document classifier. + * + * @return the classifierId + */ + public String getClassifierId() { + return classifierId; + } + + /** + * Gets the name. + * + *

A human-readable name of the document classifier. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

A description of the document classifier. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the created. + * + *

The date that the document classifier was created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the language. + * + *

The language of the training data that is associated with the document classifier. Language + * is specified by using the ISO 639-1 language code, such as `en` for English or `ja` for + * Japanese. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the enrichments. + * + *

An array of enrichments to apply to the data that is used to train and test the document + * classifier. The output from the enrichments is used as features by the classifier to classify + * the document content both during training and at run time. + * + * @return the enrichments + */ + public List getEnrichments() { + return enrichments; + } + + /** + * Gets the recognizedFields. + * + *

An array of fields that are used to train the document classifier. The same set of fields + * must exist in the training data, the test data, and the documents where the resulting document + * classifier enrichment is applied at run time. + * + * @return the recognizedFields + */ + public List getRecognizedFields() { + return recognizedFields; + } + + /** + * Gets the answerField. + * + *

The name of the field from the training and test data that contains the classification + * labels. + * + * @return the answerField + */ + public String getAnswerField() { + return answerField; + } + + /** + * Gets the trainingDataFile. + * + *

Name of the CSV file with training data that is used to train the document classifier. + * + * @return the trainingDataFile + */ + public String getTrainingDataFile() { + return trainingDataFile; + } + + /** + * Gets the testDataFile. + * + *

Name of the CSV file with data that is used to test the document classifier. If no test data + * is provided, a subset of the training data is used for testing purposes. + * + * @return the testDataFile + */ + public String getTestDataFile() { + return testDataFile; + } + + /** + * Gets the federatedClassification. + * + *

An object with details for creating federated document classifier models. + * + * @return the federatedClassification + */ + public ClassifierFederatedModel getFederatedClassification() { + return federatedClassification; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierEnrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierEnrichment.java new file mode 100644 index 00000000000..1fcd6dfcc5a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierEnrichment.java @@ -0,0 +1,148 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * An object that describes enrichments that are applied to the training and test data that is used + * by the document classifier. + */ +public class DocumentClassifierEnrichment extends GenericModel { + + @SerializedName("enrichment_id") + protected String enrichmentId; + + protected List fields; + + /** Builder. */ + public static class Builder { + private String enrichmentId; + private List fields; + + /** + * Instantiates a new Builder from an existing DocumentClassifierEnrichment instance. + * + * @param documentClassifierEnrichment the instance to initialize the Builder with + */ + private Builder(DocumentClassifierEnrichment documentClassifierEnrichment) { + this.enrichmentId = documentClassifierEnrichment.enrichmentId; + this.fields = documentClassifierEnrichment.fields; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param enrichmentId the enrichmentId + * @param fields the fields + */ + public Builder(String enrichmentId, List fields) { + this.enrichmentId = enrichmentId; + this.fields = fields; + } + + /** + * Builds a DocumentClassifierEnrichment. + * + * @return the new DocumentClassifierEnrichment instance + */ + public DocumentClassifierEnrichment build() { + return new DocumentClassifierEnrichment(this); + } + + /** + * Adds a new element to fields. + * + * @param fields the new element to be added + * @return the DocumentClassifierEnrichment builder + */ + public Builder addFields(String fields) { + com.ibm.cloud.sdk.core.util.Validator.notNull(fields, "fields cannot be null"); + if (this.fields == null) { + this.fields = new ArrayList(); + } + this.fields.add(fields); + return this; + } + + /** + * Set the enrichmentId. + * + * @param enrichmentId the enrichmentId + * @return the DocumentClassifierEnrichment builder + */ + public Builder enrichmentId(String enrichmentId) { + this.enrichmentId = enrichmentId; + return this; + } + + /** + * Set the fields. Existing fields will be replaced. + * + * @param fields the fields + * @return the DocumentClassifierEnrichment builder + */ + public Builder fields(List fields) { + this.fields = fields; + return this; + } + } + + protected DocumentClassifierEnrichment() {} + + protected DocumentClassifierEnrichment(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.enrichmentId, "enrichmentId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.fields, "fields cannot be null"); + enrichmentId = builder.enrichmentId; + fields = builder.fields; + } + + /** + * New builder. + * + * @return a DocumentClassifierEnrichment builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) of the enrichment. + * + * @return the enrichmentId + */ + public String enrichmentId() { + return enrichmentId; + } + + /** + * Gets the fields. + * + *

An array of field names where the enrichment is applied. + * + * @return the fields + */ + public List fields() { + return fields; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModel.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModel.java new file mode 100644 index 00000000000..8f482120848 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModel.java @@ -0,0 +1,181 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.Date; + +/** Information about a document classifier model. */ +public class DocumentClassifierModel extends GenericModel { + + /** The status of the training run. */ + public interface Status { + /** training. */ + String TRAINING = "training"; + /** available. */ + String AVAILABLE = "available"; + /** failed. */ + String FAILED = "failed"; + } + + @SerializedName("model_id") + protected String modelId; + + protected String name; + protected String description; + protected Date created; + protected Date updated; + + @SerializedName("training_data_file") + protected String trainingDataFile; + + @SerializedName("test_data_file") + protected String testDataFile; + + protected String status; + protected ClassifierModelEvaluation evaluation; + + @SerializedName("enrichment_id") + protected String enrichmentId; + + @SerializedName("deployed_at") + protected Date deployedAt; + + protected DocumentClassifierModel() {} + + /** + * Gets the modelId. + * + *

The Universally Unique Identifier (UUID) of the document classifier model. + * + * @return the modelId + */ + public String getModelId() { + return modelId; + } + + /** + * Gets the name. + * + *

A human-readable name of the document classifier model. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

A description of the document classifier model. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the created. + * + *

The date that the document classifier model was created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

The date that the document classifier model was last updated. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } + + /** + * Gets the trainingDataFile. + * + *

Name of the CSV file that contains the training data that is used to train the document + * classifier model. + * + * @return the trainingDataFile + */ + public String getTrainingDataFile() { + return trainingDataFile; + } + + /** + * Gets the testDataFile. + * + *

Name of the CSV file that contains data that is used to test the document classifier model. + * If no test data is provided, a subset of the training data is used for testing purposes. + * + * @return the testDataFile + */ + public String getTestDataFile() { + return testDataFile; + } + + /** + * Gets the status. + * + *

The status of the training run. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the evaluation. + * + *

An object that contains information about a trained document classifier model. + * + * @return the evaluation + */ + public ClassifierModelEvaluation getEvaluation() { + return evaluation; + } + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) of the enrichment that is generated by this + * document classifier model. + * + * @return the enrichmentId + */ + public String getEnrichmentId() { + return enrichmentId; + } + + /** + * Gets the deployedAt. + * + *

The date that the document classifier model was deployed. + * + * @return the deployedAt + */ + public Date getDeployedAt() { + return deployedAt; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModels.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModels.java new file mode 100644 index 00000000000..559257d50bf --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModels.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** An object that contains a list of document classifier model definitions. */ +public class DocumentClassifierModels extends GenericModel { + + protected List models; + + protected DocumentClassifierModels() {} + + /** + * Gets the models. + * + *

An array of document classifier model definitions. + * + * @return the models + */ + public List getModels() { + return models; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifiers.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifiers.java new file mode 100644 index 00000000000..97cf7d2afdb --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentClassifiers.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** An object that contains a list of document classifier definitions. */ +public class DocumentClassifiers extends GenericModel { + + protected List classifiers; + + protected DocumentClassifiers() {} + + /** + * Gets the classifiers. + * + *

An array of document classifier definitions. + * + * @return the classifiers + */ + public List getClassifiers() { + return classifiers; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentDetails.java new file mode 100644 index 00000000000..4440830478f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentDetails.java @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.Date; +import java.util.List; + +/** Information about a document. */ +public class DocumentDetails extends GenericModel { + + /** + * The status of the ingestion of the document. The possible values are: + * + *

* `available`: Ingestion is finished and the document is indexed. + * + *

* `failed`: Ingestion is finished, but the document is not indexed because of an error. + * + *

* `pending`: The document is uploaded, but the ingestion process is not started. + * + *

* `processing`: Ingestion is in progress. + */ + public interface Status { + /** available. */ + String AVAILABLE = "available"; + /** failed. */ + String FAILED = "failed"; + /** pending. */ + String PENDING = "pending"; + /** processing. */ + String PROCESSING = "processing"; + } + + @SerializedName("document_id") + protected String documentId; + + protected Date created; + protected Date updated; + protected String status; + protected List notices; + protected DocumentDetailsChildren children; + protected String filename; + + @SerializedName("file_type") + protected String fileType; + + protected String sha256; + + protected DocumentDetails() {} + + /** + * Gets the documentId. + * + *

The unique identifier of the document. + * + * @return the documentId + */ + public String getDocumentId() { + return documentId; + } + + /** + * Gets the created. + * + *

Date and time that the document is added to the collection. For a child document, the date + * and time when the process that generates the child document runs. The date-time format is + * `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the updated. + * + *

Date and time that the document is finished being processed and is indexed. This date + * changes whenever the document is reprocessed, including for enrichment changes. The date-time + * format is `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. + * + * @return the updated + */ + public Date getUpdated() { + return updated; + } + + /** + * Gets the status. + * + *

The status of the ingestion of the document. The possible values are: + * + *

* `available`: Ingestion is finished and the document is indexed. + * + *

* `failed`: Ingestion is finished, but the document is not indexed because of an error. + * + *

* `pending`: The document is uploaded, but the ingestion process is not started. + * + *

* `processing`: Ingestion is in progress. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the notices. + * + *

Array of JSON objects for notices, meaning warning or error messages, that are produced by + * the document ingestion process. The array does not include notices that are produced for child + * documents that are generated when a document is processed. + * + * @return the notices + */ + public List getNotices() { + return notices; + } + + /** + * Gets the children. + * + *

Information about the child documents that are generated from a single document during + * ingestion or other processing. + * + * @return the children + */ + public DocumentDetailsChildren getChildren() { + return children; + } + + /** + * Gets the filename. + * + *

Name of the original source file (if available). + * + * @return the filename + */ + public String getFilename() { + return filename; + } + + /** + * Gets the fileType. + * + *

The type of the original source file, such as `csv`, `excel`, `html`, `json`, `pdf`, `text`, + * `word`, and so on. + * + * @return the fileType + */ + public String getFileType() { + return fileType; + } + + /** + * Gets the sha256. + * + *

The SHA-256 hash of the original source file. The hash is formatted as a hexadecimal string. + * + * @return the sha256 + */ + public String getSha256() { + return sha256; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentDetailsChildren.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentDetailsChildren.java new file mode 100644 index 00000000000..a0ca90dfed9 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentDetailsChildren.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; + +/** + * Information about the child documents that are generated from a single document during ingestion + * or other processing. + */ +public class DocumentDetailsChildren extends GenericModel { + + @SerializedName("have_notices") + protected Boolean haveNotices; + + protected Long count; + + protected DocumentDetailsChildren() {} + + /** + * Gets the haveNotices. + * + *

Indicates whether the child documents have any notices. The value is `false` if the document + * does not have child documents. + * + * @return the haveNotices + */ + public Boolean isHaveNotices() { + return haveNotices; + } + + /** + * Gets the count. + * + *

Number of child documents. The value is `0` when processing of the document doesn't generate + * any child documents. + * + * @return the count + */ + public Long getCount() { + return count; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichment.java new file mode 100644 index 00000000000..5070dd19727 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichment.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; + +/** Information about a specific enrichment. */ +public class Enrichment extends GenericModel { + + /** The type of this enrichment. */ + public interface Type { + /** part_of_speech. */ + String PART_OF_SPEECH = "part_of_speech"; + /** sentiment. */ + String SENTIMENT = "sentiment"; + /** natural_language_understanding. */ + String NATURAL_LANGUAGE_UNDERSTANDING = "natural_language_understanding"; + /** dictionary. */ + String DICTIONARY = "dictionary"; + /** regular_expression. */ + String REGULAR_EXPRESSION = "regular_expression"; + /** uima_annotator. */ + String UIMA_ANNOTATOR = "uima_annotator"; + /** rule_based. */ + String RULE_BASED = "rule_based"; + /** watson_knowledge_studio_model. */ + String WATSON_KNOWLEDGE_STUDIO_MODEL = "watson_knowledge_studio_model"; + /** classifier. */ + String CLASSIFIER = "classifier"; + /** webhook. */ + String WEBHOOK = "webhook"; + /** sentence_classifier. */ + String SENTENCE_CLASSIFIER = "sentence_classifier"; + } + + @SerializedName("enrichment_id") + protected String enrichmentId; + + protected String name; + protected String description; + protected String type; + protected EnrichmentOptions options; + + protected Enrichment() {} + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) of this enrichment. + * + * @return the enrichmentId + */ + public String getEnrichmentId() { + return enrichmentId; + } + + /** + * Gets the name. + * + *

The human readable name for this enrichment. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

The description of this enrichment. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the type. + * + *

The type of this enrichment. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the options. + * + *

An object that contains options for the current enrichment. Starting with version + * `2020-08-30`, the enrichment options are not included in responses from the List Enrichments + * method. + * + * @return the options + */ + public EnrichmentOptions getOptions() { + return options; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java new file mode 100644 index 00000000000..966661ed583 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java @@ -0,0 +1,459 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * An object that contains options for the current enrichment. Starting with version `2020-08-30`, + * the enrichment options are not included in responses from the List Enrichments method. + */ +public class EnrichmentOptions extends GenericModel { + + protected List languages; + + @SerializedName("entity_type") + protected String entityType; + + @SerializedName("regular_expression") + protected String regularExpression; + + @SerializedName("result_field") + protected String resultField; + + @SerializedName("classifier_id") + protected String classifierId; + + @SerializedName("model_id") + protected String modelId; + + @SerializedName("confidence_threshold") + protected Double confidenceThreshold; + + @SerializedName("top_k") + protected Long topK; + + protected String url; + protected String version; + protected String secret; + protected WebhookHeader headers; + + @SerializedName("location_encoding") + protected String locationEncoding; + + /** Builder. */ + public static class Builder { + private List languages; + private String entityType; + private String regularExpression; + private String resultField; + private String classifierId; + private String modelId; + private Double confidenceThreshold; + private Long topK; + private String url; + private String version; + private String secret; + private WebhookHeader headers; + private String locationEncoding; + + /** + * Instantiates a new Builder from an existing EnrichmentOptions instance. + * + * @param enrichmentOptions the instance to initialize the Builder with + */ + private Builder(EnrichmentOptions enrichmentOptions) { + this.languages = enrichmentOptions.languages; + this.entityType = enrichmentOptions.entityType; + this.regularExpression = enrichmentOptions.regularExpression; + this.resultField = enrichmentOptions.resultField; + this.classifierId = enrichmentOptions.classifierId; + this.modelId = enrichmentOptions.modelId; + this.confidenceThreshold = enrichmentOptions.confidenceThreshold; + this.topK = enrichmentOptions.topK; + this.url = enrichmentOptions.url; + this.version = enrichmentOptions.version; + this.secret = enrichmentOptions.secret; + this.headers = enrichmentOptions.headers; + this.locationEncoding = enrichmentOptions.locationEncoding; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a EnrichmentOptions. + * + * @return the new EnrichmentOptions instance + */ + public EnrichmentOptions build() { + return new EnrichmentOptions(this); + } + + /** + * Adds a new element to languages. + * + * @param languages the new element to be added + * @return the EnrichmentOptions builder + */ + public Builder addLanguages(String languages) { + com.ibm.cloud.sdk.core.util.Validator.notNull(languages, "languages cannot be null"); + if (this.languages == null) { + this.languages = new ArrayList(); + } + this.languages.add(languages); + return this; + } + + /** + * Set the languages. Existing languages will be replaced. + * + * @param languages the languages + * @return the EnrichmentOptions builder + */ + public Builder languages(List languages) { + this.languages = languages; + return this; + } + + /** + * Set the entityType. + * + * @param entityType the entityType + * @return the EnrichmentOptions builder + */ + public Builder entityType(String entityType) { + this.entityType = entityType; + return this; + } + + /** + * Set the regularExpression. + * + * @param regularExpression the regularExpression + * @return the EnrichmentOptions builder + */ + public Builder regularExpression(String regularExpression) { + this.regularExpression = regularExpression; + return this; + } + + /** + * Set the resultField. + * + * @param resultField the resultField + * @return the EnrichmentOptions builder + */ + public Builder resultField(String resultField) { + this.resultField = resultField; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the EnrichmentOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the EnrichmentOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + + /** + * Set the confidenceThreshold. + * + * @param confidenceThreshold the confidenceThreshold + * @return the EnrichmentOptions builder + */ + public Builder confidenceThreshold(Double confidenceThreshold) { + this.confidenceThreshold = confidenceThreshold; + return this; + } + + /** + * Set the topK. + * + * @param topK the topK + * @return the EnrichmentOptions builder + */ + public Builder topK(long topK) { + this.topK = topK; + return this; + } + + /** + * Set the url. + * + * @param url the url + * @return the EnrichmentOptions builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the EnrichmentOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + + /** + * Set the secret. + * + * @param secret the secret + * @return the EnrichmentOptions builder + */ + public Builder secret(String secret) { + this.secret = secret; + return this; + } + + /** + * Set the headers. + * + * @param headers the headers + * @return the EnrichmentOptions builder + */ + public Builder headers(WebhookHeader headers) { + this.headers = headers; + return this; + } + + /** + * Set the locationEncoding. + * + * @param locationEncoding the locationEncoding + * @return the EnrichmentOptions builder + */ + public Builder locationEncoding(String locationEncoding) { + this.locationEncoding = locationEncoding; + return this; + } + } + + protected EnrichmentOptions() {} + + protected EnrichmentOptions(Builder builder) { + languages = builder.languages; + entityType = builder.entityType; + regularExpression = builder.regularExpression; + resultField = builder.resultField; + classifierId = builder.classifierId; + modelId = builder.modelId; + confidenceThreshold = builder.confidenceThreshold; + topK = builder.topK; + url = builder.url; + version = builder.version; + secret = builder.secret; + headers = builder.headers; + locationEncoding = builder.locationEncoding; + } + + /** + * New builder. + * + * @return a EnrichmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the languages. + * + *

An array of supported languages for this enrichment. When creating an enrichment, only + * specify a language that is used by the model or in the dictionary. Required when **type** is + * `dictionary`. Optional when **type** is `rule_based`. Not valid when creating any other type of + * enrichment. + * + * @return the languages + */ + public List languages() { + return languages; + } + + /** + * Gets the entityType. + * + *

The name of the entity type. This value is used as the field name in the index. Required + * when **type** is `dictionary` or `regular_expression`. Not valid when creating any other type + * of enrichment. + * + * @return the entityType + */ + public String entityType() { + return entityType; + } + + /** + * Gets the regularExpression. + * + *

The regular expression to apply for this enrichment. Required when **type** is + * `regular_expression`. Not valid when creating any other type of enrichment. + * + * @return the regularExpression + */ + public String regularExpression() { + return regularExpression; + } + + /** + * Gets the resultField. + * + *

The name of the result document field that this enrichment creates. Required when **type** + * is `rule_based` or `classifier`. Not valid when creating any other type of enrichment. + * + * @return the resultField + */ + public String resultField() { + return resultField; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the document classifier. Required when **type** + * is `classifier`. Not valid when creating any other type of enrichment. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } + + /** + * Gets the modelId. + * + *

The Universally Unique Identifier (UUID) of the document classifier model. Required when + * **type** is `classifier`. Not valid when creating any other type of enrichment. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } + + /** + * Gets the confidenceThreshold. + * + *

Specifies a threshold. Only classes with evaluation confidence scores that are higher than + * the specified threshold are included in the output. Optional when **type** is `classifier`. Not + * valid when creating any other type of enrichment. + * + * @return the confidenceThreshold + */ + public Double confidenceThreshold() { + return confidenceThreshold; + } + + /** + * Gets the topK. + * + *

Evaluates only the classes that fall in the top set of results when ranked by confidence. + * For example, if set to `5`, then the top five classes for each document are evaluated. If set + * to 0, the **confidence_threshold** is used to determine the predicted classes. Optional when + * **type** is `classifier`. Not valid when creating any other type of enrichment. + * + * @return the topK + */ + public Long topK() { + return topK; + } + + /** + * Gets the url. + * + *

A URL that uses the SSL protocol (begins with https) for the webhook. Required when type is + * `webhook`. Not valid when creating any other type of enrichment. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the version. + * + *

The Discovery API version that allows to distinguish the schema. The version is specified in + * the `yyyy-mm-dd` format. Optional when `type` is `webhook`. Not valid when creating any other + * type of enrichment. + * + * @return the version + */ + public String version() { + return version; + } + + /** + * Gets the secret. + * + *

A private key can be included in the request to authenticate with the external service. The + * maximum length is 1,024 characters. Optional when `type` is `webhook`. Not valid when creating + * any other type of enrichment. + * + * @return the secret + */ + public String secret() { + return secret; + } + + /** + * Gets the headers. + * + *

An array of headers to pass with the HTTP request. Optional when `type` is `webhook`. Not + * valid when creating any other type of enrichment. + * + * @return the headers + */ + public WebhookHeader headers() { + return headers; + } + + /** + * Gets the locationEncoding. + * + *

Discovery calculates offsets of the text's location with this encoding type in documents. + * Use the same location encoding type in both Discovery and external enrichment for a document. + * + *

These encoding types are supported: `utf-8`, `utf-16`, and `utf-32`. Optional when `type` is + * `webhook`. Not valid when creating any other type of enrichment. + * + * @return the locationEncoding + */ + public String locationEncoding() { + return locationEncoding; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichments.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichments.java new file mode 100644 index 00000000000..ed8de108bb1 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Enrichments.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** An object that contains an array of enrichment definitions. */ +public class Enrichments extends GenericModel { + + protected List enrichments; + + protected Enrichments() {} + + /** + * Gets the enrichments. + * + *

An array of enrichment definitions. + * + * @return the enrichments + */ + public List getEnrichments() { + return enrichments; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Expansion.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Expansion.java new file mode 100644 index 00000000000..41fc7d7c1b7 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Expansion.java @@ -0,0 +1,170 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * An expansion definition. Each object respresents one set of expandable strings. For example, you + * could have expansions for the word `hot` in one object, and expansions for the word `cold` in + * another. Follow these guidelines when you add terms: + * + *

* Specify the terms in lowercase. Lowercase terms expand to uppercase. + * + *

* Multiword terms are supported only in bidirectional expansions. + * + *

* Do not specify a term that is specified in the stop words list for the collection. + */ +public class Expansion extends GenericModel { + + @SerializedName("input_terms") + protected List inputTerms; + + @SerializedName("expanded_terms") + protected List expandedTerms; + + /** Builder. */ + public static class Builder { + private List inputTerms; + private List expandedTerms; + + /** + * Instantiates a new Builder from an existing Expansion instance. + * + * @param expansion the instance to initialize the Builder with + */ + private Builder(Expansion expansion) { + this.inputTerms = expansion.inputTerms; + this.expandedTerms = expansion.expandedTerms; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param expandedTerms the expandedTerms + */ + public Builder(List expandedTerms) { + this.expandedTerms = expandedTerms; + } + + /** + * Builds a Expansion. + * + * @return the new Expansion instance + */ + public Expansion build() { + return new Expansion(this); + } + + /** + * Adds a new element to inputTerms. + * + * @param inputTerms the new element to be added + * @return the Expansion builder + */ + public Builder addInputTerms(String inputTerms) { + com.ibm.cloud.sdk.core.util.Validator.notNull(inputTerms, "inputTerms cannot be null"); + if (this.inputTerms == null) { + this.inputTerms = new ArrayList(); + } + this.inputTerms.add(inputTerms); + return this; + } + + /** + * Adds a new element to expandedTerms. + * + * @param expandedTerms the new element to be added + * @return the Expansion builder + */ + public Builder addExpandedTerms(String expandedTerms) { + com.ibm.cloud.sdk.core.util.Validator.notNull(expandedTerms, "expandedTerms cannot be null"); + if (this.expandedTerms == null) { + this.expandedTerms = new ArrayList(); + } + this.expandedTerms.add(expandedTerms); + return this; + } + + /** + * Set the inputTerms. Existing inputTerms will be replaced. + * + * @param inputTerms the inputTerms + * @return the Expansion builder + */ + public Builder inputTerms(List inputTerms) { + this.inputTerms = inputTerms; + return this; + } + + /** + * Set the expandedTerms. Existing expandedTerms will be replaced. + * + * @param expandedTerms the expandedTerms + * @return the Expansion builder + */ + public Builder expandedTerms(List expandedTerms) { + this.expandedTerms = expandedTerms; + return this; + } + } + + protected Expansion() {} + + protected Expansion(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.expandedTerms, "expandedTerms cannot be null"); + inputTerms = builder.inputTerms; + expandedTerms = builder.expandedTerms; + } + + /** + * New builder. + * + * @return a Expansion builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the inputTerms. + * + *

A list of terms that will be expanded for this expansion. If specified, only the items in + * this list are expanded. + * + * @return the inputTerms + */ + public List inputTerms() { + return inputTerms; + } + + /** + * Gets the expandedTerms. + * + *

A list of terms that this expansion will be expanded to. If specified without + * **input_terms**, the list also functions as the input term list. + * + * @return the expandedTerms + */ + public List expandedTerms() { + return expandedTerms; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Expansions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Expansions.java new file mode 100644 index 00000000000..9b1fed43e12 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Expansions.java @@ -0,0 +1,125 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The query expansion definitions for the specified collection. */ +public class Expansions extends GenericModel { + + protected List expansions; + + /** Builder. */ + public static class Builder { + private List expansions; + + /** + * Instantiates a new Builder from an existing Expansions instance. + * + * @param expansions the instance to initialize the Builder with + */ + private Builder(Expansions expansions) { + this.expansions = expansions.expansions; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param expansions the expansions + */ + public Builder(List expansions) { + this.expansions = expansions; + } + + /** + * Builds a Expansions. + * + * @return the new Expansions instance + */ + public Expansions build() { + return new Expansions(this); + } + + /** + * Adds a new element to expansions. + * + * @param expansions the new element to be added + * @return the Expansions builder + */ + public Builder addExpansions(Expansion expansions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(expansions, "expansions cannot be null"); + if (this.expansions == null) { + this.expansions = new ArrayList(); + } + this.expansions.add(expansions); + return this; + } + + /** + * Set the expansions. Existing expansions will be replaced. + * + * @param expansions the expansions + * @return the Expansions builder + */ + public Builder expansions(List expansions) { + this.expansions = expansions; + return this; + } + } + + protected Expansions() {} + + protected Expansions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.expansions, "expansions cannot be null"); + expansions = builder.expansions; + } + + /** + * New builder. + * + * @return a Expansions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the expansions. + * + *

An array of query expansion definitions. + * + *

Each object in the **expansions** array represents a term or set of terms that will be + * expanded into other terms. Each expansion object can be configured as `bidirectional` or + * `unidirectional`. + * + *

* **Bidirectional**: Each entry in the `expanded_terms` list expands to include all expanded + * terms. For example, a query for `ibm` expands to `ibm OR international business machines OR big + * blue`. + * + *

* **Unidirectional**: The terms in `input_terms` in the query are replaced by the terms in + * `expanded_terms`. For example, a query for the often misused term `on premise` is converted to + * `on premises OR on-premises` and does not contain the original term. If you want an input term + * to be included in the query, then repeat the input term in the expanded terms list. + * + * @return the expansions + */ + public List expansions() { + return expansions; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java index b0b9ebccec0..7b774eebf85 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,19 +10,16 @@ * 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; -/** - * Object containing field details. - */ +/** Object that contains field details. */ public class Field extends GenericModel { - /** - * The type of the field. - */ + /** The type of the field. */ public interface Type { /** nested. */ String NESTED = "nested"; @@ -50,13 +47,16 @@ public interface Type { protected String field; protected String type; + @SerializedName("collection_id") protected String collectionId; + protected Field() {} + /** * Gets the field. * - * The name of the field. + *

The name of the field. * * @return the field */ @@ -67,7 +67,7 @@ public String getField() { /** * Gets the type. * - * The type of the field. + *

The type of the field. * * @return the type */ @@ -78,7 +78,7 @@ public String getType() { /** * Gets the collectionId. * - * The collection Id of the collection where the field was found. + *

The collection Id of the collection where the field was found. * * @return the collectionId */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java index 0b5fb6a78a0..72528d59733 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getAutocompletion options. - */ +/** The getAutocompletion options. */ public class GetAutocompletionOptions extends GenericModel { protected String projectId; @@ -28,9 +26,7 @@ public class GetAutocompletionOptions extends GenericModel { protected String field; protected Long count; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String prefix; @@ -38,6 +34,11 @@ public static class Builder { private String field; private Long count; + /** + * Instantiates a new Builder from an existing GetAutocompletionOptions instance. + * + * @param getAutocompletionOptions the instance to initialize the Builder with + */ private Builder(GetAutocompletionOptions getAutocompletionOptions) { this.projectId = getAutocompletionOptions.projectId; this.prefix = getAutocompletionOptions.prefix; @@ -46,11 +47,8 @@ private Builder(GetAutocompletionOptions getAutocompletionOptions) { this.count = getAutocompletionOptions.count; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -66,21 +64,20 @@ public Builder(String projectId, String prefix) { /** * Builds a GetAutocompletionOptions. * - * @return the getAutocompletionOptions + * @return the new GetAutocompletionOptions instance */ public GetAutocompletionOptions build() { return new GetAutocompletionOptions(this); } /** - * Adds an collectionIds to collectionIds. + * Adds a new element to collectionIds. * - * @param collectionIds the new collectionIds + * @param collectionIds the new element to be added * @return the GetAutocompletionOptions builder */ public Builder addCollectionIds(String collectionIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, - "collectionIds cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, "collectionIds cannot be null"); if (this.collectionIds == null) { this.collectionIds = new ArrayList(); } @@ -111,8 +108,7 @@ public Builder prefix(String prefix) { } /** - * Set the collectionIds. - * Existing collectionIds will be replaced. + * Set the collectionIds. Existing collectionIds will be replaced. * * @param collectionIds the collectionIds * @return the GetAutocompletionOptions builder @@ -145,11 +141,11 @@ public Builder count(long count) { } } + protected GetAutocompletionOptions() {} + protected GetAutocompletionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, - "projectId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.prefix, - "prefix cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.prefix, "prefix cannot be null"); projectId = builder.projectId; prefix = builder.prefix; collectionIds = builder.collectionIds; @@ -169,7 +165,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -180,8 +177,8 @@ public String projectId() { /** * Gets the prefix. * - * The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to `Hot`, `Housing`, or `How - * do I upgrade`. Possible completions are. + *

The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to + * `hot`, `housing`, or `how`. * * @return the prefix */ @@ -192,8 +189,8 @@ public String prefix() { /** * Gets the collectionIds. * - * Comma separated list of the collection IDs. If this parameter is not specified, all collections in the project are - * used. + *

Comma separated list of the collection IDs. If this parameter is not specified, all + * collections in the project are used. * * @return the collectionIds */ @@ -204,7 +201,7 @@ public List collectionIds() { /** * Gets the field. * - * The field in the result documents that autocompletion suggestions are identified from. + *

The field in the result documents that autocompletion suggestions are identified from. * * @return the field */ @@ -215,7 +212,7 @@ public String field() { /** * Gets the count. * - * The number of autocompletion suggestions to return. + *

The number of autocompletion suggestions to return. * * @return the count */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java new file mode 100644 index 00000000000..35f76d8713a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getCollection options. */ +public class GetCollectionOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing GetCollectionOptions instance. + * + * @param getCollectionOptions the instance to initialize the Builder with + */ + private Builder(GetCollectionOptions getCollectionOptions) { + this.projectId = getCollectionOptions.projectId; + this.collectionId = getCollectionOptions.collectionId; + } + + /** 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 GetCollectionOptions. + * + * @return the new GetCollectionOptions instance + */ + public GetCollectionOptions build() { + return new GetCollectionOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetCollectionOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the GetCollectionOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected GetCollectionOptions() {} + + protected GetCollectionOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a GetCollectionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java index 29e5ffaf540..2be55eef734 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getComponentSettings options. - */ +/** The getComponentSettings options. */ public class GetComponentSettingsOptions extends GenericModel { protected String projectId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; + /** + * Instantiates a new Builder from an existing GetComponentSettingsOptions instance. + * + * @param getComponentSettingsOptions the instance to initialize the Builder with + */ private Builder(GetComponentSettingsOptions getComponentSettingsOptions) { this.projectId = getComponentSettingsOptions.projectId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String projectId) { /** * Builds a GetComponentSettingsOptions. * - * @return the getComponentSettingsOptions + * @return the new GetComponentSettingsOptions instance */ public GetComponentSettingsOptions build() { return new GetComponentSettingsOptions(this); @@ -67,9 +66,10 @@ public Builder projectId(String projectId) { } } + protected GetComponentSettingsOptions() {} + protected GetComponentSettingsOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; } @@ -85,7 +85,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierModelOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierModelOptions.java new file mode 100644 index 00000000000..1eb988d99f1 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierModelOptions.java @@ -0,0 +1,155 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getDocumentClassifierModel options. */ +public class GetDocumentClassifierModelOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + protected String modelId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + private String modelId; + + /** + * Instantiates a new Builder from an existing GetDocumentClassifierModelOptions instance. + * + * @param getDocumentClassifierModelOptions the instance to initialize the Builder with + */ + private Builder(GetDocumentClassifierModelOptions getDocumentClassifierModelOptions) { + this.projectId = getDocumentClassifierModelOptions.projectId; + this.classifierId = getDocumentClassifierModelOptions.classifierId; + this.modelId = getDocumentClassifierModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + * @param modelId the modelId + */ + public Builder(String projectId, String classifierId, String modelId) { + this.projectId = projectId; + this.classifierId = classifierId; + this.modelId = modelId; + } + + /** + * Builds a GetDocumentClassifierModelOptions. + * + * @return the new GetDocumentClassifierModelOptions instance + */ + public GetDocumentClassifierModelOptions build() { + return new GetDocumentClassifierModelOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetDocumentClassifierModelOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the GetDocumentClassifierModelOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the GetDocumentClassifierModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected GetDocumentClassifierModelOptions() {} + + protected GetDocumentClassifierModelOptions(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.classifierId, "classifierId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + projectId = builder.projectId; + classifierId = builder.classifierId; + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a GetDocumentClassifierModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } + + /** + * Gets the modelId. + * + *

The Universally Unique Identifier (UUID) of the classifier model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierOptions.java new file mode 100644 index 00000000000..0dcdc3798aa --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getDocumentClassifier options. */ +public class GetDocumentClassifierOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + + /** + * Instantiates a new Builder from an existing GetDocumentClassifierOptions instance. + * + * @param getDocumentClassifierOptions the instance to initialize the Builder with + */ + private Builder(GetDocumentClassifierOptions getDocumentClassifierOptions) { + this.projectId = getDocumentClassifierOptions.projectId; + this.classifierId = getDocumentClassifierOptions.classifierId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + */ + public Builder(String projectId, String classifierId) { + this.projectId = projectId; + this.classifierId = classifierId; + } + + /** + * Builds a GetDocumentClassifierOptions. + * + * @return the new GetDocumentClassifierOptions instance + */ + public GetDocumentClassifierOptions build() { + return new GetDocumentClassifierOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetDocumentClassifierOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the GetDocumentClassifierOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + } + + protected GetDocumentClassifierOptions() {} + + protected GetDocumentClassifierOptions(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.classifierId, "classifierId cannot be empty"); + projectId = builder.projectId; + classifierId = builder.classifierId; + } + + /** + * New builder. + * + * @return a GetDocumentClassifierOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentOptions.java new file mode 100644 index 00000000000..bc13de61ae6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetDocumentOptions.java @@ -0,0 +1,156 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getDocument options. */ +public class GetDocumentOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String documentId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private String documentId; + + /** + * Instantiates a new Builder from an existing GetDocumentOptions instance. + * + * @param getDocumentOptions the instance to initialize the Builder with + */ + private Builder(GetDocumentOptions getDocumentOptions) { + this.projectId = getDocumentOptions.projectId; + this.collectionId = getDocumentOptions.collectionId; + this.documentId = getDocumentOptions.documentId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param collectionId the collectionId + * @param documentId the documentId + */ + public Builder(String projectId, String collectionId, String documentId) { + this.projectId = projectId; + this.collectionId = collectionId; + this.documentId = documentId; + } + + /** + * Builds a GetDocumentOptions. + * + * @return the new GetDocumentOptions instance + */ + public GetDocumentOptions build() { + return new GetDocumentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetDocumentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the GetDocumentOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the documentId. + * + * @param documentId the documentId + * @return the GetDocumentOptions builder + */ + public Builder documentId(String documentId) { + this.documentId = documentId; + return this; + } + } + + protected GetDocumentOptions() {} + + protected GetDocumentOptions(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.notEmpty( + builder.documentId, "documentId cannot be empty"); + projectId = builder.projectId; + collectionId = builder.collectionId; + documentId = builder.documentId; + } + + /** + * New builder. + * + * @return a GetDocumentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the documentId. + * + *

The ID of the document. + * + * @return the documentId + */ + public String documentId() { + return documentId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java new file mode 100644 index 00000000000..95c34a281e9 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getEnrichment options. */ +public class GetEnrichmentOptions extends GenericModel { + + protected String projectId; + protected String enrichmentId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String enrichmentId; + + /** + * Instantiates a new Builder from an existing GetEnrichmentOptions instance. + * + * @param getEnrichmentOptions the instance to initialize the Builder with + */ + private Builder(GetEnrichmentOptions getEnrichmentOptions) { + this.projectId = getEnrichmentOptions.projectId; + this.enrichmentId = getEnrichmentOptions.enrichmentId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param enrichmentId the enrichmentId + */ + public Builder(String projectId, String enrichmentId) { + this.projectId = projectId; + this.enrichmentId = enrichmentId; + } + + /** + * Builds a GetEnrichmentOptions. + * + * @return the new GetEnrichmentOptions instance + */ + public GetEnrichmentOptions build() { + return new GetEnrichmentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetEnrichmentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the enrichmentId. + * + * @param enrichmentId the enrichmentId + * @return the GetEnrichmentOptions builder + */ + public Builder enrichmentId(String enrichmentId) { + this.enrichmentId = enrichmentId; + return this; + } + } + + protected GetEnrichmentOptions() {} + + protected GetEnrichmentOptions(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.enrichmentId, "enrichmentId cannot be empty"); + projectId = builder.projectId; + enrichmentId = builder.enrichmentId; + } + + /** + * New builder. + * + * @return a GetEnrichmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) of the enrichment. + * + * @return the enrichmentId + */ + public String enrichmentId() { + return enrichmentId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java new file mode 100644 index 00000000000..30e1be711d9 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getProject options. */ +public class GetProjectOptions extends GenericModel { + + protected String projectId; + + /** Builder. */ + public static class Builder { + private String projectId; + + /** + * Instantiates a new Builder from an existing GetProjectOptions instance. + * + * @param getProjectOptions the instance to initialize the Builder with + */ + private Builder(GetProjectOptions getProjectOptions) { + this.projectId = getProjectOptions.projectId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a GetProjectOptions. + * + * @return the new GetProjectOptions instance + */ + public GetProjectOptions build() { + return new GetProjectOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetProjectOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected GetProjectOptions() {} + + protected GetProjectOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a GetProjectOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetStopwordListOptions.java new file mode 100644 index 00000000000..1e0bdb40e09 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetStopwordListOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getStopwordList options. */ +public class GetStopwordListOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing GetStopwordListOptions instance. + * + * @param getStopwordListOptions the instance to initialize the Builder with + */ + private Builder(GetStopwordListOptions getStopwordListOptions) { + this.projectId = getStopwordListOptions.projectId; + this.collectionId = getStopwordListOptions.collectionId; + } + + /** 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 GetStopwordListOptions. + * + * @return the new GetStopwordListOptions instance + */ + public GetStopwordListOptions build() { + return new GetStopwordListOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetStopwordListOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the GetStopwordListOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected GetStopwordListOptions() {} + + protected GetStopwordListOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a GetStopwordListOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java index 74477bd44d0..7b3395b73d5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getTrainingQuery options. - */ +/** The getTrainingQuery options. */ public class GetTrainingQueryOptions extends GenericModel { protected String projectId; protected String queryId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String queryId; + /** + * Instantiates a new Builder from an existing GetTrainingQueryOptions instance. + * + * @param getTrainingQueryOptions the instance to initialize the Builder with + */ private Builder(GetTrainingQueryOptions getTrainingQueryOptions) { this.projectId = getTrainingQueryOptions.projectId; this.queryId = getTrainingQueryOptions.queryId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String projectId, String queryId) { /** * Builds a GetTrainingQueryOptions. * - * @return the getTrainingQueryOptions + * @return the new GetTrainingQueryOptions instance */ public GetTrainingQueryOptions build() { return new GetTrainingQueryOptions(this); @@ -83,11 +82,11 @@ public Builder queryId(String queryId) { } } + protected GetTrainingQueryOptions() {} + protected GetTrainingQueryOptions(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.queryId, - "queryId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, "queryId cannot be empty"); projectId = builder.projectId; queryId = builder.queryId; } @@ -104,7 +103,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -115,7 +115,7 @@ public String projectId() { /** * Gets the queryId. * - * The ID of the query used for training. + *

The ID of the query used for training. * * @return the queryId */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListBatchesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListBatchesOptions.java new file mode 100644 index 00000000000..d2ad01f3379 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListBatchesOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listBatches options. */ +public class ListBatchesOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing ListBatchesOptions instance. + * + * @param listBatchesOptions the instance to initialize the Builder with + */ + private Builder(ListBatchesOptions listBatchesOptions) { + this.projectId = listBatchesOptions.projectId; + this.collectionId = listBatchesOptions.collectionId; + } + + /** 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 ListBatchesOptions. + * + * @return the new ListBatchesOptions instance + */ + public ListBatchesOptions build() { + return new ListBatchesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListBatchesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the ListBatchesOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected ListBatchesOptions() {} + + protected ListBatchesOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a ListBatchesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListBatchesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListBatchesResponse.java new file mode 100644 index 00000000000..8ad9f8a471c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListBatchesResponse.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** + * An object that contains a list of batches that are ready for enrichment by the external + * application. + */ +public class ListBatchesResponse extends GenericModel { + + protected List batches; + + protected ListBatchesResponse() {} + + /** + * Gets the batches. + * + *

An array that lists the batches in a collection. + * + * @return the batches + */ + public List getBatches() { + return batches; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java index 24ee10901a6..d1d4277b574 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listCollections options. - */ +/** The listCollections options. */ public class ListCollectionsOptions extends GenericModel { protected String projectId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; + /** + * Instantiates a new Builder from an existing ListCollectionsOptions instance. + * + * @param listCollectionsOptions the instance to initialize the Builder with + */ private Builder(ListCollectionsOptions listCollectionsOptions) { this.projectId = listCollectionsOptions.projectId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String projectId) { /** * Builds a ListCollectionsOptions. * - * @return the listCollectionsOptions + * @return the new ListCollectionsOptions instance */ public ListCollectionsOptions build() { return new ListCollectionsOptions(this); @@ -67,9 +66,10 @@ public Builder projectId(String projectId) { } } + protected ListCollectionsOptions() {} + protected ListCollectionsOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; } @@ -85,7 +85,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java index d91aee2a78c..ce6cd252084 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,23 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Response object containing an array of collection details. - */ +/** Response object that contains an array of collection details. */ public class ListCollectionsResponse extends GenericModel { protected List collections; + protected ListCollectionsResponse() {} + /** * Gets the collections. * - * An array containing information about each collection in the project. + *

An array that contains information about each collection in the project. * * @return the collections */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifierModelsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifierModelsOptions.java new file mode 100644 index 00000000000..ad5302611e4 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifierModelsOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listDocumentClassifierModels options. */ +public class ListDocumentClassifierModelsOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + + /** + * Instantiates a new Builder from an existing ListDocumentClassifierModelsOptions instance. + * + * @param listDocumentClassifierModelsOptions the instance to initialize the Builder with + */ + private Builder(ListDocumentClassifierModelsOptions listDocumentClassifierModelsOptions) { + this.projectId = listDocumentClassifierModelsOptions.projectId; + this.classifierId = listDocumentClassifierModelsOptions.classifierId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + */ + public Builder(String projectId, String classifierId) { + this.projectId = projectId; + this.classifierId = classifierId; + } + + /** + * Builds a ListDocumentClassifierModelsOptions. + * + * @return the new ListDocumentClassifierModelsOptions instance + */ + public ListDocumentClassifierModelsOptions build() { + return new ListDocumentClassifierModelsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListDocumentClassifierModelsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the ListDocumentClassifierModelsOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + } + + protected ListDocumentClassifierModelsOptions() {} + + protected ListDocumentClassifierModelsOptions(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.classifierId, "classifierId cannot be empty"); + projectId = builder.projectId; + classifierId = builder.classifierId; + } + + /** + * New builder. + * + * @return a ListDocumentClassifierModelsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifiersOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifiersOptions.java new file mode 100644 index 00000000000..4184363c2a2 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifiersOptions.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listDocumentClassifiers options. */ +public class ListDocumentClassifiersOptions extends GenericModel { + + protected String projectId; + + /** Builder. */ + public static class Builder { + private String projectId; + + /** + * Instantiates a new Builder from an existing ListDocumentClassifiersOptions instance. + * + * @param listDocumentClassifiersOptions the instance to initialize the Builder with + */ + private Builder(ListDocumentClassifiersOptions listDocumentClassifiersOptions) { + this.projectId = listDocumentClassifiersOptions.projectId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a ListDocumentClassifiersOptions. + * + * @return the new ListDocumentClassifiersOptions instance + */ + public ListDocumentClassifiersOptions build() { + return new ListDocumentClassifiersOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListDocumentClassifiersOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected ListDocumentClassifiersOptions() {} + + protected ListDocumentClassifiersOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a ListDocumentClassifiersOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentsOptions.java new file mode 100644 index 00000000000..a4881ab0442 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentsOptions.java @@ -0,0 +1,309 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listDocuments options. */ +public class ListDocumentsOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected Long count; + protected String status; + protected Boolean hasNotices; + protected Boolean isParent; + protected String parentDocumentId; + protected String sha256; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private Long count; + private String status; + private Boolean hasNotices; + private Boolean isParent; + private String parentDocumentId; + private String sha256; + + /** + * Instantiates a new Builder from an existing ListDocumentsOptions instance. + * + * @param listDocumentsOptions the instance to initialize the Builder with + */ + private Builder(ListDocumentsOptions listDocumentsOptions) { + this.projectId = listDocumentsOptions.projectId; + this.collectionId = listDocumentsOptions.collectionId; + this.count = listDocumentsOptions.count; + this.status = listDocumentsOptions.status; + this.hasNotices = listDocumentsOptions.hasNotices; + this.isParent = listDocumentsOptions.isParent; + this.parentDocumentId = listDocumentsOptions.parentDocumentId; + this.sha256 = listDocumentsOptions.sha256; + } + + /** 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 ListDocumentsOptions. + * + * @return the new ListDocumentsOptions instance + */ + public ListDocumentsOptions build() { + return new ListDocumentsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListDocumentsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the ListDocumentsOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the ListDocumentsOptions builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the status. + * + * @param status the status + * @return the ListDocumentsOptions builder + */ + public Builder status(String status) { + this.status = status; + return this; + } + + /** + * Set the hasNotices. + * + * @param hasNotices the hasNotices + * @return the ListDocumentsOptions builder + */ + public Builder hasNotices(Boolean hasNotices) { + this.hasNotices = hasNotices; + return this; + } + + /** + * Set the isParent. + * + * @param isParent the isParent + * @return the ListDocumentsOptions builder + */ + public Builder isParent(Boolean isParent) { + this.isParent = isParent; + return this; + } + + /** + * Set the parentDocumentId. + * + * @param parentDocumentId the parentDocumentId + * @return the ListDocumentsOptions builder + */ + public Builder parentDocumentId(String parentDocumentId) { + this.parentDocumentId = parentDocumentId; + return this; + } + + /** + * Set the sha256. + * + * @param sha256 the sha256 + * @return the ListDocumentsOptions builder + */ + public Builder sha256(String sha256) { + this.sha256 = sha256; + return this; + } + } + + protected ListDocumentsOptions() {} + + protected ListDocumentsOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + count = builder.count; + status = builder.status; + hasNotices = builder.hasNotices; + isParent = builder.isParent; + parentDocumentId = builder.parentDocumentId; + sha256 = builder.sha256; + } + + /** + * New builder. + * + * @return a ListDocumentsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the count. + * + *

The maximum number of documents to return. Up to 1,000 documents are returned by default. + * The maximum number allowed is 10,000. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the status. + * + *

Filters the documents to include only documents with the specified ingestion status. The + * options include: + * + *

* `available`: Ingestion is finished and the document is indexed. + * + *

* `failed`: Ingestion is finished, but the document is not indexed because of an error. + * + *

* `pending`: The document is uploaded, but the ingestion process is not started. + * + *

* `processing`: Ingestion is in progress. + * + *

You can specify one status value or add a comma-separated list of more than one status + * value. For example, `available,failed`. + * + * @return the status + */ + public String status() { + return status; + } + + /** + * Gets the hasNotices. + * + *

If set to `true`, only documents that have notices, meaning documents for which warnings or + * errors were generated during the ingestion, are returned. If set to `false`, only documents + * that don't have notices are returned. If unspecified, no filter based on notices is applied. + * + *

Notice details are not available in the result, but you can use the [Query collection + * notices](#querycollectionnotices) method to find details by adding the parameter + * `query=notices.document_id:{document-id}`. + * + * @return the hasNotices + */ + public Boolean hasNotices() { + return hasNotices; + } + + /** + * Gets the isParent. + * + *

If set to `true`, only parent documents, meaning documents that were split during the + * ingestion process and resulted in two or more child documents, are returned. If set to `false`, + * only child documents are returned. If unspecified, no filter based on the parent or child + * relationship is applied. + * + *

CSV files, for example, are split into separate documents per line and JSON files are split + * into separate documents per object. + * + * @return the isParent + */ + public Boolean isParent() { + return isParent; + } + + /** + * Gets the parentDocumentId. + * + *

Filters the documents to include only child documents that were generated when the specified + * parent document was processed. + * + * @return the parentDocumentId + */ + public String parentDocumentId() { + return parentDocumentId; + } + + /** + * Gets the sha256. + * + *

Filters the documents to include only documents with the specified SHA-256 hash. Format the + * hash as a hexadecimal string. + * + * @return the sha256 + */ + public String sha256() { + return sha256; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentsResponse.java new file mode 100644 index 00000000000..37fc80d0d26 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListDocumentsResponse.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.List; + +/** Response object that contains an array of documents. */ +public class ListDocumentsResponse extends GenericModel { + + @SerializedName("matching_results") + protected Long matchingResults; + + protected List documents; + + protected ListDocumentsResponse() {} + + /** + * Gets the matchingResults. + * + *

The number of matching results for the document query. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the documents. + * + *

An array that lists the documents in a collection. Only the document ID of each document is + * returned in the list. You can use the [Get document](#getdocument) method to get more + * information about an individual document. + * + * @return the documents + */ + public List getDocuments() { + return documents; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java new file mode 100644 index 00000000000..1134fcf62b0 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listEnrichments options. */ +public class ListEnrichmentsOptions extends GenericModel { + + protected String projectId; + + /** Builder. */ + public static class Builder { + private String projectId; + + /** + * Instantiates a new Builder from an existing ListEnrichmentsOptions instance. + * + * @param listEnrichmentsOptions the instance to initialize the Builder with + */ + private Builder(ListEnrichmentsOptions listEnrichmentsOptions) { + this.projectId = listEnrichmentsOptions.projectId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a ListEnrichmentsOptions. + * + * @return the new ListEnrichmentsOptions instance + */ + public ListEnrichmentsOptions build() { + return new ListEnrichmentsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListEnrichmentsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected ListEnrichmentsOptions() {} + + protected ListEnrichmentsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a ListEnrichmentsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListExpansionsOptions.java new file mode 100644 index 00000000000..35d8a20b40f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListExpansionsOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listExpansions options. */ +public class ListExpansionsOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + + /** + * Instantiates a new Builder from an existing ListExpansionsOptions instance. + * + * @param listExpansionsOptions the instance to initialize the Builder with + */ + private Builder(ListExpansionsOptions listExpansionsOptions) { + this.projectId = listExpansionsOptions.projectId; + this.collectionId = listExpansionsOptions.collectionId; + } + + /** 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 ListExpansionsOptions. + * + * @return the new ListExpansionsOptions instance + */ + public ListExpansionsOptions build() { + return new ListExpansionsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListExpansionsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the ListExpansionsOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + } + + protected ListExpansionsOptions() {} + + protected ListExpansionsOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + } + + /** + * New builder. + * + * @return a ListExpansionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java index 538c4ee63d3..6de91251c10 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,38 +10,36 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listFields options. - */ +/** The listFields options. */ public class ListFieldsOptions extends GenericModel { protected String projectId; protected List collectionIds; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private List collectionIds; + /** + * Instantiates a new Builder from an existing ListFieldsOptions instance. + * + * @param listFieldsOptions the instance to initialize the Builder with + */ private Builder(ListFieldsOptions listFieldsOptions) { this.projectId = listFieldsOptions.projectId; this.collectionIds = listFieldsOptions.collectionIds; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -55,21 +53,20 @@ public Builder(String projectId) { /** * Builds a ListFieldsOptions. * - * @return the listFieldsOptions + * @return the new ListFieldsOptions instance */ public ListFieldsOptions build() { return new ListFieldsOptions(this); } /** - * Adds an collectionIds to collectionIds. + * Adds a new element to collectionIds. * - * @param collectionIds the new collectionIds + * @param collectionIds the new element to be added * @return the ListFieldsOptions builder */ public Builder addCollectionIds(String collectionIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, - "collectionIds cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, "collectionIds cannot be null"); if (this.collectionIds == null) { this.collectionIds = new ArrayList(); } @@ -89,8 +86,7 @@ public Builder projectId(String projectId) { } /** - * Set the collectionIds. - * Existing collectionIds will be replaced. + * Set the collectionIds. Existing collectionIds will be replaced. * * @param collectionIds the collectionIds * @return the ListFieldsOptions builder @@ -101,9 +97,10 @@ public Builder collectionIds(List collectionIds) { } } + protected ListFieldsOptions() {} + protected ListFieldsOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; collectionIds = builder.collectionIds; } @@ -120,7 +117,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -131,8 +129,8 @@ public String projectId() { /** * Gets the collectionIds. * - * Comma separated list of the collection IDs. If this parameter is not specified, all collections in the project are - * used. + *

Comma separated list of the collection IDs. If this parameter is not specified, all + * collections in the project are used. * * @return the collectionIds */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java index 7c52c167fce..f2ab4f5eb5c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,31 +10,34 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; /** * The list of fetched fields. * - * The fields are returned using a fully qualified name format, however, the format differs slightly from that used by - * the query operations. + *

The fields are returned using a fully qualified name format, however, the format differs + * slightly from that used by the query operations. * - * * Fields which contain nested objects are assigned a type of "nested". + *

* Fields which contain nested objects are assigned a type of "nested". * - * * Fields which belong to a nested object are prefixed with `.properties` (for example, - * `warnings.properties.severity` means that the `warnings` object has a property called `severity`). + *

* Fields which belong to a nested object are prefixed with `.properties` (for example, + * `warnings.properties.severity` means that the `warnings` object has a property called + * `severity`). */ public class ListFieldsResponse extends GenericModel { protected List fields; + protected ListFieldsResponse() {} + /** * Gets the fields. * - * An array containing information about each field in the collections. + *

An array that contains information about each field in the collections. * * @return the fields */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListProjectsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListProjectsOptions.java new file mode 100644 index 00000000000..c561ddbbaa4 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListProjectsOptions.java @@ -0,0 +1,23 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listProjects options. */ +public class ListProjectsOptions extends GenericModel { + + /** Construct a new instance of ListProjectsOptions. */ + public ListProjectsOptions() {} +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListProjectsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListProjectsResponse.java new file mode 100644 index 00000000000..d80dbaa4f26 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListProjectsResponse.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** A list of projects in this instance. */ +public class ListProjectsResponse extends GenericModel { + + protected List projects; + + protected ListProjectsResponse() {} + + /** + * Gets the projects. + * + *

An array of project details. + * + * @return the projects + */ + public List getProjects() { + return projects; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java index c45f717057d..2fab873f4d2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listTrainingQueries options. - */ +/** The listTrainingQueries options. */ public class ListTrainingQueriesOptions extends GenericModel { protected String projectId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; + /** + * Instantiates a new Builder from an existing ListTrainingQueriesOptions instance. + * + * @param listTrainingQueriesOptions the instance to initialize the Builder with + */ private Builder(ListTrainingQueriesOptions listTrainingQueriesOptions) { this.projectId = listTrainingQueriesOptions.projectId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String projectId) { /** * Builds a ListTrainingQueriesOptions. * - * @return the listTrainingQueriesOptions + * @return the new ListTrainingQueriesOptions instance */ public ListTrainingQueriesOptions build() { return new ListTrainingQueriesOptions(this); @@ -67,9 +66,10 @@ public Builder projectId(String projectId) { } } + protected ListTrainingQueriesOptions() {} + protected ListTrainingQueriesOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; } @@ -85,7 +85,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMacroAverage.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMacroAverage.java new file mode 100644 index 00000000000..35a230e8811 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMacroAverage.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A macro-average computes metric independently for each class and then takes the average. Class + * refers to the classification label that is specified in the **answer_field**. + */ +public class ModelEvaluationMacroAverage extends GenericModel { + + protected Double precision; + protected Double recall; + protected Double f1; + + protected ModelEvaluationMacroAverage() {} + + /** + * Gets the precision. + * + *

A metric that measures how many of the overall documents are classified correctly. + * + * @return the precision + */ + public Double getPrecision() { + return precision; + } + + /** + * Gets the recall. + * + *

A metric that measures how often documents that should be classified into certain classes + * are classified into those classes. + * + * @return the recall + */ + public Double getRecall() { + return recall; + } + + /** + * Gets the f1. + * + *

A metric that measures whether the optimal balance between precision and recall is reached. + * The F1 score can be interpreted as a weighted average of the precision and recall values. An F1 + * score reaches its best value at 1 and worst value at 0. + * + * @return the f1 + */ + public Double getF1() { + return f1; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMicroAverage.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMicroAverage.java new file mode 100644 index 00000000000..48fb2c4cdb9 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMicroAverage.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A micro-average aggregates the contributions of all classes to compute the average metric. + * Classes refers to the classification labels that are specified in the **answer_field**. + */ +public class ModelEvaluationMicroAverage extends GenericModel { + + protected Double precision; + protected Double recall; + protected Double f1; + + protected ModelEvaluationMicroAverage() {} + + /** + * Gets the precision. + * + *

A metric that measures how many of the overall documents are classified correctly. + * + * @return the precision + */ + public Double getPrecision() { + return precision; + } + + /** + * Gets the recall. + * + *

A metric that measures how often documents that should be classified into certain classes + * are classified into those classes. + * + * @return the recall + */ + public Double getRecall() { + return recall; + } + + /** + * Gets the f1. + * + *

A metric that measures whether the optimal balance between precision and recall is reached. + * The F1 score can be interpreted as a weighted average of the precision and recall values. An F1 + * score reaches its best value at 1 and worst value at 0. + * + * @return the f1 + */ + public Double getF1() { + return f1; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java index e7a3492480c..743f2aed93a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,21 +10,17 @@ * 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.Date; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; -/** - * A notice produced for the collection. - */ +/** A notice produced for the collection. */ public class Notice extends GenericModel { - /** - * Severity level of the notice. - */ + /** Severity level of the notice. */ public interface Severity { /** warning. */ String WARNING = "warning"; @@ -34,28 +30,40 @@ public interface Severity { @SerializedName("notice_id") protected String noticeId; + protected Date created; + @SerializedName("document_id") protected String documentId; + @SerializedName("collection_id") protected String collectionId; + @SerializedName("query_id") protected String queryId; + protected String severity; protected String step; protected String description; + protected Notice() {} + /** * Gets the noticeId. * - * Identifies the notice. Many notices might have the same ID. This field exists so that user applications can - * programmatically identify a notice and take automatic corrective action. Typical notice IDs include: - * `index_failed`, `index_failed_too_many_requests`, `index_failed_incompatible_field`, - * `index_failed_cluster_unavailable`, `ingestion_timeout`, `ingestion_error`, `bad_request`, `internal_error`, - * `missing_model`, `unsupported_model`, `smart_document_understanding_failed_incompatible_field`, - * `smart_document_understanding_failed_internal_error`, `smart_document_understanding_failed_internal_error`, + *

Identifies the notice. Many notices might have the same ID. This field exists so that user + * applications can programmatically identify a notice and take automatic corrective action. + * Typical notice IDs include: + * + *

`index_failed`, `index_failed_too_many_requests`, `index_failed_incompatible_field`, + * `index_failed_cluster_unavailable`, `ingestion_timeout`, `ingestion_error`, `bad_request`, + * `internal_error`, `missing_model`, `unsupported_model`, + * `smart_document_understanding_failed_incompatible_field`, + * `smart_document_understanding_failed_internal_error`, + * `smart_document_understanding_failed_internal_error`, * `smart_document_understanding_failed_warning`, `smart_document_understanding_page_error`, - * `smart_document_understanding_page_warning`. **Note:** This is not a complete list, other values might be returned. + * `smart_document_understanding_page_warning`. **Note:** This is not a complete list. Other + * values might be returned. * * @return the noticeId */ @@ -66,7 +74,7 @@ public String getNoticeId() { /** * Gets the created. * - * The creation date of the collection in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. + *

The creation date of the collection in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. * * @return the created */ @@ -77,7 +85,7 @@ public Date getCreated() { /** * Gets the documentId. * - * Unique identifier of the document. + *

Unique identifier of the document. * * @return the documentId */ @@ -88,7 +96,7 @@ public String getDocumentId() { /** * Gets the collectionId. * - * Unique identifier of the collection. + *

Unique identifier of the collection. * * @return the collectionId */ @@ -99,7 +107,7 @@ public String getCollectionId() { /** * Gets the queryId. * - * Unique identifier of the query used for relevance training. + *

Unique identifier of the query used for relevance training. * * @return the queryId */ @@ -110,7 +118,7 @@ public String getQueryId() { /** * Gets the severity. * - * Severity level of the notice. + *

Severity level of the notice. * * @return the severity */ @@ -121,7 +129,7 @@ public String getSeverity() { /** * Gets the step. * - * Ingestion or training step in which the notice occurred. + *

Ingestion or training step in which the notice occurred. * * @return the step */ @@ -132,7 +140,7 @@ public String getStep() { /** * Gets the description. * - * The description of the notice. + *

The description of the notice. * * @return the description */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PerClassModelEvaluation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PerClassModelEvaluation.java new file mode 100644 index 00000000000..2112aef7fb5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PerClassModelEvaluation.java @@ -0,0 +1,76 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object that measures the metrics from a training run for each classification label separately. + */ +public class PerClassModelEvaluation extends GenericModel { + + protected String name; + protected Double precision; + protected Double recall; + protected Double f1; + + protected PerClassModelEvaluation() {} + + /** + * Gets the name. + * + *

Class name. Each class name is derived from a value in the **answer_field**. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the precision. + * + *

A metric that measures how many of the overall documents are classified correctly. + * + * @return the precision + */ + public Double getPrecision() { + return precision; + } + + /** + * Gets the recall. + * + *

A metric that measures how often documents that should be classified into certain classes + * are classified into those classes. + * + * @return the recall + */ + public Double getRecall() { + return recall; + } + + /** + * Gets the f1. + * + *

A metric that measures whether the optimal balance between precision and recall is reached. + * The F1 score can be interpreted as a weighted average of the precision and recall values. An F1 + * score reaches its best value at 1 and worst value at 0. + * + * @return the f1 + */ + public Double getF1() { + return f1; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectDetails.java new file mode 100644 index 00000000000..86d08058bff --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectDetails.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; + +/** Detailed information about the specified project. */ +public class ProjectDetails extends GenericModel { + + /** + * The type of project. + * + *

The `content_intelligence` type is a *Document Retrieval for Contracts* project and the + * `other` type is a *Custom* project. + * + *

The `content_mining` and `content_intelligence` types are available with Premium plan + * managed deployments and installed deployments only. + * + *

The Intelligent Document Processing (IDP) project type is available from IBM Cloud-managed + * instances only. + */ + public interface Type { + /** intelligent_document_processing. */ + String INTELLIGENT_DOCUMENT_PROCESSING = "intelligent_document_processing"; + /** document_retrieval. */ + String DOCUMENT_RETRIEVAL = "document_retrieval"; + /** conversational_search. */ + String CONVERSATIONAL_SEARCH = "conversational_search"; + /** content_mining. */ + String CONTENT_MINING = "content_mining"; + /** content_intelligence. */ + String CONTENT_INTELLIGENCE = "content_intelligence"; + /** other. */ + String OTHER = "other"; + } + + @SerializedName("project_id") + protected String projectId; + + protected String name; + protected String type; + + @SerializedName("relevancy_training_status") + protected ProjectListDetailsRelevancyTrainingStatus relevancyTrainingStatus; + + @SerializedName("collection_count") + protected Long collectionCount; + + @SerializedName("default_query_parameters") + protected DefaultQueryParams defaultQueryParameters; + + protected ProjectDetails() {} + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of this project. + * + * @return the projectId + */ + public String getProjectId() { + return projectId; + } + + /** + * Gets the name. + * + *

The human readable name of this project. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the type. + * + *

The type of project. + * + *

The `content_intelligence` type is a *Document Retrieval for Contracts* project and the + * `other` type is a *Custom* project. + * + *

The `content_mining` and `content_intelligence` types are available with Premium plan + * managed deployments and installed deployments only. + * + *

The Intelligent Document Processing (IDP) project type is available from IBM Cloud-managed + * instances only. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the relevancyTrainingStatus. + * + *

Relevancy training status information for this project. + * + * @return the relevancyTrainingStatus + */ + public ProjectListDetailsRelevancyTrainingStatus getRelevancyTrainingStatus() { + return relevancyTrainingStatus; + } + + /** + * Gets the collectionCount. + * + *

The number of collections configured in this project. + * + * @return the collectionCount + */ + public Long getCollectionCount() { + return collectionCount; + } + + /** + * Gets the defaultQueryParameters. + * + *

Default query parameters for this project. + * + * @return the defaultQueryParameters + */ + public DefaultQueryParams getDefaultQueryParameters() { + return defaultQueryParameters; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetails.java new file mode 100644 index 00000000000..75f708329db --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetails.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; + +/** Details about a specific project. */ +public class ProjectListDetails extends GenericModel { + + /** + * The type of project. + * + *

The `content_intelligence` type is a *Document Retrieval for Contracts* project and the + * `other` type is a *Custom* project. + * + *

The `content_mining` and `content_intelligence` types are available with Premium plan + * managed deployments and installed deployments only. + * + *

The Intelligent Document Processing (IDP) project type is available from IBM Cloud-managed + * instances only. + */ + public interface Type { + /** intelligent_document_processing. */ + String INTELLIGENT_DOCUMENT_PROCESSING = "intelligent_document_processing"; + /** document_retrieval. */ + String DOCUMENT_RETRIEVAL = "document_retrieval"; + /** conversational_search. */ + String CONVERSATIONAL_SEARCH = "conversational_search"; + /** content_mining. */ + String CONTENT_MINING = "content_mining"; + /** content_intelligence. */ + String CONTENT_INTELLIGENCE = "content_intelligence"; + /** other. */ + String OTHER = "other"; + } + + @SerializedName("project_id") + protected String projectId; + + protected String name; + protected String type; + + @SerializedName("relevancy_training_status") + protected ProjectListDetailsRelevancyTrainingStatus relevancyTrainingStatus; + + @SerializedName("collection_count") + protected Long collectionCount; + + protected ProjectListDetails() {} + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of this project. + * + * @return the projectId + */ + public String getProjectId() { + return projectId; + } + + /** + * Gets the name. + * + *

The human readable name of this project. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the type. + * + *

The type of project. + * + *

The `content_intelligence` type is a *Document Retrieval for Contracts* project and the + * `other` type is a *Custom* project. + * + *

The `content_mining` and `content_intelligence` types are available with Premium plan + * managed deployments and installed deployments only. + * + *

The Intelligent Document Processing (IDP) project type is available from IBM Cloud-managed + * instances only. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the relevancyTrainingStatus. + * + *

Relevancy training status information for this project. + * + * @return the relevancyTrainingStatus + */ + public ProjectListDetailsRelevancyTrainingStatus getRelevancyTrainingStatus() { + return relevancyTrainingStatus; + } + + /** + * Gets the collectionCount. + * + *

The number of collections configured in this project. + * + * @return the collectionCount + */ + public Long getCollectionCount() { + return collectionCount; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java new file mode 100644 index 00000000000..4ff60c983c4 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java @@ -0,0 +1,145 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; + +/** Relevancy training status information for this project. */ +public class ProjectListDetailsRelevancyTrainingStatus extends GenericModel { + + @SerializedName("data_updated") + protected String dataUpdated; + + @SerializedName("total_examples") + protected Long totalExamples; + + @SerializedName("sufficient_label_diversity") + protected Boolean sufficientLabelDiversity; + + protected Boolean processing; + + @SerializedName("minimum_examples_added") + protected Boolean minimumExamplesAdded; + + @SerializedName("successfully_trained") + protected String successfullyTrained; + + protected Boolean available; + protected Long notices; + + @SerializedName("minimum_queries_added") + protected Boolean minimumQueriesAdded; + + protected ProjectListDetailsRelevancyTrainingStatus() {} + + /** + * Gets the dataUpdated. + * + *

When the training data was updated. + * + * @return the dataUpdated + */ + public String getDataUpdated() { + return dataUpdated; + } + + /** + * Gets the totalExamples. + * + *

The total number of examples. + * + * @return the totalExamples + */ + public Long getTotalExamples() { + return totalExamples; + } + + /** + * Gets the sufficientLabelDiversity. + * + *

When `true`, sufficient label diversity is present to allow training for this project. + * + * @return the sufficientLabelDiversity + */ + public Boolean isSufficientLabelDiversity() { + return sufficientLabelDiversity; + } + + /** + * Gets the processing. + * + *

When `true`, the relevancy training is in processing. + * + * @return the processing + */ + public Boolean isProcessing() { + return processing; + } + + /** + * Gets the minimumExamplesAdded. + * + *

When `true`, the minimum number of examples required to train has been met. + * + * @return the minimumExamplesAdded + */ + public Boolean isMinimumExamplesAdded() { + return minimumExamplesAdded; + } + + /** + * Gets the successfullyTrained. + * + *

The time that the most recent successful training occurred. + * + * @return the successfullyTrained + */ + public String getSuccessfullyTrained() { + return successfullyTrained; + } + + /** + * Gets the available. + * + *

When `true`, relevancy training is available when querying collections in the project. + * + * @return the available + */ + public Boolean isAvailable() { + return available; + } + + /** + * Gets the notices. + * + *

The number of notices generated during the relevancy training. + * + * @return the notices + */ + public Long getNotices() { + return notices; + } + + /** + * Gets the minimumQueriesAdded. + * + *

When `true`, the minimum number of queries required to train has been met. + * + * @return the minimumQueriesAdded + */ + public Boolean isMinimumQueriesAdded() { + return minimumQueriesAdded; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PullBatchesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PullBatchesOptions.java new file mode 100644 index 00000000000..5684ab4793f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PullBatchesOptions.java @@ -0,0 +1,156 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The pullBatches options. */ +public class PullBatchesOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String batchId; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private String batchId; + + /** + * Instantiates a new Builder from an existing PullBatchesOptions instance. + * + * @param pullBatchesOptions the instance to initialize the Builder with + */ + private Builder(PullBatchesOptions pullBatchesOptions) { + this.projectId = pullBatchesOptions.projectId; + this.collectionId = pullBatchesOptions.collectionId; + this.batchId = pullBatchesOptions.batchId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param collectionId the collectionId + * @param batchId the batchId + */ + public Builder(String projectId, String collectionId, String batchId) { + this.projectId = projectId; + this.collectionId = collectionId; + this.batchId = batchId; + } + + /** + * Builds a PullBatchesOptions. + * + * @return the new PullBatchesOptions instance + */ + public PullBatchesOptions build() { + return new PullBatchesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the PullBatchesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the PullBatchesOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the batchId. + * + * @param batchId the batchId + * @return the PullBatchesOptions builder + */ + public Builder batchId(String batchId) { + this.batchId = batchId; + return this; + } + } + + protected PullBatchesOptions() {} + + protected PullBatchesOptions(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.notEmpty(builder.batchId, "batchId cannot be empty"); + projectId = builder.projectId; + collectionId = builder.collectionId; + batchId = builder.batchId; + } + + /** + * New builder. + * + * @return a PullBatchesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the batchId. + * + *

The Universally Unique Identifier (UUID) of the document batch that is being requested from + * Discovery. + * + * @return the batchId + */ + public String batchId() { + return batchId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PullBatchesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PullBatchesResponse.java new file mode 100644 index 00000000000..bc895802a6d --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PullBatchesResponse.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A compressed newline delimited JSON (NDJSON) file containing the document. The NDJSON format is + * used to describe structured data. The file name format is `{batch_id}.ndjson.gz`. For more + * information, see [Binary attachment from the pull batches + * method](/docs/discovery-data?topic=discovery-data-external-enrichment#binary-attachment-pull-batches). + */ +public class PullBatchesResponse extends GenericModel { + + protected String file; + + protected PullBatchesResponse() {} + + /** + * Gets the file. + * + *

A compressed NDJSON file containing the document. + * + * @return the file + */ + public String getFile() { + return file; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PushBatchesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PushBatchesOptions.java new file mode 100644 index 00000000000..af86c0af80a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/PushBatchesOptions.java @@ -0,0 +1,234 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The pushBatches options. */ +public class PushBatchesOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String batchId; + protected InputStream file; + protected String filename; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private String batchId; + private InputStream file; + private String filename; + + /** + * Instantiates a new Builder from an existing PushBatchesOptions instance. + * + * @param pushBatchesOptions the instance to initialize the Builder with + */ + private Builder(PushBatchesOptions pushBatchesOptions) { + this.projectId = pushBatchesOptions.projectId; + this.collectionId = pushBatchesOptions.collectionId; + this.batchId = pushBatchesOptions.batchId; + this.file = pushBatchesOptions.file; + this.filename = pushBatchesOptions.filename; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param collectionId the collectionId + * @param batchId the batchId + */ + public Builder(String projectId, String collectionId, String batchId) { + this.projectId = projectId; + this.collectionId = collectionId; + this.batchId = batchId; + } + + /** + * Builds a PushBatchesOptions. + * + * @return the new PushBatchesOptions instance + */ + public PushBatchesOptions build() { + return new PushBatchesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the PushBatchesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the PushBatchesOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the batchId. + * + * @param batchId the batchId + * @return the PushBatchesOptions builder + */ + public Builder batchId(String batchId) { + this.batchId = batchId; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the PushBatchesOptions builder + */ + public Builder file(InputStream file) { + this.file = file; + return this; + } + + /** + * Set the filename. + * + * @param filename the filename + * @return the PushBatchesOptions builder + */ + public Builder filename(String filename) { + this.filename = filename; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the PushBatchesOptions 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; + } + } + + protected PushBatchesOptions() {} + + protected PushBatchesOptions(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.notEmpty(builder.batchId, "batchId 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; + batchId = builder.batchId; + file = builder.file; + filename = builder.filename; + } + + /** + * New builder. + * + * @return a PushBatchesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the batchId. + * + *

The Universally Unique Identifier (UUID) of the document batch that is being requested from + * Discovery. + * + * @return the batchId + */ + public String batchId() { + return batchId; + } + + /** + * Gets the file. + * + *

A compressed newline-delimited JSON (NDJSON), which is a JSON file with one row of data per + * line. For example, `{batch_id}.ndjson.gz`. For more information, see [Binary attachment in the + * push batches + * method](/docs/discovery-data?topic=discovery-data-external-enrichment#binary-attachment-push-batches). + * + *

There is no limitation on the name of the file because Discovery does not use the name for + * processing. The list of features in the document is specified in the `features` object. + * + * @return the file + */ + public InputStream file() { + return file; + } + + /** + * Gets the filename. + * + *

The filename for file. + * + * @return the filename + */ + public String filename() { + return filename; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java index 23f98a40e02..7cabf8636dd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,43 +10,268 @@ * 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; +import java.util.List; +import java.util.Map; /** - * An abstract aggregation type produced by Discovery to analyze the input provided. + * An object that defines how to aggregate query results. + * + *

Classes which extend this class: - QueryAggregationQueryTermAggregation - + * QueryAggregationQueryGroupByAggregation - QueryAggregationQueryHistogramAggregation - + * QueryAggregationQueryTimesliceAggregation - QueryAggregationQueryNestedAggregation - + * QueryAggregationQueryFilterAggregation - QueryAggregationQueryCalculationAggregation - + * QueryAggregationQueryTopHitsAggregation - QueryAggregationQueryPairAggregation - + * QueryAggregationQueryTrendAggregation - QueryAggregationQueryTopicAggregation */ public class QueryAggregation extends GenericModel { @SuppressWarnings("unused") protected static String discriminatorPropertyName = "type"; + protected static java.util.Map> discriminatorMapping; + static { discriminatorMapping = new java.util.HashMap<>(); - discriminatorMapping.put("term", QueryTermAggregation.class); - discriminatorMapping.put("histogram", QueryHistogramAggregation.class); - discriminatorMapping.put("timeslice", QueryTimesliceAggregation.class); - discriminatorMapping.put("nested", QueryNestedAggregation.class); - discriminatorMapping.put("filter", QueryFilterAggregation.class); - discriminatorMapping.put("min", QueryCalculationAggregation.class); - discriminatorMapping.put("max", QueryCalculationAggregation.class); - discriminatorMapping.put("sum", QueryCalculationAggregation.class); - discriminatorMapping.put("average", QueryCalculationAggregation.class); - discriminatorMapping.put("unique_count", QueryCalculationAggregation.class); - discriminatorMapping.put("top_hits", QueryTopHitsAggregation.class); + discriminatorMapping.put("term", QueryAggregationQueryTermAggregation.class); + discriminatorMapping.put("group_by", QueryAggregationQueryGroupByAggregation.class); + discriminatorMapping.put("histogram", QueryAggregationQueryHistogramAggregation.class); + discriminatorMapping.put("timeslice", QueryAggregationQueryTimesliceAggregation.class); + discriminatorMapping.put("nested", QueryAggregationQueryNestedAggregation.class); + discriminatorMapping.put("filter", QueryAggregationQueryFilterAggregation.class); + discriminatorMapping.put("min", QueryAggregationQueryCalculationAggregation.class); + discriminatorMapping.put("max", QueryAggregationQueryCalculationAggregation.class); + discriminatorMapping.put("sum", QueryAggregationQueryCalculationAggregation.class); + discriminatorMapping.put("average", QueryAggregationQueryCalculationAggregation.class); + discriminatorMapping.put("unique_count", QueryAggregationQueryCalculationAggregation.class); + discriminatorMapping.put("top_hits", QueryAggregationQueryTopHitsAggregation.class); + discriminatorMapping.put("pair", QueryAggregationQueryPairAggregation.class); + discriminatorMapping.put("trend", QueryAggregationQueryTrendAggregation.class); + discriminatorMapping.put("topic", QueryAggregationQueryTopicAggregation.class); } protected String type; + protected String field; + protected Long count; + protected String name; + protected String path; + + @SerializedName("matching_results") + protected Long matchingResults; + + protected List> aggregations; + protected String match; + protected Double value; + protected Long size; + protected QueryTopHitsAggregationResult hits; + protected String first; + protected String second; + + @SerializedName("show_estimated_matching_results") + protected Boolean showEstimatedMatchingResults; + + @SerializedName("show_total_matching_documents") + protected Boolean showTotalMatchingDocuments; + + protected String facet; + + @SerializedName("time_segments") + protected String timeSegments; + + protected QueryAggregation() {} /** * Gets the type. * - * The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, - * average, unique_count, and top_hits. + *

Specifies that the aggregation type is `term`. * * @return the type */ public String getType() { return type; } + + /** + * Gets the field. + * + *

The field in the document where the values come from. + * + * @return the field + */ + public String getField() { + return field; + } + + /** + * Gets the count. + * + *

The number of results returned. Not returned if `relevancy:true` is specified in the + * request. + * + * @return the count + */ + public Long getCount() { + return count; + } + + /** + * Gets the name. + * + *

Identifier specified in the query request of this aggregation. Not returned if + * `relevancy:true` is specified in the request. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the path. + * + *

The path to the document field to scope subsequent aggregations to. + * + * @return the path + */ + public String getPath() { + return path; + } + + /** + * Gets the matchingResults. + * + *

Number of nested documents found in the specified field. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the aggregations. + * + *

An array of subaggregations. + * + * @return the aggregations + */ + public List> getAggregations() { + return aggregations; + } + + /** + * Gets the match. + * + *

The filter that is written in Discovery Query Language syntax and is applied to the + * documents before subaggregations are run. + * + * @return the match + */ + public String getMatch() { + return match; + } + + /** + * Gets the value. + * + *

The value of the calculation. + * + * @return the value + */ + public Double getValue() { + return value; + } + + /** + * Gets the size. + * + *

The number of documents to return. + * + * @return the size + */ + public Long getSize() { + return size; + } + + /** + * Gets the hits. + * + *

A query response that contains the matching documents for the preceding aggregations. + * + * @return the hits + */ + public QueryTopHitsAggregationResult getHits() { + return hits; + } + + /** + * Gets the first. + * + *

Specifies the first aggregation in the pair. The aggregation must be a `term`, `group_by`, + * `histogram`, or `timeslice` aggregation type. + * + * @return the first + */ + public String getFirst() { + return first; + } + + /** + * Gets the second. + * + *

Specifies the second aggregation in the pair. The aggregation must be a `term`, `group_by`, + * `histogram`, or `timeslice` aggregation type. + * + * @return the second + */ + public String getSecond() { + return second; + } + + /** + * Gets the showEstimatedMatchingResults. + * + *

Indicates whether to include estimated matching result information. + * + * @return the showEstimatedMatchingResults + */ + public Boolean isShowEstimatedMatchingResults() { + return showEstimatedMatchingResults; + } + + /** + * Gets the showTotalMatchingDocuments. + * + *

Indicates whether to include total matching documents information. + * + * @return the showTotalMatchingDocuments + */ + public Boolean isShowTotalMatchingDocuments() { + return showTotalMatchingDocuments; + } + + /** + * Gets the facet. + * + *

Specifies the `term` or `group_by` aggregation for the facet that you want to analyze. + * + * @return the facet + */ + public String getFacet() { + return facet; + } + + /** + * Gets the timeSegments. + * + *

Specifies the `timeslice` aggregation that defines the time segments. + * + * @return the timeSegments + */ + public String getTimeSegments() { + return timeSegments; + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryCalculationAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryCalculationAggregation.java new file mode 100644 index 00000000000..26a0effdb9a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryCalculationAggregation.java @@ -0,0 +1,23 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** + * Returns a scalar calculation across all documents for the field specified. Possible calculations + * include min, max, sum, average, and unique_count. + */ +public class QueryAggregationQueryCalculationAggregation extends QueryAggregation { + + protected QueryAggregationQueryCalculationAggregation() {} +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryFilterAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryFilterAggregation.java new file mode 100644 index 00000000000..a6919f70e7b --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryFilterAggregation.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** A modifier that narrows the document set of the subaggregations it precedes. */ +public class QueryAggregationQueryFilterAggregation extends QueryAggregation { + + protected QueryAggregationQueryFilterAggregation() {} +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryGroupByAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryGroupByAggregation.java new file mode 100644 index 00000000000..bbd2f0bf2ee --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryGroupByAggregation.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** Separates document results into groups that meet the conditions you specify. */ +public class QueryAggregationQueryGroupByAggregation extends QueryAggregation { + + protected List results; + + protected QueryAggregationQueryGroupByAggregation() {} + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryHistogramAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryHistogramAggregation.java new file mode 100644 index 00000000000..198c555edfc --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryHistogramAggregation.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** + * Numeric interval segments to categorize documents by using field values from a single numeric + * field to describe the category. + */ +public class QueryAggregationQueryHistogramAggregation extends QueryAggregation { + + protected Long interval; + + protected List results; + + protected QueryAggregationQueryHistogramAggregation() {} + + /** + * Gets the interval. + * + *

The size of the sections that the results are split into. + * + * @return the interval + */ + public Long getInterval() { + return interval; + } + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryNestedAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryNestedAggregation.java new file mode 100644 index 00000000000..12c0a9c5805 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryNestedAggregation.java @@ -0,0 +1,23 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** + * A restriction that alters the document set that is used by the aggregations that it precedes. + * Subsequent aggregations are applied to nested documents from the specified field. + */ +public class QueryAggregationQueryNestedAggregation extends QueryAggregation { + + protected QueryAggregationQueryNestedAggregation() {} +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryPairAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryPairAggregation.java new file mode 100644 index 00000000000..a4da517ff8c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryPairAggregation.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** + * Calculates relevancy values using combinations of document sets from results of the specified + * pair of aggregations. + */ +public class QueryAggregationQueryPairAggregation extends QueryAggregation { + + protected List results; + + protected QueryAggregationQueryPairAggregation() {} + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTermAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTermAggregation.java new file mode 100644 index 00000000000..d512af8f6e4 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTermAggregation.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** Returns results from the field that is specified. */ +public class QueryAggregationQueryTermAggregation extends QueryAggregation { + + protected List results; + + protected QueryAggregationQueryTermAggregation() {} + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTimesliceAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTimesliceAggregation.java new file mode 100644 index 00000000000..34cfd56179f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTimesliceAggregation.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** A specialized histogram aggregation that uses dates to create interval segments. */ +public class QueryAggregationQueryTimesliceAggregation extends QueryAggregation { + + protected String interval; + + protected List results; + + protected QueryAggregationQueryTimesliceAggregation() {} + + /** + * Gets the interval. + * + *

The date interval value. + * + * @return the interval + */ + public String getInterval() { + return interval; + } + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopHitsAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopHitsAggregation.java new file mode 100644 index 00000000000..0a147fc2ec8 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopHitsAggregation.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** Returns the top documents ranked by the score of the query. */ +public class QueryAggregationQueryTopHitsAggregation extends QueryAggregation { + + protected List results; + + protected QueryAggregationQueryTopHitsAggregation() {} + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopicAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopicAggregation.java new file mode 100644 index 00000000000..4e0109c6f97 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopicAggregation.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** + * Detects how much the frequency of a given facet value deviates from the expected average for the + * given time period. This aggregation type does not use data from previous time periods. It + * calculates an index by using the averages of frequency counts of other facet values for the given + * time period. + */ +public class QueryAggregationQueryTopicAggregation extends QueryAggregation { + + protected List results; + + protected QueryAggregationQueryTopicAggregation() {} + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTrendAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTrendAggregation.java new file mode 100644 index 00000000000..ee38b65ec9a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTrendAggregation.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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; + +/** + * Detects sharp and unexpected changes in the frequency of a facet or facet value over time based + * on the past history of frequency changes of the facet value. + */ +public class QueryAggregationQueryTrendAggregation extends QueryAggregation { + + protected List results; + + protected QueryAggregationQueryTrendAggregation() {} + + /** + * Gets the results. + * + *

An array of results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java deleted file mode 100644 index 95aeefdc720..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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; - -/** - * Returns a scalar calculation across all documents for the field specified. Possible calculations include min, max, - * sum, average, and unique_count. - */ -public class QueryCalculationAggregation extends QueryAggregation { - - protected String field; - protected Double value; - - /** - * Gets the field. - * - * The field to perform the calculation on. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the value. - * - * The value of the calculation. - * - * @return the value - */ - public Double getValue() { - return value; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCollectionNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCollectionNoticesOptions.java new file mode 100644 index 00000000000..6c9859786f2 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCollectionNoticesOptions.java @@ -0,0 +1,269 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The queryCollectionNotices options. */ +public class QueryCollectionNoticesOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String filter; + protected String query; + protected String naturalLanguageQuery; + protected Long count; + protected Long offset; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private String filter; + private String query; + private String naturalLanguageQuery; + private Long count; + private Long offset; + + /** + * Instantiates a new Builder from an existing QueryCollectionNoticesOptions instance. + * + * @param queryCollectionNoticesOptions the instance to initialize the Builder with + */ + private Builder(QueryCollectionNoticesOptions queryCollectionNoticesOptions) { + this.projectId = queryCollectionNoticesOptions.projectId; + this.collectionId = queryCollectionNoticesOptions.collectionId; + this.filter = queryCollectionNoticesOptions.filter; + this.query = queryCollectionNoticesOptions.query; + this.naturalLanguageQuery = queryCollectionNoticesOptions.naturalLanguageQuery; + this.count = queryCollectionNoticesOptions.count; + this.offset = queryCollectionNoticesOptions.offset; + } + + /** 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 QueryCollectionNoticesOptions. + * + * @return the new QueryCollectionNoticesOptions instance + */ + public QueryCollectionNoticesOptions build() { + return new QueryCollectionNoticesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the QueryCollectionNoticesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the QueryCollectionNoticesOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the QueryCollectionNoticesOptions builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the query. + * + * @param query the query + * @return the QueryCollectionNoticesOptions builder + */ + public Builder query(String query) { + this.query = query; + return this; + } + + /** + * Set the naturalLanguageQuery. + * + * @param naturalLanguageQuery the naturalLanguageQuery + * @return the QueryCollectionNoticesOptions builder + */ + public Builder naturalLanguageQuery(String naturalLanguageQuery) { + this.naturalLanguageQuery = naturalLanguageQuery; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the QueryCollectionNoticesOptions builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the offset. + * + * @param offset the offset + * @return the QueryCollectionNoticesOptions builder + */ + public Builder offset(long offset) { + this.offset = offset; + return this; + } + } + + protected QueryCollectionNoticesOptions() {} + + protected QueryCollectionNoticesOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + filter = builder.filter; + query = builder.query; + naturalLanguageQuery = builder.naturalLanguageQuery; + count = builder.count; + offset = builder.offset; + } + + /** + * New builder. + * + * @return a QueryCollectionNoticesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the filter. + * + *

Searches for documents that match the Discovery Query Language criteria that is specified as + * input. Filter calls are cached and are faster than query calls because the results are not + * ordered by relevance. When used with the `aggregation`, `query`, or `natural_language_query` + * parameters, the `filter` parameter runs first. This parameter is useful for limiting results to + * those that contain specific metadata values. + * + * @return the filter + */ + public String filter() { + return filter; + } + + /** + * Gets the query. + * + *

A query search that is written in the Discovery Query Language and returns all matching + * documents in your data set with full enrichments and full text, and with the most relevant + * documents listed first. You can use this parameter or the **natural_language_query** parameter + * to specify the query input, but not both. + * + * @return the query + */ + public String query() { + return query; + } + + /** + * Gets the naturalLanguageQuery. + * + *

A natural language query that returns relevant documents by using natural language + * understanding. You can use this parameter or the **query** parameter to specify the query + * input, but not both. To filter the results based on criteria you specify, include the + * **filter** parameter in the request. + * + * @return the naturalLanguageQuery + */ + public String naturalLanguageQuery() { + return naturalLanguageQuery; + } + + /** + * Gets the count. + * + *

Number of results to return. The maximum for the **count** and **offset** values together in + * any one query is **10,000**. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the offset. + * + *

The number of query results to skip at the beginning. For example, if the total number of + * results that are returned is 10 and the offset is 8, it returns the last two results. The + * maximum for the **count** and **offset** values together in any one query is **10000**. + * + * @return the offset + */ + public Long offset() { + return offset; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java deleted file mode 100644 index 00529be6539..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.google.gson.annotations.SerializedName; - -/** - * A modifier that will narrow down the document set of the sub aggregations it precedes. - */ -public class QueryFilterAggregation extends QueryAggregation { - - protected String match; - @SerializedName("matching_results") - protected Long matchingResults; - protected List aggregations; - - /** - * Gets the match. - * - * The filter written in Discovery Query Language syntax applied to the documents before sub aggregations are run. - * - * @return the match - */ - public String getMatch() { - return match; - } - - /** - * Gets the matchingResults. - * - * Number of documents matching the filter. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the aggregations. - * - * An array of sub aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResult.java new file mode 100644 index 00000000000..6dc6e6b1275 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResult.java @@ -0,0 +1,109 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.List; +import java.util.Map; + +/** Result group for the `group_by` aggregation. */ +public class QueryGroupByAggregationResult extends GenericModel { + + protected String key; + + @SerializedName("matching_results") + protected Long matchingResults; + + protected Double relevancy; + + @SerializedName("total_matching_documents") + protected Long totalMatchingDocuments; + + @SerializedName("estimated_matching_results") + protected Double estimatedMatchingResults; + + protected List> aggregations; + + protected QueryGroupByAggregationResult() {} + + /** + * Gets the key. + * + *

The condition that is met by the documents in this group. For example, `YEARTXT<2000`. + * + * @return the key + */ + public String getKey() { + return key; + } + + /** + * Gets the matchingResults. + * + *

Number of documents that meet the query and condition. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the relevancy. + * + *

The relevancy for this group. Returned only if `relevancy:true` is specified in the request. + * + * @return the relevancy + */ + public Double getRelevancy() { + return relevancy; + } + + /** + * Gets the totalMatchingDocuments. + * + *

Number of documents that meet the condition in the whole set of documents in this + * collection. Returned only when `relevancy:true` is specified in the request. + * + * @return the totalMatchingDocuments + */ + public Long getTotalMatchingDocuments() { + return totalMatchingDocuments; + } + + /** + * Gets the estimatedMatchingResults. + * + *

The number of documents that are estimated to match the query and condition. Returned only + * when `relevancy:true` is specified in the request. + * + * @return the estimatedMatchingResults + */ + public Double getEstimatedMatchingResults() { + return estimatedMatchingResults; + } + + /** + * Gets the aggregations. + * + *

An array of subaggregations. Returned only when this aggregation is returned as a + * subaggregation. + * + * @return the aggregations + */ + public List> getAggregations() { + return aggregations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java deleted file mode 100644 index 37868db9d21..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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; - -/** - * Numeric interval segments to categorize documents by using field values from a single numeric field to describe the - * category. - */ -public class QueryHistogramAggregation extends QueryAggregation { - - protected String field; - protected Long interval; - protected List results; - - /** - * Gets the field. - * - * The numeric field name used to create the histogram. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the interval. - * - * The size of the sections the results are split into. - * - * @return the interval - */ - public Long getInterval() { - return interval; - } - - /** - * Gets the results. - * - * Array of numeric intervals. - * - * @return the results - */ - public List getResults() { - return results; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java index 742a59dcac1..e7e9327eafc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,27 +10,30 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; -/** - * Histogram numeric interval result. - */ +/** Histogram numeric interval result. */ public class QueryHistogramAggregationResult extends GenericModel { protected Long key; + @SerializedName("matching_results") protected Long matchingResults; - protected List aggregations; + + protected List> aggregations; + + protected QueryHistogramAggregationResult() {} /** * Gets the key. * - * The value of the upper bound for the numeric segment. + *

The value of the upper bound for the numeric segment. * * @return the key */ @@ -41,7 +44,7 @@ public Long getKey() { /** * Gets the matchingResults. * - * Number of documents with the specified key as the upper bound. + *

Number of documents with the specified key as the upper bound. * * @return the matchingResults */ @@ -52,11 +55,12 @@ public Long getMatchingResults() { /** * Gets the aggregations. * - * An array of sub aggregations. + *

An array of subaggregations. Returned only when this aggregation is returned as a + * subaggregation. * * @return the aggregations */ - public List getAggregations() { + public List> getAggregations() { return aggregations; } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java index 039e3ef3a2e..804e9c86a5a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,31 +10,36 @@ * 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.ArrayList; -import java.util.List; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; -/** - * Configuration for passage retrieval. - */ +/** Configuration for passage retrieval. */ public class QueryLargePassages extends GenericModel { protected Boolean enabled; + @SerializedName("per_document") protected Boolean perDocument; + @SerializedName("max_per_document") protected Long maxPerDocument; + protected List fields; protected Long count; protected Long characters; - /** - * Builder. - */ + @SerializedName("find_answers") + protected Boolean findAnswers; + + @SerializedName("max_answers_per_passage") + protected Long maxAnswersPerPassage; + + /** Builder. */ public static class Builder { private Boolean enabled; private Boolean perDocument; @@ -42,7 +47,14 @@ public static class Builder { private List fields; private Long count; private Long characters; + private Boolean findAnswers; + private Long maxAnswersPerPassage; + /** + * Instantiates a new Builder from an existing QueryLargePassages instance. + * + * @param queryLargePassages the instance to initialize the Builder with + */ private Builder(QueryLargePassages queryLargePassages) { this.enabled = queryLargePassages.enabled; this.perDocument = queryLargePassages.perDocument; @@ -50,32 +62,30 @@ private Builder(QueryLargePassages queryLargePassages) { this.fields = queryLargePassages.fields; this.count = queryLargePassages.count; this.characters = queryLargePassages.characters; + this.findAnswers = queryLargePassages.findAnswers; + this.maxAnswersPerPassage = queryLargePassages.maxAnswersPerPassage; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a QueryLargePassages. * - * @return the queryLargePassages + * @return the new QueryLargePassages instance */ public QueryLargePassages build() { return new QueryLargePassages(this); } /** - * Adds an fields to fields. + * Adds a new element to fields. * - * @param fields the new fields + * @param fields the new element to be added * @return the QueryLargePassages builder */ public Builder addFields(String fields) { - com.ibm.cloud.sdk.core.util.Validator.notNull(fields, - "fields cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(fields, "fields cannot be null"); if (this.fields == null) { this.fields = new ArrayList(); } @@ -117,8 +127,7 @@ public Builder maxPerDocument(long maxPerDocument) { } /** - * Set the fields. - * Existing fields will be replaced. + * Set the fields. Existing fields will be replaced. * * @param fields the fields * @return the QueryLargePassages builder @@ -149,8 +158,32 @@ public Builder characters(long characters) { this.characters = characters; return this; } + + /** + * Set the findAnswers. + * + * @param findAnswers the findAnswers + * @return the QueryLargePassages builder + */ + public Builder findAnswers(Boolean findAnswers) { + this.findAnswers = findAnswers; + return this; + } + + /** + * Set the maxAnswersPerPassage. + * + * @param maxAnswersPerPassage the maxAnswersPerPassage + * @return the QueryLargePassages builder + */ + public Builder maxAnswersPerPassage(long maxAnswersPerPassage) { + this.maxAnswersPerPassage = maxAnswersPerPassage; + return this; + } } + protected QueryLargePassages() {} + protected QueryLargePassages(Builder builder) { enabled = builder.enabled; perDocument = builder.perDocument; @@ -158,6 +191,8 @@ protected QueryLargePassages(Builder builder) { fields = builder.fields; count = builder.count; characters = builder.characters; + findAnswers = builder.findAnswers; + maxAnswersPerPassage = builder.maxAnswersPerPassage; } /** @@ -172,7 +207,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - * A passages query that returns the most relevant passages from the results. + *

A passages query that returns the most relevant passages from the results. * * @return the enabled */ @@ -183,7 +218,12 @@ public Boolean enabled() { /** * Gets the perDocument. * - * When `true`, passages will be returned within their respective result. + *

If `true`, ranks the documents by document quality, and then returns the highest-ranked + * passages per document in a `document_passages` field for each document entry in the results + * list of the response. + * + *

If `false`, ranks the passages from all of the documents by passage quality regardless of + * the document quality and returns them in a separate `passages` field in the response. * * @return the perDocument */ @@ -194,7 +234,8 @@ public Boolean perDocument() { /** * Gets the maxPerDocument. * - * Maximum number of passages to return per result. + *

Maximum number of passages to return per document in the result. Ignored if + * **passages.per_document** is `false`. * * @return the maxPerDocument */ @@ -205,8 +246,9 @@ public Long maxPerDocument() { /** * Gets the fields. * - * A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are - * included. + *

A list of fields to extract passages from. By default, passages are extracted from the + * `text` and `title` fields only. If you add this parameter and specify an empty list (`[]`) as + * its value, then the service searches all root-level fields for suitable passages. * * @return the fields */ @@ -217,8 +259,7 @@ public List fields() { /** * Gets the count. * - * The maximum number of passages to return. The search returns fewer passages if the requested total is not found. - * The default is `10`. The maximum is `100`. + *

The maximum number of passages to return. Ignored if **passages.per_document** is `true`. * * @return the count */ @@ -229,11 +270,50 @@ public Long count() { /** * Gets the characters. * - * The approximate number of characters that any one passage will have. + *

The approximate number of characters that any one passage will have. * * @return the characters */ public Long characters() { return characters; } + + /** + * Gets the findAnswers. + * + *

When true, `answer` objects are returned as part of each passage in the query results. The + * primary difference between an `answer` and a `passage` is that the length of a passage is + * defined by the query, where the length of an `answer` is calculated by Discovery based on how + * much text is needed to answer the question. + * + *

This parameter is ignored if passages are not enabled for the query, or no + * **natural_language_query** is specified. + * + *

If the **find_answers** parameter is set to `true` and **per_document** parameter is also + * set to `true`, then the document search results and the passage search results within each + * document are reordered using the answer confidences. The goal of this reordering is to place + * the best answer as the first answer of the first passage of the first document. Similarly, if + * the **find_answers** parameter is set to `true` and **per_document** parameter is set to + * `false`, then the passage search results are reordered in decreasing order of the highest + * confidence answer for each document and passage. + * + *

The **find_answers** parameter is available only on managed instances of Discovery. + * + * @return the findAnswers + */ + public Boolean findAnswers() { + return findAnswers; + } + + /** + * Gets the maxAnswersPerPassage. + * + *

The number of `answer` objects to return per passage if the **find_answers** parmeter is + * specified as `true`. + * + * @return the maxAnswersPerPassage + */ + public Long maxAnswersPerPassage() { + return maxAnswersPerPassage; + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSimilar.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSimilar.java new file mode 100644 index 00000000000..dd81cf096fa --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSimilar.java @@ -0,0 +1,179 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * Finds results from documents that are similar to documents of interest. Use this parameter to add + * a *More like these* function to your search. You can include this parameter with or without a + * **query**, **filter** or **natural_language_query** parameter. + */ +public class QueryLargeSimilar extends GenericModel { + + protected Boolean enabled; + + @SerializedName("document_ids") + protected List documentIds; + + protected List fields; + + /** Builder. */ + public static class Builder { + private Boolean enabled; + private List documentIds; + private List fields; + + /** + * Instantiates a new Builder from an existing QueryLargeSimilar instance. + * + * @param queryLargeSimilar the instance to initialize the Builder with + */ + private Builder(QueryLargeSimilar queryLargeSimilar) { + this.enabled = queryLargeSimilar.enabled; + this.documentIds = queryLargeSimilar.documentIds; + this.fields = queryLargeSimilar.fields; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a QueryLargeSimilar. + * + * @return the new QueryLargeSimilar instance + */ + public QueryLargeSimilar build() { + return new QueryLargeSimilar(this); + } + + /** + * Adds a new element to documentIds. + * + * @param documentIds the new element to be added + * @return the QueryLargeSimilar builder + */ + public Builder addDocumentIds(String documentIds) { + com.ibm.cloud.sdk.core.util.Validator.notNull(documentIds, "documentIds cannot be null"); + if (this.documentIds == null) { + this.documentIds = new ArrayList(); + } + this.documentIds.add(documentIds); + return this; + } + + /** + * Adds a new element to fields. + * + * @param fields the new element to be added + * @return the QueryLargeSimilar builder + */ + public Builder addFields(String fields) { + com.ibm.cloud.sdk.core.util.Validator.notNull(fields, "fields cannot be null"); + if (this.fields == null) { + this.fields = new ArrayList(); + } + this.fields.add(fields); + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the QueryLargeSimilar builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the documentIds. Existing documentIds will be replaced. + * + * @param documentIds the documentIds + * @return the QueryLargeSimilar builder + */ + public Builder documentIds(List documentIds) { + this.documentIds = documentIds; + return this; + } + + /** + * Set the fields. Existing fields will be replaced. + * + * @param fields the fields + * @return the QueryLargeSimilar builder + */ + public Builder fields(List fields) { + this.fields = fields; + return this; + } + } + + protected QueryLargeSimilar() {} + + protected QueryLargeSimilar(Builder builder) { + enabled = builder.enabled; + documentIds = builder.documentIds; + fields = builder.fields; + } + + /** + * New builder. + * + * @return a QueryLargeSimilar builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

When `true`, includes documents in the query results that are similar to documents you + * specify. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the documentIds. + * + *

The list of documents of interest. Required if **enabled** is `true`. + * + * @return the documentIds + */ + public List documentIds() { + return documentIds; + } + + /** + * Gets the fields. + * + *

Looks for similarities in the specified subset of fields in the documents. If not specified, + * all of the document fields are used. + * + * @return the fields + */ + public List fields() { + return fields; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java index 867d7868814..03fd2e0a0bc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,40 +10,44 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; /** * Configuration for suggested refinements. + * + *

**Note**: The **suggested_refinements** parameter that identified dynamic facets from the data + * is deprecated. */ public class QueryLargeSuggestedRefinements extends GenericModel { protected Boolean enabled; protected Long count; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean enabled; private Long count; + /** + * Instantiates a new Builder from an existing QueryLargeSuggestedRefinements instance. + * + * @param queryLargeSuggestedRefinements the instance to initialize the Builder with + */ private Builder(QueryLargeSuggestedRefinements queryLargeSuggestedRefinements) { this.enabled = queryLargeSuggestedRefinements.enabled; this.count = queryLargeSuggestedRefinements.count; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a QueryLargeSuggestedRefinements. * - * @return the queryLargeSuggestedRefinements + * @return the new QueryLargeSuggestedRefinements instance */ public QueryLargeSuggestedRefinements build() { return new QueryLargeSuggestedRefinements(this); @@ -72,6 +76,8 @@ public Builder count(long count) { } } + protected QueryLargeSuggestedRefinements() {} + protected QueryLargeSuggestedRefinements(Builder builder) { enabled = builder.enabled; count = builder.count; @@ -89,7 +95,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - * Whether to perform suggested refinements. + *

Whether to perform suggested refinements. * * @return the enabled */ @@ -100,7 +106,7 @@ public Boolean enabled() { /** * Gets the count. * - * Maximum number of suggested refinements texts to be returned. The default is `10`. The maximum is `100`. + *

Maximum number of suggested refinements texts to be returned. The maximum is `100`. * * @return the count */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java index 01fb5e04f4a..4510f6ac52b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,40 +10,39 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Configuration for table retrieval. - */ +/** Configuration for table retrieval. */ public class QueryLargeTableResults extends GenericModel { protected Boolean enabled; protected Long count; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean enabled; private Long count; + /** + * Instantiates a new Builder from an existing QueryLargeTableResults instance. + * + * @param queryLargeTableResults the instance to initialize the Builder with + */ private Builder(QueryLargeTableResults queryLargeTableResults) { this.enabled = queryLargeTableResults.enabled; this.count = queryLargeTableResults.count; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a QueryLargeTableResults. * - * @return the queryLargeTableResults + * @return the new QueryLargeTableResults instance */ public QueryLargeTableResults build() { return new QueryLargeTableResults(this); @@ -72,6 +71,8 @@ public Builder count(long count) { } } + protected QueryLargeTableResults() {} + protected QueryLargeTableResults(Builder builder) { enabled = builder.enabled; count = builder.count; @@ -89,7 +90,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - * Whether to enable table retrieval. + *

Whether to enable table retrieval. * * @return the enabled */ @@ -100,7 +101,7 @@ public Boolean enabled() { /** * Gets the count. * - * Maximum number of tables to return. + *

Maximum number of tables to return. * * @return the count */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java deleted file mode 100644 index 118c4640be5..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.google.gson.annotations.SerializedName; - -/** - * A restriction that alter the document set used for sub aggregations it precedes to nested documents found in the - * field specified. - */ -public class QueryNestedAggregation extends QueryAggregation { - - protected String path; - @SerializedName("matching_results") - protected Long matchingResults; - protected List aggregations; - - /** - * Gets the path. - * - * The path to the document field to scope sub aggregations to. - * - * @return the path - */ - public String getPath() { - return path; - } - - /** - * Gets the matchingResults. - * - * Number of nested documents found in the specified field. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the aggregations. - * - * An array of sub aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java index 55771a08d37..e4072f6688e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,13 +10,12 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The queryNotices options. - */ +/** The queryNotices options. */ public class QueryNoticesOptions extends GenericModel { protected String projectId; @@ -26,9 +25,7 @@ public class QueryNoticesOptions extends GenericModel { protected Long count; protected Long offset; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String filter; @@ -37,6 +34,11 @@ public static class Builder { private Long count; private Long offset; + /** + * Instantiates a new Builder from an existing QueryNoticesOptions instance. + * + * @param queryNoticesOptions the instance to initialize the Builder with + */ private Builder(QueryNoticesOptions queryNoticesOptions) { this.projectId = queryNoticesOptions.projectId; this.filter = queryNoticesOptions.filter; @@ -46,11 +48,8 @@ private Builder(QueryNoticesOptions queryNoticesOptions) { this.offset = queryNoticesOptions.offset; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -64,7 +63,7 @@ public Builder(String projectId) { /** * Builds a QueryNoticesOptions. * - * @return the queryNoticesOptions + * @return the new QueryNoticesOptions instance */ public QueryNoticesOptions build() { return new QueryNoticesOptions(this); @@ -137,9 +136,10 @@ public Builder offset(long offset) { } } + protected QueryNoticesOptions() {} + protected QueryNoticesOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; filter = builder.filter; query = builder.query; @@ -160,7 +160,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -171,8 +172,11 @@ public String projectId() { /** * Gets the filter. * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. + *

Searches for documents that match the Discovery Query Language criteria that is specified as + * input. Filter calls are cached and are faster than query calls because the results are not + * ordered by relevance. When used with the `aggregation`, `query`, or `natural_language_query` + * parameters, the `filter` parameter runs first. This parameter is useful for limiting results to + * those that contain specific metadata values. * * @return the filter */ @@ -183,8 +187,10 @@ public String filter() { /** * Gets the query. * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. + *

A query search that is written in the Discovery Query Language and returns all matching + * documents in your data set with full enrichments and full text, and with the most relevant + * documents listed first. You can use this parameter or the **natural_language_query** parameter + * to specify the query input, but not both. * * @return the query */ @@ -195,8 +201,10 @@ public String query() { /** * Gets the naturalLanguageQuery. * - * A natural language query that returns relevant documents by utilizing training data and natural language - * understanding. + *

A natural language query that returns relevant documents by using natural language + * understanding. You can use this parameter or the **query** parameter to specify the query + * input, but not both. To filter the results based on criteria you specify, include the + * **filter** parameter in the request. * * @return the naturalLanguageQuery */ @@ -207,8 +215,8 @@ public String naturalLanguageQuery() { /** * Gets the count. * - * Number of results to return. The maximum for the **count** and **offset** values together in any one query is - * **10000**. + *

Number of results to return. The maximum for the **count** and **offset** values together in + * any one query is **10,000**. * * @return the count */ @@ -219,9 +227,9 @@ public Long count() { /** * Gets the offset. * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. The maximum for the **count** and **offset** values - * together in any one query is **10000**. + *

The number of query results to skip at the beginning. For example, if the total number of + * results that are returned is 10 and the offset is 8, it returns the last two results. The + * maximum for the **count** and **offset** values together in any one query is **10000**. * * @return the offset */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java index 957c5018008..874b6aabc87 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,26 +10,27 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Object containing notice query results. - */ +/** Object that contains notice query results. */ public class QueryNoticesResponse extends GenericModel { @SerializedName("matching_results") protected Long matchingResults; + protected List notices; + protected QueryNoticesResponse() {} + /** * Gets the matchingResults. * - * The number of matching results. + *

The number of matching results. * * @return the matchingResults */ @@ -40,7 +41,7 @@ public Long getMatchingResults() { /** * Gets the notices. * - * Array of document results that match the query. + *

Array of document results that match the query. * * @return the notices */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResult.java deleted file mode 100644 index 9ae8cf02ed9..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResult.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * (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 java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; - -/** - * Result document for the specified query. - */ -public class QueryNoticesResult extends DynamicModel { - /** - * The type of the original source file. - */ - public interface FileType { - /** pdf. */ - String PDF = "pdf"; - /** html. */ - String HTML = "html"; - /** word. */ - String WORD = "word"; - /** json. */ - String JSON = "json"; - } - - @SerializedName("document_id") - private String documentId; - @SerializedName("metadata") - private Map metadata; - @SerializedName("result_metadata") - private QueryResultMetadata resultMetadata; - @SerializedName("document_passages") - private List documentPassages; - @SerializedName("code") - private Long code; - @SerializedName("filename") - private String filename; - @SerializedName("file_type") - private String fileType; - @SerializedName("sha1") - private String sha1; - @SerializedName("notices") - private List notices; - - public QueryNoticesResult() { - super(new TypeToken() { - }); - } - - /** - * Gets the documentId. - * - * The unique identifier of the document. - * - * @return the documentId - */ - public String getDocumentId() { - return this.documentId; - } - - /** - * Gets the metadata. - * - * Metadata of the document. - * - * @return the metadata - */ - public Map getMetadata() { - return this.metadata; - } - - /** - * Gets the resultMetadata. - * - * Metadata of a query result. - * - * @return the resultMetadata - */ - public QueryResultMetadata getResultMetadata() { - return this.resultMetadata; - } - - /** - * Gets the documentPassages. - * - * Passages returned by Discovery. - * - * @return the documentPassages - */ - public List getDocumentPassages() { - return this.documentPassages; - } - - /** - * Gets the code. - * - * The internal status code returned by the ingestion subsystem indicating the overall result of ingesting the source - * document. - * - * @return the code - */ - public Long getCode() { - return this.code; - } - - /** - * Gets the filename. - * - * Name of the original source file (if available). - * - * @return the filename - */ - public String getFilename() { - return this.filename; - } - - /** - * Gets the fileType. - * - * The type of the original source file. - * - * @return the fileType - */ - public String getFileType() { - return this.fileType; - } - - /** - * Gets the sha1. - * - * The SHA-1 hash of the original source file (formatted as a hexadecimal string). - * - * @return the sha1 - */ - public String getSha1() { - return this.sha1; - } - - /** - * Gets the notices. - * - * Array of notices for the document. - * - * @return the notices - */ - public List getNotices() { - return this.notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java index eebd9685900..03c409deb13 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The query options. - */ +/** The query options. */ public class QueryOptions extends GenericModel { protected String projectId; @@ -37,10 +35,9 @@ public class QueryOptions extends GenericModel { protected QueryLargeTableResults tableResults; protected QueryLargeSuggestedRefinements suggestedRefinements; protected QueryLargePassages passages; + protected QueryLargeSimilar similar; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private List collectionIds; @@ -57,7 +54,13 @@ public static class Builder { private QueryLargeTableResults tableResults; private QueryLargeSuggestedRefinements suggestedRefinements; private QueryLargePassages passages; + private QueryLargeSimilar similar; + /** + * Instantiates a new Builder from an existing QueryOptions instance. + * + * @param queryOptions the instance to initialize the Builder with + */ private Builder(QueryOptions queryOptions) { this.projectId = queryOptions.projectId; this.collectionIds = queryOptions.collectionIds; @@ -74,13 +77,11 @@ private Builder(QueryOptions queryOptions) { this.tableResults = queryOptions.tableResults; this.suggestedRefinements = queryOptions.suggestedRefinements; this.passages = queryOptions.passages; + this.similar = queryOptions.similar; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -94,21 +95,20 @@ public Builder(String projectId) { /** * Builds a QueryOptions. * - * @return the queryOptions + * @return the new QueryOptions instance */ public QueryOptions build() { return new QueryOptions(this); } /** - * Adds an collectionIds to collectionIds. + * Adds a new element to collectionIds. * - * @param collectionIds the new collectionIds + * @param collectionIds the new element to be added * @return the QueryOptions builder */ public Builder addCollectionIds(String collectionIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, - "collectionIds cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, "collectionIds cannot be null"); if (this.collectionIds == null) { this.collectionIds = new ArrayList(); } @@ -117,14 +117,13 @@ public Builder addCollectionIds(String collectionIds) { } /** - * Adds an returnField to xReturn. + * Adds a new element to xReturn. * - * @param returnField the new returnField + * @param returnField the new element to be added * @return the QueryOptions builder */ public Builder addReturnField(String returnField) { - com.ibm.cloud.sdk.core.util.Validator.notNull(returnField, - "returnField cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(returnField, "returnField cannot be null"); if (this.xReturn == null) { this.xReturn = new ArrayList(); } @@ -144,8 +143,7 @@ public Builder projectId(String projectId) { } /** - * Set the collectionIds. - * Existing collectionIds will be replaced. + * Set the collectionIds. Existing collectionIds will be replaced. * * @param collectionIds the collectionIds * @return the QueryOptions builder @@ -211,8 +209,7 @@ public Builder count(long count) { } /** - * Set the xReturn. - * Existing xReturn will be replaced. + * Set the xReturn. Existing xReturn will be replaced. * * @param xReturn the xReturn * @return the QueryOptions builder @@ -298,11 +295,23 @@ public Builder passages(QueryLargePassages passages) { this.passages = passages; return this; } + + /** + * Set the similar. + * + * @param similar the similar + * @return the QueryOptions builder + */ + public Builder similar(QueryLargeSimilar similar) { + this.similar = similar; + return this; + } } + protected QueryOptions() {} + protected QueryOptions(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.projectId, "projectId cannot be empty"); projectId = builder.projectId; collectionIds = builder.collectionIds; filter = builder.filter; @@ -318,6 +327,7 @@ protected QueryOptions(Builder builder) { tableResults = builder.tableResults; suggestedRefinements = builder.suggestedRefinements; passages = builder.passages; + similar = builder.similar; } /** @@ -332,7 +342,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -343,7 +354,7 @@ public String projectId() { /** * Gets the collectionIds. * - * A comma-separated list of collection IDs to be queried against. + *

A comma-separated list of collection IDs to be queried against. * * @return the collectionIds */ @@ -354,8 +365,11 @@ public List collectionIds() { /** * Gets the filter. * - * A cacheable query that excludes documents that don't mention the query content. Filter searches are better for - * metadata-type searches and for assessing the concepts in the data set. + *

Searches for documents that match the Discovery Query Language criteria that is specified as + * input. Filter calls are cached and are faster than query calls because the results are not + * ordered by relevance. When used with the **aggregation**, **query**, or + * **natural_language_query** parameters, the **filter** parameter runs first. This parameter is + * useful for limiting results to those that contain specific metadata values. * * @return the filter */ @@ -366,8 +380,11 @@ public String filter() { /** * Gets the query. * - * A query search returns all documents in your data set with full enrichments and full text, but with the most - * relevant documents listed first. Use a query search when you want to find the most relevant search results. + *

A query search that is written in the Discovery Query Language and returns all matching + * documents in your data set with full enrichments and full text, and with the most relevant + * documents listed first. Use a query search when you want to find the most relevant search + * results. You can use this parameter or the **natural_language_query** parameter to specify the + * query input, but not both. * * @return the query */ @@ -378,8 +395,10 @@ public String query() { /** * Gets the naturalLanguageQuery. * - * A natural language query that returns relevant documents by utilizing training data and natural language - * understanding. + *

A natural language query that returns relevant documents by using training data and natural + * language understanding. You can use this parameter or the **query** parameter to specify the + * query input, but not both. To filter the results based on criteria you specify, include the + * **filter** parameter in the request. * * @return the naturalLanguageQuery */ @@ -390,8 +409,10 @@ public String naturalLanguageQuery() { /** * Gets the aggregation. * - * An aggregation search that returns an exact answer by combining query search with filters. Useful for applications - * to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference. + *

An aggregation search that returns an exact answer by combining query search with filters. + * Useful for applications to build lists, tables, and time series. For more information about the + * supported types of aggregations, see the [Discovery + * documentation](/docs/discovery-data?topic=discovery-data-query-aggregations). * * @return the aggregation */ @@ -402,7 +423,7 @@ public String aggregation() { /** * Gets the count. * - * Number of results to return. + *

Number of results to return. * * @return the count */ @@ -413,8 +434,9 @@ public Long count() { /** * Gets the xReturn. * - * A list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level - * fields are returned. + *

A list of the fields in the document hierarchy to return. You can specify both root-level + * (`text`) and nested (`extracted_metadata.filename`) fields. If this parameter is an empty list, + * then all fields are returned. * * @return the xReturn */ @@ -425,8 +447,15 @@ public List xReturn() { /** * Gets the offset. * - * The number of query results to skip at the beginning. For example, if the total number of results that are returned - * is 10 and the offset is 8, it returns the last two results. + *

The number of query results to skip at the beginning. Consider that the `count` is set to 10 + * (the default value) and the total number of results that are returned is 100. In this case, the + * following examples show the returned results for different `offset` values: + * + *

* If `offset` is set to 95, it returns the last 5 results. + * + *

* If `offset` is set to 10, it returns the second batch of 10 results. + * + *

* If `offset` is set to 100 or more, it returns empty results. * * @return the offset */ @@ -437,9 +466,9 @@ public Long offset() { /** * Gets the sort. * - * A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by - * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no - * prefix is specified. This parameter cannot be used in the same query as the **bias** parameter. + *

A comma-separated list of fields in the document to sort on. You can optionally specify a + * sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending + * is the default sort direction if no prefix is specified. * * @return the sort */ @@ -450,8 +479,10 @@ public String sort() { /** * Gets the highlight. * - * When `true`, a highlight field is returned for each result which contains the fields which match the query with - * `` tags around the matching query terms. + *

When `true`, a highlight field is returned for each result that contains fields that match + * the query. The matching query terms are emphasized with surrounding `<em></em>` + * tags. This parameter is ignored if **passages.enabled** and **passages.per_document** are + * `true`, in which case passages are returned for each document instead of highlights. * * @return the highlight */ @@ -462,8 +493,9 @@ public Boolean highlight() { /** * Gets the spellingSuggestions. * - * When `true` and the **natural_language_query** parameter is used, the **natural_language_query** parameter is spell - * checked. The most likely correction is returned in the **suggested_query** field of the response (if one exists). + *

When `true` and the **natural_language_query** parameter is used, the + * **natural_language_query** parameter is spell checked. The most likely correction is returned + * in the **suggested_query** field of the response (if one exists). * * @return the spellingSuggestions */ @@ -474,7 +506,7 @@ public Boolean spellingSuggestions() { /** * Gets the tableResults. * - * Configuration for table retrieval. + *

Configuration for table retrieval. * * @return the tableResults */ @@ -485,7 +517,10 @@ public QueryLargeTableResults tableResults() { /** * Gets the suggestedRefinements. * - * Configuration for suggested refinements. + *

Configuration for suggested refinements. + * + *

**Note**: The **suggested_refinements** parameter that identified dynamic facets from the + * data is deprecated. * * @return the suggestedRefinements */ @@ -496,11 +531,24 @@ public QueryLargeSuggestedRefinements suggestedRefinements() { /** * Gets the passages. * - * Configuration for passage retrieval. + *

Configuration for passage retrieval. * * @return the passages */ public QueryLargePassages passages() { return passages; } + + /** + * Gets the similar. + * + *

Finds results from documents that are similar to documents of interest. Use this parameter + * to add a *More like these* function to your search. You can include this parameter with or + * without a **query**, **filter** or **natural_language_query** parameter. + * + * @return the similar + */ + public QueryLargeSimilar similar() { + return similar; + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryPairAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryPairAggregationResult.java new file mode 100644 index 00000000000..d3da1992d6f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryPairAggregationResult.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** Result for the `pair` aggregation. */ +public class QueryPairAggregationResult extends GenericModel { + + protected List> aggregations; + + protected QueryPairAggregationResult() {} + + /** + * Gets the aggregations. + * + *

Array of subaggregations of type `term`, `group_by`, `histogram`, or `timeslice`. Each + * element of the matrix that is returned contains a **relevancy** value that is calculated from + * the combination of each value from the first and second aggregations. + * + * @return the aggregations + */ + public List> getAggregations() { + return aggregations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java index 0b731046152..d3840a7058c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,35 +10,43 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * A response containing the documents and aggregations for the query. - */ +/** A response that contains the documents and aggregations for the query. */ public class QueryResponse extends GenericModel { @SerializedName("matching_results") protected Long matchingResults; + protected List results; protected List aggregations; + @SerializedName("retrieval_details") protected RetrievalDetails retrievalDetails; + @SerializedName("suggested_query") protected String suggestedQuery; + @SerializedName("suggested_refinements") protected List suggestedRefinements; + @SerializedName("table_results") protected List tableResults; + protected List passages; + + protected QueryResponse() {} + /** * Gets the matchingResults. * - * The number of matching results for the query. + *

The number of matching results for the query. Results that match due to a curation only are + * not counted in the total. * * @return the matchingResults */ @@ -49,7 +57,7 @@ public Long getMatchingResults() { /** * Gets the results. * - * Array of document results for the query. + *

Array of document results for the query. * * @return the results */ @@ -60,7 +68,7 @@ public List getResults() { /** * Gets the aggregations. * - * Array of aggregations for the query. + *

Array of aggregations for the query. * * @return the aggregations */ @@ -71,7 +79,7 @@ public List getAggregations() { /** * Gets the retrievalDetails. * - * An object contain retrieval type information. + *

An object contain retrieval type information. * * @return the retrievalDetails */ @@ -82,7 +90,7 @@ public RetrievalDetails getRetrievalDetails() { /** * Gets the suggestedQuery. * - * Suggested correction to the submitted **natural_language_query** value. + *

Suggested correction to the submitted **natural_language_query** value. * * @return the suggestedQuery */ @@ -93,10 +101,13 @@ public String getSuggestedQuery() { /** * Gets the suggestedRefinements. * - * Array of suggested refinements. + *

Array of suggested refinements. **Note**: The `suggested_refinements` parameter that + * identified dynamic facets from the data is deprecated. * * @return the suggestedRefinements + * @deprecated this method is deprecated and may be removed in a future release */ + @Deprecated public List getSuggestedRefinements() { return suggestedRefinements; } @@ -104,11 +115,23 @@ public List getSuggestedRefinements() { /** * Gets the tableResults. * - * Array of table results. + *

Array of table results. * * @return the tableResults */ public List getTableResults() { return tableResults; } + + /** + * Gets the passages. + * + *

Passages that best match the query from across all of the collections in the project. + * Returned if **passages.per_document** is `false`. + * + * @return the passages + */ + public List getPassages() { + return passages; + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java new file mode 100644 index 00000000000..bd8295bee9f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java @@ -0,0 +1,136 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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; +import java.util.List; + +/** A passage query response. */ +public class QueryResponsePassage extends GenericModel { + + @SerializedName("passage_text") + protected String passageText; + + @SerializedName("passage_score") + protected Double passageScore; + + @SerializedName("document_id") + protected String documentId; + + @SerializedName("collection_id") + protected String collectionId; + + @SerializedName("start_offset") + protected Long startOffset; + + @SerializedName("end_offset") + protected Long endOffset; + + protected String field; + protected List answers; + + protected QueryResponsePassage() {} + + /** + * Gets the passageText. + * + *

The content of the extracted passage. + * + * @return the passageText + */ + public String getPassageText() { + return passageText; + } + + /** + * Gets the passageScore. + * + *

The confidence score of the passage's analysis. A higher score indicates greater confidence. + * The score is used to rank the passages from all documents and is returned only if + * **passages.per_document** is `false`. + * + * @return the passageScore + */ + public Double getPassageScore() { + return passageScore; + } + + /** + * Gets the documentId. + * + *

The unique identifier of the ingested document. + * + * @return the documentId + */ + public String getDocumentId() { + return documentId; + } + + /** + * Gets the collectionId. + * + *

The unique identifier of the collection. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * Gets the startOffset. + * + *

The position of the first character of the extracted passage in the originating field. + * + * @return the startOffset + */ + public Long getStartOffset() { + return startOffset; + } + + /** + * Gets the endOffset. + * + *

The position after the last character of the extracted passage in the originating field. + * + * @return the endOffset + */ + public Long getEndOffset() { + return endOffset; + } + + /** + * Gets the field. + * + *

The label of the field from which the passage has been extracted. + * + * @return the field + */ + public String getField() { + return field; + } + + /** + * Gets the answers. + * + *

An array of extracted answers to the specified query. Returned for natural language queries + * when **passages.per_document** is `false`. + * + * @return the answers + */ + public List getAnswers() { + return answers; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java index 6c546d68b55..a126a24114f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,38 +10,42 @@ * 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 java.util.Map; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.List; +import java.util.Map; /** * Result document for the specified query. + * + *

This type supports additional properties of type Object. The remaining key-value pairs. */ public class QueryResult extends DynamicModel { @SerializedName("document_id") protected String documentId; + @SerializedName("metadata") protected Map metadata; + @SerializedName("result_metadata") protected QueryResultMetadata resultMetadata; + @SerializedName("document_passages") protected List documentPassages; public QueryResult() { - super(new TypeToken() { - }); + super(new TypeToken() {}); } /** * Gets the documentId. * - * The unique identifier of the document. + *

The unique identifier of the document. * * @return the documentId */ @@ -52,7 +56,7 @@ public String getDocumentId() { /** * Gets the metadata. * - * Metadata of the document. + *

Metadata of the document. * * @return the metadata */ @@ -63,7 +67,7 @@ public Map getMetadata() { /** * Gets the resultMetadata. * - * Metadata of a query result. + *

Metadata of a query result. * * @return the resultMetadata */ @@ -74,7 +78,8 @@ public QueryResultMetadata getResultMetadata() { /** * Gets the documentPassages. * - * Passages returned by Discovery. + *

Passages from the document that best matches the query. Returned if + * **passages.per_document** is `true`. * * @return the documentPassages */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java index c0c994f3a87..b8225b35dd7 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,19 +10,16 @@ * 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; -/** - * Metadata of a query result. - */ +/** Metadata of a query result. */ public class QueryResultMetadata extends GenericModel { - /** - * The document retrieval source that produced this search result. - */ + /** The document retrieval source that produced this search result. */ public interface DocumentRetrievalSource { /** search. */ String SEARCH = "search"; @@ -32,14 +29,18 @@ public interface DocumentRetrievalSource { @SerializedName("document_retrieval_source") protected String documentRetrievalSource; + @SerializedName("collection_id") protected String collectionId; + protected Double confidence; + protected QueryResultMetadata() {} + /** * Gets the documentRetrievalSource. * - * The document retrieval source that produced this search result. + *

The document retrieval source that produced this search result. * * @return the documentRetrievalSource */ @@ -50,7 +51,7 @@ public String getDocumentRetrievalSource() { /** * Gets the collectionId. * - * The collection id associated with this training data set. + *

The collection id associated with this training data set. * * @return the collectionId */ @@ -61,10 +62,11 @@ public String getCollectionId() { /** * Gets the confidence. * - * The confidence score for the given result. Calculated based on how relevant the result is estimated to be. - * confidence can range from `0.0` to `1.0`. The higher the number, the more relevant the document. The `confidence` - * value for a result was calculated using the model specified in the `document_retrieval_strategy` field of the - * result set. This field is only returned if the **natural_language_query** parameter is specified in the query. + *

The confidence score for the given result. Calculated based on how relevant the result is + * estimated to be. The score can range from `0.0` to `1.0`. The higher the number, the more + * relevant the document. The `confidence` value for a result was calculated using the model + * specified in the `document_retrieval_strategy` field of the result set. This field is returned + * only if the **natural_language_query** parameter is specified in the query. * * @return the confidence */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java index ae275b74b29..9c9e82588b1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,28 +10,34 @@ * 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; +import java.util.List; -/** - * A passage query result. - */ +/** A passage query result. */ public class QueryResultPassage extends GenericModel { @SerializedName("passage_text") protected String passageText; + @SerializedName("start_offset") protected Long startOffset; + @SerializedName("end_offset") protected Long endOffset; + protected String field; + protected List answers; + + protected QueryResultPassage() {} /** * Gets the passageText. * - * The content of the extracted passage. + *

The content of the extracted passage. * * @return the passageText */ @@ -42,7 +48,7 @@ public String getPassageText() { /** * Gets the startOffset. * - * The position of the first character of the extracted passage in the originating field. + *

The position of the first character of the extracted passage in the originating field. * * @return the startOffset */ @@ -53,7 +59,7 @@ public Long getStartOffset() { /** * Gets the endOffset. * - * The position of the last character of the extracted passage in the originating field. + *

The position after the last character of the extracted passage in the originating field. * * @return the endOffset */ @@ -64,11 +70,23 @@ public Long getEndOffset() { /** * Gets the field. * - * The label of the field from which the passage has been extracted. + *

The label of the field from which the passage has been extracted. * * @return the field */ public String getField() { return field; } + + /** + * Gets the answers. + * + *

An arry of extracted answers to the specified query. Returned for natural language queries + * when **passages.per_document** is `true`. + * + * @return the answers + */ + public List getAnswers() { + return answers; + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java index 5730de30c0a..78813097492 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,21 +10,25 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; /** - * A suggested additional query term or terms user to filter results. + * A suggested additional query term or terms user to filter results. **Note**: The + * `suggested_refinements` parameter is deprecated. */ public class QuerySuggestedRefinement extends GenericModel { protected String text; + protected QuerySuggestedRefinement() {} + /** * Gets the text. * - * The text used to filter. + *

The text used to filter. * * @return the text */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java index f41f0491822..6f79b5367cd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,32 +10,38 @@ * 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 tables whose content or context match a search query. - */ +/** A tables whose content or context match a search query. */ public class QueryTableResult extends GenericModel { @SerializedName("table_id") protected String tableId; + @SerializedName("source_document_id") protected String sourceDocumentId; + @SerializedName("collection_id") protected String collectionId; + @SerializedName("table_html") protected String tableHtml; + @SerializedName("table_html_offset") protected Long tableHtmlOffset; + protected TableResultTable table; + protected QueryTableResult() {} + /** * Gets the tableId. * - * The identifier for the retrieved table. + *

The identifier for the retrieved table. * * @return the tableId */ @@ -46,7 +52,7 @@ public String getTableId() { /** * Gets the sourceDocumentId. * - * The identifier of the document the table was retrieved from. + *

The identifier of the document the table was retrieved from. * * @return the sourceDocumentId */ @@ -57,7 +63,7 @@ public String getSourceDocumentId() { /** * Gets the collectionId. * - * The identifier of the collection the table was retrieved from. + *

The identifier of the collection the table was retrieved from. * * @return the collectionId */ @@ -68,7 +74,7 @@ public String getCollectionId() { /** * Gets the tableHtml. * - * HTML snippet of the table info. + *

HTML snippet of the table info. * * @return the tableHtml */ @@ -79,7 +85,7 @@ public String getTableHtml() { /** * Gets the tableHtmlOffset. * - * The offset of the table html snippet in the original document html. + *

The offset of the table html snippet in the original document html. * * @return the tableHtmlOffset */ @@ -90,7 +96,7 @@ public Long getTableHtmlOffset() { /** * Gets the table. * - * Full table object retrieved from Table Understanding Enrichment. + *

Full table object retrieved from Table Understanding Enrichment. * * @return the table */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java deleted file mode 100644 index 97705de6595..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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; - -/** - * Returns the top values for the field specified. - */ -public class QueryTermAggregation extends QueryAggregation { - - protected String field; - protected Long count; - protected List results; - - /** - * Gets the field. - * - * The field in the document used to generate top values from. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the count. - * - * The number of top values returned. - * - * @return the count - */ - public Long getCount() { - return count; - } - - /** - * Gets the results. - * - * Array of top values for the field. - * - * @return the results - */ - public List getResults() { - return results; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java index c2671787013..3dc53751d36 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,27 +10,38 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; -/** - * Top value result for the term aggregation. - */ +/** Top value result for the `term` aggregation. */ public class QueryTermAggregationResult extends GenericModel { protected String key; + @SerializedName("matching_results") protected Long matchingResults; - protected List aggregations; + + protected Double relevancy; + + @SerializedName("total_matching_documents") + protected Long totalMatchingDocuments; + + @SerializedName("estimated_matching_results") + protected Double estimatedMatchingResults; + + protected List> aggregations; + + protected QueryTermAggregationResult() {} /** * Gets the key. * - * Value of the field with a non-zero frequency in the document set. + *

Value of the field with a nonzero frequency in the document set. * * @return the key */ @@ -41,7 +52,7 @@ public String getKey() { /** * Gets the matchingResults. * - * Number of documents containing the 'key'. + *

Number of documents that contain the 'key'. * * @return the matchingResults */ @@ -49,14 +60,51 @@ public Long getMatchingResults() { return matchingResults; } + /** + * Gets the relevancy. + * + *

The relevancy score for this result. Returned only if `relevancy:true` is specified in the + * request. + * + * @return the relevancy + */ + public Double getRelevancy() { + return relevancy; + } + + /** + * Gets the totalMatchingDocuments. + * + *

Number of documents in the collection that contain the term in the specified field. Returned + * only when `relevancy:true` is specified in the request. + * + * @return the totalMatchingDocuments + */ + public Long getTotalMatchingDocuments() { + return totalMatchingDocuments; + } + + /** + * Gets the estimatedMatchingResults. + * + *

Number of documents that are estimated to match the query and also meet the condition. + * Returned only when `relevancy:true` is specified in the request. + * + * @return the estimatedMatchingResults + */ + public Double getEstimatedMatchingResults() { + return estimatedMatchingResults; + } + /** * Gets the aggregations. * - * An array of sub aggregations. + *

An array of subaggregations. Returned only when this aggregation is combined with other + * aggregations in the request or is returned as a subaggregation. * * @return the aggregations */ - public List getAggregations() { + public List> getAggregations() { return aggregations; } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java deleted file mode 100644 index df4f5dbb566..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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; - -/** - * A specialized histogram aggregation that uses dates to create interval segments. - */ -public class QueryTimesliceAggregation extends QueryAggregation { - - protected String field; - protected String interval; - protected List results; - - /** - * Gets the field. - * - * The date field name used to create the timeslice. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the interval. - * - * The date interval value. Valid values are seconds, minutes, hours, days, weeks, and years. - * - * @return the interval - */ - public String getInterval() { - return interval; - } - - /** - * Gets the results. - * - * Array of aggregation results. - * - * @return the results - */ - public List getResults() { - return results; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java index a3e8df15adf..a35b541d1f1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,29 +10,33 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; -/** - * A timeslice interval segment. - */ +/** A timeslice interval segment. */ public class QueryTimesliceAggregationResult extends GenericModel { @SerializedName("key_as_string") protected String keyAsString; + protected Long key; + @SerializedName("matching_results") protected Long matchingResults; - protected List aggregations; + + protected List> aggregations; + + protected QueryTimesliceAggregationResult() {} /** * Gets the keyAsString. * - * String date value of the upper bound for the timeslice interval in ISO-8601 format. + *

String date value of the upper bound for the timeslice interval in ISO-8601 format. * * @return the keyAsString */ @@ -43,7 +47,8 @@ public String getKeyAsString() { /** * Gets the key. * - * Numeric date value of the upper bound for the timeslice interval in UNIX milliseconds since epoch. + *

Numeric date value of the upper bound for the timeslice interval in UNIX milliseconds since + * epoch. * * @return the key */ @@ -54,7 +59,7 @@ public Long getKey() { /** * Gets the matchingResults. * - * Number of documents with the specified key as the upper bound. + *

Number of documents with the specified key as the upper bound. * * @return the matchingResults */ @@ -65,11 +70,12 @@ public Long getMatchingResults() { /** * Gets the aggregations. * - * An array of sub aggregations. + *

An array of subaggregations. Returned only when this aggregation is returned as a + * subaggregation. * * @return the aggregations */ - public List getAggregations() { + public List> getAggregations() { return aggregations; } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java deleted file mode 100644 index 491fd80aa55..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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; - -/** - * Returns the top documents ranked by the score of the query. - */ -public class QueryTopHitsAggregation extends QueryAggregation { - - protected Long size; - protected QueryTopHitsAggregationResult hits; - - /** - * Gets the size. - * - * The number of documents to return. - * - * @return the size - */ - public Long getSize() { - return size; - } - - /** - * Gets the hits. - * - * @return the hits - */ - public QueryTopHitsAggregationResult getHits() { - return hits; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java index 4ae64c9043a..3b0a65566d1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,27 +10,28 @@ * 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 java.util.Map; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; -/** - * A query response containing the matching documents for the preceding aggregations. - */ +/** A query response that contains the matching documents for the preceding aggregations. */ public class QueryTopHitsAggregationResult extends GenericModel { @SerializedName("matching_results") protected Long matchingResults; + protected List> hits; + protected QueryTopHitsAggregationResult() {} + /** * Gets the matchingResults. * - * Number of matching results. + *

Number of matching results. * * @return the matchingResults */ @@ -41,7 +42,7 @@ public Long getMatchingResults() { /** * Gets the hits. * - * An array of the document results. + *

An array of the document results in an ordered list. * * @return the hits */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopicAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopicAggregationResult.java new file mode 100644 index 00000000000..35c4b4cdcd2 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopicAggregationResult.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** Result for the `topic` aggregation. */ +public class QueryTopicAggregationResult extends GenericModel { + + protected List> aggregations; + + protected QueryTopicAggregationResult() {} + + /** + * Gets the aggregations. + * + *

Array of subaggregations of type `term` or `group_by` and `timeslice`. Each element of the + * matrix that is returned contains a **topic_indicator** that is calculated from the combination + * of each aggregation value and segment of time. + * + * @return the aggregations + */ + public List> getAggregations() { + return aggregations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTrendAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTrendAggregationResult.java new file mode 100644 index 00000000000..ae89e655a30 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTrendAggregationResult.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** Result for the `trend` aggregation. */ +public class QueryTrendAggregationResult extends GenericModel { + + protected List> aggregations; + + protected QueryTrendAggregationResult() {} + + /** + * Gets the aggregations. + * + *

Array of subaggregations of type `term` or `group_by` and `timeslice`. Each element of the + * matrix that is returned contains a **trend_indicator** that is calculated from the combination + * of each aggregation value and segment of time. + * + * @return the aggregations + */ + public List> getAggregations() { + return aggregations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ResultPassageAnswer.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ResultPassageAnswer.java new file mode 100644 index 00000000000..481fbdf12b5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ResultPassageAnswer.java @@ -0,0 +1,78 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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; + +/** Object that contains a potential answer to the specified query. */ +public class ResultPassageAnswer extends GenericModel { + + @SerializedName("answer_text") + protected String answerText; + + @SerializedName("start_offset") + protected Long startOffset; + + @SerializedName("end_offset") + protected Long endOffset; + + protected Double confidence; + + protected ResultPassageAnswer() {} + + /** + * Gets the answerText. + * + *

Answer text for the specified query as identified by Discovery. + * + * @return the answerText + */ + public String getAnswerText() { + return answerText; + } + + /** + * Gets the startOffset. + * + *

The position of the first character of the extracted answer in the originating field. + * + * @return the startOffset + */ + public Long getStartOffset() { + return startOffset; + } + + /** + * Gets the endOffset. + * + *

The position after the last character of the extracted answer in the originating field. + * + * @return the endOffset + */ + public Long getEndOffset() { + return endOffset; + } + + /** + * Gets the confidence. + * + *

An estimate of the probability that the answer is relevant. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java index 9fcd1fefaac..cbb2dbf140d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,22 +10,21 @@ * 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; -/** - * An object contain retrieval type information. - */ +/** An object contain retrieval type information. */ public class RetrievalDetails extends GenericModel { /** - * Identifies the document retrieval strategy used for this query. `relevancy_training` indicates that the results - * were returned using a relevancy trained model. + * Identifies the document retrieval strategy used for this query. `relevancy_training` indicates + * that the results were returned using a relevancy trained model. * - * **Note**: In the event of trained collections being queried, but the trained model is not used to return results, - * the **document_retrieval_strategy** will be listed as `untrained`. + *

**Note**: In the event of trained collections being queried, but the trained model is not + * used to return results, the **document_retrieval_strategy** is listed as `untrained`. */ public interface DocumentRetrievalStrategy { /** untrained. */ @@ -37,14 +36,16 @@ public interface DocumentRetrievalStrategy { @SerializedName("document_retrieval_strategy") protected String documentRetrievalStrategy; + protected RetrievalDetails() {} + /** * Gets the documentRetrievalStrategy. * - * Identifies the document retrieval strategy used for this query. `relevancy_training` indicates that the results - * were returned using a relevancy trained model. + *

Identifies the document retrieval strategy used for this query. `relevancy_training` + * indicates that the results were returned using a relevancy trained model. * - * **Note**: In the event of trained collections being queried, but the trained model is not used to return results, - * the **document_retrieval_strategy** will be listed as `untrained`. + *

**Note**: In the event of trained collections being queried, but the trained model is not + * used to return results, the **document_retrieval_strategy** is listed as `untrained`. * * @return the documentRetrievalStrategy */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/StopWordList.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/StopWordList.java new file mode 100644 index 00000000000..a42dc874f63 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/StopWordList.java @@ -0,0 +1,112 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** List of words to filter out of text that is submitted in queries. */ +public class StopWordList extends GenericModel { + + protected List stopwords; + + /** Builder. */ + public static class Builder { + private List stopwords; + + /** + * Instantiates a new Builder from an existing StopWordList instance. + * + * @param stopWordList the instance to initialize the Builder with + */ + private Builder(StopWordList stopWordList) { + this.stopwords = stopWordList.stopwords; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param stopwords the stopwords + */ + public Builder(List stopwords) { + this.stopwords = stopwords; + } + + /** + * Builds a StopWordList. + * + * @return the new StopWordList instance + */ + public StopWordList build() { + return new StopWordList(this); + } + + /** + * Adds a new element to stopwords. + * + * @param stopwords the new element to be added + * @return the StopWordList builder + */ + public Builder addStopwords(String stopwords) { + com.ibm.cloud.sdk.core.util.Validator.notNull(stopwords, "stopwords cannot be null"); + if (this.stopwords == null) { + this.stopwords = new ArrayList(); + } + this.stopwords.add(stopwords); + return this; + } + + /** + * Set the stopwords. Existing stopwords will be replaced. + * + * @param stopwords the stopwords + * @return the StopWordList builder + */ + public Builder stopwords(List stopwords) { + this.stopwords = stopwords; + return this; + } + } + + protected StopWordList() {} + + protected StopWordList(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.stopwords, "stopwords cannot be null"); + stopwords = builder.stopwords; + } + + /** + * New builder. + * + * @return a StopWordList builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the stopwords. + * + *

List of stop words. + * + * @return the stopwords + */ + public List stopwords() { + return stopwords; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java index 38bba5e2820..2274a56e4df 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,48 +10,60 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Cells that are not table header, column header, or row header cells. - */ +/** Cells that are not table header, column header, or row header cells. */ public class TableBodyCells extends GenericModel { @SerializedName("cell_id") protected String cellId; + protected TableElementLocation location; protected String text; + @SerializedName("row_index_begin") protected Long rowIndexBegin; + @SerializedName("row_index_end") protected Long rowIndexEnd; + @SerializedName("column_index_begin") protected Long columnIndexBegin; + @SerializedName("column_index_end") protected Long columnIndexEnd; + @SerializedName("row_header_ids") - protected List rowHeaderIds; + protected List rowHeaderIds; + @SerializedName("row_header_texts") - protected List rowHeaderTexts; + protected List rowHeaderTexts; + @SerializedName("row_header_texts_normalized") - protected List rowHeaderTextsNormalized; + protected List rowHeaderTextsNormalized; + @SerializedName("column_header_ids") - protected List columnHeaderIds; + protected List columnHeaderIds; + @SerializedName("column_header_texts") - protected List columnHeaderTexts; + protected List columnHeaderTexts; + @SerializedName("column_header_texts_normalized") - protected List columnHeaderTextsNormalized; + protected List columnHeaderTextsNormalized; + protected List attributes; + protected TableBodyCells() {} + /** * Gets the cellId. * - * The unique ID of the cell in the current table. + *

The unique ID of the cell in the current table. * * @return the cellId */ @@ -62,8 +74,8 @@ public String getCellId() { /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ @@ -74,7 +86,7 @@ public TableElementLocation getLocation() { /** * Gets the text. * - * The textual contents of this cell from the input document without associated markup content. + *

The textual contents of this cell from the input document without associated markup content. * * @return the text */ @@ -85,7 +97,7 @@ public String getText() { /** * Gets the rowIndexBegin. * - * The `begin` index of this cell's `row` location in the current table. + *

The `begin` index of this cell's `row` location in the current table. * * @return the rowIndexBegin */ @@ -96,7 +108,7 @@ public Long getRowIndexBegin() { /** * Gets the rowIndexEnd. * - * The `end` index of this cell's `row` location in the current table. + *

The `end` index of this cell's `row` location in the current table. * * @return the rowIndexEnd */ @@ -107,7 +119,7 @@ public Long getRowIndexEnd() { /** * Gets the columnIndexBegin. * - * The `begin` index of this cell's `column` location in the current table. + *

The `begin` index of this cell's `column` location in the current table. * * @return the columnIndexBegin */ @@ -118,7 +130,7 @@ public Long getColumnIndexBegin() { /** * Gets the columnIndexEnd. * - * The `end` index of this cell's `column` location in the current table. + *

The `end` index of this cell's `column` location in the current table. * * @return the columnIndexEnd */ @@ -129,73 +141,75 @@ public Long getColumnIndexEnd() { /** * Gets the rowHeaderIds. * - * A list of table row header ids. + *

A list of ID values that represent the table row headers that are associated with this body + * cell. * * @return the rowHeaderIds */ - public List getRowHeaderIds() { + public List getRowHeaderIds() { return rowHeaderIds; } /** * Gets the rowHeaderTexts. * - * A list of table row header texts. + *

A list of row header values that are associated with this body cell. * * @return the rowHeaderTexts */ - public List getRowHeaderTexts() { + public List getRowHeaderTexts() { return rowHeaderTexts; } /** * Gets the rowHeaderTextsNormalized. * - * A list of table row header texts normalized. + *

A list of normalized row header values that are associated with this body cell. * * @return the rowHeaderTextsNormalized */ - public List getRowHeaderTextsNormalized() { + public List getRowHeaderTextsNormalized() { return rowHeaderTextsNormalized; } /** * Gets the columnHeaderIds. * - * A list of table column header ids. + *

A list of ID values that represent the column headers that are associated with this body + * cell. * * @return the columnHeaderIds */ - public List getColumnHeaderIds() { + public List getColumnHeaderIds() { return columnHeaderIds; } /** * Gets the columnHeaderTexts. * - * A list of table column header texts. + *

A list of column header values that are associated with this body cell. * * @return the columnHeaderTexts */ - public List getColumnHeaderTexts() { + public List getColumnHeaderTexts() { return columnHeaderTexts; } /** * Gets the columnHeaderTextsNormalized. * - * A list of table column header texts normalized. + *

A list of normalized column header values that are associated with this body cell. * * @return the columnHeaderTextsNormalized */ - public List getColumnHeaderTextsNormalized() { + public List getColumnHeaderTextsNormalized() { return columnHeaderTextsNormalized; } /** * Gets the attributes. * - * A list of document attributes. + *

A list of document attributes. * * @return the attributes */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java index dbb5a9037cd..999e4244d5f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,25 +10,27 @@ * 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 key in a key-value pair. - */ +/** A key in a key-value pair. */ public class TableCellKey extends GenericModel { @SerializedName("cell_id") protected String cellId; + protected TableElementLocation location; protected String text; + protected TableCellKey() {} + /** * Gets the cellId. * - * The unique ID of the key in the table. + *

The unique ID of the key in the table. * * @return the cellId */ @@ -39,8 +41,8 @@ public String getCellId() { /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ @@ -51,7 +53,7 @@ public TableElementLocation getLocation() { /** * Gets the text. * - * The text content of the table cell without HTML markup. + *

The text content of the table cell without HTML markup. * * @return the text */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java index ad1b11837fa..7dabdd25825 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,25 +10,27 @@ * 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 value in a key-value pair. - */ +/** A value in a key-value pair. */ public class TableCellValues extends GenericModel { @SerializedName("cell_id") protected String cellId; + protected TableElementLocation location; protected String text; + protected TableCellValues() {} + /** * Gets the cellId. * - * The unique ID of the value in the table. + *

The unique ID of the value in the table. * * @return the cellId */ @@ -39,8 +41,8 @@ public String getCellId() { /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ @@ -51,7 +53,7 @@ public TableElementLocation getLocation() { /** * Gets the text. * - * The text content of the table cell without HTML markup. + *

The text content of the table cell without HTML markup. * * @return the text */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java index 95f426f5997..d8fa9c7c826 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,16 +15,19 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An array of values, each being the `id` value of a column header that is applicable to the current cell. + * An array of values, each being the `id` value of a column header that is applicable to the + * current cell. */ public class TableColumnHeaderIds extends GenericModel { protected String id; + protected TableColumnHeaderIds() {} + /** * Gets the id. * - * The `id` value of a column header. + *

The `id` value of a column header. * * @return the id */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java index 964945c6b2e..883d86955ba 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,16 +15,19 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An array of values, each being the `text` value of a column header that is applicable to the current cell. + * An array of values, each being the `text` value of a column header that is applicable to the + * current cell. */ public class TableColumnHeaderTexts extends GenericModel { protected String text; + protected TableColumnHeaderTexts() {} + /** * Gets the text. * - * The `text` value of a column header. + *

The `text` value of a column header. * * @return the text */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java index 15f1b061d25..0bcbfbb66fe 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -16,18 +16,20 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * If you provide customization input, the normalized version of the column header texts according to the customization; - * otherwise, the same value as `column_header_texts`. + * If you provide customization input, the normalized version of the column header texts according + * to the customization; otherwise, the same value as `column_header_texts`. */ public class TableColumnHeaderTextsNormalized extends GenericModel { @SerializedName("text_normalized") protected String textNormalized; + protected TableColumnHeaderTextsNormalized() {} + /** * Gets the textNormalized. * - * The normalized version of a column header text. + *

The normalized version of a column header text. * * @return the textNormalized */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java index b189817d3a3..2c48b7d3408 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,37 +10,45 @@ * 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.Map; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Column-level cells, each applicable as a header to other cells in the same column as itself, of the current table. + * Column-level cells, each applicable as a header to other cells in the same column as itself, of + * the current table. */ public class TableColumnHeaders extends GenericModel { @SerializedName("cell_id") protected String cellId; - protected Map location; + + protected TableElementLocation location; protected String text; + @SerializedName("text_normalized") protected String textNormalized; + @SerializedName("row_index_begin") protected Long rowIndexBegin; + @SerializedName("row_index_end") protected Long rowIndexEnd; + @SerializedName("column_index_begin") protected Long columnIndexBegin; + @SerializedName("column_index_end") protected Long columnIndexEnd; + protected TableColumnHeaders() {} + /** * Gets the cellId. * - * The unique ID of the cell in the current table. + *

The unique ID of the cell in the current table. * * @return the cellId */ @@ -51,19 +59,19 @@ public String getCellId() { /** * Gets the location. * - * The location of the column header cell in the current table as defined by its `begin` and `end` offsets, - * respectfully, in the input document. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ - public Map getLocation() { + public TableElementLocation getLocation() { return location; } /** * Gets the text. * - * The textual contents of this cell from the input document without associated markup content. + *

The textual contents of this cell from the input document without associated markup content. * * @return the text */ @@ -74,8 +82,7 @@ public String getText() { /** * Gets the textNormalized. * - * If you provide customization input, the normalized version of the cell text according to the customization; - * otherwise, the same value as `text`. + *

Normalized column header text. * * @return the textNormalized */ @@ -86,7 +93,7 @@ public String getTextNormalized() { /** * Gets the rowIndexBegin. * - * The `begin` index of this cell's `row` location in the current table. + *

The `begin` index of this cell's `row` location in the current table. * * @return the rowIndexBegin */ @@ -97,7 +104,7 @@ public Long getRowIndexBegin() { /** * Gets the rowIndexEnd. * - * The `end` index of this cell's `row` location in the current table. + *

The `end` index of this cell's `row` location in the current table. * * @return the rowIndexEnd */ @@ -108,7 +115,7 @@ public Long getRowIndexEnd() { /** * Gets the columnIndexBegin. * - * The `begin` index of this cell's `column` location in the current table. + *

The `begin` index of this cell's `column` location in the current table. * * @return the columnIndexBegin */ @@ -119,7 +126,7 @@ public Long getColumnIndexBegin() { /** * Gets the columnIndexEnd. * - * The `end` index of this cell's `column` location in the current table. + *

The `end` index of this cell's `column` location in the current table. * * @return the columnIndexEnd */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java index 557fdeb55c0..64dd5f2c678 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,26 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; /** - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + * The numeric location of the identified element in the document, represented with two integers + * labeled `begin` and `end`. */ public class TableElementLocation extends GenericModel { protected Long begin; protected Long end; + protected TableElementLocation() {} + /** * Gets the begin. * - * The element's `begin` index. + *

The element's `begin` index. * * @return the begin */ @@ -37,7 +40,7 @@ public Long getBegin() { /** * Gets the end. * - * The element's `end` index. + *

The element's `end` index. * * @return the end */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java index 944205ae54b..41f62d2fbab 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,39 @@ * 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.Map; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The contents of the current table's header. - */ +/** The contents of the current table's header. */ public class TableHeaders extends GenericModel { @SerializedName("cell_id") protected String cellId; - protected Map location; + + protected TableElementLocation location; protected String text; + @SerializedName("row_index_begin") protected Long rowIndexBegin; + @SerializedName("row_index_end") protected Long rowIndexEnd; + @SerializedName("column_index_begin") protected Long columnIndexBegin; + @SerializedName("column_index_end") protected Long columnIndexEnd; + protected TableHeaders() {} + /** * Gets the cellId. * - * The unique ID of the cell in the current table. + *

The unique ID of the cell in the current table. * * @return the cellId */ @@ -49,19 +53,19 @@ public String getCellId() { /** * Gets the location. * - * The location of the table header cell in the current table as defined by its `begin` and `end` offsets, - * respectfully, in the input document. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ - public Map getLocation() { + public TableElementLocation getLocation() { return location; } /** * Gets the text. * - * The textual contents of the cell from the input document without associated markup content. + *

The textual contents of the cell from the input document without associated markup content. * * @return the text */ @@ -72,7 +76,7 @@ public String getText() { /** * Gets the rowIndexBegin. * - * The `begin` index of this cell's `row` location in the current table. + *

The `begin` index of this cell's `row` location in the current table. * * @return the rowIndexBegin */ @@ -83,7 +87,7 @@ public Long getRowIndexBegin() { /** * Gets the rowIndexEnd. * - * The `end` index of this cell's `row` location in the current table. + *

The `end` index of this cell's `row` location in the current table. * * @return the rowIndexEnd */ @@ -94,7 +98,7 @@ public Long getRowIndexEnd() { /** * Gets the columnIndexBegin. * - * The `begin` index of this cell's `column` location in the current table. + *

The `begin` index of this cell's `column` location in the current table. * * @return the columnIndexBegin */ @@ -105,7 +109,7 @@ public Long getColumnIndexBegin() { /** * Gets the columnIndexEnd. * - * The `end` index of this cell's `column` location in the current table. + *

The `end` index of this cell's `column` location in the current table. * * @return the columnIndexEnd */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java index e793eb7d85f..1b93fd28d43 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,24 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Key-value pairs detected across cell boundaries. - */ +/** Key-value pairs detected across cell boundaries. */ public class TableKeyValuePairs extends GenericModel { protected TableCellKey key; protected List value; + protected TableKeyValuePairs() {} + /** * Gets the key. * - * A key in a key-value pair. + *

A key in a key-value pair. * * @return the key */ @@ -38,7 +38,7 @@ public TableCellKey getKey() { /** * Gets the value. * - * A list of values in a key-value pair. + *

A list of values in a key-value pair. * * @return the value */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java index 858ba153d59..718d00f56ed 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,40 +10,48 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Full table object retrieved from Table Understanding Enrichment. - */ +/** Full table object retrieved from Table Understanding Enrichment. */ public class TableResultTable extends GenericModel { protected TableElementLocation location; protected String text; + @SerializedName("section_title") protected TableTextLocation sectionTitle; + protected TableTextLocation title; + @SerializedName("table_headers") protected List tableHeaders; + @SerializedName("row_headers") protected List rowHeaders; + @SerializedName("column_headers") protected List columnHeaders; + @SerializedName("key_value_pairs") protected List keyValuePairs; + @SerializedName("body_cells") protected List bodyCells; + protected List contexts; + protected TableResultTable() {} + /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ @@ -54,7 +62,8 @@ public TableElementLocation getLocation() { /** * Gets the text. * - * The textual contents of the current table from the input document without associated markup content. + *

The textual contents of the current table from the input document without associated markup + * content. * * @return the text */ @@ -65,7 +74,7 @@ public String getText() { /** * Gets the sectionTitle. * - * Text and associated location within a table. + *

Text and associated location within a table. * * @return the sectionTitle */ @@ -76,7 +85,7 @@ public TableTextLocation getSectionTitle() { /** * Gets the title. * - * Text and associated location within a table. + *

Text and associated location within a table. * * @return the title */ @@ -87,7 +96,8 @@ public TableTextLocation getTitle() { /** * Gets the tableHeaders. * - * An array of table-level cells that apply as headers to all the other cells in the current table. + *

An array of table-level cells that apply as headers to all the other cells in the current + * table. * * @return the tableHeaders */ @@ -98,8 +108,8 @@ public List getTableHeaders() { /** * Gets the rowHeaders. * - * An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current - * table. + *

An array of row-level cells, each applicable as a header to other cells in the same row as + * itself, of the current table. * * @return the rowHeaders */ @@ -110,8 +120,8 @@ public List getRowHeaders() { /** * Gets the columnHeaders. * - * An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the - * current table. + *

An array of column-level cells, each applicable as a header to other cells in the same + * column as itself, of the current table. * * @return the columnHeaders */ @@ -122,7 +132,7 @@ public List getColumnHeaders() { /** * Gets the keyValuePairs. * - * An array of key-value pairs identified in the current table. + *

An array of key-value pairs identified in the current table. * * @return the keyValuePairs */ @@ -133,8 +143,8 @@ public List getKeyValuePairs() { /** * Gets the bodyCells. * - * An array of cells that are neither table header nor column header nor row header cells, of the current table with - * corresponding row and column header associations. + *

An array of cells that are neither table header nor column header nor row header cells, of + * the current table with corresponding row and column header associations. * * @return the bodyCells */ @@ -145,7 +155,8 @@ public List getBodyCells() { /** * Gets the contexts. * - * An array of lists of textual entries across the document related to the current table being parsed. + *

An array of lists of textual entries across the document related to the current table being + * parsed. * * @return the contexts */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java index df40c0b959f..53718523ace 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,16 +15,19 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An array of values, each being the `id` value of a row header that is applicable to this body cell. + * An array of values, each being the `id` value of a row header that is applicable to this body + * cell. */ public class TableRowHeaderIds extends GenericModel { protected String id; + protected TableRowHeaderIds() {} + /** * Gets the id. * - * The `id` values of a row header. + *

The `id` values of a row header. * * @return the id */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java index b4ffba5019b..5b832a5d8a0 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,16 +15,19 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * An array of values, each being the `text` value of a row header that is applicable to this body cell. + * An array of values, each being the `text` value of a row header that is applicable to this body + * cell. */ public class TableRowHeaderTexts extends GenericModel { protected String text; + protected TableRowHeaderTexts() {} + /** * Gets the text. * - * The `text` value of a row header. + *

The `text` value of a row header. * * @return the text */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java index 94c39c3b246..23caa5b5889 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -16,18 +16,20 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * If you provide customization input, the normalized version of the row header texts according to the customization; - * otherwise, the same value as `row_header_texts`. + * If you provide customization input, the normalized version of the row header texts according to + * the customization; otherwise, the same value as `row_header_texts`. */ public class TableRowHeaderTextsNormalized extends GenericModel { @SerializedName("text_normalized") protected String textNormalized; + protected TableRowHeaderTextsNormalized() {} + /** * Gets the textNormalized. * - * The normalized version of a row header text. + *

The normalized version of a row header text. * * @return the textNormalized */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java index 1a63c7a7e31..23f990bd81f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,35 +10,45 @@ * 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; /** - * Row-level cells, each applicable as a header to other cells in the same row as itself, of the current table. + * Row-level cells, each applicable as a header to other cells in the same row as itself, of the + * current table. */ public class TableRowHeaders extends GenericModel { @SerializedName("cell_id") protected String cellId; + protected TableElementLocation location; protected String text; + @SerializedName("text_normalized") protected String textNormalized; + @SerializedName("row_index_begin") protected Long rowIndexBegin; + @SerializedName("row_index_end") protected Long rowIndexEnd; + @SerializedName("column_index_begin") protected Long columnIndexBegin; + @SerializedName("column_index_end") protected Long columnIndexEnd; + protected TableRowHeaders() {} + /** * Gets the cellId. * - * The unique ID of the cell in the current table. + *

The unique ID of the cell in the current table. * * @return the cellId */ @@ -49,8 +59,8 @@ public String getCellId() { /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ @@ -61,7 +71,7 @@ public TableElementLocation getLocation() { /** * Gets the text. * - * The textual contents of this cell from the input document without associated markup content. + *

The textual contents of this cell from the input document without associated markup content. * * @return the text */ @@ -72,8 +82,7 @@ public String getText() { /** * Gets the textNormalized. * - * If you provide customization input, the normalized version of the cell text according to the customization; - * otherwise, the same value as `text`. + *

Normalized row header text. * * @return the textNormalized */ @@ -84,7 +93,7 @@ public String getTextNormalized() { /** * Gets the rowIndexBegin. * - * The `begin` index of this cell's `row` location in the current table. + *

The `begin` index of this cell's `row` location in the current table. * * @return the rowIndexBegin */ @@ -95,7 +104,7 @@ public Long getRowIndexBegin() { /** * Gets the rowIndexEnd. * - * The `end` index of this cell's `row` location in the current table. + *

The `end` index of this cell's `row` location in the current table. * * @return the rowIndexEnd */ @@ -106,7 +115,7 @@ public Long getRowIndexEnd() { /** * Gets the columnIndexBegin. * - * The `begin` index of this cell's `column` location in the current table. + *

The `begin` index of this cell's `column` location in the current table. * * @return the columnIndexBegin */ @@ -117,7 +126,7 @@ public Long getColumnIndexBegin() { /** * Gets the columnIndexEnd. * - * The `end` index of this cell's `column` location in the current table. + *

The `end` index of this cell's `column` location in the current table. * * @return the columnIndexEnd */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java index 37679c59c18..b1308b4e16e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,22 +10,23 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Text and associated location within a table. - */ +/** Text and associated location within a table. */ public class TableTextLocation extends GenericModel { protected String text; protected TableElementLocation location; + protected TableTextLocation() {} + /** * Gets the text. * - * The text retrieved. + *

The text retrieved. * * @return the text */ @@ -36,8 +37,8 @@ public String getText() { /** * Gets the location. * - * The numeric location of the identified element in the document, represented with two integers labeled `begin` and - * `end`. + *

The numeric location of the identified element in the document, represented with two + * integers labeled `begin` and `end`. * * @return the location */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java index 1317fdf65c1..c2d02cf1c29 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,49 +10,45 @@ * 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.Date; +package com.ibm.watson.discovery.v2.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; -/** - * Object containing example response details for a training query. - */ +/** Object that contains example response details for a training query. */ public class TrainingExample extends GenericModel { @SerializedName("document_id") protected String documentId; + @SerializedName("collection_id") protected String collectionId; + protected Long relevance; protected Date created; protected Date updated; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String documentId; private String collectionId; private Long relevance; - private Date created; - private Date updated; + /** + * Instantiates a new Builder from an existing TrainingExample instance. + * + * @param trainingExample the instance to initialize the Builder with + */ private Builder(TrainingExample trainingExample) { this.documentId = trainingExample.documentId; this.collectionId = trainingExample.collectionId; this.relevance = trainingExample.relevance; - this.created = trainingExample.created; - this.updated = trainingExample.updated; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -70,7 +66,7 @@ public Builder(String documentId, String collectionId, Long relevance) { /** * Builds a TrainingExample. * - * @return the trainingExample + * @return the new TrainingExample instance */ public TrainingExample build() { return new TrainingExample(this); @@ -108,42 +104,18 @@ public Builder relevance(long relevance) { this.relevance = relevance; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the TrainingExample builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the TrainingExample builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } + protected TrainingExample() {} + protected TrainingExample(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.documentId, - "documentId cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionId, - "collectionId cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.relevance, - "relevance cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.documentId, "documentId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.collectionId, "collectionId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.relevance, "relevance cannot be null"); documentId = builder.documentId; collectionId = builder.collectionId; relevance = builder.relevance; - created = builder.created; - updated = builder.updated; } /** @@ -158,7 +130,7 @@ public Builder newBuilder() { /** * Gets the documentId. * - * The document ID associated with this training example. + *

The document ID associated with this training example. * * @return the documentId */ @@ -169,7 +141,7 @@ public String documentId() { /** * Gets the collectionId. * - * The collection ID associated with this training example. + *

The collection ID associated with this training example. * * @return the collectionId */ @@ -180,7 +152,8 @@ public String collectionId() { /** * Gets the relevance. * - * The relevance of the training example. + *

The relevance score of the training example. Scores range from `0` to `100`. Zero means not + * relevant. The higher the number, the more relevant the example. * * @return the relevance */ @@ -191,7 +164,7 @@ public Long relevance() { /** * Gets the created. * - * The date and time the example was created. + *

The date and time the example was created. * * @return the created */ @@ -202,7 +175,7 @@ public Date created() { /** * Gets the updated. * - * The date and time the example was updated. + *

The date and time the example was updated. * * @return the updated */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java index 7c128590111..8a2d95bfd31 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,54 +10,48 @@ * 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; import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Object containing training query details. - */ +/** Object that contains training query details. */ public class TrainingQuery extends GenericModel { @SerializedName("query_id") protected String queryId; + @SerializedName("natural_language_query") protected String naturalLanguageQuery; + protected String filter; protected Date created; protected Date updated; protected List examples; - /** - * Builder. - */ + /** Builder. */ public static class Builder { - private String queryId; private String naturalLanguageQuery; private String filter; - private Date created; - private Date updated; private List examples; + /** + * Instantiates a new Builder from an existing TrainingQuery instance. + * + * @param trainingQuery the instance to initialize the Builder with + */ private Builder(TrainingQuery trainingQuery) { - this.queryId = trainingQuery.queryId; this.naturalLanguageQuery = trainingQuery.naturalLanguageQuery; this.filter = trainingQuery.filter; - this.created = trainingQuery.created; - this.updated = trainingQuery.updated; this.examples = trainingQuery.examples; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -73,21 +67,20 @@ public Builder(String naturalLanguageQuery, List examples) { /** * Builds a TrainingQuery. * - * @return the trainingQuery + * @return the new TrainingQuery instance */ public TrainingQuery build() { return new TrainingQuery(this); } /** - * Adds an examples to examples. + * Adds a new element to examples. * - * @param examples the new examples + * @param examples the new element to be added * @return the TrainingQuery builder */ public Builder addExamples(TrainingExample examples) { - com.ibm.cloud.sdk.core.util.Validator.notNull(examples, - "examples cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(examples, "examples cannot be null"); if (this.examples == null) { this.examples = new ArrayList(); } @@ -95,17 +88,6 @@ public Builder addExamples(TrainingExample examples) { return this; } - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the TrainingQuery builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - /** * Set the naturalLanguageQuery. * @@ -129,30 +111,7 @@ public Builder filter(String filter) { } /** - * Set the created. - * - * @param created the created - * @return the TrainingQuery builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the TrainingQuery builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. + * Set the examples. Existing examples will be replaced. * * @param examples the examples * @return the TrainingQuery builder @@ -163,16 +122,14 @@ public Builder examples(List examples) { } } + protected TrainingQuery() {} + protected TrainingQuery(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.naturalLanguageQuery, - "naturalLanguageQuery cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, - "examples cannot be null"); - queryId = builder.queryId; + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.naturalLanguageQuery, "naturalLanguageQuery cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, "examples cannot be null"); naturalLanguageQuery = builder.naturalLanguageQuery; filter = builder.filter; - created = builder.created; - updated = builder.updated; examples = builder.examples; } @@ -188,7 +145,7 @@ public Builder newBuilder() { /** * Gets the queryId. * - * The query ID associated with the training query. + *

The query ID associated with the training query. * * @return the queryId */ @@ -199,7 +156,7 @@ public String queryId() { /** * Gets the naturalLanguageQuery. * - * The natural text query for the training query. + *

The natural text query that is used as the training query. * * @return the naturalLanguageQuery */ @@ -210,7 +167,10 @@ public String naturalLanguageQuery() { /** * Gets the filter. * - * The filter used on the collection before the **natural_language_query** is applied. + *

The filter used on the collection before the **natural_language_query** is applied. Only + * specify a filter if the documents that you consider to be most relevant are not included in the + * top 100 results when you submit test queries. If you specify a filter during training, apply + * the same filter to queries that are submitted at runtime for optimal ranking results. * * @return the filter */ @@ -221,7 +181,7 @@ public String filter() { /** * Gets the created. * - * The date and time the query was created. + *

The date and time the query was created. * * @return the created */ @@ -232,7 +192,7 @@ public Date created() { /** * Gets the updated. * - * The date and time the query was updated. + *

The date and time the query was updated. * * @return the updated */ @@ -243,7 +203,7 @@ public Date updated() { /** * Gets the examples. * - * Array of training examples. + *

Array of training examples. * * @return the examples */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java index 73c957237de..77f2e94e23d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,24 @@ * 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; +package com.ibm.watson.discovery.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Object specifying the training queries contained in the identified training set. - */ +/** Object specifying the training queries contained in the identified training set. */ public class TrainingQuerySet extends GenericModel { protected List queries; + protected TrainingQuerySet() {} + /** * Gets the queries. * - * Array of training queries. + *

Array of training queries. At least 50 queries are required for training to begin. A maximum + * of 10,000 queries are returned. * * @return the queries */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java new file mode 100644 index 00000000000..baae8079b03 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java @@ -0,0 +1,248 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The updateCollection options. */ +public class UpdateCollectionOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String name; + protected String description; + protected Boolean ocrEnabled; + protected List enrichments; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private String name; + private String description; + private Boolean ocrEnabled; + private List enrichments; + + /** + * Instantiates a new Builder from an existing UpdateCollectionOptions instance. + * + * @param updateCollectionOptions the instance to initialize the Builder with + */ + private Builder(UpdateCollectionOptions updateCollectionOptions) { + this.projectId = updateCollectionOptions.projectId; + this.collectionId = updateCollectionOptions.collectionId; + this.name = updateCollectionOptions.name; + this.description = updateCollectionOptions.description; + this.ocrEnabled = updateCollectionOptions.ocrEnabled; + this.enrichments = updateCollectionOptions.enrichments; + } + + /** 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 UpdateCollectionOptions. + * + * @return the new UpdateCollectionOptions instance + */ + public UpdateCollectionOptions build() { + return new UpdateCollectionOptions(this); + } + + /** + * Adds a new element to enrichments. + * + * @param enrichments the new element to be added + * @return the UpdateCollectionOptions builder + */ + public Builder addEnrichments(CollectionEnrichment enrichments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(enrichments, "enrichments cannot be null"); + if (this.enrichments == null) { + this.enrichments = new ArrayList(); + } + this.enrichments.add(enrichments); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateCollectionOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the UpdateCollectionOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateCollectionOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateCollectionOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the ocrEnabled. + * + * @param ocrEnabled the ocrEnabled + * @return the UpdateCollectionOptions builder + */ + public Builder ocrEnabled(Boolean ocrEnabled) { + this.ocrEnabled = ocrEnabled; + return this; + } + + /** + * Set the enrichments. Existing enrichments will be replaced. + * + * @param enrichments the enrichments + * @return the UpdateCollectionOptions builder + */ + public Builder enrichments(List enrichments) { + this.enrichments = enrichments; + return this; + } + } + + protected UpdateCollectionOptions() {} + + protected UpdateCollectionOptions(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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + name = builder.name; + description = builder.description; + ocrEnabled = builder.ocrEnabled; + enrichments = builder.enrichments; + } + + /** + * New builder. + * + * @return a UpdateCollectionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the name. + * + *

The new name of the collection. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

The new description of the collection. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the ocrEnabled. + * + *

If set to `true`, optical character recognition (OCR) is enabled. For more information, see + * [Optical character recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). + * + * @return the ocrEnabled + */ + public Boolean ocrEnabled() { + return ocrEnabled; + } + + /** + * Gets the enrichments. + * + *

An array of enrichments that are applied to this collection. + * + * @return the enrichments + */ + public List enrichments() { + return enrichments; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifier.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifier.java new file mode 100644 index 00000000000..330258583f6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifier.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An object that contains a new name or description for a document classifier, updated training + * data, or new or updated test data. + */ +public class UpdateDocumentClassifier extends GenericModel { + + protected String name; + protected String description; + + /** Builder. */ + public static class Builder { + private String name; + private String description; + + /** + * Instantiates a new Builder from an existing UpdateDocumentClassifier instance. + * + * @param updateDocumentClassifier the instance to initialize the Builder with + */ + private Builder(UpdateDocumentClassifier updateDocumentClassifier) { + this.name = updateDocumentClassifier.name; + this.description = updateDocumentClassifier.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a UpdateDocumentClassifier. + * + * @return the new UpdateDocumentClassifier instance + */ + public UpdateDocumentClassifier build() { + return new UpdateDocumentClassifier(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateDocumentClassifier builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateDocumentClassifier builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected UpdateDocumentClassifier() {} + + protected UpdateDocumentClassifier(Builder builder) { + name = builder.name; + description = builder.description; + } + + /** + * New builder. + * + * @return a UpdateDocumentClassifier builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

A new name for the classifier. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A new description for the classifier. + * + * @return the description + */ + public String description() { + return description; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierModelOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierModelOptions.java new file mode 100644 index 00000000000..a9f7616effa --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierModelOptions.java @@ -0,0 +1,207 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The updateDocumentClassifierModel options. */ +public class UpdateDocumentClassifierModelOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + protected String modelId; + protected String name; + protected String description; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + private String modelId; + private String name; + private String description; + + /** + * Instantiates a new Builder from an existing UpdateDocumentClassifierModelOptions instance. + * + * @param updateDocumentClassifierModelOptions the instance to initialize the Builder with + */ + private Builder(UpdateDocumentClassifierModelOptions updateDocumentClassifierModelOptions) { + this.projectId = updateDocumentClassifierModelOptions.projectId; + this.classifierId = updateDocumentClassifierModelOptions.classifierId; + this.modelId = updateDocumentClassifierModelOptions.modelId; + this.name = updateDocumentClassifierModelOptions.name; + this.description = updateDocumentClassifierModelOptions.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + * @param modelId the modelId + */ + public Builder(String projectId, String classifierId, String modelId) { + this.projectId = projectId; + this.classifierId = classifierId; + this.modelId = modelId; + } + + /** + * Builds a UpdateDocumentClassifierModelOptions. + * + * @return the new UpdateDocumentClassifierModelOptions instance + */ + public UpdateDocumentClassifierModelOptions build() { + return new UpdateDocumentClassifierModelOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateDocumentClassifierModelOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the UpdateDocumentClassifierModelOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the UpdateDocumentClassifierModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateDocumentClassifierModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateDocumentClassifierModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected UpdateDocumentClassifierModelOptions() {} + + protected UpdateDocumentClassifierModelOptions(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.classifierId, "classifierId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + projectId = builder.projectId; + classifierId = builder.classifierId; + modelId = builder.modelId; + name = builder.name; + description = builder.description; + } + + /** + * New builder. + * + * @return a UpdateDocumentClassifierModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } + + /** + * Gets the modelId. + * + *

The Universally Unique Identifier (UUID) of the classifier model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } + + /** + * Gets the name. + * + *

A new name for the enrichment. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A new description for the enrichment. + * + * @return the description + */ + public String description() { + return description; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierOptions.java new file mode 100644 index 00000000000..b97ac9c8084 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierOptions.java @@ -0,0 +1,242 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The updateDocumentClassifier options. */ +public class UpdateDocumentClassifierOptions extends GenericModel { + + protected String projectId; + protected String classifierId; + protected UpdateDocumentClassifier classifier; + protected InputStream trainingData; + protected InputStream testData; + + /** Builder. */ + public static class Builder { + private String projectId; + private String classifierId; + private UpdateDocumentClassifier classifier; + private InputStream trainingData; + private InputStream testData; + + /** + * Instantiates a new Builder from an existing UpdateDocumentClassifierOptions instance. + * + * @param updateDocumentClassifierOptions the instance to initialize the Builder with + */ + private Builder(UpdateDocumentClassifierOptions updateDocumentClassifierOptions) { + this.projectId = updateDocumentClassifierOptions.projectId; + this.classifierId = updateDocumentClassifierOptions.classifierId; + this.classifier = updateDocumentClassifierOptions.classifier; + this.trainingData = updateDocumentClassifierOptions.trainingData; + this.testData = updateDocumentClassifierOptions.testData; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param classifierId the classifierId + * @param classifier the classifier + */ + public Builder(String projectId, String classifierId, UpdateDocumentClassifier classifier) { + this.projectId = projectId; + this.classifierId = classifierId; + this.classifier = classifier; + } + + /** + * Builds a UpdateDocumentClassifierOptions. + * + * @return the new UpdateDocumentClassifierOptions instance + */ + public UpdateDocumentClassifierOptions build() { + return new UpdateDocumentClassifierOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateDocumentClassifierOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the classifierId. + * + * @param classifierId the classifierId + * @return the UpdateDocumentClassifierOptions builder + */ + public Builder classifierId(String classifierId) { + this.classifierId = classifierId; + return this; + } + + /** + * Set the classifier. + * + * @param classifier the classifier + * @return the UpdateDocumentClassifierOptions builder + */ + public Builder classifier(UpdateDocumentClassifier classifier) { + this.classifier = classifier; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateDocumentClassifierOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the testData. + * + * @param testData the testData + * @return the UpdateDocumentClassifierOptions builder + */ + public Builder testData(InputStream testData) { + this.testData = testData; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateDocumentClassifierOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + + /** + * Set the testData. + * + * @param testData the testData + * @return the UpdateDocumentClassifierOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder testData(File testData) throws FileNotFoundException { + this.testData = new FileInputStream(testData); + return this; + } + } + + protected UpdateDocumentClassifierOptions() {} + + protected UpdateDocumentClassifierOptions(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.classifierId, "classifierId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.classifier, "classifier cannot be null"); + projectId = builder.projectId; + classifierId = builder.classifierId; + classifier = builder.classifier; + trainingData = builder.trainingData; + testData = builder.testData; + } + + /** + * New builder. + * + * @return a UpdateDocumentClassifierOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the classifierId. + * + *

The Universally Unique Identifier (UUID) of the classifier. + * + * @return the classifierId + */ + public String classifierId() { + return classifierId; + } + + /** + * Gets the classifier. + * + *

An object that contains a new name or description for a document classifier, updated + * training data, or new or updated test data. + * + * @return the classifier + */ + public UpdateDocumentClassifier classifier() { + return classifier; + } + + /** + * Gets the trainingData. + * + *

The training data CSV file to upload. The CSV file must have headers. The file must include + * a field that contains the text you want to classify and a field that contains the + * classification labels that you want to use to classify your data. If you want to specify + * multiple values in a single column, use a semicolon as the value separator. For a sample file, + * see [the product documentation](/docs/discovery-data?topic=discovery-data-cm-doc-classifier). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the testData. + * + *

The CSV with test data to upload. The column values in the test file must be the same as the + * column values in the training data file. If no test data is provided, the training data is + * split into two separate groups of training and test data. + * + * @return the testData + */ + public InputStream testData() { + return testData; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java index 18162517d6c..fc7282a1624 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,18 +10,16 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; 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 updateDocument options. - */ +/** The updateDocument options. */ public class UpdateDocumentOptions extends GenericModel { protected String projectId; @@ -33,9 +31,7 @@ public class UpdateDocumentOptions extends GenericModel { protected String metadata; protected Boolean xWatsonDiscoveryForce; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String collectionId; @@ -46,6 +42,11 @@ public static class Builder { private String metadata; private Boolean xWatsonDiscoveryForce; + /** + * Instantiates a new Builder from an existing UpdateDocumentOptions instance. + * + * @param updateDocumentOptions the instance to initialize the Builder with + */ private Builder(UpdateDocumentOptions updateDocumentOptions) { this.projectId = updateDocumentOptions.projectId; this.collectionId = updateDocumentOptions.collectionId; @@ -57,11 +58,8 @@ private Builder(UpdateDocumentOptions updateDocumentOptions) { this.xWatsonDiscoveryForce = updateDocumentOptions.xWatsonDiscoveryForce; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -79,7 +77,7 @@ public Builder(String projectId, String collectionId, String documentId) { /** * Builds a UpdateDocumentOptions. * - * @return the updateDocumentOptions + * @return the new UpdateDocumentOptions instance */ public UpdateDocumentOptions build() { return new UpdateDocumentOptions(this); @@ -178,7 +176,6 @@ public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { * * @param file the file * @return the UpdateDocumentOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder file(File file) throws FileNotFoundException { @@ -188,14 +185,16 @@ public Builder file(File file) throws FileNotFoundException { } } + protected UpdateDocumentOptions() {} + protected UpdateDocumentOptions(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.notEmpty(builder.documentId, - "documentId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((builder.file == null) || (builder.filename != null), + 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.notEmpty( + builder.documentId, "documentId 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; @@ -219,7 +218,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -230,7 +230,7 @@ public String projectId() { /** * Gets the collectionId. * - * The ID of the collection. + *

The Universally Unique Identifier (UUID) of the collection. * * @return the collectionId */ @@ -241,7 +241,7 @@ public String collectionId() { /** * Gets the documentId. * - * The ID of the document. + *

The ID of the document. * * @return the documentId */ @@ -252,9 +252,14 @@ public String documentId() { /** * 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 configuration is 1 megabyte. Files larger than the - * supported size are rejected. + *

**Add a document**: The content of the document to ingest. For the supported file types and + * maximum supported file size limits when adding a document, see [the + * documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes). + * + *

**Analyze a document**: The content of the document to analyze but not ingest. Only the + * `application/json` content type is supported by the Analyze API. For maximum supported file + * size limits, see [the product + * documentation](/docs/discovery-data?topic=discovery-data-analyzeapi#analyzeapi-limits). * * @return the file */ @@ -265,7 +270,7 @@ public InputStream file() { /** * Gets the filename. * - * The filename for file. + *

The filename for file. * * @return the filename */ @@ -276,7 +281,8 @@ public String filename() { /** * Gets the fileContentType. * - * The content type of file. Values for this parameter can be obtained from the HttpMediaType class. + *

The content type of file. Values for this parameter can be obtained from the HttpMediaType + * class. * * @return the fileContentType */ @@ -287,10 +293,14 @@ public String 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" - * } ```. + *

Add information about the file that you want to include in the response. + * + *

The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are + * rejected. + * + *

Example: + * + *

``` { "filename": "favorites2.json", "file_type": "json" }. * * @return the metadata */ @@ -301,8 +311,8 @@ public String 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. + *

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 */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java new file mode 100644 index 00000000000..0a2adf5ac91 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java @@ -0,0 +1,181 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The updateEnrichment options. */ +public class UpdateEnrichmentOptions extends GenericModel { + + protected String projectId; + protected String enrichmentId; + protected String name; + protected String description; + + /** Builder. */ + public static class Builder { + private String projectId; + private String enrichmentId; + private String name; + private String description; + + /** + * Instantiates a new Builder from an existing UpdateEnrichmentOptions instance. + * + * @param updateEnrichmentOptions the instance to initialize the Builder with + */ + private Builder(UpdateEnrichmentOptions updateEnrichmentOptions) { + this.projectId = updateEnrichmentOptions.projectId; + this.enrichmentId = updateEnrichmentOptions.enrichmentId; + this.name = updateEnrichmentOptions.name; + this.description = updateEnrichmentOptions.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param enrichmentId the enrichmentId + * @param name the name + */ + public Builder(String projectId, String enrichmentId, String name) { + this.projectId = projectId; + this.enrichmentId = enrichmentId; + this.name = name; + } + + /** + * Builds a UpdateEnrichmentOptions. + * + * @return the new UpdateEnrichmentOptions instance + */ + public UpdateEnrichmentOptions build() { + return new UpdateEnrichmentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateEnrichmentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the enrichmentId. + * + * @param enrichmentId the enrichmentId + * @return the UpdateEnrichmentOptions builder + */ + public Builder enrichmentId(String enrichmentId) { + this.enrichmentId = enrichmentId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateEnrichmentOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateEnrichmentOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected UpdateEnrichmentOptions() {} + + protected UpdateEnrichmentOptions(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.enrichmentId, "enrichmentId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + projectId = builder.projectId; + enrichmentId = builder.enrichmentId; + name = builder.name; + description = builder.description; + } + + /** + * New builder. + * + * @return a UpdateEnrichmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the enrichmentId. + * + *

The Universally Unique Identifier (UUID) of the enrichment. + * + * @return the enrichmentId + */ + public String enrichmentId() { + return enrichmentId; + } + + /** + * Gets the name. + * + *

A new name for the enrichment. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A new description for the enrichment. + * + * @return the description + */ + public String description() { + return description; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java new file mode 100644 index 00000000000..8736c708cb4 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java @@ -0,0 +1,122 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The updateProject options. */ +public class UpdateProjectOptions extends GenericModel { + + protected String projectId; + protected String name; + + /** Builder. */ + public static class Builder { + private String projectId; + private String name; + + /** + * Instantiates a new Builder from an existing UpdateProjectOptions instance. + * + * @param updateProjectOptions the instance to initialize the Builder with + */ + private Builder(UpdateProjectOptions updateProjectOptions) { + this.projectId = updateProjectOptions.projectId; + this.name = updateProjectOptions.name; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a UpdateProjectOptions. + * + * @return the new UpdateProjectOptions instance + */ + public UpdateProjectOptions build() { + return new UpdateProjectOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateProjectOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateProjectOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + } + + protected UpdateProjectOptions() {} + + protected UpdateProjectOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + name = builder.name; + } + + /** + * New builder. + * + * @return a UpdateProjectOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the name. + * + *

The new name to give this project. + * + * @return the name + */ + public String name() { + return name; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java index 6c437d06bd8..70c52b8a757 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,16 +10,14 @@ * 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.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateTrainingQuery options. - */ +/** The updateTrainingQuery options. */ public class UpdateTrainingQueryOptions extends GenericModel { protected String projectId; @@ -28,9 +26,7 @@ public class UpdateTrainingQueryOptions extends GenericModel { protected List examples; protected String filter; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String projectId; private String queryId; @@ -38,6 +34,11 @@ public static class Builder { private List examples; private String filter; + /** + * Instantiates a new Builder from an existing UpdateTrainingQueryOptions instance. + * + * @param updateTrainingQueryOptions the instance to initialize the Builder with + */ private Builder(UpdateTrainingQueryOptions updateTrainingQueryOptions) { this.projectId = updateTrainingQueryOptions.projectId; this.queryId = updateTrainingQueryOptions.queryId; @@ -46,11 +47,8 @@ private Builder(UpdateTrainingQueryOptions updateTrainingQueryOptions) { this.filter = updateTrainingQueryOptions.filter; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -60,7 +58,11 @@ public Builder() { * @param naturalLanguageQuery the naturalLanguageQuery * @param examples the examples */ - public Builder(String projectId, String queryId, String naturalLanguageQuery, List examples) { + public Builder( + String projectId, + String queryId, + String naturalLanguageQuery, + List examples) { this.projectId = projectId; this.queryId = queryId; this.naturalLanguageQuery = naturalLanguageQuery; @@ -70,21 +72,20 @@ public Builder(String projectId, String queryId, String naturalLanguageQuery, Li /** * Builds a UpdateTrainingQueryOptions. * - * @return the updateTrainingQueryOptions + * @return the new UpdateTrainingQueryOptions instance */ public UpdateTrainingQueryOptions build() { return new UpdateTrainingQueryOptions(this); } /** - * Adds an examples to examples. + * Adds a new element to examples. * - * @param examples the new examples + * @param examples the new element to be added * @return the UpdateTrainingQueryOptions builder */ public Builder addExamples(TrainingExample examples) { - com.ibm.cloud.sdk.core.util.Validator.notNull(examples, - "examples cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(examples, "examples cannot be null"); if (this.examples == null) { this.examples = new ArrayList(); } @@ -126,8 +127,7 @@ public Builder naturalLanguageQuery(String naturalLanguageQuery) { } /** - * Set the examples. - * Existing examples will be replaced. + * Set the examples. Existing examples will be replaced. * * @param examples the examples * @return the UpdateTrainingQueryOptions builder @@ -162,15 +162,14 @@ public Builder trainingQuery(TrainingQuery trainingQuery) { } } + protected UpdateTrainingQueryOptions() {} + protected UpdateTrainingQueryOptions(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.queryId, - "queryId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.naturalLanguageQuery, - "naturalLanguageQuery cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, - "examples cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.queryId, "queryId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.naturalLanguageQuery, "naturalLanguageQuery cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, "examples cannot be null"); projectId = builder.projectId; queryId = builder.queryId; naturalLanguageQuery = builder.naturalLanguageQuery; @@ -190,7 +189,8 @@ public Builder newBuilder() { /** * Gets the projectId. * - * The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. + *

The Universally Unique Identifier (UUID) of the project. This information can be found from + * the *Integrate and Deploy* page in Discovery. * * @return the projectId */ @@ -201,7 +201,7 @@ public String projectId() { /** * Gets the queryId. * - * The ID of the query used for training. + *

The ID of the query used for training. * * @return the queryId */ @@ -212,7 +212,7 @@ public String queryId() { /** * Gets the naturalLanguageQuery. * - * The natural text query for the training query. + *

The natural text query that is used as the training query. * * @return the naturalLanguageQuery */ @@ -223,7 +223,7 @@ public String naturalLanguageQuery() { /** * Gets the examples. * - * Array of training examples. + *

Array of training examples. * * @return the examples */ @@ -234,7 +234,10 @@ public List examples() { /** * Gets the filter. * - * The filter used on the collection before the **natural_language_query** is applied. + *

The filter used on the collection before the **natural_language_query** is applied. Only + * specify a filter if the documents that you consider to be most relevant are not included in the + * top 100 results when you submit test queries. If you specify a filter during training, apply + * the same filter to queries that are submitted at runtime for optimal ranking results. * * @return the filter */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/WebhookHeader.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/WebhookHeader.java new file mode 100644 index 00000000000..7b67a8eb232 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/WebhookHeader.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * An array of headers to pass with the HTTP request. Optional when `type` is `webhook`. Not valid + * when creating any other type of enrichment. + */ +public class WebhookHeader extends GenericModel { + + protected String name; + protected String value; + + /** Builder. */ + public static class Builder { + private String name; + private String value; + + /** + * Instantiates a new Builder from an existing WebhookHeader instance. + * + * @param webhookHeader the instance to initialize the Builder with + */ + private Builder(WebhookHeader webhookHeader) { + this.name = webhookHeader.name; + this.value = webhookHeader.value; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param value the value + */ + public Builder(String name, String value) { + this.name = name; + this.value = value; + } + + /** + * Builds a WebhookHeader. + * + * @return the new WebhookHeader instance + */ + public WebhookHeader build() { + return new WebhookHeader(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the WebhookHeader builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the WebhookHeader builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + } + + protected WebhookHeader() {} + + protected WebhookHeader(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, "value cannot be null"); + name = builder.name; + value = builder.value; + } + + /** + * New builder. + * + * @return a WebhookHeader builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of an HTTP header. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the value. + * + *

The value of an HTTP header. + * + * @return the value + */ + public String value() { + return value; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java index 6c8bdd9da23..a93b9daa2e6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,7 +10,6 @@ * 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. */ -/** - * IBM Watson Discovery for IBM Cloud Pak for Data v2. - */ + +/** Discovery v2 v2. */ package com.ibm.watson.discovery.v2; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/query/AggregationDeserializer.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/query/AggregationDeserializer.java deleted file mode 100644 index 5115c6bb9c4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/query/AggregationDeserializer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.query; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.discovery.query.AggregationType; -import com.ibm.watson.discovery.v2.model.QueryAggregation; -import com.ibm.watson.discovery.v2.model.QueryCalculationAggregation; -import com.ibm.watson.discovery.v2.model.QueryFilterAggregation; -import com.ibm.watson.discovery.v2.model.QueryHistogramAggregation; -import com.ibm.watson.discovery.v2.model.QueryNestedAggregation; -import com.ibm.watson.discovery.v2.model.QueryTermAggregation; -import com.ibm.watson.discovery.v2.model.QueryTimesliceAggregation; -import com.ibm.watson.discovery.v2.model.QueryTopHitsAggregation; - -import java.lang.reflect.Type; - -/** - * Deserializer to transform JSON into a {@link QueryAggregation}. - * - * @deprecated This class has been replaced by logic inside of the QueryAggregation class. - */ -public class AggregationDeserializer implements JsonDeserializer { - - private static final String TYPE = "type"; - - /** - * Deserializes JSON and converts it to the appropriate {@link QueryAggregation} subclass. - * - * @param json the JSON data being deserialized - * @param typeOfT the type to deserialize to, which should be {@link QueryAggregation} - * @param context additional information about the deserialization state - * @return the appropriate {@link QueryAggregation} subclass - * @throws JsonParseException signals that there has been an issue parsing the JSON - */ - @Override - public QueryAggregation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - - // get aggregation type from response - JsonObject jsonObject = json.getAsJsonObject(); - String aggregationType = ""; - for (String key : jsonObject.keySet()) { - if (key.equals(TYPE)) { - aggregationType = jsonObject.get(key).getAsString(); - } - } - - QueryAggregation aggregation; - if (aggregationType.equals(AggregationType.HISTOGRAM.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryHistogramAggregation.class); - } else if (aggregationType.equals(AggregationType.MAX.getName()) - || aggregationType.equals(AggregationType.MIN.getName()) - || aggregationType.equals(AggregationType.AVERAGE.getName()) - || aggregationType.equals(AggregationType.SUM.getName()) - || aggregationType.equals(AggregationType.UNIQUE_COUNT.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryCalculationAggregation.class); - } else if (aggregationType.equals(AggregationType.TERM.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryTermAggregation.class); - } else if (aggregationType.equals(AggregationType.FILTER.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryFilterAggregation.class); - } else if (aggregationType.equals(AggregationType.NESTED.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryNestedAggregation.class); - } else if (aggregationType.equals(AggregationType.TIMESLICE.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryTimesliceAggregation.class); - } else if (aggregationType.equals(AggregationType.TOP_HITS.getName())) { - aggregation = GsonSingleton.getGson().fromJson(json, QueryTopHitsAggregation.class); - } else { - aggregation = GsonSingleton.getGson().fromJson(json, GenericQueryAggregation.class); - } - - return aggregation; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/query/GenericQueryAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/query/GenericQueryAggregation.java deleted file mode 100644 index 33d652b461e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/query/GenericQueryAggregation.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ibm.watson.discovery.v2.query; - -import com.ibm.watson.discovery.v2.model.QueryAggregation; - -/** - * Catch-all class for query aggregations which can't be identified and deserialized to a known class. - * - * @deprecated This class is no longer necessary with the built-in deserialization logic in the QueryAggregation class. - */ -public class GenericQueryAggregation extends QueryAggregation { -} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java deleted file mode 100644 index 731843fee46..00000000000 --- a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java +++ /dev/null @@ -1,2207 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1; - -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.internal.LazilyParsedNumber; -import com.ibm.cloud.sdk.core.http.HttpConfigOptions; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.BasicAuthenticator; -import com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.cloud.sdk.core.service.exception.BadRequestException; -import com.ibm.cloud.sdk.core.service.exception.InternalServerErrorException; -import com.ibm.cloud.sdk.core.service.exception.NotFoundException; -import com.ibm.cloud.sdk.core.service.exception.UnauthorizedException; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.common.RetryRunner; -import com.ibm.watson.common.WaitFor; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.discovery.v1.model.AddDocumentOptions; -import com.ibm.watson.discovery.v1.model.AddTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.Calculation; -import com.ibm.watson.discovery.v1.model.Collection; -import com.ibm.watson.discovery.v1.model.Completions; -import com.ibm.watson.discovery.v1.model.Configuration; -import com.ibm.watson.discovery.v1.model.Conversions; -import com.ibm.watson.discovery.v1.model.CreateCollectionOptions; -import com.ibm.watson.discovery.v1.model.CreateConfigurationOptions; -import com.ibm.watson.discovery.v1.model.CreateCredentialsOptions; -import com.ibm.watson.discovery.v1.model.CreateEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.CreateEventOptions; -import com.ibm.watson.discovery.v1.model.CreateEventResponse; -import com.ibm.watson.discovery.v1.model.CreateExpansionsOptions; -import com.ibm.watson.discovery.v1.model.CreateGatewayOptions; -import com.ibm.watson.discovery.v1.model.CreateStopwordListOptions; -import com.ibm.watson.discovery.v1.model.CreateTokenizationDictionaryOptions; -import com.ibm.watson.discovery.v1.model.CreateTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.CredentialDetails; -import com.ibm.watson.discovery.v1.model.Credentials; -import com.ibm.watson.discovery.v1.model.CredentialsList; -import com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.DeleteCollectionOptions; -import com.ibm.watson.discovery.v1.model.DeleteConfigurationOptions; -import com.ibm.watson.discovery.v1.model.DeleteCredentialsOptions; -import com.ibm.watson.discovery.v1.model.DeleteDocumentOptions; -import com.ibm.watson.discovery.v1.model.DeleteEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.DeleteExpansionsOptions; -import com.ibm.watson.discovery.v1.model.DeleteGatewayOptions; -import com.ibm.watson.discovery.v1.model.DeleteStopwordListOptions; -import com.ibm.watson.discovery.v1.model.DeleteTokenizationDictionaryOptions; -import com.ibm.watson.discovery.v1.model.DeleteTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.DeleteTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.DeleteUserDataOptions; -import com.ibm.watson.discovery.v1.model.DocumentAccepted; -import com.ibm.watson.discovery.v1.model.DocumentStatus; -import com.ibm.watson.discovery.v1.model.Enrichment; -import com.ibm.watson.discovery.v1.model.EnrichmentOptions; -import com.ibm.watson.discovery.v1.model.Environment; -import com.ibm.watson.discovery.v1.model.EventData; -import com.ibm.watson.discovery.v1.model.Expansion; -import com.ibm.watson.discovery.v1.model.Expansions; -import com.ibm.watson.discovery.v1.model.Filter; -import com.ibm.watson.discovery.v1.model.Gateway; -import com.ibm.watson.discovery.v1.model.GatewayList; -import com.ibm.watson.discovery.v1.model.GetAutocompletionOptions; -import com.ibm.watson.discovery.v1.model.GetCollectionOptions; -import com.ibm.watson.discovery.v1.model.GetConfigurationOptions; -import com.ibm.watson.discovery.v1.model.GetCredentialsOptions; -import com.ibm.watson.discovery.v1.model.GetDocumentStatusOptions; -import com.ibm.watson.discovery.v1.model.GetEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.GetGatewayOptions; -import com.ibm.watson.discovery.v1.model.GetStopwordListStatusOptions; -import com.ibm.watson.discovery.v1.model.GetTokenizationDictionaryStatusOptions; -import com.ibm.watson.discovery.v1.model.GetTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.GetTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.Histogram; -import com.ibm.watson.discovery.v1.model.HtmlSettings; -import com.ibm.watson.discovery.v1.model.ListCollectionFieldsOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionFieldsResponse; -import com.ibm.watson.discovery.v1.model.ListCollectionsOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionsResponse; -import com.ibm.watson.discovery.v1.model.ListConfigurationsOptions; -import com.ibm.watson.discovery.v1.model.ListConfigurationsResponse; -import com.ibm.watson.discovery.v1.model.ListCredentialsOptions; -import com.ibm.watson.discovery.v1.model.ListEnvironmentsOptions; -import com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse; -import com.ibm.watson.discovery.v1.model.ListExpansionsOptions; -import com.ibm.watson.discovery.v1.model.ListGatewaysOptions; -import com.ibm.watson.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.LogQueryResponse; -import com.ibm.watson.discovery.v1.model.MetricResponse; -import com.ibm.watson.discovery.v1.model.MetricTokenResponse; -import com.ibm.watson.discovery.v1.model.Nested; -import com.ibm.watson.discovery.v1.model.NluEnrichmentEmotion; -import com.ibm.watson.discovery.v1.model.NluEnrichmentEntities; -import com.ibm.watson.discovery.v1.model.NluEnrichmentFeatures; -import com.ibm.watson.discovery.v1.model.NluEnrichmentKeywords; -import com.ibm.watson.discovery.v1.model.NluEnrichmentSemanticRoles; -import com.ibm.watson.discovery.v1.model.NluEnrichmentSentiment; -import com.ibm.watson.discovery.v1.model.NormalizationOperation; -import com.ibm.watson.discovery.v1.model.NormalizationOperation.Operation; -import com.ibm.watson.discovery.v1.model.QueryAggregation; -import com.ibm.watson.discovery.v1.model.QueryNoticesOptions; -import com.ibm.watson.discovery.v1.model.QueryNoticesResponse; -import com.ibm.watson.discovery.v1.model.QueryOptions; -import com.ibm.watson.discovery.v1.model.QueryPassages; -import com.ibm.watson.discovery.v1.model.QueryResponse; -import com.ibm.watson.discovery.v1.model.Term; -import com.ibm.watson.discovery.v1.model.Timeslice; -import com.ibm.watson.discovery.v1.model.TokenDictRule; -import com.ibm.watson.discovery.v1.model.TokenDictStatusResponse; -import com.ibm.watson.discovery.v1.model.TopHits; -import com.ibm.watson.discovery.v1.model.TrainingDataSet; -import com.ibm.watson.discovery.v1.model.TrainingExample; -import com.ibm.watson.discovery.v1.model.TrainingQuery; -import com.ibm.watson.discovery.v1.model.UpdateCollectionOptions; -import com.ibm.watson.discovery.v1.model.UpdateConfigurationOptions; -import com.ibm.watson.discovery.v1.model.UpdateCredentialsOptions; -import com.ibm.watson.discovery.v1.model.UpdateDocumentOptions; -import com.ibm.watson.discovery.v1.model.UpdateEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.UpdateTrainingExampleOptions; -import com.ibm.watson.discovery.query.AggregationType; -import com.ibm.watson.discovery.query.Operator; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Integration tests for {@link Discovery}. - */ -@RunWith(RetryRunner.class) -public class DiscoveryServiceIT extends WatsonServiceTest { - - private static final String DISCOVERY1_TEST_CONFIG_FILE = "src/test/resources/discovery/v1/issue517.json"; - private static final String DISCOVERY2_TEST_CONFIG_FILE = "src/test/resources/discovery/v1/issue518.json"; - private static final String PASSAGES_TEST_FILE_1 = "src/test/resources/discovery/v1/passages_test_doc_1.json"; - private static final String PASSAGES_TEST_FILE_2 = "src/test/resources/discovery/v1/passages_test_doc_2.json"; - private static final String STOPWORDS_TEST_FILE = "src/test/resources/discovery/v1/stopwords.txt"; - private static String environmentId; - private static String collectionId; - private Discovery discovery; - private String uniqueName; - - private Set configurationIds = new HashSet<>(); - private Set collectionIds = new HashSet<>(); - - private static DiscoveryServiceIT dummyTest; - - @BeforeClass - public static void setupClass() throws Exception { - // get the properties - dummyTest = new DiscoveryServiceIT(); - String apiKey = dummyTest.getProperty("discovery.apikey"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); - - dummyTest.setup(); - - ListEnvironmentsOptions listOptions = new ListEnvironmentsOptions.Builder().build(); - ListEnvironmentsResponse listResponse = dummyTest.discovery.listEnvironments(listOptions).execute().getResult(); - for (Environment environment : listResponse.getEnvironments()) { - // look for an existing environment that isn't read only - if (!environment.isReadOnly()) { - environmentId = environment.getEnvironmentId(); - break; - } - } - - if (environmentId == null) { - // no environment found, create a new one (assuming we are a FREE plan) - String environmentName = "watson_developer_cloud_test_environment"; - CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder() - .name(environmentName).build(); - Environment createResponse = dummyTest.discovery.createEnvironment(createOptions).execute().getResult(); - environmentId = createResponse.getEnvironmentId(); - WaitFor.Condition environmentReady = new EnvironmentReady(dummyTest.discovery, environmentId); - WaitFor.waitFor(environmentReady, 30, TimeUnit.SECONDS, 500); - } - - collectionId = dummyTest.setupTestDocuments(); - } - - @AfterClass - public static void cleanupClass() throws Exception { - dummyTest.cleanup(); - } - - @Before - public void setup() throws Exception { - super.setUp(); - String apiKey = getProperty("discovery.apikey"); - String url = getProperty("discovery.url"); - Authenticator authenticator = new IamAuthenticator(apiKey); - discovery = new Discovery("2019-04-30", authenticator); - discovery.setServiceUrl(url); - discovery.setDefaultHeaders(getDefaultHeaders()); - - uniqueName = UUID.randomUUID().toString(); - } - - @After - public void cleanup() { - for (String collectionId : collectionIds) { - DeleteCollectionOptions deleteOptions = new DeleteCollectionOptions.Builder(environmentId, collectionId).build(); - try { - discovery.deleteCollection(deleteOptions).execute(); - } catch (NotFoundException ex) { - // Ignore this failure - just print msg - System.out.println("deleteCollection failed. Collection " + collectionId + " not found"); - } - } - - for (String configurationId : configurationIds) { - DeleteConfigurationOptions deleteOptions = new DeleteConfigurationOptions.Builder(environmentId, configurationId) - .build(); - try { - discovery.deleteConfiguration(deleteOptions).execute(); - } catch (NotFoundException ex) { - // Ignore this failure - just print msg - System.out.println("deleteConfiguration failed. Configuration " + configurationId + " not found"); - } - } - } - - public boolean ping() throws RuntimeException { - discovery.listEnvironments(null).execute().getResult(); - return true; - } - - private static final String DEFAULT_CONFIG_NAME = "Default Configuration"; - - @Test - public void exampleIsSuccessful() { - // Discovery discovery = new Discovery("2016-12-15"); - // discovery.setServiceUrl("https://gateway.watsonplatform.net/discovery/api"); - // discovery.setUsernameAndPassword("", " normalizations = Collections.singletonList(operation); - - NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment.Builder() - .document(true) - .build(); - NluEnrichmentEmotion emotion = new NluEnrichmentEmotion.Builder() - .document(true) - .build(); - NluEnrichmentEntities entities = new NluEnrichmentEntities.Builder() - .emotion(true) - .sentiment(true) - .model("WhatComesAfterQux") - .build(); - NluEnrichmentKeywords keywords = new NluEnrichmentKeywords.Builder() - .emotion(true) - .sentiment(true) - .build(); - NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles.Builder() - .entities(true) - .build(); - NluEnrichmentFeatures features = new NluEnrichmentFeatures.Builder() - .sentiment(sentiment) - .emotion(emotion) - .entities(entities) - .keywords(keywords) - .semanticRoles(semanticRoles) - .build(); - EnrichmentOptions options = new EnrichmentOptions.Builder() - .features(features) - .language(EnrichmentOptions.Language.EN) - .build(); - - Enrichment enrichment = new Enrichment.Builder() - .sourceField("foo") - .destinationField("bar") - .enrichment("baz") - .description("Erich foo to bar with baz") - .ignoreDownstreamErrors(true) - .overwrite(false) - .options(options) - .build(); - List enrichments = Collections.singletonList(enrichment); - - CreateConfigurationOptions createOptions = new CreateConfigurationOptions.Builder() - .environmentId(environmentId) - .name(uniqueConfigName) - .description(description) - .conversions(conversionsBuilder.build()) - .normalizations(normalizations) - .enrichments(enrichments) - .build(); - Configuration createResponse = createConfiguration(createOptions); - - assertEquals(uniqueConfigName, createResponse.name()); - assertEquals(description, createResponse.description()); - assertEquals(conversionsBuilder.build(), createResponse.conversions()); - assertEquals(normalizations, createResponse.normalizations()); - assertEquals(enrichments, createResponse.enrichments()); - - Date now = new Date(); - assertTrue(fuzzyBefore(createResponse.created(), now)); - assertTrue(fuzzyAfter(createResponse.created(), start)); - assertTrue(fuzzyBefore(createResponse.updated(), now)); - assertTrue(fuzzyAfter(createResponse.updated(), start)); - - } - - @Test - public void deleteConfigurationIsSuccessful() { - Configuration createResponse = createTestConfig(); - - DeleteConfigurationOptions deleteOptions = new DeleteConfigurationOptions.Builder(environmentId, createResponse - .configurationId()).build(); - deleteConfiguration(deleteOptions); - } - - @Test - public void getConfigurationIsSuccessful() { - Configuration createResponse = createTestConfig(); - - GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse - .configurationId()).build(); - Configuration getResponse = discovery.getConfiguration(getOptions).execute().getResult(); - - assertEquals(createResponse.name(), getResponse.name()); - } - - @Test - public void getConfigurationsByNameIsSuccessful() { - Configuration createResponse = createTestConfig(); - - ListConfigurationsOptions.Builder getBuilder = new ListConfigurationsOptions.Builder(environmentId); - getBuilder.name(createResponse.name()); - ListConfigurationsResponse getResponse = discovery.listConfigurations(getBuilder.build()).execute().getResult(); - - assertEquals(1, getResponse.getConfigurations().size()); - assertEquals(createResponse.name(), getResponse.getConfigurations().get(0).name()); - } - - @Test - public void getConfigurationsWithFunkyNameIsSuccessful() { - String uniqueConfigName = uniqueName + " with \"funky\" ?x=y&foo=bar ,[x](y) ~!@#$%^&*()-+ {} | ;:<>\\/ chars"; - - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId, - uniqueConfigName); - createConfiguration(createBuilder.build()); - - ListConfigurationsOptions.Builder getBuilder = new ListConfigurationsOptions.Builder(environmentId); - getBuilder.name(uniqueConfigName); - ListConfigurationsResponse getResponse = discovery.listConfigurations(getBuilder.build()).execute().getResult(); - - assertEquals(1, getResponse.getConfigurations().size()); - assertEquals(uniqueConfigName, getResponse.getConfigurations().get(0).name()); - } - - @Test - public void updateConfigurationIsSuccessful() { - - Configuration testConfig = createTestConfig(); - - Date start = new Date(); - - String updatedName = testConfig.name() + UUID.randomUUID().toString(); - String updatedDescription = "Description of " + updatedName; - HtmlSettings newHtmlSettings = new HtmlSettings.Builder() - .excludeTagsCompletely(Arrays.asList("table", "h6", "header")) - .build(); - Conversions updatedConversions = new Conversions.Builder() - .html(newHtmlSettings) - .build(); - NormalizationOperation operation = new NormalizationOperation.Builder() - .operation("foo") - .sourceField("bar") - .destinationField("baz") - .build(); - List updatedNormalizations = Arrays.asList(operation); - - NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment.Builder() - .document(true) - .build(); - NluEnrichmentEmotion emotion = new NluEnrichmentEmotion.Builder() - .document(true) - .build(); - NluEnrichmentEntities entities = new NluEnrichmentEntities.Builder() - .emotion(true) - .sentiment(true) - .model("WhatComesAfterQux") - .build(); - NluEnrichmentKeywords keywords = new NluEnrichmentKeywords.Builder() - .emotion(true) - .sentiment(true) - .build(); - NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles.Builder() - .entities(true) - .build(); - NluEnrichmentFeatures features = new NluEnrichmentFeatures.Builder() - .sentiment(sentiment) - .emotion(emotion) - .entities(entities) - .keywords(keywords) - .semanticRoles(semanticRoles) - .build(); - EnrichmentOptions options = new EnrichmentOptions.Builder() - .features(features) - .build(); - - Enrichment enrichment = new Enrichment.Builder() - .sourceField("foo") - .destinationField("bar") - .enrichment("baz") - .description("Erich foo to bar with baz") - .ignoreDownstreamErrors(true) - .overwrite(false) - .options(options) - .build(); - List updatedEnrichments = Collections.singletonList(enrichment); - - UpdateConfigurationOptions.Builder updateBuilder = new UpdateConfigurationOptions.Builder(environmentId, testConfig - .configurationId(), updatedName); - updateBuilder.description(updatedDescription); - updateBuilder.conversions(updatedConversions); - updateBuilder.normalizations(updatedNormalizations); - updateBuilder.enrichments(updatedEnrichments); - Configuration updatedConfiguration = discovery.updateConfiguration(updateBuilder.build()).execute().getResult(); - - assertEquals(updatedName, updatedConfiguration.name()); - assertEquals(updatedDescription, updatedConfiguration.description()); - assertEquals(updatedConversions, updatedConfiguration.conversions()); - assertEquals(updatedNormalizations, updatedConfiguration.normalizations()); - assertEquals(updatedEnrichments, updatedConfiguration.enrichments()); - - Date now = new Date(); - assertTrue(fuzzyBefore(updatedConfiguration.created(), start)); - assertTrue(fuzzyBefore(updatedConfiguration.updated(), now)); - assertTrue(fuzzyAfter(updatedConfiguration.updated(), start)); - } - - // Collections - - @Test - public void listCollectionsIsSuccessful() { - createTestCollection(); - ListCollectionsOptions listOptions = new ListCollectionsOptions.Builder(environmentId).build(); - ListCollectionsResponse listResponse = discovery.listCollections(listOptions).execute().getResult(); - - assertFalse(listResponse.getCollections().isEmpty()); - } - - @Test - public void createCollectionIsSuccessful() { - Configuration createConfigResponse = createTestConfig(); - - String uniqueCollectionName = uniqueName + "-collection"; - String uniqueCollectionDescription = "Description of " + uniqueCollectionName; - - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.configurationId()) - .description(uniqueCollectionDescription); - Collection createResponse = createCollection(createCollectionBuilder.build()); - - assertEquals(createConfigResponse.configurationId(), createResponse.getConfigurationId()); - assertEquals(uniqueCollectionName, createResponse.getName()); - assertEquals(uniqueCollectionDescription, createResponse.getDescription()); - } - - @Test - public void createCollectionWithMinimalParametersIsSuccessful() { - String uniqueCollectionName = uniqueName + "-collection"; - CreateCollectionOptions createOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName) - .build(); - Collection createResponse = createCollection(createOptions); - - assertNotNull(createResponse.getCollectionId()); - } - - @Test - public void updateCollectionIsSuccessful() { - String uniqueCollectionName = uniqueName + "-collection"; - CreateCollectionOptions createOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName) - .build(); - Collection collection = createCollection(createOptions); - assertNotNull(collection.getCollectionId()); - - Configuration testConfig = createTestConfig(); - String updatedCollectionName = UUID.randomUUID().toString() + "-collection"; - String updatedCollectionDescription = "Description for " + updatedCollectionName; - String newCollectionId = collection.getCollectionId(); - - UpdateCollectionOptions updateOptions = new UpdateCollectionOptions.Builder() - .environmentId(environmentId) - .collectionId(newCollectionId) - .name(updatedCollectionName) - .description(updatedCollectionDescription) - .configurationId(testConfig.configurationId()) - .build(); - Collection updatedCollection = discovery.updateCollection(updateOptions).execute().getResult(); - - assertEquals(updatedCollectionName, updatedCollection.getName()); - assertEquals(updatedCollectionDescription, updatedCollection.getDescription()); - assertEquals(testConfig.configurationId(), updatedCollection.getConfigurationId()); - } - - @Test - public void deleteCollectionIsSuccessful() { - Configuration createConfigResponse = createTestConfig(); - - String uniqueCollectionName = uniqueName + "-collection"; - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.configurationId()); - Collection createResponse = createCollection(createCollectionBuilder.build()); - - // need to wait for collection to be ready - - DeleteCollectionOptions deleteOptions = new DeleteCollectionOptions.Builder(environmentId, createResponse - .getCollectionId()).build(); - deleteCollection(deleteOptions); - } - - @Test - public void getCollectionIsSuccessful() { - Configuration createConfigResponse = createTestConfig(); - - String uniqueCollectionName = uniqueName + "-collection"; - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.configurationId()); - Collection createResponse = createCollection(createCollectionBuilder.build()); - - GetCollectionOptions getOptions = new GetCollectionOptions.Builder(environmentId, createResponse.getCollectionId()) - .build(); - - // need to wait for collection to be ready - - Collection getResponse = discovery.getCollection(getOptions).execute().getResult(); - - assertEquals(createResponse.getName(), getResponse.getName()); - } - - @Test - public void getCollectionsByNameIsSuccessful() { - Configuration createConfigResponse = createTestConfig(); - - String uniqueCollectionName = uniqueName + "-collection"; - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.configurationId()); - createCollection(createCollectionBuilder.build()); - - ListCollectionsOptions.Builder getBuilder = new ListCollectionsOptions.Builder(environmentId); - getBuilder.name(uniqueCollectionName); - ListCollectionsResponse getResponse = discovery.listCollections(getBuilder.build()).execute().getResult(); - - assertEquals(1, getResponse.getCollections().size()); - assertEquals(uniqueCollectionName, getResponse.getCollections().get(0).getName()); - } - - @SuppressWarnings("deprecation") - @Test - public void addDocumentIsSuccessful() { - String myDocumentJson = "{\"field\":\"value\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(); - builder.environmentId(environmentId); - builder.collectionId(collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename(UUID.randomUUID().toString()); - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute().getResult(); - - assertFalse(createResponse.getDocumentId().isEmpty()); - assertNull(createResponse.getNotices()); - } - - @Test - public void addDocumentWithConfigurationIsSuccessful() { - uniqueName = UUID.randomUUID().toString(); - - String myDocumentJson = "{\"field\":\"value\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(); - builder.environmentId(environmentId); - builder.collectionId(collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename(UUID.randomUUID().toString()); - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute().getResult(); - - assertFalse(createResponse.getDocumentId().isEmpty()); - assertNull(createResponse.getNotices()); - } - - @Ignore - @SuppressWarnings("deprecation") - @Test - public void addDocumentWithMetadataIsSuccessful() { - String myDocumentJson = "{\"field\":\"value\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename(UUID.randomUUID().toString()); - builder.metadata(myMetadata.toString()); - - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute().getResult(); - - WaitFor.Condition documentAccepted = new WaitForDocumentAccepted(environmentId, collectionId, createResponse - .getDocumentId()); - WaitFor.waitFor(documentAccepted, 5, TimeUnit.SECONDS, 500); - - QueryOptions queryOptions = new QueryOptions.Builder(environmentId, collectionId).build(); - QueryResponse queryResponse = discovery.query(queryOptions).execute().getResult(); - - assertTrue(queryResponse.getResults().get(0).getMetadata() != null); - } - - @Ignore - @Test - public void deleteDocumentIsSuccessful() { - DocumentAccepted createResponse = createTestDocument(collectionId); - String documentId = createResponse.getDocumentId(); - - WaitFor.Condition documentAccepted = new WaitForDocumentAccepted(environmentId, collectionId, documentId); - WaitFor.waitFor(documentAccepted, 5, TimeUnit.SECONDS, 500); - - DeleteDocumentOptions deleteOptions = new DeleteDocumentOptions.Builder(environmentId, collectionId, documentId) - .build(); - discovery.deleteDocument(deleteOptions).execute(); - } - - @Ignore - @Test - public void getDocumentIsSuccessful() { - DocumentAccepted documentAccepted = createTestDocument(collectionId); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - documentAccepted.getDocumentId()).build(); - DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute().getResult(); - - assertEquals(DocumentStatus.Status.AVAILABLE, getResponse.getStatus()); - } - - @Test - public void updateDocumentIsSuccessful() { - DocumentAccepted documentAccepted = createTestDocument(collectionId); - - uniqueName = UUID.randomUUID().toString(); - String myDocumentJson = "{\"field\":\"value2\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - UpdateDocumentOptions.Builder updateBuilder = new UpdateDocumentOptions.Builder(environmentId, collectionId, - documentAccepted.getDocumentId()); - updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - updateBuilder.filename(UUID.randomUUID().toString()); - DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute().getResult(); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - updateResponse.getDocumentId()).build(); - DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute().getResult(); - - assertNotNull(getResponse); - } - - @Test - public void updateAnotherDocumentIsSuccessful() { - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.metadata(myMetadata.toString()); - DocumentAccepted documentAccepted = discovery.addDocument(builder.build()).execute().getResult(); - - String myDocumentJson = "{\"field\":\"value2\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - UpdateDocumentOptions.Builder updateBuilder = new UpdateDocumentOptions.Builder(environmentId, collectionId, - documentAccepted.getDocumentId()); - updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - updateBuilder.filename(UUID.randomUUID().toString()); - DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute().getResult(); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - updateResponse.getDocumentId()).build(); - DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute().getResult(); - - assertNotNull(getResponse); - } - - @Test - @Ignore("Pending implementation of 'processing' after document update") - public void updateDocumentWithMetadataIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - DocumentAccepted documentAccepted = createTestDocument(collectionId); - - String myDocumentJson = "{\"field\":\"value2\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - - UpdateDocumentOptions.Builder updateBuilder = new UpdateDocumentOptions.Builder(environmentId, collectionId, - documentAccepted.getDocumentId()); - updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - updateBuilder.metadata(myMetadata.toString()); - DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute().getResult(); - - WaitFor.Condition waitForDocumentAccepted = new WaitForDocumentAccepted(environmentId, collectionId, updateResponse - .getDocumentId()); - WaitFor.waitFor(waitForDocumentAccepted, 5, TimeUnit.SECONDS, 500); - - QueryOptions queryOptions = new QueryOptions.Builder(environmentId, collectionId).build(); - QueryResponse queryResponse = discovery.query(queryOptions).execute().getResult(); - - assertTrue(queryResponse.getResults().get(0).getMetadata() != null); - } - - @Ignore - @Test - public void getCollectionFieldsIsSuccessful() { - ListCollectionFieldsOptions getOptions = new ListCollectionFieldsOptions.Builder(environmentId, collectionId) - .build(); - ListCollectionFieldsResponse getResponse = discovery.listCollectionFields(getOptions).execute().getResult(); - - assertFalse(getResponse.getFields().isEmpty()); - } - - // query tests - - @Test - public void queryWithCountIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.count(5L); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - assertTrue(queryResponse.getMatchingResults() > 0); - } - - @Test - public void queryWithOffsetIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.offset(5L); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - assertTrue(queryResponse.getMatchingResults() > 0); - } - - @Ignore - @Test - public void queryWithQueryIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.query("field" + Operator.CONTAINS + 1); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - assertEquals(new Long(1), queryResponse.getMatchingResults()); - assertEquals(1, queryResponse.getResults().size()); - } - - @Test - public void queryWithFilterIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.filter("field" + Operator.CONTAINS + 1); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - assertEquals(new Long(1), queryResponse.getMatchingResults()); - assertEquals(1, queryResponse.getResults().size()); - } - - @Test - public void queryWithSortIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - String sortList = "field"; - queryBuilder.sort(sortList); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - assertTrue(queryResponse.getResults().size() > 1); - int v0 = ((LazilyParsedNumber) queryResponse.getResults().get(0).get("field")).intValue(); - int v1 = ((LazilyParsedNumber) queryResponse.getResults().get(1).get("field")).intValue(); - assertTrue(v0 <= v1); - } - - @Test - public void queryWithAggregationTermIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.TERM); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.AND); - sb.append(10L); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Term term = (Term) queryResponse.getAggregations().get(0); - assertEquals(1, queryResponse.getAggregations().size()); - assertEquals(new Long(10), term.getCount()); - } - - @Test - public void queryWithAggregationHistogramIsSuccessful() throws InterruptedException { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.HISTOGRAM); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.AND); - sb.append(5L); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Histogram histogram = (Histogram) queryResponse.getAggregations().get(0); - Long interval = histogram.getInterval(); - assertEquals(new Long(5), interval); - assertEquals(2, histogram.getResults().size()); - } - - @Test - public void queryWithAggregationMaximumIsSuccessful() throws InterruptedException { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.MAX); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Calculation max = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.MAX.getName(), max.getType()); - assertEquals(new Double(9), max.getValue()); - } - - @Test - public void queryWithAggregationMinimumIsSuccessful() throws InterruptedException { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.MIN); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Calculation min = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.MIN.getName(), min.getType()); - assertEquals(new Double(0), min.getValue()); - } - - @Test - public void queryWithAggregationSummationIsSuccessful() throws InterruptedException { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.SUM); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Calculation sum = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.SUM.getName(), sum.getType()); - assertEquals(new Double(45), sum.getValue()); - } - - @Test - public void queryWithAggregationAverageIsSuccessful() throws InterruptedException { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.AVERAGE); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Calculation avg = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.AVERAGE.getName(), avg.getType()); - assertEquals(new Double(4.5), avg.getValue()); - } - - @Test - public void queryWithAggregationFilterIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.FILTER); - sb.append(Operator.OPENING_GROUPING); - sb.append("field:9"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Filter filter = (Filter) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.FILTER.getName(), filter.getType()); - assertEquals("field:9", filter.getMatch()); - assertEquals(new Long(1), filter.getMatchingResults()); - } - - @Test - public void queryWithAggregationNestedIsSuccessful() throws InterruptedException { - DocumentAccepted testDocument = createNestedTestDocument(collectionId); - String documentId = testDocument.getDocumentId(); - - WaitFor.Condition documentAccepted = new WaitForDocumentAccepted(environmentId, collectionId, documentId); - WaitFor.waitFor(documentAccepted, 5, TimeUnit.SECONDS, 500); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.NESTED); - sb.append(Operator.OPENING_GROUPING); - sb.append("nested_fields"); - sb.append(Operator.CLOSING_GROUPING); - sb.append(Operator.NEST_AGGREGATION); - sb.append(AggregationType.TERM); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Nested nested = (Nested) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.NESTED.getName(), nested.getType()); - assertNotNull(nested.getAggregations()); - QueryAggregation innerAggregation = nested.getAggregations().get(0); - assertEquals(AggregationType.TERM.getName(), innerAggregation.getType()); - } - - @Test - public void queryWithAggregationTimesliceIsSuccessful() throws InterruptedException { - String myDocumentJson = "{\"time\":\"1999-02-16T00:00:00.000-05:00\"}"; - DocumentAccepted testDocument1 = createTestDocument(myDocumentJson, UUID.randomUUID().toString(), collectionId); - String documentId1 = testDocument1.getDocumentId(); - myDocumentJson = "{\"time\":\"1999-04-16T00:00:00.000-05:00\"}"; - DocumentAccepted testDocument2 = createTestDocument(myDocumentJson, UUID.randomUUID().toString(), collectionId); - String documentId2 = testDocument2.getDocumentId(); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.TIMESLICE); - sb.append(Operator.OPENING_GROUPING); - sb.append("time,1day,EST"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - - GetDocumentStatusOptions getOptions1 = new GetDocumentStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .documentId(documentId1) - .build(); - DocumentStatus status1 = discovery.getDocumentStatus(getOptions1).execute().getResult(); - GetDocumentStatusOptions getOptions2 = new GetDocumentStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .documentId(documentId2) - .build(); - DocumentStatus status2 = discovery.getDocumentStatus(getOptions2).execute().getResult(); - while (status1.getStatus().equals(DocumentAccepted.Status.PROCESSING) - || status2.getStatus().equals(DocumentAccepted.Status.PROCESSING)) { - Thread.sleep(3000); - status1 = discovery.getDocumentStatus(getOptions1).execute().getResult(); - status2 = discovery.getDocumentStatus(getOptions2).execute().getResult(); - } - - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Timeslice timeslice = (Timeslice) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.TIMESLICE.getName(), timeslice.getType()); - assertNotNull(timeslice.getResults()); - } - - @Test - public void queryWithAggregationTopHitsIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.TERM); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - sb.append(Operator.NEST_AGGREGATION); - sb.append(AggregationType.TOP_HITS); - sb.append(Operator.OPENING_GROUPING); - sb.append("3"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Term term = (Term) queryResponse.getAggregations().get(0); - TopHits topHits = (TopHits) term.getResults().get(0).getAggregations().get(0); - assertEquals(new Long(3), topHits.getSize()); - assertNotNull(topHits.getHits()); - } - - public void queryWithAggregationUniqueCountIsSuccessful() { - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.UNIQUE_COUNT); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - Calculation uniqueCount = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(new Double(10), uniqueCount.getValue()); - } - - @Test - public void queryWithPassagesIsSuccessful() throws InterruptedException, FileNotFoundException { - createTestDocument(getStringFromInputStream(new FileInputStream(PASSAGES_TEST_FILE_1)), - UUID.randomUUID().toString(), collectionId); - createTestDocument(getStringFromInputStream(new FileInputStream(PASSAGES_TEST_FILE_2)), - UUID.randomUUID().toString(), collectionId); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.passages(true); - queryBuilder.naturalLanguageQuery("Watson"); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - List passages = queryResponse.getPassages(); - assertNotNull(passages); - } - - // queryNotices tests - - @Test - public void queryNoticesCountIsSuccessful() { - QueryNoticesOptions.Builder queryBuilder = new QueryNoticesOptions.Builder(environmentId, collectionId); - queryBuilder.count(5L); - QueryNoticesResponse queryResponse = discovery.queryNotices(queryBuilder.build()).execute().getResult(); - assertTrue(queryResponse.getResults().size() <= 5); - } - - // Tests for reported issues - - @Test - public void issueNumber517() { - String uniqueConfigName = uniqueName + "-config"; - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(); - createBuilder.environmentId(environmentId); - Configuration configuration = getTestConfiguration(DISCOVERY1_TEST_CONFIG_FILE); - - configuration = configuration.newBuilder().name(uniqueConfigName).build(); - createBuilder.configuration(configuration); - Configuration createResponse = createConfiguration(createBuilder.build()); - - GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse - .configurationId()).build(); - Configuration getResponse = discovery.getConfiguration(getOptions).execute().getResult(); - - // returned config should have some json data - assertEquals(1, getResponse.conversions().jsonNormalizations().size()); - } - - @Test - public void issueNumber518() { - String[] operations = new String[] { Operation.MOVE, Operation.COPY, Operation.MERGE, Operation.REMOVE, - Operation.REMOVE_NULLS }; - - String uniqueConfigName = uniqueName + "-config"; - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(); - createBuilder.environmentId(environmentId); - Configuration configuration = getTestConfiguration(DISCOVERY2_TEST_CONFIG_FILE); - - configuration = configuration.newBuilder().name(uniqueConfigName).build(); - createBuilder.configuration(configuration); - Configuration createResponse = createConfiguration(createBuilder.build()); - - GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse - .configurationId()).build(); - Configuration getResponse = discovery.getConfiguration(getOptions).execute().getResult(); - - // verify getResponse deserializes the operations appropriately - for (NormalizationOperation normalization : getResponse.normalizations()) { - String operation = normalization.operation(); - assertEquals(true, Arrays.asList(operations).contains(operation)); - } - } - - @Test - public void issueNumber654() { - String collectionId = setupTestDocuments(); - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.query("field:1|3"); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - - assertEquals(new Long(2), queryResponse.getMatchingResults()); - assertEquals(2, queryResponse.getResults().size()); - } - - /* Issue 659: creating a collection does not use the configuration id */ - @Test - public void issueNumber659() { - String uniqueConfigName = UUID.randomUUID().toString() + "-config"; - CreateConfigurationOptions configOptions = new CreateConfigurationOptions.Builder() - .environmentId(environmentId) - .name(uniqueConfigName) - .build(); - Configuration configuration = discovery.createConfiguration(configOptions).execute().getResult(); - configurationIds.add(configuration.configurationId()); - - String uniqueCollectionName = UUID.randomUUID().toString() + "-collection"; - CreateCollectionOptions collectionOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName) - .configurationId(configuration.configurationId()) - .build(); - Collection collection = discovery.createCollection(collectionOptions).execute().getResult(); - collectionIds.add(collection.getCollectionId()); - - assertEquals(collection.getConfigurationId(), configuration.configurationId()); - } - - @Test - public void addTrainingDataIsSuccessful() { - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - String naturalLanguageQuery = "Example query" + UUID.randomUUID().toString(); - builder.naturalLanguageQuery(naturalLanguageQuery); - String documentId = createTestDocument(collectionId).getDocumentId(); - int relevance = 0; - TrainingExample example = new TrainingExample.Builder() - .documentId(documentId) - .relevance(relevance) - .build(); - builder.addExamples(example); - TrainingQuery response = discovery.addTrainingData(builder.build()).execute().getResult(); - - assertFalse(response.getQueryId().isEmpty()); - assertEquals(response.getNaturalLanguageQuery(), naturalLanguageQuery); - assertTrue(response.getFilter().isEmpty()); - assertEquals(response.getExamples().size(), 1); - - TrainingExample returnedExample = response.getExamples().get(0); - assertEquals(returnedExample.documentId(), documentId); - assertTrue(returnedExample.crossReference().isEmpty()); - assertEquals(returnedExample.relevance(), new Long(relevance)); - } - - @Test - public void addTrainingExampleIsSuccessful() { - TrainingQuery query = createTestQuery(collectionId, "Query" + UUID.randomUUID().toString()); - int startingExampleCount = query.getExamples().size(); - String queryId = query.getQueryId(); - - String documentId = "document_id"; - String crossReference = "cross_reference"; - int relevance = 50; - CreateTrainingExampleOptions.Builder exampleBuilder = new CreateTrainingExampleOptions.Builder(environmentId, - collectionId, queryId); - exampleBuilder.documentId(documentId); - exampleBuilder.crossReference(crossReference); - exampleBuilder.relevance(relevance); - discovery.createTrainingExample(exampleBuilder.build()).execute().getResult(); - - GetTrainingDataOptions.Builder queryBuilder = new GetTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - TrainingQuery updatedQuery = discovery.getTrainingData(queryBuilder.build()).execute().getResult(); - - assertTrue(updatedQuery.getExamples().size() > startingExampleCount); - TrainingExample newExample = updatedQuery.getExamples().get(0); - assertEquals(newExample.documentId(), documentId); - assertEquals(newExample.crossReference(), crossReference); - assertEquals(newExample.relevance(), new Long(relevance)); - } - - @Test - public void deleteAllCollectionTrainingDataIsSuccessful() { - String collId = setupTestQueries(collectionId); - DeleteAllTrainingDataOptions.Builder deleteBuilder = new DeleteAllTrainingDataOptions.Builder(environmentId, - collId); - discovery.deleteAllTrainingData(deleteBuilder.build()).execute(); - - ListTrainingDataOptions.Builder listBuilder = new ListTrainingDataOptions.Builder(environmentId, collId); - TrainingDataSet trainingData = discovery.listTrainingData(listBuilder.build()).execute().getResult(); - - assertEquals(trainingData.getQueries().size(), 0); - } - - @Test - public void deleteTrainingDataQueryIsSuccessful() { - TrainingQuery query = createTestQuery(collectionId, "Query" + UUID.randomUUID().toString()); - String queryId = query.getQueryId(); - - ListTrainingDataOptions.Builder listBuilder = new ListTrainingDataOptions.Builder(environmentId, collectionId); - TrainingDataSet trainingData = discovery.listTrainingData(listBuilder.build()).execute().getResult(); - List queryList = trainingData.getQueries(); - boolean doesQueryExist = false; - for (TrainingQuery q : queryList) { - if (q.getQueryId().equals(queryId)) { - doesQueryExist = true; - break; - } - } - assertTrue(doesQueryExist); - - DeleteTrainingDataOptions.Builder deleteBuilder = new DeleteTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - discovery.deleteTrainingData(deleteBuilder.build()).execute(); - - listBuilder = new ListTrainingDataOptions.Builder(environmentId, collectionId); - trainingData = discovery.listTrainingData(listBuilder.build()).execute().getResult(); - queryList = trainingData.getQueries(); - doesQueryExist = false; - for (TrainingQuery q : queryList) { - if (q.getQueryId().equals(queryId)) { - doesQueryExist = true; - break; - } - } - assertFalse(doesQueryExist); - } - - @Test - public void deleteTrainingDataExampleIsSuccessful() { - TrainingQuery newQuery = createTestQuery(collectionId, "Query" + UUID.randomUUID().toString()); - String queryId = newQuery.getQueryId(); - - String documentId = "document_id"; - String crossReference = "cross_reference"; - int relevance = 50; - CreateTrainingExampleOptions.Builder exampleBuilder = new CreateTrainingExampleOptions.Builder(environmentId, - collectionId, queryId); - exampleBuilder.documentId(documentId); - exampleBuilder.crossReference(crossReference); - exampleBuilder.relevance(relevance); - TrainingExample createdExample = discovery.createTrainingExample(exampleBuilder.build()).execute().getResult(); - String exampleId = createdExample.documentId(); - - GetTrainingDataOptions.Builder queryBuilder = new GetTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - TrainingQuery queryWithAddedExample = discovery.getTrainingData(queryBuilder.build()).execute().getResult(); - int startingCount = queryWithAddedExample.getExamples().size(); - - DeleteTrainingExampleOptions.Builder deleteBuilder = new DeleteTrainingExampleOptions.Builder(environmentId, - collectionId, queryId, exampleId); - discovery.deleteTrainingExample(deleteBuilder.build()).execute(); - - GetTrainingDataOptions.Builder newQueryBuilder = new GetTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - TrainingQuery queryWithDeletedExample = discovery.getTrainingData(newQueryBuilder.build()).execute().getResult(); - - assertTrue(startingCount > queryWithDeletedExample.getExamples().size()); - } - - @Test - public void getTrainingDataIsSuccessful() { - String naturalLanguageQuery = "Query" + UUID.randomUUID().toString(); - TrainingQuery newQuery = createTestQuery(collectionId, naturalLanguageQuery); - String queryId = newQuery.getQueryId(); - - GetTrainingDataOptions.Builder queryBuilder = new GetTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - TrainingQuery queryResponse = discovery.getTrainingData(queryBuilder.build()).execute().getResult(); - - assertEquals(queryResponse.getNaturalLanguageQuery(), naturalLanguageQuery); - } - - @Test - public void getTrainingExampleIsSuccessful() { - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - String naturalLanguageQuery = "Query" + UUID.randomUUID().toString(); - builder.naturalLanguageQuery(naturalLanguageQuery); - String documentId = "Document" + UUID.randomUUID().toString(); - int relevance = 0; - TrainingExample example = new TrainingExample.Builder() - .documentId(documentId) - .relevance(relevance) - .build(); - builder.addExamples(example); - TrainingQuery response = discovery.addTrainingData(builder.build()).execute().getResult(); - String queryId = response.getQueryId(); - - GetTrainingExampleOptions.Builder getExampleBuilder = new GetTrainingExampleOptions.Builder(environmentId, - collectionId, queryId, documentId); - TrainingExample returnedExample = discovery.getTrainingExample(getExampleBuilder.build()).execute().getResult(); - - assertEquals(returnedExample.documentId(), documentId); - } - - @Test - public void updateTrainingExampleIsSuccessful() { - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - String naturalLanguageQuery = "Query" + UUID.randomUUID().toString(); - builder.naturalLanguageQuery(naturalLanguageQuery); - String documentId = "Document" + UUID.randomUUID().toString(); - int relevance = 0; - TrainingExample example = new TrainingExample.Builder() - .documentId(documentId) - .relevance(relevance) - .build(); - builder.addExamples(example); - TrainingQuery response = discovery.addTrainingData(builder.build()).execute().getResult(); - String queryId = response.getQueryId(); - - UpdateTrainingExampleOptions.Builder updateBuilder = new UpdateTrainingExampleOptions.Builder(environmentId, - collectionId, queryId, documentId); - String newCrossReference = "cross_reference"; - updateBuilder.crossReference(newCrossReference); - int newRelevance = 50; - updateBuilder.relevance(newRelevance); - TrainingExample updatedExample = discovery.updateTrainingExample(updateBuilder.build()).execute().getResult(); - - assertEquals(updatedExample.crossReference(), newCrossReference); - assertEquals(updatedExample.relevance(), new Long(newRelevance)); - } - - @Test - public void expansionsOperationsAreSuccessful() { - List expansion1InputTerms = Arrays.asList("weekday", "week day"); - List expansion1ExpandedTerms = Arrays.asList("monday", "tuesday", "wednesday", "thursday", "friday"); - List expansion2InputTerms = Arrays.asList("weekend", "week end"); - List expansion2ExpandedTerms = Arrays.asList("saturday", "sunday"); - Expansion expansion1 = new Expansion.Builder() - .inputTerms(expansion1InputTerms) - .expandedTerms(expansion1ExpandedTerms) - .build(); - Expansion expansion2 = new Expansion.Builder() - .inputTerms(expansion2InputTerms) - .expandedTerms(expansion2ExpandedTerms) - .build(); - Expansions expansions = new Expansions.Builder() - .expansions(Arrays.asList(expansion1, expansion2)) - .build(); - CreateExpansionsOptions createOptions = new CreateExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .expansions(expansions) - .build(); - try { - Expansions createResults = discovery.createExpansions(createOptions).execute().getResult(); - assertEquals(createResults.expansions().size(), 2); - assertEquals(createResults.expansions().get(0).inputTerms(), expansion1InputTerms); - assertEquals(createResults.expansions().get(0).expandedTerms(), expansion1ExpandedTerms); - assertEquals(createResults.expansions().get(1).inputTerms(), expansion2InputTerms); - assertEquals(createResults.expansions().get(1).expandedTerms(), expansion2ExpandedTerms); - - ListExpansionsOptions listOptions = new ListExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - Expansions listResults = discovery.listExpansions(listOptions).execute().getResult(); - - assertEquals(listResults.expansions().size(), 2); - - DeleteExpansionsOptions deleteOptions = new DeleteExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - discovery.deleteExpansions(deleteOptions).execute(); - - Expansions emptyListResults = discovery.listExpansions(listOptions).execute().getResult(); - - assertTrue(emptyListResults.expansions().get(0).inputTerms() == null - || emptyListResults.expansions().get(0).inputTerms().isEmpty()); - assertTrue(emptyListResults.expansions().get(0).expandedTerms() == null - || emptyListResults.expansions().get(0).expandedTerms().get(0).isEmpty()); - } catch (InternalServerErrorException e) { - System.out.println("Internal server error while trying to create expansion ¯\\_(ツ)_/¯ Probably not our issue" - + " but may be worth looking into."); - e.printStackTrace(); - } - } - - @Test - public void deleteUserDataIsSuccessful() { - String customerId = "java_sdk_test_id"; - - try { - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); - discovery.deleteUserData(deleteOptions).execute(); - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - @Test - public void credentialsOperationsAreSuccessful() { - String url = "https://login.salesforce.com"; - String username = "test@username.com"; - String password = "test_password"; //pragma: whitelist secret - CredentialDetails credentialDetails = new CredentialDetails.Builder() - .credentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD) - .url(url) - .username(username) - .password(password) - .build(); - Credentials credentials = new Credentials.Builder() - .sourceType(Credentials.SourceType.SALESFORCE) - .credentialDetails(credentialDetails) - .build(); - - CreateCredentialsOptions createOptions = new CreateCredentialsOptions.Builder() - .environmentId(environmentId) - .credentials(credentials) - .build(); - Credentials createdCredentials = discovery.createCredentials(createOptions).execute().getResult(); - String credentialId = createdCredentials.credentialId(); - - // Create assertions - assertEquals(Credentials.SourceType.SALESFORCE, createdCredentials.sourceType()); - assertEquals(CredentialDetails.CredentialType.USERNAME_PASSWORD, - createdCredentials.credentialDetails().credentialType()); - assertEquals(url, createdCredentials.credentialDetails().url()); - assertEquals(username, createdCredentials.credentialDetails().username()); - - String newUrl = "https://newlogin.salesforce.com"; - CredentialDetails updatedDetails = new CredentialDetails.Builder() - .credentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD) - .url(newUrl) - .username(username) - .password(password) - .build(); - - UpdateCredentialsOptions updateOptions = new UpdateCredentialsOptions.Builder() - .environmentId(environmentId) - .credentialId(credentialId) - .sourceType(Credentials.SourceType.SALESFORCE) - .credentialDetails(updatedDetails) - .build(); - Credentials updatedCredentials = discovery.updateCredentials(updateOptions).execute().getResult(); - - // Update assertion - assertEquals(newUrl, updatedCredentials.credentialDetails().url()); - - GetCredentialsOptions getOptions = new GetCredentialsOptions.Builder() - .environmentId(environmentId) - .credentialId(credentialId) - .build(); - Credentials retrievedCredentials = discovery.getCredentials(getOptions).execute().getResult(); - - // Get assertions - assertEquals(Credentials.SourceType.SALESFORCE, retrievedCredentials.sourceType()); - assertEquals(CredentialDetails.CredentialType.USERNAME_PASSWORD, - retrievedCredentials.credentialDetails().credentialType()); - assertEquals(newUrl, retrievedCredentials.credentialDetails().url()); - assertEquals(username, retrievedCredentials.credentialDetails().username()); - - ListCredentialsOptions listOptions = new ListCredentialsOptions.Builder() - .environmentId(environmentId) - .build(); - CredentialsList credentialsList = discovery.listCredentials(listOptions).execute().getResult(); - - // List assertion - assertTrue(!credentialsList.getCredentials().isEmpty()); - - DeleteCredentialsOptions deleteOptions = new DeleteCredentialsOptions.Builder() - .environmentId(environmentId) - .credentialId(credentialId) - .build(); - discovery.deleteCredentials(deleteOptions).execute(); - } - - @Test - public void createEventIsSuccessful() { - // create test document - DocumentAccepted accepted = createTestDocument(collectionId); - - // make query to get session_token - QueryOptions queryOptions = new QueryOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .naturalLanguageQuery("field number 1") - .build(); - QueryResponse queryResponse = discovery.query(queryOptions).execute().getResult(); - String sessionToken = queryResponse.getSessionToken(); - - // make createEvent call - EventData eventData = new EventData.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .documentId(accepted.getDocumentId()) - .sessionToken(sessionToken) - .build(); - CreateEventOptions createEventOptions = new CreateEventOptions.Builder() - .type(CreateEventOptions.Type.CLICK) - .data(eventData) - .build(); - CreateEventResponse response = discovery.createEvent(createEventOptions).execute().getResult(); - - assertNotNull(response); - } - - @Test - public void queryLogIsSuccessful() { - LogQueryResponse response = discovery.queryLog().execute().getResult(); - assertNotNull(response); - } - - @Test - public void getMetricsEventRateIsSuccessful() { - MetricResponse response = discovery.getMetricsEventRate().execute().getResult(); - assertNotNull(response); - } - - @Test - public void getMetricsQueryIsSuccessful() { - MetricResponse response = discovery.getMetricsQuery().execute().getResult(); - assertNotNull(response); - } - - @Test - public void getMetricsQueryEventIsSuccessful() { - MetricResponse response = discovery.getMetricsQueryEvent().execute().getResult(); - assertNotNull(response); - } - - @Test - public void getMetricsQueryNoResultsIsSuccessful() { - MetricResponse response = discovery.getMetricsQueryNoResults().execute().getResult(); - assertNotNull(response); - } - - @Test - public void getMetricsQueryTokenEventIsSuccessful() { - MetricTokenResponse response = discovery.getMetricsQueryTokenEvent().execute().getResult(); - assertNotNull(response); - } - - @Test - public void tokenizationDictionaryOperationsAreSuccessful() throws InterruptedException { - // create collection first because creating a tokenization dictionary currently is only supported in Japanese - // collections - CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder() - .environmentId(environmentId) - .name("tokenization-dict-testing-collection " + UUID.randomUUID().toString()) - .language(CreateCollectionOptions.Language.JA) - .build(); - Collection tokenDictTestCollection = discovery.createCollection(createCollectionOptions).execute().getResult(); - String testCollectionId = tokenDictTestCollection.getCollectionId(); - - System.out.println("Test collection created!"); - - try { - TokenDictRule tokenDictRule = new TokenDictRule.Builder() - .text("token") - .partOfSpeech("noun") - .readings(Arrays.asList("reading_1", "reading_2")) - .tokens(Arrays.asList("token_1", "token_2")) - .build(); - - // the service doesn't seem to like when we try and move too fast - Thread.sleep(5000); - - // test creating tokenization dictionary - CreateTokenizationDictionaryOptions createOptions = new CreateTokenizationDictionaryOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .addTokenizationRules(tokenDictRule) - .build(); - TokenDictStatusResponse createResponse = discovery.createTokenizationDictionary(createOptions).execute() - .getResult(); - assertNotNull(createResponse); - - // test getting tokenization dictionary - GetTokenizationDictionaryStatusOptions getOptions = new GetTokenizationDictionaryStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .build(); - TokenDictStatusResponse getResponse = discovery.getTokenizationDictionaryStatus(getOptions).execute().getResult(); - assertNotNull(getResponse); - - Thread.sleep(5000); - - // test deleting tokenization dictionary - DeleteTokenizationDictionaryOptions deleteOptions = new DeleteTokenizationDictionaryOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .build(); - discovery.deleteTokenizationDictionary(deleteOptions).execute(); - } catch (BadRequestException ex) { - // this most likely means the environment wasn't ready to handle another tokenization file - this is fine - System.out.println("Service wasn't ready yet! Error: " + ex.getMessage()); - } finally { - // delete test collection - DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .build(); - discovery.deleteCollection(deleteCollectionOptions).execute(); - - System.out.println("Test collection deleted"); - } - } - - @Test - public void stopwordListOperationsAreSuccessful() throws FileNotFoundException, InterruptedException { - CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder() - .environmentId(environmentId) - .name("stopword-list-testing-collection " + UUID.randomUUID().toString()) - .language(CreateCollectionOptions.Language.EN) - .build(); - Collection tokenDictTestCollection = discovery.createCollection(createCollectionOptions).execute().getResult(); - String testCollectionId = tokenDictTestCollection.getCollectionId(); - System.out.println("Test collection created!"); - - try { - CreateStopwordListOptions createStopwordListOptions = new CreateStopwordListOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .stopwordFile(new FileInputStream(STOPWORDS_TEST_FILE)) - .stopwordFilename("test_stopword_file") - .build(); - TokenDictStatusResponse createResponse = discovery.createStopwordList(createStopwordListOptions).execute() - .getResult(); - assertEquals("stopwords", createResponse.getType()); - - GetStopwordListStatusOptions getStopwordListStatusOptions = new GetStopwordListStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .build(); - TokenDictStatusResponse getResponse = discovery.getStopwordListStatus(getStopwordListStatusOptions).execute() - .getResult(); - assertEquals("stopwords", getResponse.getType()); - - DeleteStopwordListOptions deleteStopwordListOptions = new DeleteStopwordListOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .build(); - discovery.deleteStopwordList(deleteStopwordListOptions).execute(); - } catch (BadRequestException ex) { - // this most likely means the environment wasn't ready to handle another stopwords file - this is fine - System.out.println("Service wasn't ready yet! Error: " + ex.getMessage()); - } finally { - DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder() - .environmentId(environmentId) - .collectionId(testCollectionId) - .build(); - discovery.deleteCollection(deleteCollectionOptions).execute(); - System.out.println("Test collection deleted"); - } - } - - @Test - public void gatewayOperationsAreSuccessful() { - String gatewayName = "java-sdk-test-gateway"; - - ListGatewaysOptions listGatewaysOptions = new ListGatewaysOptions.Builder() - .environmentId(environmentId) - .build(); - GatewayList gatewayList = discovery.listGateways(listGatewaysOptions).execute().getResult(); - assertNotNull(gatewayList); - int originalListSize = gatewayList.getGateways().size(); - - CreateGatewayOptions createGatewayOptions = new CreateGatewayOptions.Builder() - .environmentId(environmentId) - .name(gatewayName) - .build(); - Gateway gatewayResponse = discovery.createGateway(createGatewayOptions).execute().getResult(); - assertNotNull(gatewayResponse); - assertEquals(gatewayName, gatewayResponse.getName()); - String testGatewayId = gatewayResponse.getGatewayId(); - - gatewayList = discovery.listGateways(listGatewaysOptions).execute().getResult(); - assertTrue(gatewayList.getGateways().size() > originalListSize); - - GetGatewayOptions getGatewayOptions = new GetGatewayOptions.Builder() - .environmentId(environmentId) - .gatewayId(testGatewayId) - .build(); - Gateway getGatewayResponse = discovery.getGateway(getGatewayOptions).execute().getResult(); - assertNotNull(getGatewayResponse); - assertEquals(gatewayName, getGatewayResponse.getName()); - - DeleteGatewayOptions deleteGatewayOptions = new DeleteGatewayOptions.Builder() - .environmentId(environmentId) - .gatewayId(testGatewayId) - .build(); - discovery.deleteGateway(deleteGatewayOptions).execute(); - } - - private Environment createEnvironment(CreateEnvironmentOptions createOptions) { - return discovery.createEnvironment(createOptions).execute().getResult(); - } - - private void deleteEnvironment(DeleteEnvironmentOptions deleteOptions) { - discovery.deleteEnvironment(deleteOptions).execute(); - } - - private Configuration createConfiguration(CreateConfigurationOptions createOptions) { - Configuration createResponse = discovery.createConfiguration(createOptions).execute().getResult(); - configurationIds.add(createResponse.configurationId()); - return createResponse; - } - - private void deleteConfiguration(DeleteConfigurationOptions deleteOptions) { - discovery.deleteConfiguration(deleteOptions).execute(); - configurationIds.remove(deleteOptions.configurationId()); - } - - private Configuration createTestConfig() { - String uniqueConfigName = uniqueName + "-config"; - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId, - uniqueConfigName); - return createConfiguration(createBuilder.build()); - } - - private Collection createCollection(CreateCollectionOptions createOptions) { - Collection createResponse = discovery.createCollection(createOptions).execute().getResult(); - collectionIds.add(createResponse.getCollectionId()); - return createResponse; - } - - private void deleteCollection(DeleteCollectionOptions deleteOptions) { - discovery.deleteCollection(deleteOptions).execute(); - collectionIds.remove(deleteOptions.collectionId()); - } - - private Collection createTestCollection() { - Configuration createConfigResponse = createTestConfig(); - - String uniqueCollectionName = "java-sdk-" + uniqueName + "-collection"; - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.configurationId()); - return createCollection(createCollectionBuilder.build()); - } - - private DocumentAccepted createNestedTestDocument(String collectionId) { - String myDocumentJson = "{\"nested_fields\":{\"field\":\"value\"}}"; - return createTestDocument(myDocumentJson, UUID.randomUUID().toString(), collectionId); - } - - private DocumentAccepted createTestDocument(String collectionId) { - String myDocumentJson = "{\"field\":\"value\"}"; - return createTestDocument(myDocumentJson, UUID.randomUUID().toString(), collectionId); - } - - private DocumentAccepted createTestDocument(String filename, String collectionId) { - String myDocumentJson = "{\"field\":\"value\"}"; - return createTestDocument(myDocumentJson, filename, collectionId); - } - - @SuppressWarnings("deprecation") - private DocumentAccepted createTestDocument(String json, String filename, String collectionId) { - InputStream documentStream = new ByteArrayInputStream(json.getBytes()); - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename(filename); - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute().getResult(); - WaitFor.Condition documentAccepted = new WaitForDocumentAccepted(environmentId, collectionId, createResponse - .getDocumentId()); - WaitFor.waitFor(documentAccepted, 5, TimeUnit.SECONDS, 500); - return createResponse; - } - - private List createTestDocuments(String collectionId, int totalDocuments) { - List responses = new ArrayList(); - String baseDocumentJson = "{\"field\":"; - for (int i = 0; i < totalDocuments; i++) { - String json = baseDocumentJson + i + "}"; - String filename = "test_document_" + i; - responses.add(createTestDocument(json, filename, collectionId)); - } - return responses; - } - - private synchronized String setupTestDocuments() { - if (collectionId != null) { - return collectionId; - } - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - @SuppressWarnings("unused") - List documentAccepted = createTestDocuments(collectionId, 10); - - WaitFor.Condition collectionAvailable = new WaitForCollectionAvailable(environmentId, collectionId); - WaitFor.waitFor(collectionAvailable, 5, TimeUnit.SECONDS, 500); - - return collectionId; - } - - private TrainingQuery createTestQuery(String collectionId, String naturalLanguageQuery) { - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - builder.naturalLanguageQuery(naturalLanguageQuery); - return discovery.addTrainingData(builder.build()).execute().getResult(); - } - - private List createTestQueries(String collectionId, int totalQueries) { - List responses = new ArrayList<>(); - for (int i = 0; i < totalQueries; i++) { - String naturalLanguageQuery = "Test query " + i; - responses.add(createTestQuery(collectionId, naturalLanguageQuery)); - } - return responses; - } - - private synchronized String setupTestQueries(String collectionId) { - ListTrainingDataOptions.Builder builder = new ListTrainingDataOptions.Builder(environmentId, collectionId); - if (discovery.listTrainingData(builder.build()).execute().getResult().getQueries().size() > 0) { - return collectionId; - } - createTestQueries(collectionId, 10); - - WaitFor.Condition collectionAvailable = new WaitForCollectionAvailable(environmentId, collectionId); - WaitFor.waitFor(collectionAvailable, 5, TimeUnit.SECONDS, 500); - - return collectionId; - } - - public static Configuration getTestConfiguration(String jsonFile) { - try { - return GsonSingleton.getGson().fromJson(new FileReader(jsonFile), Configuration.class); - } catch (FileNotFoundException e) { - return null; - } - } - - private static class EnvironmentReady implements WaitFor.Condition { - private final Discovery discovery; - private final String environmentId; - - private EnvironmentReady(Discovery discovery, String environmentId) { - this.discovery = discovery; - this.environmentId = environmentId; - } - - @Override - public boolean isSatisfied() { - GetEnvironmentOptions getOptions = new GetEnvironmentOptions.Builder(environmentId).build(); - String status = discovery.getEnvironment(getOptions).execute().getResult().getStatus(); - return status.equals(Environment.Status.ACTIVE); - } - } - - private class WaitForDocumentAccepted implements WaitFor.Condition { - WaitForDocumentAccepted(String environmentId, String collectionId, String documentId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - this.documentId = documentId; - } - - @Override - public boolean isSatisfied() { - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - documentId).build(); - String status = discovery.getDocumentStatus(getOptions).execute().getResult().getStatus(); - return status.equals(DocumentStatus.Status.AVAILABLE); - } - - private final String environmentId; - private final String collectionId; - private final String documentId; - - } - - private class WaitForCollectionAvailable implements WaitFor.Condition { - WaitForCollectionAvailable(String environmentId, String collectionId) { - this.environmentId = environmentId; - this.collectionId = collectionId; - } - - @Override - public boolean isSatisfied() { - GetCollectionOptions getOptions = new GetCollectionOptions.Builder(environmentId, collectionId).build(); - String status = discovery.getCollection(getOptions).execute().getResult().getStatus(); - return status.equals(Collection.Status.ACTIVE); - } - - private final String environmentId; - private final String collectionId; - - } - - /** - * This only works on a Cloud Pak for Data instance, so ignoring to just run manually. - */ - @Test - @Ignore - public void testQueryWithSpellingSuggestions() { - Authenticator authenticator = new BearerTokenAuthenticator(""); // fill in - Discovery service = new Discovery("2019-10-03", authenticator); - service.setServiceUrl(""); - - HttpConfigOptions configOptions = new HttpConfigOptions.Builder() - .disableSslVerification(true) - .build(); - service.configureClient(configOptions); - - QueryOptions options = new QueryOptions.Builder() - .naturalLanguageQuery("cluod") - .spellingSuggestions(true) - .environmentId("") // fill in - .collectionId("") // fill in - .build(); - QueryResponse response = service.query(options).execute().getResult(); - System.out.println(response); - } - - /** - * This only works on a Cloud Pak for Data instance, so ignoring to just run manually. - */ - @Test - @Ignore - public void testGetAutocompletion() { - Authenticator authenticator = new BearerTokenAuthenticator(""); // fill in - Discovery service = new Discovery("2019-10-03", authenticator); - service.setServiceUrl(""); - - HttpConfigOptions configOptions = new HttpConfigOptions.Builder() - .disableSslVerification(true) - .build(); - service.configureClient(configOptions); - - GetAutocompletionOptions options = new GetAutocompletionOptions.Builder() - .environmentId("") // fill in - .collectionId("") // fill in - .prefix("Ba") - .count(10L) - .build(); - Completions response = service.getAutocompletion(options).execute().getResult(); - System.out.println(response); - } - -} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceTest.java deleted file mode 100644 index 5a5094bec27..00000000000 --- a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceTest.java +++ /dev/null @@ -1,2108 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.v1; - -import com.google.gson.JsonIOException; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSyntaxException; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.discovery.v1.model.AddDocumentOptions; -import com.ibm.watson.discovery.v1.model.AddTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.Collection; -import com.ibm.watson.discovery.v1.model.Configuration; -import com.ibm.watson.discovery.v1.model.Conversions; -import com.ibm.watson.discovery.v1.model.CreateCollectionOptions; -import com.ibm.watson.discovery.v1.model.CreateConfigurationOptions; -import com.ibm.watson.discovery.v1.model.CreateCredentialsOptions; -import com.ibm.watson.discovery.v1.model.CreateEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.CreateEventOptions; -import com.ibm.watson.discovery.v1.model.CreateEventResponse; -import com.ibm.watson.discovery.v1.model.CreateExpansionsOptions; -import com.ibm.watson.discovery.v1.model.CreateGatewayOptions; -import com.ibm.watson.discovery.v1.model.CreateStopwordListOptions; -import com.ibm.watson.discovery.v1.model.CreateTokenizationDictionaryOptions; -import com.ibm.watson.discovery.v1.model.CreateTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.CredentialDetails; -import com.ibm.watson.discovery.v1.model.Credentials; -import com.ibm.watson.discovery.v1.model.CredentialsList; -import com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.DeleteCollectionOptions; -import com.ibm.watson.discovery.v1.model.DeleteCollectionResponse; -import com.ibm.watson.discovery.v1.model.DeleteConfigurationOptions; -import com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse; -import com.ibm.watson.discovery.v1.model.DeleteCredentials; -import com.ibm.watson.discovery.v1.model.DeleteCredentialsOptions; -import com.ibm.watson.discovery.v1.model.DeleteDocumentOptions; -import com.ibm.watson.discovery.v1.model.DeleteDocumentResponse; -import com.ibm.watson.discovery.v1.model.DeleteEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.DeleteEnvironmentResponse; -import com.ibm.watson.discovery.v1.model.DeleteExpansionsOptions; -import com.ibm.watson.discovery.v1.model.DeleteGatewayOptions; -import com.ibm.watson.discovery.v1.model.DeleteStopwordListOptions; -import com.ibm.watson.discovery.v1.model.DeleteTokenizationDictionaryOptions; -import com.ibm.watson.discovery.v1.model.DeleteTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.DeleteTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.DeleteUserDataOptions; -import com.ibm.watson.discovery.v1.model.DocumentAccepted; -import com.ibm.watson.discovery.v1.model.DocumentStatus; -import com.ibm.watson.discovery.v1.model.Enrichment; -import com.ibm.watson.discovery.v1.model.Environment; -import com.ibm.watson.discovery.v1.model.EventData; -import com.ibm.watson.discovery.v1.model.Expansion; -import com.ibm.watson.discovery.v1.model.Expansions; -import com.ibm.watson.discovery.v1.model.FederatedQueryNoticesOptions; -import com.ibm.watson.discovery.v1.model.FederatedQueryOptions; -import com.ibm.watson.discovery.v1.model.Gateway; -import com.ibm.watson.discovery.v1.model.GatewayDelete; -import com.ibm.watson.discovery.v1.model.GatewayList; -import com.ibm.watson.discovery.v1.model.GetCollectionOptions; -import com.ibm.watson.discovery.v1.model.GetConfigurationOptions; -import com.ibm.watson.discovery.v1.model.GetCredentialsOptions; -import com.ibm.watson.discovery.v1.model.GetDocumentStatusOptions; -import com.ibm.watson.discovery.v1.model.GetEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.GetGatewayOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsEventRateOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryEventOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryNoResultsOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryOptions; -import com.ibm.watson.discovery.v1.model.GetMetricsQueryTokenEventOptions; -import com.ibm.watson.discovery.v1.model.GetStopwordListStatusOptions; -import com.ibm.watson.discovery.v1.model.GetTokenizationDictionaryStatusOptions; -import com.ibm.watson.discovery.v1.model.GetTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.GetTrainingExampleOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionFieldsOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionFieldsResponse; -import com.ibm.watson.discovery.v1.model.ListCollectionsOptions; -import com.ibm.watson.discovery.v1.model.ListCollectionsResponse; -import com.ibm.watson.discovery.v1.model.ListConfigurationsOptions; -import com.ibm.watson.discovery.v1.model.ListConfigurationsResponse; -import com.ibm.watson.discovery.v1.model.ListCredentialsOptions; -import com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse; -import com.ibm.watson.discovery.v1.model.ListExpansionsOptions; -import com.ibm.watson.discovery.v1.model.ListFieldsOptions; -import com.ibm.watson.discovery.v1.model.ListGatewaysOptions; -import com.ibm.watson.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.discovery.v1.model.ListTrainingExamplesOptions; -import com.ibm.watson.discovery.v1.model.LogQueryResponse; -import com.ibm.watson.discovery.v1.model.MetricResponse; -import com.ibm.watson.discovery.v1.model.MetricTokenResponse; -import com.ibm.watson.discovery.v1.model.NormalizationOperation; -import com.ibm.watson.discovery.v1.model.QueryLogOptions; -import com.ibm.watson.discovery.v1.model.QueryNoticesOptions; -import com.ibm.watson.discovery.v1.model.QueryNoticesResponse; -import com.ibm.watson.discovery.v1.model.QueryOptions; -import com.ibm.watson.discovery.v1.model.QueryResponse; -import com.ibm.watson.discovery.v1.model.Source; -import com.ibm.watson.discovery.v1.model.SourceOptions; -import com.ibm.watson.discovery.v1.model.SourceOptionsBuckets; -import com.ibm.watson.discovery.v1.model.SourceOptionsFolder; -import com.ibm.watson.discovery.v1.model.SourceOptionsObject; -import com.ibm.watson.discovery.v1.model.SourceOptionsSiteColl; -import com.ibm.watson.discovery.v1.model.SourceOptionsWebCrawl; -import com.ibm.watson.discovery.v1.model.TokenDictRule; -import com.ibm.watson.discovery.v1.model.TokenDictStatusResponse; -import com.ibm.watson.discovery.v1.model.TrainingDataSet; -import com.ibm.watson.discovery.v1.model.TrainingExample; -import com.ibm.watson.discovery.v1.model.TrainingExampleList; -import com.ibm.watson.discovery.v1.model.TrainingQuery; -import com.ibm.watson.discovery.v1.model.UpdateConfigurationOptions; -import com.ibm.watson.discovery.v1.model.UpdateCredentialsOptions; -import com.ibm.watson.discovery.v1.model.UpdateDocumentOptions; -import com.ibm.watson.discovery.v1.model.UpdateEnvironmentOptions; -import com.ibm.watson.discovery.v1.model.UpdateTrainingExampleOptions; -import com.ibm.watson.discovery.v1.query.AggregationType; -import com.ibm.watson.discovery.v1.query.Operator; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Unit tests for {@link Discovery}. - */ -public class DiscoveryServiceTest extends WatsonServiceUnitTest { - private Discovery discoveryService; - - private static final String VERSION = "2019-04-30"; - - private static final String RESOURCE = "src/test/resources/discovery/v1/"; - private static final String DISCOVERY_TEST_CONFIG_FILE = RESOURCE + "test-config.json"; - private static final String ENV1_PATH = "/v1/environments/mock_envid?version=" + VERSION; - private static final String ENV2_PATH = "/v1/environments?version=" + VERSION; - private static final String CONF1_PATH = "/v1/environments/mock_envid/configurations?version=" + VERSION; - private static final String CONF2_PATH = "/v1/environments/mock_envid/configurations/mock_confid?version=" + VERSION; - private static final String COLL1_PATH = "/v1/environments/mock_envid/collections?version=" + VERSION; - private static final String COLL2_PATH = "/v1/environments/mock_envid/collections/mock_collid?version=" + VERSION; - private static final String COLL3_PATH = "/v1/environments/mock_envid/collections/mock_collid/fields?version=" - + VERSION; - private static final String DOCS1_PATH = "/v1/environments/mock_envid/collections/mock_collid/documents?version=" - + VERSION; - private static final String DOCS2_PATH - = "/v1/environments/mock_envid/collections/mock_collid/documents/mock_docid?version=" - + VERSION; - private static final String Q1_PATH = "/v1/environments/mock_envid/collections/mock_collid/query?version=" + VERSION; - private static final String Q2_PATH = "/v1/environments/mock_envid/query?version=" + VERSION; - private static final String Q3_PATH = "/v1/environments/mock_envid/notices?version=" - + VERSION + "&collection_ids=mock_collid"; - private static final String Q4_PATH = "/v1/environments/mock_envid/collections/mock_collid/notices?version=" - + VERSION; - private static final String TRAINING1_PATH - = "/v1/environments/mock_envid/collections/mock_collid/training_data?version=" - + VERSION; - private static final String TRAINING2_PATH - = "/v1/environments/mock_envid/collections/mock_collid/training_data/mock_queryid/examples?version=" - + VERSION; - private static final String TRAINING3_PATH - = "/v1/environments/mock_envid/collections/mock_collid/training_data/mock_queryid?version=" - + VERSION; - private static final String TRAINING4_PATH - = "/v1/environments/mock_envid/collections/mock_collid/training_data/mock_queryid/examples/mock_docid?version=" - + VERSION; - private static final String FIELD_PATH = "/v1/environments/mock_envid/fields?version=" - + VERSION + "&collection_ids=mock_collid"; - private static final String EXPANSIONS_PATH - = "/v1/environments/mock_envid/collections/mock_collid/expansions?version=" - + VERSION; - private static final String DELETE_USER_DATA_PATH = "/v1/user_data?version=" - + VERSION - + "&customer_id=java_sdk_test_id"; - private static final String CREATE_CREDENTIALS_PATH - = "/v1/environments/mock_envid/credentials?version=" - + VERSION; - private static final String DELETE_CREDENTIALS_PATH - = "/v1/environments/mock_envid/credentials/credential_id?version=" - + VERSION; - private static final String GET_CREDENTIALS_PATH - = "/v1/environments/mock_envid/credentials/credential_id?version=" - + VERSION; - private static final String LIST_CREDENTIALS_PATH - = "/v1/environments/mock_envid/credentials?version=" - + VERSION; - private static final String UPDATE_CREDENTIALS_PATH - = "/v1/environments/mock_envid/credentials/new_credential_id?version=" - + VERSION; - private static final String CREATE_EVENT_PATH - = "/v1/events?version=" - + VERSION; - private static final String GET_METRICS_EVENT_RATE_PATH - = "/v1/metrics/event_rate?version=" - + VERSION; - private static final String GET_METRICS_QUERY_PATH - = "/v1/metrics/number_of_queries?version=" - + VERSION; - private static final String GET_METRICS_QUERY_EVENT_PATH - = "/v1/metrics/number_of_queries_with_event?version=" - + VERSION; - private static final String GET_METRICS_QUERY_NO_RESULTS_PATH - = "/v1/metrics/number_of_queries_with_no_search_results?version=" - + VERSION; - private static final String GET_METRICS_QUERY_TOKEN_EVENT_PATH - = "/v1/metrics/top_query_tokens_with_event_rate?version=" - + VERSION; - private static final String QUERY_LOG_PATH - = "/v1/logs?version=" - + VERSION; - - private String environmentId; - private String environmentName; - private String environmentDesc; - private String uniqueConfigName; - private String configurationId; - private String uniqueCollectionName; - private String collectionId; - private String documentId; - private String queryId; - private Date date; - private InputStream testStream; - - private Environment envResp; - private ListEnvironmentsResponse envsResp; - private Environment createEnvResp; - private DeleteEnvironmentResponse deleteEnvResp; - private Environment updateEnvResp; - private Configuration createConfResp; - private ListConfigurationsResponse getConfsResp; - private Configuration getConfResp; - private DeleteConfigurationResponse deleteConfResp; - private Configuration updateConfResp; - private Collection createCollResp; - private ListCollectionsResponse getCollsResp; - private Collection getCollResp; - private DeleteCollectionResponse deleteCollResp; - private ListCollectionFieldsResponse listfieldsCollResp; - private DocumentAccepted createDocResp; - private DocumentAccepted updateDocResp; - private DocumentStatus getDocResp; - private DeleteDocumentResponse deleteDocResp; - private QueryResponse queryResp; - private QueryNoticesResponse queryNoticesResp; - private TrainingQuery addTrainingQueryResp; - private TrainingDataSet listTrainingDataResp; - private TrainingExample createTrainingExampleResp; - private TrainingQuery getTrainingDataResp; - private TrainingExample getTrainingExampleResp; - private TrainingExample updateTrainingExampleResp; - private TrainingExampleList listTrainingExamplesResp; - private ListCollectionFieldsResponse listFieldsResp; - private Expansions expansionsResp; - private Credentials credentialsResp; - private CredentialsList listCredentialsResp; - private DeleteCredentials deleteCredentialsResp; - private CreateEventResponse createEventResp; - private MetricResponse metricResp; - private MetricTokenResponse metricTokenResp; - private LogQueryResponse logQueryResp; - private TokenDictStatusResponse tokenDictStatusResponse; - private TokenDictStatusResponse tokenDictStatusResponseStopwords; - private Gateway gatewayResponse; - private GatewayList listGatewaysResponse; - private GatewayDelete deleteGatewayResponse; - - @BeforeClass - public static void setupClass() { - } - - @Before - public void setup() throws Exception { - super.setUp(); - discoveryService = new Discovery(VERSION, new NoAuthAuthenticator()); - discoveryService.setServiceUrl(getMockWebServerUrl()); - - environmentId = "mock_envid"; - environmentName = "my_environment"; - environmentDesc = "My environment"; - uniqueConfigName = "my-config"; - configurationId = "mock_confid"; - uniqueCollectionName = "mock_collname"; - collectionId = "mock_collid"; - documentId = "mock_docid"; - queryId = "mock_queryid"; - date = new Date(); - testStream = new FileInputStream(RESOURCE + "get_env_resp.json"); - - envResp = loadFixture(RESOURCE + "get_env_resp.json", Environment.class); - envsResp = loadFixture(RESOURCE + "get_envs_resp.json", ListEnvironmentsResponse.class); - createEnvResp = loadFixture(RESOURCE + "create_env_resp.json", Environment.class); - deleteEnvResp = loadFixture(RESOURCE + "delete_env_resp.json", DeleteEnvironmentResponse.class); - updateEnvResp = loadFixture(RESOURCE + "update_env_resp.json", Environment.class); - createConfResp = loadFixture(RESOURCE + "create_conf_resp.json", Configuration.class); - getConfsResp = loadFixture(RESOURCE + "get_confs_resp.json", ListConfigurationsResponse.class); - getConfResp = loadFixture(RESOURCE + "get_conf_resp.json", Configuration.class); - deleteConfResp = loadFixture(RESOURCE + "delete_conf_resp.json", DeleteConfigurationResponse.class); - updateConfResp = loadFixture(RESOURCE + "update_conf_resp.json", Configuration.class); - createCollResp = loadFixture(RESOURCE + "create_coll_resp.json", Collection.class); - getCollsResp = loadFixture(RESOURCE + "get_coll_resp.json", ListCollectionsResponse.class); - getCollResp = loadFixture(RESOURCE + "get_coll1_resp.json", Collection.class); - deleteCollResp = loadFixture(RESOURCE + "delete_coll_resp.json", DeleteCollectionResponse.class); - listfieldsCollResp - = loadFixture(RESOURCE + "listfields_coll_resp.json", ListCollectionFieldsResponse.class); - createDocResp = loadFixture(RESOURCE + "create_doc_resp.json", DocumentAccepted.class); - updateDocResp = loadFixture(RESOURCE + "update_doc_resp.json", DocumentAccepted.class); - getDocResp = loadFixture(RESOURCE + "get_doc_resp.json", DocumentStatus.class); - deleteDocResp = loadFixture(RESOURCE + "delete_doc_resp.json", DeleteDocumentResponse.class); - queryResp = loadFixture(RESOURCE + "query1_resp.json", QueryResponse.class); - queryNoticesResp = loadFixture(RESOURCE + "query1_resp.json", QueryNoticesResponse.class); - addTrainingQueryResp = loadFixture(RESOURCE + "add_training_query_resp.json", TrainingQuery.class); - listTrainingDataResp = loadFixture(RESOURCE + "list_training_data_resp.json", TrainingDataSet.class); - createTrainingExampleResp - = loadFixture(RESOURCE + "add_training_example_resp.json", TrainingExample.class); - getTrainingDataResp = loadFixture(RESOURCE + "get_training_data_resp.json", TrainingQuery.class); - getTrainingExampleResp = loadFixture(RESOURCE + "get_training_example_resp.json", TrainingExample.class); - updateTrainingExampleResp - = loadFixture(RESOURCE + "update_training_example_resp.json", TrainingExample.class); - listTrainingExamplesResp - = loadFixture(RESOURCE + "list_training_examples_resp.json", TrainingExampleList.class); - listFieldsResp = loadFixture(RESOURCE + "list_fields_resp.json", ListCollectionFieldsResponse.class); - expansionsResp = loadFixture(RESOURCE + "expansions_resp.json", Expansions.class); - credentialsResp = loadFixture(RESOURCE + "credentials_resp.json", Credentials.class); - listCredentialsResp = loadFixture(RESOURCE + "list_credentials_resp.json", CredentialsList.class); - deleteCredentialsResp = loadFixture(RESOURCE + "delete_credentials_resp.json", DeleteCredentials.class); - createEventResp = loadFixture(RESOURCE + "create_event_resp.json", CreateEventResponse.class); - metricResp = loadFixture(RESOURCE + "metric_resp.json", MetricResponse.class); - metricTokenResp = loadFixture(RESOURCE + "metric_token_resp.json", MetricTokenResponse.class); - logQueryResp = loadFixture(RESOURCE + "log_query_resp.json", LogQueryResponse.class); - tokenDictStatusResponse - = loadFixture(RESOURCE + "token_dict_status_resp.json", TokenDictStatusResponse.class); - tokenDictStatusResponseStopwords = loadFixture(RESOURCE + "token_dict_status_resp_stopwords.json", - TokenDictStatusResponse.class); - gatewayResponse = loadFixture(RESOURCE + "gateway_resp.json", Gateway.class); - listGatewaysResponse = loadFixture(RESOURCE + "list_gateways_resp.json", GatewayList.class); - deleteGatewayResponse = loadFixture(RESOURCE + "delete_gateway_resp.json", GatewayDelete.class); - } - - @After - public void cleanup() { - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new Discovery(null, new NoAuthAuthenticator()); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new Discovery("", new NoAuthAuthenticator()); - } - - // Environment tests - @Test - public void getEnvironmentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(envResp)); - GetEnvironmentOptions getRequest = new GetEnvironmentOptions.Builder(environmentId).build(); - Environment response = discoveryService.getEnvironment(getRequest).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ENV1_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(envResp, response); - } - - @Test(expected = IllegalArgumentException.class) - public void getEnvironmentFails1() { - GetEnvironmentOptions getRequest = new GetEnvironmentOptions.Builder().build(); - @SuppressWarnings("unused") - Environment response = discoveryService.getEnvironment(getRequest).execute().getResult(); - } - - @Test(expected = IllegalArgumentException.class) - public void getEnvironmentFails2() { - @SuppressWarnings("unused") - Environment response = discoveryService.getEnvironment(null).execute().getResult(); - } - - @Test - public void listEnvironmentsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(envsResp)); - ListEnvironmentsResponse response = discoveryService.listEnvironments(null).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ENV2_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(envsResp, response); - } - - // Deleted test for listEnvironments with null name as this does not fail in the current SDK - - @Test - public void createEnvironmentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createEnvResp)); - CreateEnvironmentOptions.Builder createRequestBuilder = new CreateEnvironmentOptions.Builder().name(environmentName) - .size(CreateEnvironmentOptions.Size.XS); - createRequestBuilder.description(environmentDesc); - Environment response = discoveryService.createEnvironment(createRequestBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(ENV2_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createEnvResp, response); - } - - // Deleted test for createEnvironment with null name as this does not fail in the current SDK - - @Test - public void deleteEnvironmentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(deleteEnvResp)); - DeleteEnvironmentOptions deleteRequest = new DeleteEnvironmentOptions.Builder(environmentId).build(); - DeleteEnvironmentResponse response = discoveryService.deleteEnvironment(deleteRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(ENV1_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - assertEquals(deleteEnvResp.getEnvironmentId(), response.getEnvironmentId()); - assertEquals(deleteEnvResp.getStatus(), response.getStatus()); - } - - @Test(expected = IllegalArgumentException.class) - public void deleteEnvironmentFails() { - discoveryService.deleteEnvironment(null).execute().getResult(); - } - - @Test - public void updateEnvironmentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(updateEnvResp)); - UpdateEnvironmentOptions updateOptions = new UpdateEnvironmentOptions.Builder(environmentId) - .name(environmentName) - .description(environmentDesc) - .size(UpdateEnvironmentOptions.Size.L) - .build(); - - assertEquals(environmentId, updateOptions.environmentId()); - assertEquals(environmentName, updateOptions.name()); - assertEquals(environmentDesc, updateOptions.description()); - assertEquals(UpdateEnvironmentOptions.Size.L, updateOptions.size()); - - Environment response = discoveryService.updateEnvironment(updateOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(ENV1_PATH, request.getPath()); - assertEquals(PUT, request.getMethod()); - assertEquals(updateEnvResp, response); - } - - @Test - public void testSourceOptions() { - String folderOwnerUserId = "folder_owner_user_id"; - String folderId = "folder_id"; - Long limit = 10L; - String objectName = "object_name"; - String siteCollectionPath = "site_collection_path"; - String url = "url"; - Long maximumHops = 5L; - Long requestTimeout = 2L; - String bucketName = "bucket_name"; - - SourceOptionsFolder folder = new SourceOptionsFolder.Builder() - .ownerUserId(folderOwnerUserId) - .folderId(folderId) - .limit(limit) - .build(); - SourceOptionsObject object = new SourceOptionsObject.Builder() - .name(objectName) - .limit(limit) - .build(); - SourceOptionsSiteColl siteColl = new SourceOptionsSiteColl.Builder() - .siteCollectionPath(siteCollectionPath) - .limit(limit) - .build(); - SourceOptionsWebCrawl webCrawl = new SourceOptionsWebCrawl.Builder() - .url(url) - .limitToStartingHosts(true) - .crawlSpeed(SourceOptionsWebCrawl.CrawlSpeed.AGGRESSIVE) - .allowUntrustedCertificate(true) - .maximumHops(maximumHops) - .requestTimeout(requestTimeout) - .overrideRobotsTxt(true) - .build(); - SourceOptionsBuckets buckets = new SourceOptionsBuckets.Builder() - .name(bucketName) - .limit(limit) - .build(); - SourceOptions sourceOptions = new SourceOptions.Builder() - .folders(Collections.singletonList(folder)) - .objects(Collections.singletonList(object)) - .siteCollections(Collections.singletonList(siteColl)) - .urls(Collections.singletonList(webCrawl)) - .buckets(Collections.singletonList(buckets)) - .crawlAllBuckets(true) - .build(); - - assertEquals(folderOwnerUserId, sourceOptions.folders().get(0).ownerUserId()); - assertEquals(folderId, sourceOptions.folders().get(0).folderId()); - assertEquals(limit, sourceOptions.folders().get(0).limit()); - assertEquals(objectName, sourceOptions.objects().get(0).name()); - assertEquals(limit, sourceOptions.objects().get(0).limit()); - assertEquals(siteCollectionPath, sourceOptions.siteCollections().get(0).siteCollectionPath()); - assertEquals(limit, sourceOptions.siteCollections().get(0).limit()); - assertEquals(url, sourceOptions.urls().get(0).url()); - assertTrue(sourceOptions.urls().get(0).limitToStartingHosts()); - assertEquals(SourceOptionsWebCrawl.CrawlSpeed.AGGRESSIVE, sourceOptions.urls().get(0).crawlSpeed()); - assertTrue(sourceOptions.urls().get(0).allowUntrustedCertificate()); - assertEquals(maximumHops, sourceOptions.urls().get(0).maximumHops()); - assertEquals(requestTimeout, sourceOptions.urls().get(0).requestTimeout()); - assertTrue(sourceOptions.urls().get(0).overrideRobotsTxt()); - assertEquals(bucketName, sourceOptions.buckets().get(0).name()); - assertEquals(limit, sourceOptions.buckets().get(0).limit()); - assertTrue(sourceOptions.crawlAllBuckets()); - } - - // Configuration tests - @Test - public void testCreateConfigurationOptions() { - String name = "name"; - String description = "description"; - Conversions conversions = new Conversions.Builder().build(); - String firstEnrichmentName = "first"; - String secondEnrichmentName = "second"; - String sourceField = "source_field"; - String destinationField = "destination_field"; - List enrichments = new ArrayList<>(); - Enrichment firstEnrichment = new Enrichment.Builder() - .enrichment(firstEnrichmentName) - .sourceField(sourceField) - .destinationField(destinationField) - .build(); - enrichments.add(firstEnrichment); - Enrichment secondEnrichment = new Enrichment.Builder() - .enrichment(secondEnrichmentName) - .sourceField(sourceField) - .destinationField(destinationField) - .build(); - List normalizationOperations = new ArrayList<>(); - NormalizationOperation firstOp = new NormalizationOperation.Builder() - .operation(NormalizationOperation.Operation.MERGE) - .build(); - NormalizationOperation secondOp = new NormalizationOperation.Builder() - .operation(NormalizationOperation.Operation.COPY) - .build(); - normalizationOperations.add(firstOp); - Source source = new Source.Builder().build(); - - CreateConfigurationOptions createConfigurationOptions = new CreateConfigurationOptions.Builder() - .environmentId(environmentId) - .name(name) - .description(description) - .conversions(conversions) - .enrichments(enrichments) - .addEnrichment(secondEnrichment) - .normalizations(normalizationOperations) - .addNormalization(secondOp) - .source(source) - .build(); - createConfigurationOptions = createConfigurationOptions.newBuilder().build(); - - enrichments.add(secondEnrichment); - normalizationOperations.add(secondOp); - - assertEquals(environmentId, createConfigurationOptions.environmentId()); - assertEquals(name, createConfigurationOptions.name()); - assertEquals(description, createConfigurationOptions.description()); - assertEquals(conversions, createConfigurationOptions.conversions()); - assertEquals(enrichments, createConfigurationOptions.enrichments()); - assertEquals(normalizationOperations, createConfigurationOptions.normalizations()); - assertEquals(source, createConfigurationOptions.source()); - } - - @Test - public void createConfigurationIsSuccessful() throws JsonSyntaxException, JsonIOException, - FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(createConfResp)); - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(); - Configuration configuration = GsonSingleton.getGson().fromJson(new FileReader(DISCOVERY_TEST_CONFIG_FILE), - Configuration.class); - createBuilder.configuration(configuration); - createBuilder.environmentId(environmentId); - createBuilder.name(uniqueConfigName); - Configuration response = discoveryService.createConfiguration(createBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONF1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createConfResp, response); - } - - @Test - public void getConfigurationIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getConfResp)); - - GetConfigurationOptions getRequest = new GetConfigurationOptions.Builder(environmentId, configurationId).build(); - Configuration response = discoveryService.getConfiguration(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONF2_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getConfResp, response); - } - - @Test - public void getConfigurationsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getConfsResp)); - ListConfigurationsOptions getRequest = new ListConfigurationsOptions.Builder(environmentId).build(); - ListConfigurationsResponse response = discoveryService.listConfigurations(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONF1_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getConfsResp, response); - } - - @Test - public void deleteConfigurationIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(deleteConfResp)); - DeleteConfigurationOptions deleteRequest = new DeleteConfigurationOptions.Builder(environmentId, configurationId) - .build(); - DeleteConfigurationResponse response = discoveryService.deleteConfiguration(deleteRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONF2_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - assertEquals(deleteConfResp.getConfigurationId(), response.getConfigurationId()); - assertEquals(DeleteConfigurationResponse.Status.DELETED, response.getStatus()); - assertNotNull(response.getNotices()); - } - - @Test - public void updateConfigurationIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(updateConfResp)); - UpdateConfigurationOptions.Builder updateBuilder = new UpdateConfigurationOptions.Builder(); - updateBuilder.configurationId(configurationId); - updateBuilder.environmentId(environmentId); - Configuration newConf = new Configuration.Builder() - .name("newName") - .build(); - updateBuilder.configuration(newConf); - - Configuration response = discoveryService.updateConfiguration(updateBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONF2_PATH, request.getPath()); - assertEquals(PUT, request.getMethod()); - assertEquals(updateConfResp, response); - } - - // Collection tests - @Test - public void createCollectionIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createCollResp)); - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName).configurationId(configurationId); - Collection response = discoveryService.createCollection(createCollectionBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COLL1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createCollResp, response); - } - - @Test - public void getCollectionsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getCollsResp)); - ListCollectionsOptions getRequest = new ListCollectionsOptions.Builder(environmentId).build(); - ListCollectionsResponse response = discoveryService.listCollections(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COLL1_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getCollsResp, response); - } - - @Test - public void getCollectionIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getCollResp)); - GetCollectionOptions getRequest = new GetCollectionOptions.Builder(environmentId, collectionId).build(); - Collection response = discoveryService.getCollection(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COLL2_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getCollResp, response); - } - - // no updateCollection yet? - - @Test - public void listfieldsCollectionIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(listfieldsCollResp)); - ListCollectionFieldsOptions getRequest = new ListCollectionFieldsOptions.Builder(environmentId, collectionId) - .build(); - ListCollectionFieldsResponse response = discoveryService.listCollectionFields(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COLL3_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(listfieldsCollResp, response); - } - - @Test - public void deleteCollectionIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(deleteCollResp)); - DeleteCollectionOptions deleteRequest = new DeleteCollectionOptions.Builder(environmentId, collectionId).build(); - DeleteCollectionResponse response = discoveryService.deleteCollection(deleteRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COLL2_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - assertEquals(DeleteCollectionResponse.Status.DELETED, response.getStatus()); - assertEquals(deleteCollResp.getCollectionId(), response.getCollectionId()); - } - - // Document tests - @Test - public void addDocumentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createDocResp)); - String myDocumentJson = "{\"field\":\"value\"}"; - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename("test_file"); - builder.metadata(myMetadata.toString()); - DocumentAccepted response = discoveryService.addDocument(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createDocResp, response); - } - - @Test - public void addDocumentFromInputStreamIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createDocResp)); - String myDocumentJson = "{\"field\":\"value\"}"; - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.file(documentStream); - builder.filename("test_file"); - builder.metadata(myMetadata.toString()); - DocumentAccepted response = discoveryService.addDocument(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createDocResp, response); - } - - @Test - public void addDocumentFromInputStreamWithMediaTypeIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createDocResp)); - String myDocumentJson = "{\"field\":\"value\"}"; - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename("test_file"); - builder.metadata(myMetadata.toString()); - DocumentAccepted response = discoveryService.addDocument(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createDocResp, response); - } - - @Test(expected = IllegalArgumentException.class) - public void addDocumentWithoutRequiredParametersFails() { - AddDocumentOptions options = new AddDocumentOptions.Builder(environmentId, collectionId).build(); - discoveryService.addDocument(options).execute().getResult(); - } - - @Test - public void addDocumentFromInputStreamWithFileNameAndMediaTypeIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createDocResp)); - String myDocumentJson = "{\"field\":\"value\"}"; - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename("test_file"); - builder.metadata(myMetadata.toString()); - DocumentAccepted response = discoveryService.addDocument(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createDocResp, response); - } - - // Deleted tests for (create)addDocument with file parameter as this is deprecated - - @Test - public void updateDocumentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(updateDocResp)); - UpdateDocumentOptions.Builder updateBuilder = new UpdateDocumentOptions.Builder(environmentId, collectionId, - documentId); - String myDocumentJson = "{\"field\":\"value2\"}"; - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - updateBuilder.filename("test_file"); - updateBuilder.metadata(myMetadata.toString()); - DocumentAccepted response = discoveryService.updateDocument(updateBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS2_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(updateDocResp, response); - } - - @Test(expected = IllegalArgumentException.class) - public void updateDocumentWithoutRequiredParametersFails() { - UpdateDocumentOptions options = new UpdateDocumentOptions.Builder(environmentId, collectionId, documentId).build(); - discoveryService.updateDocument(options).execute().getResult(); - } - - @Test - public void getDocumentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getDocResp)); - GetDocumentStatusOptions getRequest = new GetDocumentStatusOptions.Builder(environmentId, collectionId, documentId) - .build(); - DocumentStatus response = discoveryService.getDocumentStatus(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS2_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getDocResp, response); - } - - @Test - public void deleteDocumentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(deleteDocResp)); - DeleteDocumentOptions deleteRequest = new DeleteDocumentOptions.Builder(environmentId, collectionId, documentId) - .build(); - DeleteDocumentResponse response = discoveryService.deleteDocument(deleteRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS2_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - assertEquals(deleteDocResp.getDocumentId(), response.getDocumentId()); - assertEquals(deleteDocResp.getStatus(), response.getStatus()); - } - - // Query tests - @Test - public void queryIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryResp)); - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.count(5L); - queryBuilder.offset(5L); - String fieldNames = "field"; - queryBuilder.xReturn(fieldNames); - queryBuilder.query("field" + Operator.CONTAINS + 1); - queryBuilder.filter("field" + Operator.CONTAINS + 1); - queryBuilder.similar(true); - String similarDocumentIds = "doc1, doc2"; - queryBuilder.similarDocumentIds(similarDocumentIds); - String similarFields = "field1, field2"; - queryBuilder.similarFields(similarFields); - queryBuilder.xWatsonLoggingOptOut(true); - queryBuilder.bias("bias"); - QueryResponse response = discoveryService.query(queryBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(GsonSingleton.getGson().toJsonTree(queryResp), GsonSingleton.getGson().toJsonTree(response)); - } - - @Test - public void queryWithAggregationTermIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryResp)); - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - StringBuilder sb = new StringBuilder(); - sb.append(AggregationType.TERM); - sb.append(Operator.OPENING_GROUPING); - sb.append("field"); - sb.append(Operator.CLOSING_GROUPING); - String aggregation = sb.toString(); - queryBuilder.aggregation(aggregation); - QueryResponse response = discoveryService.query(queryBuilder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(GsonSingleton.getGson().toJsonTree(queryResp), GsonSingleton.getGson().toJsonTree(response)); - } - - // Training data tests - @Test - public void addTrainingDataIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(addTrainingQueryResp)); - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - builder.naturalLanguageQuery("Example query"); - TrainingExample example = new TrainingExample.Builder() - .documentId(documentId) - .relevance(0) - .build(); - builder.addExamples(example); - TrainingQuery response = discoveryService.addTrainingData(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING1_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(addTrainingQueryResp, response); - } - - @Test - public void listTrainingDataIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(listTrainingDataResp)); - ListTrainingDataOptions getRequest = new ListTrainingDataOptions.Builder(environmentId, collectionId).build(); - TrainingDataSet response = discoveryService.listTrainingData(getRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING1_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(listTrainingDataResp, response); - } - - @Test - public void deleteAllCollectionTrainingDataIsSuccessful() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(204); - server.enqueue(desiredResponse); - DeleteAllTrainingDataOptions deleteRequest = new DeleteAllTrainingDataOptions.Builder(environmentId, collectionId) - .build(); - discoveryService.deleteAllTrainingData(deleteRequest).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING1_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void createTrainingExampleIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createTrainingExampleResp)); - CreateTrainingExampleOptions.Builder builder = new CreateTrainingExampleOptions.Builder(environmentId, collectionId, - queryId); - builder.documentId(documentId); - builder.relevance(0); - TrainingExample response = discoveryService.createTrainingExample(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING2_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(createTrainingExampleResp, response); - } - - @Test - public void getTrainingDataIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getTrainingDataResp)); - GetTrainingDataOptions.Builder builder = new GetTrainingDataOptions.Builder(environmentId, collectionId, queryId); - TrainingQuery response = discoveryService.getTrainingData(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING3_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getTrainingDataResp, response); - } - - @Test - public void getTrainingExampleIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(getTrainingExampleResp)); - GetTrainingExampleOptions.Builder builder = new GetTrainingExampleOptions.Builder(environmentId, collectionId, - queryId, documentId); - TrainingExample response = discoveryService.getTrainingExample(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING4_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(getTrainingExampleResp, response); - } - - @Test - public void deleteTrainingDataIsSuccessful() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(204); - server.enqueue(desiredResponse); - DeleteTrainingDataOptions.Builder builder = new DeleteTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - discoveryService.deleteTrainingData(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING3_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void deleteTrainingExampleIsSuccessful() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(204); - server.enqueue(desiredResponse); - DeleteTrainingExampleOptions.Builder builder = new DeleteTrainingExampleOptions.Builder(environmentId, collectionId, - queryId, documentId); - discoveryService.deleteTrainingExample(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING4_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void updateTrainingExampleIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(updateTrainingExampleResp)); - UpdateTrainingExampleOptions.Builder builder = new UpdateTrainingExampleOptions.Builder(environmentId, collectionId, - queryId, documentId); - builder.relevance(100); - TrainingExample response = discoveryService.updateTrainingExample(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING4_PATH, request.getPath()); - assertEquals(PUT, request.getMethod()); - assertEquals(updateTrainingExampleResp, response); - } - - @Test - public void listTrainingExamplesIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(listTrainingExamplesResp)); - ListTrainingExamplesOptions.Builder builder = new ListTrainingExamplesOptions.Builder(environmentId, collectionId, - queryId); - TrainingExampleList response = discoveryService.listTrainingExamples(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(TRAINING2_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(listTrainingExamplesResp, response); - } - - @Test - public void listFieldsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(listFieldsResp)); - ListFieldsOptions.Builder builder = new ListFieldsOptions.Builder(environmentId, new ArrayList<>(Arrays.asList( - collectionId))); - ListCollectionFieldsResponse response = discoveryService.listFields(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(FIELD_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(listFieldsResp, response); - } - - @Test - public void queryNoticesIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryNoticesResp)); - QueryNoticesOptions.Builder builder = new QueryNoticesOptions.Builder(environmentId, collectionId); - discoveryService.queryNotices(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q4_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - } - - @Test - public void federatedQueryIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryResp)); - FederatedQueryOptions.Builder builder = new FederatedQueryOptions.Builder() - .environmentId(environmentId) - .collectionIds(collectionId) - .bias("bias") - .xWatsonLoggingOptOut(true); - discoveryService.federatedQuery(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q2_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - } - - @Test - public void federatedQueryNoticesIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryNoticesResp)); - FederatedQueryNoticesOptions.Builder builder = new FederatedQueryNoticesOptions.Builder(environmentId, - new ArrayList<>(Arrays.asList(collectionId))); - discoveryService.federatedQueryNotices(builder.build()).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q3_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - } - - @Test - public void createExpansionsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(expansionsResp)); - - List expansion1InputTerms = Arrays.asList("weekday", "week day"); - List expansion1ExpandedTerms = Arrays.asList("monday", "tuesday", "wednesday", "thursday", "friday"); - List expansion2InputTerms = Arrays.asList("weekend", "week end"); - List expansion2ExpandedTerms = Arrays.asList("saturday", "sunday"); - Expansion expansion1 = new Expansion.Builder() - .inputTerms(expansion1InputTerms) - .expandedTerms(expansion1ExpandedTerms) - .build(); - Expansion expansion2 = new Expansion.Builder() - .inputTerms(expansion2InputTerms) - .expandedTerms(expansion2ExpandedTerms) - .build(); - Expansions expansions = new Expansions.Builder() - .expansions(Arrays.asList(expansion1, expansion2)) - .build(); - - CreateExpansionsOptions createOptions = new CreateExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .expansions(expansions) - .build(); - Expansions createResults = discoveryService.createExpansions(createOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(EXPANSIONS_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(expansion1, createResults.expansions().get(0)); - assertEquals(expansion2, createResults.expansions().get(1)); - } - - @Test - public void listExpansionsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(expansionsResp)); - - List expansion1InputTerms = Arrays.asList("weekday", "week day"); - List expansion1ExpandedTerms = Arrays.asList("monday", "tuesday", "wednesday", "thursday", "friday"); - List expansion2InputTerms = Arrays.asList("weekend", "week end"); - List expansion2ExpandedTerms = Arrays.asList("saturday", "sunday"); - Expansion expansion1 = new Expansion.Builder() - .inputTerms(expansion1InputTerms) - .expandedTerms(expansion1ExpandedTerms) - .build(); - Expansion expansion2 = new Expansion.Builder() - .inputTerms(expansion2InputTerms) - .expandedTerms(expansion2ExpandedTerms) - .build(); - - ListExpansionsOptions listOptions = new ListExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - Expansions listResults = discoveryService.listExpansions(listOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(EXPANSIONS_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(expansion1, listResults.expansions().get(0)); - assertEquals(expansion2, listResults.expansions().get(1)); - } - - @Test - public void deleteExpansionsIsSuccessful() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); - - DeleteExpansionsOptions deleteOptions = new DeleteExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - discoveryService.deleteExpansions(deleteOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(EXPANSIONS_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void deleteUserDataIsSuccessful() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); - - String customerId = "java_sdk_test_id"; - - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); - discoveryService.deleteUserData(deleteOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE_USER_DATA_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void testCredentialDetails() { - String clientId = "client_id"; - String clientSecret = "client_secret"; //pragma: whitelist secret - String enterpriseId = "enterprise_id"; - String organizationUrl = "organization_url"; - String passphrase = "passphrase"; - String password = "password"; //pragma: whitelist secret - String privateKey = "private_key"; - String publicKeyId = "public_key_id"; - String siteCollectionPath = "site_collection_path"; - String url = "url"; - String username = "username"; - String gatewayId = "gateway_id"; - String sourceVersion = "source_version"; - String webApplicationUrl = "web_application_url"; - String domain = "domain"; - String endpoint = "endpoint"; - String accessKeyId = "access_key"; - String secretAccessKey = "secret_access_key"; - - CredentialDetails details = new CredentialDetails.Builder() - .clientId(clientId) - .clientSecret(clientSecret) - .credentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD) - .enterpriseId(enterpriseId) - .organizationUrl(organizationUrl) - .passphrase(passphrase) - .password(password) - .privateKey(privateKey) - .publicKeyId(publicKeyId) - .siteCollectionPath(siteCollectionPath) - .url(url) - .username(username) - .gatewayId(gatewayId) - .sourceVersion(sourceVersion) - .webApplicationUrl(webApplicationUrl) - .domain(domain) - .endpoint(endpoint) - .accessKeyId(accessKeyId) - .secretAccessKey(secretAccessKey) - .build(); - - assertEquals(clientId, details.clientId()); - assertEquals(clientSecret, details.clientSecret()); - assertEquals(CredentialDetails.CredentialType.USERNAME_PASSWORD, details.credentialType()); - assertEquals(enterpriseId, details.enterpriseId()); - assertEquals(organizationUrl, details.organizationUrl()); - assertEquals(passphrase, details.passphrase()); - assertEquals(password, details.password()); - assertEquals(privateKey, details.privateKey()); - assertEquals(publicKeyId, details.publicKeyId()); - assertEquals(siteCollectionPath, details.siteCollectionPath()); - assertEquals(url, details.url()); - assertEquals(username, details.username()); - assertEquals(gatewayId, details.gatewayId()); - assertEquals(sourceVersion, details.sourceVersion()); - assertEquals(webApplicationUrl, details.webApplicationUrl()); - assertEquals(domain, details.domain()); - assertEquals(accessKeyId, details.accessKeyId()); - assertEquals(secretAccessKey, details.secretAccessKey()); - } - - @Test - public void createCredentialsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(credentialsResp)); - - CredentialDetails details = new CredentialDetails.Builder() - .credentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD) - .url("url") - .username("username") - .build(); - Credentials credentials = new Credentials.Builder() - .sourceType(Credentials.SourceType.SALESFORCE) - .credentialDetails(details) - .build(); - - CreateCredentialsOptions options = new CreateCredentialsOptions.Builder() - .environmentId(environmentId) - .sourceType(Credentials.SourceType.SALESFORCE) - .credentials(credentials) - .credentialDetails(details) - .build(); - Credentials credentialsResponse = discoveryService.createCredentials(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CREATE_CREDENTIALS_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(credentialsResp, credentialsResponse); - assertEquals(credentialsResp.credentialDetails(), credentialsResponse.credentialDetails()); - } - - @Test - public void deleteCredentialsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(deleteCredentialsResp)); - - DeleteCredentialsOptions options = new DeleteCredentialsOptions.Builder() - .environmentId(environmentId) - .credentialId("credential_id") - .build(); - DeleteCredentials response = discoveryService.deleteCredentials(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE_CREDENTIALS_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - assertEquals(deleteCredentialsResp.getCredentialId(), response.getCredentialId()); - assertEquals(deleteCredentialsResp.getStatus(), response.getStatus()); - } - - @Test - public void getCredentialsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(credentialsResp)); - - GetCredentialsOptions options = new GetCredentialsOptions.Builder() - .environmentId(environmentId) - .credentialId("credential_id") - .build(); - Credentials credentialsResponse = discoveryService.getCredentials(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_CREDENTIALS_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(credentialsResp, credentialsResponse); - } - - @Test - public void listCredentialsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(listCredentialsResp)); - - ListCredentialsOptions options = new ListCredentialsOptions.Builder() - .environmentId(environmentId) - .build(); - CredentialsList response = discoveryService.listCredentials(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(LIST_CREDENTIALS_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(listCredentialsResp, response); - assertTrue(response.getCredentials().size() == 3); - } - - @Test - public void updateCredentialsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(credentialsResp)); - - CredentialDetails newDetails = new CredentialDetails.Builder() - .clientId("new_client_id") - .clientSecret("new_client_secret") - .credentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD) - .enterpriseId("new_enterprise_id") - .organizationUrl("new_organization_url") - .passphrase("new_passphrase") - .password("new_password") - .privateKey("new_private_key") - .publicKeyId("new_public_key_id") - .siteCollectionPath("new_site_collection_path") - .url("new_url") - .username("new_username") - .build(); - Credentials newCredentials = new Credentials.Builder() - .sourceType(Credentials.SourceType.SALESFORCE) - .credentialDetails(newDetails) - .build(); - - UpdateCredentialsOptions options = new UpdateCredentialsOptions.Builder() - .environmentId(environmentId) - .credentialId("new_credential_id") - .sourceType(Credentials.SourceType.SALESFORCE) - .credentials(newCredentials) - .credentialDetails(newDetails) - .build(); - Credentials response = discoveryService.updateCredentials(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(UPDATE_CREDENTIALS_PATH, request.getPath()); - assertEquals(PUT, request.getMethod()); - assertEquals(credentialsResp, response); - } - - @Test - public void createEventIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createEventResp)); - - Long displayRank = 1L; - String sessionToken = "mock_session_token"; - - EventData eventData = new EventData.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .documentId(documentId) - .displayRank(displayRank) - .sessionToken(sessionToken) - .clientTimestamp(date) - .build(); - CreateEventOptions createEventOptions = new CreateEventOptions.Builder() - .type(CreateEventOptions.Type.CLICK) - .data(eventData) - .build(); - - CreateEventResponse response = discoveryService.createEvent(createEventOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CREATE_EVENT_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(CreateEventOptions.Type.CLICK, response.getType()); - assertEquals(environmentId, response.getData().environmentId()); - assertEquals(collectionId, response.getData().collectionId()); - assertEquals(documentId, response.getData().documentId()); - assertNotNull(response.getData().clientTimestamp()); - assertEquals(displayRank, response.getData().displayRank()); - assertEquals(queryId, response.getData().queryId()); - assertEquals(sessionToken, response.getData().sessionToken()); - } - - @Test - public void getMetricsEventRateIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - GetMetricsEventRateOptions options = new GetMetricsEventRateOptions.Builder() - .startTime(date) - .endTime(date) - .resultType(GetMetricsEventRateOptions.ResultType.DOCUMENT) - .build(); - - MetricResponse response = discoveryService.getMetricsEventRate(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsEventRateNoArgsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - MetricResponse response = discoveryService.getMetricsEventRate().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_METRICS_EVENT_RATE_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - GetMetricsQueryOptions options = new GetMetricsQueryOptions.Builder() - .startTime(date) - .endTime(date) - .resultType(GetMetricsQueryOptions.ResultType.DOCUMENT) - .build(); - - MetricResponse response = discoveryService.getMetricsQuery(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryNoArgsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - MetricResponse response = discoveryService.getMetricsQuery().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_METRICS_QUERY_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryEventIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - GetMetricsQueryEventOptions options = new GetMetricsQueryEventOptions.Builder() - .startTime(date) - .endTime(date) - .resultType(GetMetricsQueryEventOptions.ResultType.DOCUMENT) - .build(); - - MetricResponse response = discoveryService.getMetricsQueryEvent(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryEventNoArgsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - MetricResponse response = discoveryService.getMetricsQueryEvent().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_METRICS_QUERY_EVENT_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryNoResultsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - GetMetricsQueryNoResultsOptions options = new GetMetricsQueryNoResultsOptions.Builder() - .startTime(date) - .endTime(date) - .resultType(GetMetricsQueryEventOptions.ResultType.DOCUMENT) - .build(); - - MetricResponse response = discoveryService.getMetricsQueryNoResults(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryNoResultsNoArgsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricResp)); - - String interval = "1d"; - Long key = 1533513600000L; - Double eventRate = 0.0; - - MetricResponse response = discoveryService.getMetricsQueryNoResults().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_METRICS_QUERY_NO_RESULTS_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(interval, response.getAggregations().get(0).getInterval()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryTokenEventIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricTokenResp)); - - Long count = 10L; - String key = "beat"; - Long matchingResults = 117L; - Double eventRate = 0.0; - - GetMetricsQueryTokenEventOptions options = new GetMetricsQueryTokenEventOptions.Builder() - .count(count) - .build(); - - MetricTokenResponse response = discoveryService.getMetricsQueryTokenEvent(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertEquals(matchingResults, response.getAggregations().get(0).getResults().get(0).getMatchingResults()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void getMetricsQueryTokenEventNoArgsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(metricTokenResp)); - - String key = "beat"; - Long matchingResults = 117L; - Double eventRate = 0.0; - - MetricTokenResponse response = discoveryService.getMetricsQueryTokenEvent().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_METRICS_QUERY_TOKEN_EVENT_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertTrue(!response.getAggregations().isEmpty()); - assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); - assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); - assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); - assertEquals(matchingResults, response.getAggregations().get(0).getResults().get(0).getMatchingResults()); - assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); - } - - @Test - public void queryLogIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(logQueryResp)); - - List sortList = new ArrayList<>(); - sortList.add("field_a"); - String extraSort = "field_b"; - String filter = "filter"; - String naturalLanguageQuery = "Who beat Ken Jennings in Jeopardy!"; - Long count = 5L; - Long offset = 5L; - Long matchingResults = 2L; - String customerId = ""; - String sessionToken = "mock_session_token"; - String eventType = "query"; - Long resultCount = 0L; - - QueryLogOptions options = new QueryLogOptions.Builder() - .sort(sortList) - .addSort(extraSort) - .count(count) - .filter(filter) - .offset(offset) - .query(naturalLanguageQuery) - .build(); - - LogQueryResponse response = discoveryService.queryLog(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(matchingResults, response.getMatchingResults()); - assertTrue(!response.getResults().isEmpty()); - assertEquals(environmentId, response.getResults().get(0).getEnvironmentId()); - assertEquals(customerId, response.getResults().get(0).getCustomerId()); - assertNotNull(response.getResults().get(0).getCreatedTimestamp()); - assertEquals(queryId, response.getResults().get(0).getQueryId()); - assertEquals(sessionToken, response.getResults().get(0).getSessionToken()); - assertEquals(eventType, response.getResults().get(0).getEventType()); - assertNotNull(response.getResults().get(0).getDocumentResults().getResults()); - assertEquals(resultCount, response.getResults().get(0).getDocumentResults().getCount()); - } - - @Test - public void queryLogNoArgsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(logQueryResp)); - - List sortList = new ArrayList<>(); - sortList.add("field_a"); - Long matchingResults = 2L; - String customerId = ""; - String sessionToken = "mock_session_token"; - String eventType = "query"; - Long resultCount = 0L; - - LogQueryResponse response = discoveryService.queryLog().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(QUERY_LOG_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(matchingResults, response.getMatchingResults()); - assertTrue(!response.getResults().isEmpty()); - assertEquals(environmentId, response.getResults().get(0).getEnvironmentId()); - assertEquals(customerId, response.getResults().get(0).getCustomerId()); - assertNotNull(response.getResults().get(0).getCreatedTimestamp()); - assertEquals(queryId, response.getResults().get(0).getQueryId()); - assertEquals(sessionToken, response.getResults().get(0).getSessionToken()); - assertEquals(eventType, response.getResults().get(0).getEventType()); - assertNotNull(response.getResults().get(0).getDocumentResults().getResults()); - assertEquals(resultCount, response.getResults().get(0).getDocumentResults().getCount()); - } - - @Test - public void testTokenDictRule() { - String text = "text"; - String partOfSpeech = "noun"; - List readings = Arrays.asList("reading 1", "reading 2"); - List tokens = Arrays.asList("token 1", "token 2"); - - TokenDictRule tokenDictRule = new TokenDictRule.Builder() - .text(text) - .partOfSpeech(partOfSpeech) - .readings(readings) - .tokens(tokens) - .build(); - - assertEquals(text, tokenDictRule.text()); - assertEquals(partOfSpeech, tokenDictRule.partOfSpeech()); - assertEquals(readings, tokenDictRule.readings()); - assertEquals(tokens, tokenDictRule.tokens()); - } - - @Test - public void testCreateTokenizationDictionaryOptions() { - String text = "text"; - String partOfSpeech = "noun"; - List tokens = Arrays.asList("token 1", "token 2"); - - TokenDictRule firstTokenDictRule = new TokenDictRule.Builder() - .text(text) - .partOfSpeech(partOfSpeech) - .tokens(tokens) - .build(); - TokenDictRule secondTokenDictRule = new TokenDictRule.Builder() - .text(text) - .partOfSpeech(partOfSpeech) - .tokens(tokens) - .build(); - List tokenDictRuleList = new ArrayList<>(); - tokenDictRuleList.add(firstTokenDictRule); - - CreateTokenizationDictionaryOptions createOptions = new CreateTokenizationDictionaryOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .tokenizationRules(tokenDictRuleList) - .addTokenizationRules(secondTokenDictRule) - .build(); - - tokenDictRuleList.add(secondTokenDictRule); - - assertEquals(environmentId, createOptions.environmentId()); - assertEquals(collectionId, createOptions.collectionId()); - assertEquals(tokenDictRuleList, createOptions.tokenizationRules()); - } - - @Test - public void testGetTokenizationDictionaryStatusOptions() { - GetTokenizationDictionaryStatusOptions getOptions = new GetTokenizationDictionaryStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - - assertEquals(environmentId, getOptions.environmentId()); - assertEquals(collectionId, getOptions.collectionId()); - } - - @Test - public void testDeleteTokenizationDictionaryOptions() { - DeleteTokenizationDictionaryOptions deleteOptions = new DeleteTokenizationDictionaryOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - - assertEquals(environmentId, deleteOptions.environmentId()); - assertEquals(collectionId, deleteOptions.collectionId()); - } - - @Test - public void testCreateTokenizationDictionary() throws InterruptedException { - server.enqueue(jsonResponse(tokenDictStatusResponse)); - - String text = "text"; - String partOfSpeech = "noun"; - List tokens = Arrays.asList("token 1", "token 2"); - TokenDictRule tokenDictRule = new TokenDictRule.Builder() - .text(text) - .tokens(tokens) - .partOfSpeech(partOfSpeech) - .build(); - CreateTokenizationDictionaryOptions createOptions = new CreateTokenizationDictionaryOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .tokenizationRules(Collections.singletonList(tokenDictRule)) - .build(); - TokenDictStatusResponse response - = discoveryService.createTokenizationDictionary(createOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(POST, request.getMethod()); - assertEquals(tokenDictStatusResponse, response); - } - - @Test - public void testGetTokenizationDictionaryStatus() throws InterruptedException { - server.enqueue(jsonResponse(tokenDictStatusResponse)); - - GetTokenizationDictionaryStatusOptions getOptions = new GetTokenizationDictionaryStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - TokenDictStatusResponse response - = discoveryService.getTokenizationDictionaryStatus(getOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(tokenDictStatusResponse, response); - } - - @Test - public void testDeleteTokenizationDictionary() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); - - DeleteTokenizationDictionaryOptions deleteOptions = new DeleteTokenizationDictionaryOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - discoveryService.deleteTokenizationDictionary(deleteOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void testCreateStopwordListOptions() { - String testFilename = "test_filename"; - - CreateStopwordListOptions createStopwordListOptions = new CreateStopwordListOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .stopwordFile(testStream) - .stopwordFilename(testFilename) - .build(); - - assertEquals(environmentId, createStopwordListOptions.environmentId()); - assertEquals(collectionId, createStopwordListOptions.collectionId()); - assertEquals(testStream, createStopwordListOptions.stopwordFile()); - assertEquals(testFilename, createStopwordListOptions.stopwordFilename()); - } - - @Test - public void testCreateStopwordList() throws InterruptedException { - server.enqueue(jsonResponse(tokenDictStatusResponse)); - - String testFilename = "test_filename"; - - CreateStopwordListOptions createStopwordListOptions = new CreateStopwordListOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .stopwordFile(testStream) - .stopwordFilename(testFilename) - .build(); - TokenDictStatusResponse response - = discoveryService.createStopwordList(createStopwordListOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(POST, request.getMethod()); - assertEquals(tokenDictStatusResponse, response); - } - - @Test - public void testDeleteStopwordListOptions() { - DeleteStopwordListOptions deleteStopwordListOptions = new DeleteStopwordListOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - - assertEquals(environmentId, deleteStopwordListOptions.environmentId()); - assertEquals(collectionId, deleteStopwordListOptions.collectionId()); - } - - @Test - public void testDeleteStopwordList() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); - - DeleteStopwordListOptions deleteStopwordListOptions = new DeleteStopwordListOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - discoveryService.deleteStopwordList(deleteStopwordListOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void testGetStopwordListStatusOptions() { - GetStopwordListStatusOptions getStopwordListStatusOptions = new GetStopwordListStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - - assertEquals(environmentId, getStopwordListStatusOptions.environmentId()); - assertEquals(collectionId, getStopwordListStatusOptions.collectionId()); - } - - @Test - public void testGetStopwordListStatus() throws InterruptedException { - server.enqueue(jsonResponse(tokenDictStatusResponseStopwords)); - - String type = "stopwords"; - - GetStopwordListStatusOptions getStopwordListStatusOptions = new GetStopwordListStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - TokenDictStatusResponse response - = discoveryService.getStopwordListStatus(getStopwordListStatusOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(TokenDictStatusResponse.Status.ACTIVE, response.getStatus()); - assertEquals(type, response.getType()); - } - - @Test - public void testCreateGatewayOptions() { - String name = "name"; - - CreateGatewayOptions createGatewayOptions = new CreateGatewayOptions.Builder() - .environmentId(environmentId) - .name(name) - .build(); - - assertEquals(environmentId, createGatewayOptions.environmentId()); - assertEquals(name, createGatewayOptions.name()); - } - - @Test - public void testCreateGateway() throws InterruptedException { - server.enqueue(jsonResponse(gatewayResponse)); - - String name = "name"; - - CreateGatewayOptions createGatewayOptions = new CreateGatewayOptions.Builder() - .environmentId(environmentId) - .name(name) - .build(); - Gateway response = discoveryService.createGateway(createGatewayOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(POST, request.getMethod()); - assertEquals(gatewayResponse, response); - } - - @Test - public void testDeleteGatewayOptions() { - String gatewayId = "gateway_id"; - - DeleteGatewayOptions deleteGatewayOptions = new DeleteGatewayOptions.Builder() - .environmentId(environmentId) - .gatewayId(gatewayId) - .build(); - - assertEquals(environmentId, deleteGatewayOptions.environmentId()); - assertEquals(gatewayId, deleteGatewayOptions.gatewayId()); - } - - @Test - public void testDeleteGateway() throws InterruptedException { - server.enqueue(jsonResponse(deleteGatewayResponse)); - - String gatewayId = "gateway_id"; - - DeleteGatewayOptions deleteGatewayOptions = new DeleteGatewayOptions.Builder() - .environmentId(environmentId) - .gatewayId(gatewayId) - .build(); - GatewayDelete response = discoveryService.deleteGateway(deleteGatewayOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE, request.getMethod()); - assertEquals(deleteGatewayResponse.getGatewayId(), response.getGatewayId()); - assertEquals(deleteGatewayResponse.getStatus(), response.getStatus()); - } - - @Test - public void testGetGatewayOptions() { - String gatewayId = "gateway_id"; - - GetGatewayOptions getGatewayOptions = new GetGatewayOptions.Builder() - .environmentId(environmentId) - .gatewayId(gatewayId) - .build(); - - assertEquals(environmentId, getGatewayOptions.environmentId()); - assertEquals(gatewayId, getGatewayOptions.gatewayId()); - } - - @Test - public void testGetGateway() throws InterruptedException { - server.enqueue(jsonResponse(gatewayResponse)); - - String gatewayId = "gateway_id"; - - GetGatewayOptions getGatewayOptions = new GetGatewayOptions.Builder() - .environmentId(environmentId) - .gatewayId(gatewayId) - .build(); - Gateway response = discoveryService.getGateway(getGatewayOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(gatewayResponse, response); - } - - @Test - public void testListGatewaysOptions() { - ListGatewaysOptions listGatewaysOptions = new ListGatewaysOptions.Builder() - .environmentId(environmentId) - .build(); - - assertEquals(environmentId, listGatewaysOptions.environmentId()); - } - - @Test - public void testListGateways() throws InterruptedException { - server.enqueue(jsonResponse(listGatewaysResponse)); - - ListGatewaysOptions listGatewaysOptions = new ListGatewaysOptions.Builder() - .environmentId(environmentId) - .build(); - GatewayList response = discoveryService.listGateways(listGatewaysOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(listGatewaysResponse, response); - } - - @Test - public void testSourceOptionsWebCrawl() { - String url = "url"; - String crawlSpeed = "crawl_speed"; - Long maximumHops = 1L; - Long requestTimeout = 2000L; - - SourceOptionsWebCrawl sourceOptionsWebCrawl = new SourceOptionsWebCrawl.Builder() - .url(url) - .limitToStartingHosts(true) - .crawlSpeed(crawlSpeed) - .allowUntrustedCertificate(true) - .maximumHops(maximumHops) - .requestTimeout(requestTimeout) - .overrideRobotsTxt(true) - .build(); - - assertEquals(url, sourceOptionsWebCrawl.url()); - assertTrue(sourceOptionsWebCrawl.limitToStartingHosts()); - assertEquals(crawlSpeed, sourceOptionsWebCrawl.crawlSpeed()); - assertTrue(sourceOptionsWebCrawl.allowUntrustedCertificate()); - assertEquals(maximumHops, sourceOptionsWebCrawl.maximumHops()); - assertEquals(requestTimeout, sourceOptionsWebCrawl.requestTimeout()); - assertTrue(sourceOptionsWebCrawl.overrideRobotsTxt()); - } -} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryIT.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryIT.java index 70a6c6d620b..a45cc4f08c0 100644 --- a/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryIT.java +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryIT.java @@ -1,105 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2019, 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 + * + * 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; +import static junit.framework.TestCase.assertNotNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + import com.ibm.cloud.sdk.core.http.HttpConfigOptions; import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator; +import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.common.RetryRunner; import com.ibm.watson.common.WatsonServiceTest; import com.ibm.watson.discovery.query.AggregationType; import com.ibm.watson.discovery.query.Operator; -import com.ibm.watson.discovery.v2.model.AddDocumentOptions; -import com.ibm.watson.discovery.v2.model.Collection; -import com.ibm.watson.discovery.v2.model.Completions; -import com.ibm.watson.discovery.v2.model.ComponentSettingsResponse; -import com.ibm.watson.discovery.v2.model.CreateTrainingQueryOptions; -import com.ibm.watson.discovery.v2.model.DeleteDocumentOptions; -import com.ibm.watson.discovery.v2.model.DeleteDocumentResponse; -import com.ibm.watson.discovery.v2.model.DeleteTrainingQueriesOptions; -import com.ibm.watson.discovery.v2.model.DocumentAccepted; -import com.ibm.watson.discovery.v2.model.GetAutocompletionOptions; -import com.ibm.watson.discovery.v2.model.GetComponentSettingsOptions; -import com.ibm.watson.discovery.v2.model.GetTrainingQueryOptions; -import com.ibm.watson.discovery.v2.model.ListCollectionsOptions; -import com.ibm.watson.discovery.v2.model.ListCollectionsResponse; -import com.ibm.watson.discovery.v2.model.ListFieldsOptions; -import com.ibm.watson.discovery.v2.model.ListFieldsResponse; -import com.ibm.watson.discovery.v2.model.ListTrainingQueriesOptions; -import com.ibm.watson.discovery.v2.model.QueryCalculationAggregation; -import com.ibm.watson.discovery.v2.model.QueryFilterAggregation; -import com.ibm.watson.discovery.v2.model.QueryHistogramAggregation; -import com.ibm.watson.discovery.v2.model.QueryLargePassages; -import com.ibm.watson.discovery.v2.model.QueryLargeSuggestedRefinements; -import com.ibm.watson.discovery.v2.model.QueryLargeTableResults; -import com.ibm.watson.discovery.v2.model.QueryNestedAggregation; -import com.ibm.watson.discovery.v2.model.QueryNoticesOptions; -import com.ibm.watson.discovery.v2.model.QueryNoticesResponse; -import com.ibm.watson.discovery.v2.model.QueryOptions; -import com.ibm.watson.discovery.v2.model.QueryResponse; -import com.ibm.watson.discovery.v2.model.QueryResult; -import com.ibm.watson.discovery.v2.model.QueryResultPassage; -import com.ibm.watson.discovery.v2.model.QueryTermAggregation; -import com.ibm.watson.discovery.v2.model.QueryTimesliceAggregation; -import com.ibm.watson.discovery.v2.model.QueryTopHitsAggregation; -import com.ibm.watson.discovery.v2.model.TrainingExample; -import com.ibm.watson.discovery.v2.model.TrainingQuery; -import com.ibm.watson.discovery.v2.model.TrainingQuerySet; -import com.ibm.watson.discovery.v2.model.UpdateDocumentOptions; -import com.ibm.watson.discovery.v2.model.UpdateTrainingQueryOptions; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - +import com.ibm.watson.discovery.v2.model.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; -import static junit.framework.TestCase.assertNotNull; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - -@Ignore +/** The Class DiscoveryIT. */ @RunWith(RetryRunner.class) public class DiscoveryIT extends WatsonServiceTest { - private static final String VERSION = "2019-11-22"; + private static final String VERSION = "2022-07-29"; private static final String RESOURCE = "src/test/resources/discovery/v2/"; - private static final String PROJECT_ID = "9558dc01-8554-4d18-b0a5-70196f9f2fe6"; - private static final String COLLECTION_ID = "161d1e47-9651-e657-0000-016e8e939caf"; + private static final String PROJECT_ID = "ff7985e8-3bea-427a-8256-0327c73ec0c7"; + private static final String COLLECTION_ID = "02cd572a-8e9d-0cb5-0000-017cf13ffc2b"; + private static final String PREMIUM_PROJECT_ID = "feb5ab3a-1e22-4968-9c5e-021eeaabbf32"; + private static final String PREMIUM_COLLECTION_ID = "0a7b633c-e41d-319c-0000-018264bf5fcd"; private Discovery service; + private Discovery premiumService; + /** + * Sets up the tests. + * + * @throws Exception the exception + */ /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - String bearerToken = getProperty("discovery_v2.bearer_token"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", (bearerToken == null)); - Authenticator authenticator = new BearerTokenAuthenticator(bearerToken); + String apiKey = System.getenv("DISCOVERY_V2_APIKEY"); + // String premiumApiKey = getProperty("discovery_v2.apikeyPremium"); + // String premiumUrl = getProperty("discovery_v2.urlPremium"); + String serviceUrl = System.getenv("DISCOVERY_V2_URL"); + + if (apiKey == null) { + apiKey = getProperty("discovery_v2.apikey"); + serviceUrl = getProperty("discovery_v2.url"); + } + + assertNotNull( + "DISCOVERY_V2_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey); + + Authenticator authenticator = new IamAuthenticator.Builder().apikey(apiKey).build(); + // Authenticator premiumAuthenticator = + // new IamAuthenticator.Builder().apikey(premiumApiKey).build(); + service = new Discovery(VERSION, authenticator); service.setDefaultHeaders(getDefaultHeaders()); - service.setServiceUrl(getProperty("discovery_v2.url")); + service.setServiceUrl(serviceUrl); + // premiumService = new Discovery(VERSION, premiumAuthenticator); + // premiumService.setDefaultHeaders(getDefaultHeaders()); + // premiumService.setServiceUrl(premiumUrl); - HttpConfigOptions configOptions = new HttpConfigOptions.Builder() - .disableSslVerification(true) - .build(); + HttpConfigOptions configOptions = + new HttpConfigOptions.Builder().disableSslVerification(true).build(); service.configureClient(configOptions); + // premiumService.configureClient(configOptions); } + /** Test list collections. */ @Test public void testListCollections() { - ListCollectionsOptions options = new ListCollectionsOptions.Builder() - .projectId(PROJECT_ID) - .build(); + ListCollectionsOptions options = + new ListCollectionsOptions.Builder().projectId(PROJECT_ID).build(); ListCollectionsResponse response = service.listCollections(options).execute().getResult(); assertNotNull(response); @@ -113,29 +116,136 @@ public void testListCollections() { assertTrue(foundTestCollection); } + /** Test Create Collection. */ + // @Test + public void testCreateCollection() { + CreateCollectionOptions createCollectionOptions = + new CreateCollectionOptions.Builder() + .projectId(PROJECT_ID) + .name("name test") + .description("description test") + .language("en") + .build(); + CollectionDetails response = + service.createCollection(createCollectionOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.name().equals("name test")); + assertTrue(response.description().equals("description test")); + assertTrue(response.language().equals("en")); + + DeleteCollectionOptions deleteCollectionOptions = + new DeleteCollectionOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(response.collectionId()) + .build(); + Response deleteCollectionResponse = + service.deleteCollection(deleteCollectionOptions).execute(); + + assertTrue(deleteCollectionResponse.getStatusCode() == 204); + } + + /** Get Collection. */ + // @Test + public void testGetCollection() { + GetCollectionOptions getCollectionOptions = + new GetCollectionOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + CollectionDetails response = service.getCollection(getCollectionOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.collectionId().equals(COLLECTION_ID)); + } + + /** Update Collection. */ + // @Test + public void testUpdateCollection() { + // get the collection to reset variables at the end. + GetCollectionOptions getCollectionOptions = + new GetCollectionOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + CollectionDetails getCollectionResponse = + service.getCollection(getCollectionOptions).execute().getResult(); + + assertNotNull(getCollectionResponse); + try { + UpdateCollectionOptions updateCollectionOptions = + new UpdateCollectionOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .name("name updated") + .description("description updated") + .build(); + CollectionDetails updateCollectionResponse = + service.updateCollection(updateCollectionOptions).execute().getResult(); + + assertNotNull(updateCollectionResponse); + assertNotNull(updateCollectionResponse.collectionId()); + assertTrue(updateCollectionResponse.name().equals("name updated")); + assertTrue(updateCollectionResponse.description().equals("description updated")); + } finally { + UpdateCollectionOptions updateCollectionOptionsOriginal = + new UpdateCollectionOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .name(getCollectionResponse.name()) + .description(getCollectionResponse.description()) + .build(); + CollectionDetails updateCollectionResponseOriginal = + service.updateCollection(updateCollectionOptionsOriginal).execute().getResult(); + + assertNotNull(updateCollectionResponseOriginal); + assertNotNull(updateCollectionResponseOriginal.collectionId()); + } + } + + /** Delete Collection. */ + // @Test + public void testDeleteCollection() { + String collectionId = "{COLLECTION_ID}"; + DeleteCollectionOptions deleteCollectionOptions = + new DeleteCollectionOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(collectionId) + .build(); + Response deleteCollectionResponse = + service.deleteCollection(deleteCollectionOptions).execute(); + + assertTrue(deleteCollectionResponse.getStatusCode() == 204); + } + + /** Test query. */ @Test public void testQuery() { - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .addCollectionIds(COLLECTION_ID) - .query("field" + Operator.CONTAINS + "1") - .build(); + QueryLargePassages queryLargePassages = + new QueryLargePassages.Builder().findAnswers(true).maxAnswersPerPassage(2).build(); + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .addCollectionIds(COLLECTION_ID) + .query("field" + Operator.CONTAINS + "1") + .passages(queryLargePassages) + .build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); } + /** Test query natural language. */ @Test public void testQueryNaturalLanguage() { - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("test query") - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).naturalLanguageQuery("test query").build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); } + /** Test query with calculation aggregation. */ @Test public void testQueryWithCalculationAggregation() { StringBuilder sb = new StringBuilder(); @@ -144,20 +254,20 @@ public void testQueryWithCalculationAggregation() { sb.append("field"); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryCalculationAggregation histogramAggregation = (QueryCalculationAggregation) response.getAggregations().get(0); + QueryAggregationQueryCalculationAggregation histogramAggregation = + (QueryAggregationQueryCalculationAggregation) response.getAggregations().get(0); assertNotNull(histogramAggregation); assertNotNull(response); } + /** Test query with filter aggregation. */ @Test public void testQueryWithFilterAggregation() { StringBuilder sb = new StringBuilder(); @@ -166,20 +276,20 @@ public void testQueryWithFilterAggregation() { sb.append("field:9"); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryFilterAggregation filterAggregation = (QueryFilterAggregation) response.getAggregations().get(0); + QueryAggregationQueryFilterAggregation filterAggregation = + (QueryAggregationQueryFilterAggregation) response.getAggregations().get(0); assertNotNull(filterAggregation); assertNotNull(response); } + /** Test query with histogram aggregation. */ @Test public void testQueryWithHistogramAggregation() { StringBuilder sb = new StringBuilder(); @@ -190,20 +300,20 @@ public void testQueryWithHistogramAggregation() { sb.append(5L); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryHistogramAggregation histogramAggregation = (QueryHistogramAggregation) response.getAggregations().get(0); + QueryAggregationQueryHistogramAggregation histogramAggregation = + (QueryAggregationQueryHistogramAggregation) response.getAggregations().get(0); assertNotNull(histogramAggregation); assertNotNull(response); } + /** Test query with nested aggregation. */ @Test public void testQueryWithNestedAggregation() { StringBuilder sb = new StringBuilder(); @@ -219,20 +329,20 @@ public void testQueryWithNestedAggregation() { sb.append("field"); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryNestedAggregation nestedAggregation = (QueryNestedAggregation) response.getAggregations().get(0); + QueryAggregationQueryNestedAggregation nestedAggregation = + (QueryAggregationQueryNestedAggregation) response.getAggregations().get(0); assertNotNull(nestedAggregation); assertNotNull(response); } + /** Test query with term aggregation. */ @Test public void testQueryWithTermAggregation() { StringBuilder sb = new StringBuilder(); @@ -243,20 +353,20 @@ public void testQueryWithTermAggregation() { sb.append(10L); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryTermAggregation termAggregation = (QueryTermAggregation) response.getAggregations().get(0); + QueryAggregationQueryTermAggregation termAggregation = + (QueryAggregationQueryTermAggregation) response.getAggregations().get(0); assertNotNull(termAggregation); assertNotNull(response); } + /** Test query with timeslice aggregation. */ @Test public void testQueryWithTimesliceAggregation() { StringBuilder sb = new StringBuilder(); @@ -265,20 +375,20 @@ public void testQueryWithTimesliceAggregation() { sb.append("time,1day,EST"); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryTimesliceAggregation timesliceAggregation = (QueryTimesliceAggregation) response.getAggregations().get(0); + QueryAggregationQueryTimesliceAggregation timesliceAggregation = + (QueryAggregationQueryTimesliceAggregation) response.getAggregations().get(0); assertNotNull(timesliceAggregation); assertNotNull(response); } + /** Test query with top hits aggregation. */ @Test public void testQueryWithTopHitsAggregation() { StringBuilder sb = new StringBuilder(); @@ -287,45 +397,39 @@ public void testQueryWithTopHitsAggregation() { sb.append("3"); sb.append(Operator.CLOSING_GROUPING); String aggregation = sb.toString(); - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .aggregation(aggregation) - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).aggregation(aggregation).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getAggregations().size() > 0); - QueryTopHitsAggregation topHitsAggregation = (QueryTopHitsAggregation) response.getAggregations().get(0); + QueryAggregationQueryTopHitsAggregation topHitsAggregation = + (QueryAggregationQueryTopHitsAggregation) response.getAggregations().get(0); assertNotNull(topHitsAggregation); assertNotNull(response); } + /** Test query with count. */ @Test public void testQueryWithCount() { - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .count(5L) - .build(); + QueryOptions options = new QueryOptions.Builder().projectId(PROJECT_ID).count(5L).build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertTrue(response.getResults().size() <= 5); } + /** Test query with offset. */ @Test public void testQueryWithOffset() { - QueryOptions optionsNoOffset = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .build(); + QueryOptions optionsNoOffset = new QueryOptions.Builder().projectId(PROJECT_ID).build(); QueryResponse responseNoOffset = service.query(optionsNoOffset).execute().getResult(); assertNotNull(responseNoOffset); - QueryOptions optionsWithOffset = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .offset(2L) - .build(); + QueryOptions optionsWithOffset = + new QueryOptions.Builder().projectId(PROJECT_ID).offset(2L).build(); QueryResponse responseWithOffset = service.query(optionsWithOffset).execute().getResult(); assertNotNull(responseWithOffset); @@ -334,12 +438,11 @@ public void testQueryWithOffset() { } } + /** Test query with sort. */ @Test public void testQueryWithSort() { - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .sort("document_id") - .build(); + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).sort("document_id").build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); @@ -350,13 +453,15 @@ public void testQueryWithSort() { } } + /** Test query with highlight. */ @Test public void testQueryWithHighlight() { - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("president") - .highlight(true) - .build(); + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("president") + .highlight(true) + .build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); @@ -374,31 +479,33 @@ public void testQueryWithHighlight() { } } + /** Test query with spelling suggestions. */ @Test public void testQueryWithSpellingSuggestions() { - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("presdent") - .spellingSuggestions(true) - .build(); + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("presdent") + .spellingSuggestions(true) + .build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); assertNotNull(response.getSuggestedQuery()); } + /** Test query with table results. */ @Test public void testQueryWithTableResults() { - QueryLargeTableResults tableResults = new QueryLargeTableResults.Builder() - .enabled(true) - .count(5L) - .build(); - - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("test query") - .tableResults(tableResults) - .build(); + QueryLargeTableResults tableResults = + new QueryLargeTableResults.Builder().enabled(true).count(5L).build(); + + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("test query") + .tableResults(tableResults) + .build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); @@ -406,18 +513,18 @@ public void testQueryWithTableResults() { assertTrue(response.getTableResults().size() <= 5); } + /** Test query with suggested refinements. */ @Test public void testQueryWithSuggestedRefinements() { - QueryLargeSuggestedRefinements suggestedRefinements = new QueryLargeSuggestedRefinements.Builder() - .enabled(true) - .count(5L) - .build(); - - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("test query") - .suggestedRefinements(suggestedRefinements) - .build(); + QueryLargeSuggestedRefinements suggestedRefinements = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(5L).build(); + + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("test query") + .suggestedRefinements(suggestedRefinements) + .build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); @@ -425,19 +532,18 @@ public void testQueryWithSuggestedRefinements() { assertTrue(response.getSuggestedRefinements().size() <= 5); } + /** Test query with passages. */ @Test public void testQueryWithPassages() { - QueryLargePassages passages = new QueryLargePassages.Builder() - .enabled(true) - .count(5L) - .perDocument(true) - .build(); - - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("test query") - .passages(passages) - .build(); + QueryLargePassages passages = + new QueryLargePassages.Builder().enabled(true).count(5L).perDocument(true).build(); + + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("test query") + .passages(passages) + .build(); QueryResponse response = service.query(options).execute().getResult(); assertNotNull(response); @@ -452,13 +558,15 @@ public void testQueryWithPassages() { assertTrue(foundPassages); } + /** Test get autocompletion. */ @Test public void testGetAutocompletion() { - GetAutocompletionOptions options = new GetAutocompletionOptions.Builder() - .projectId(PROJECT_ID) - .prefix("pre") - .count(5L) - .build(); + GetAutocompletionOptions options = + new GetAutocompletionOptions.Builder() + .projectId(PROJECT_ID) + .prefix("pre") + .count(5L) + .build(); Completions response = service.getAutocompletion(options).execute().getResult(); assertNotNull(response); @@ -466,56 +574,59 @@ public void testGetAutocompletion() { assertTrue(response.getCompletions().get(0).startsWith("pre")); } + /** Test query notices. */ @Test public void testQueryNotices() { - QueryNoticesOptions options = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .query("field" + Operator.CONTAINS + "1") - .build(); + QueryNoticesOptions options = + new QueryNoticesOptions.Builder() + .projectId(PROJECT_ID) + .query("field" + Operator.CONTAINS + "1") + .build(); QueryNoticesResponse response = service.queryNotices(options).execute().getResult(); assertNotNull(response); assertNotNull(response.getNotices()); } + /** Test query notices natural language. */ @Test public void testQueryNoticesNaturalLanguage() { - QueryNoticesOptions options = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery("test query") - .build(); + QueryNoticesOptions options = + new QueryNoticesOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("test query") + .build(); QueryNoticesResponse response = service.queryNotices(options).execute().getResult(); assertNotNull(response); assertNotNull(response.getNotices()); } + /** Test query notices with count. */ @Test public void testQueryNoticesWithCount() { - QueryNoticesOptions options = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .count(5L) - .build(); + QueryNoticesOptions options = + new QueryNoticesOptions.Builder().projectId(PROJECT_ID).count(5L).build(); QueryNoticesResponse response = service.queryNotices(options).execute().getResult(); assertNotNull(response); assertTrue(response.getNotices().size() <= 5); } + /** Test query notices with offset. */ @Test public void testQueryNoticesWithOffset() { - QueryNoticesOptions optionsNoOffset = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - QueryNoticesResponse responseNoOffset = service.queryNotices(optionsNoOffset).execute().getResult(); + QueryNoticesOptions optionsNoOffset = + new QueryNoticesOptions.Builder().projectId(PROJECT_ID).build(); + QueryNoticesResponse responseNoOffset = + service.queryNotices(optionsNoOffset).execute().getResult(); assertNotNull(responseNoOffset); - QueryNoticesOptions optionsWithOffset = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .offset(2L) - .build(); - QueryNoticesResponse responseWithOffset = service.queryNotices(optionsWithOffset).execute().getResult(); + QueryNoticesOptions optionsWithOffset = + new QueryNoticesOptions.Builder().projectId(PROJECT_ID).offset(2L).build(); + QueryNoticesResponse responseWithOffset = + service.queryNotices(optionsWithOffset).execute().getResult(); assertNotNull(responseWithOffset); if (responseNoOffset.getNotices().size() > 2) { @@ -523,86 +634,100 @@ public void testQueryNoticesWithOffset() { } } + /** Test list fields. */ @Test public void testListFields() { - ListFieldsOptions options = new ListFieldsOptions.Builder() - .projectId(PROJECT_ID) - .addCollectionIds(COLLECTION_ID) - .build(); + ListFieldsOptions options = + new ListFieldsOptions.Builder() + .projectId(PROJECT_ID) + .addCollectionIds(COLLECTION_ID) + .build(); ListFieldsResponse response = service.listFields(options).execute().getResult(); assertNotNull(response); assertTrue(response.getFields().size() > 0); } + /** Test get component settings. */ @Test public void testGetComponentSettings() { - GetComponentSettingsOptions options = new GetComponentSettingsOptions.Builder() - .projectId(PROJECT_ID) - .build(); - ComponentSettingsResponse response = service.getComponentSettings(options).execute().getResult(); + GetComponentSettingsOptions options = + new GetComponentSettingsOptions.Builder().projectId(PROJECT_ID).build(); + ComponentSettingsResponse response = + service.getComponentSettings(options).execute().getResult(); assertNotNull(response); } + /** + * Test document operations. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws InterruptedException the interrupted exception + */ @Test public void testDocumentOperations() throws IOException, InterruptedException { InputStream testFile = new FileInputStream(RESOURCE + "test-pdf.pdf"); String metadata = "{ \"metadata\": \"value\" }"; - AddDocumentOptions addDocumentOptions = new AddDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .file(testFile) - .filename("test-file") - .fileContentType(HttpMediaType.APPLICATION_PDF) - .xWatsonDiscoveryForce(true) - .build(); + AddDocumentOptions addDocumentOptions = + new AddDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .file(testFile) + .filename("test-file") + .fileContentType(HttpMediaType.APPLICATION_PDF) + .xWatsonDiscoveryForce(true) + .build(); DocumentAccepted addResponse = service.addDocument(addDocumentOptions).execute().getResult(); assertNotNull(addResponse); String documentId = addResponse.getDocumentId(); - // Assert that we can find the new document with an empty query. We'll try 5 times and sleep in between. - // TODO: Uncomment once service GAs. WAY too slow in processing now to work. - /*QueryOptions queryOptions = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .addCollectionIds(COLLECTION_ID) - .build(); - boolean foundAddedDocument = false; - for (int i = 0; i < 5; i++) { - Thread.sleep(5000); - - QueryResponse queryResponse = service.query(queryOptions).execute().getResult(); - for (QueryResult result : queryResponse.getResults()) { - if (result.getDocumentId().equals(documentId)) { - foundAddedDocument = true; - break; - } - } - } - assertTrue(foundAddedDocument);*/ - + ListDocumentsOptions listDocumentsOptions = + new ListDocumentsOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + ListDocumentsResponse documentList = + service.listDocuments(listDocumentsOptions).execute().getResult(); + + assertNotNull(documentList); + assertTrue(documentList.getDocuments().size() > 0); + + GetDocumentOptions getDocumentOptions = + new GetDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .documentId(documentId) + .build(); + DocumentDetails gotDocument = service.getDocument(getDocumentOptions).execute().getResult(); + + assertNotNull(gotDocument.getDocumentId()); try { - UpdateDocumentOptions updateDocumentOptions = new UpdateDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(documentId) - .xWatsonDiscoveryForce(true) - .metadata(metadata) - .build(); - DocumentAccepted updateResponse = service.updateDocument(updateDocumentOptions).execute().getResult(); + UpdateDocumentOptions updateDocumentOptions = + new UpdateDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .documentId(documentId) + .xWatsonDiscoveryForce(true) + .metadata(metadata) + .build(); + DocumentAccepted updateResponse = + service.updateDocument(updateDocumentOptions).execute().getResult(); assertNotNull(updateResponse); assertEquals(documentId, updateResponse.getDocumentId()); } finally { - DeleteDocumentOptions deleteDocumentOptions = new DeleteDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(documentId) - .xWatsonDiscoveryForce(true) - .build(); - DeleteDocumentResponse deleteResponse = service.deleteDocument(deleteDocumentOptions).execute().getResult(); + DeleteDocumentOptions deleteDocumentOptions = + new DeleteDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .documentId(documentId) + .xWatsonDiscoveryForce(true) + .build(); + DeleteDocumentResponse deleteResponse = + service.deleteDocument(deleteDocumentOptions).execute().getResult(); assertNotNull(deleteResponse); assertEquals(documentId, deleteResponse.getDocumentId()); @@ -611,43 +736,52 @@ public void testDocumentOperations() throws IOException, InterruptedException { } } + /** + * Test training query operations. + * + * @throws FileNotFoundException the file not found exception + */ @Test public void testTrainingQueryOperations() throws FileNotFoundException { - ListTrainingQueriesOptions listTrainingQueriesOptions = new ListTrainingQueriesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - TrainingQuerySet listResponse = service.listTrainingQueries(listTrainingQueriesOptions).execute().getResult(); + ListTrainingQueriesOptions listTrainingQueriesOptions = + new ListTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); + TrainingQuerySet listResponse = + service.listTrainingQueries(listTrainingQueriesOptions).execute().getResult(); assertNotNull(listResponse); int initialNumOfTrainingQueries = listResponse.getQueries().size(); // Create test document. InputStream testFile = new FileInputStream(RESOURCE + "test-pdf.pdf"); - AddDocumentOptions addDocumentOptions = new AddDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .file(testFile) - .filename("test-file") - .fileContentType(HttpMediaType.APPLICATION_PDF) - .xWatsonDiscoveryForce(true) - .build(); + AddDocumentOptions addDocumentOptions = + new AddDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .file(testFile) + .filename("test-file") + .fileContentType(HttpMediaType.APPLICATION_PDF) + .xWatsonDiscoveryForce(true) + .build(); DocumentAccepted addResponse = service.addDocument(addDocumentOptions).execute().getResult(); assertNotNull(addResponse); String documentId = addResponse.getDocumentId(); - TrainingExample trainingExample = new TrainingExample.Builder() - .collectionId(COLLECTION_ID) - .documentId(documentId) - .relevance(1L) - .build(); - - CreateTrainingQueryOptions createTrainingQueryOptions = new CreateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .addExamples(trainingExample) - .naturalLanguageQuery("test query" + UUID.randomUUID().toString()) - .build(); - TrainingQuery createResponse = service.createTrainingQuery(createTrainingQueryOptions).execute().getResult(); + TrainingExample trainingExample = + new TrainingExample.Builder() + .collectionId(COLLECTION_ID) + .documentId(documentId) + .relevance(1L) + .build(); + + CreateTrainingQueryOptions createTrainingQueryOptions = + new CreateTrainingQueryOptions.Builder() + .projectId(PROJECT_ID) + .addExamples(trainingExample) + .naturalLanguageQuery("test query" + UUID.randomUUID().toString()) + .build(); + TrainingQuery createResponse = + service.createTrainingQuery(createTrainingQueryOptions).execute().getResult(); assertNotNull(createResponse); assertEquals(trainingExample.collectionId(), createResponse.examples().get(0).collectionId()); @@ -656,48 +790,753 @@ public void testTrainingQueryOperations() throws FileNotFoundException { String queryId = createResponse.queryId(); try { - TrainingQuerySet updatedListResponse - = service.listTrainingQueries(listTrainingQueriesOptions).execute().getResult(); + TrainingQuerySet updatedListResponse = + service.listTrainingQueries(listTrainingQueriesOptions).execute().getResult(); assertNotNull(updatedListResponse); assertTrue(updatedListResponse.getQueries().size() > initialNumOfTrainingQueries); - GetTrainingQueryOptions getTrainingQueryOptions = new GetTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(queryId) - .build(); - TrainingQuery getResponse = service.getTrainingQuery(getTrainingQueryOptions).execute().getResult(); + GetTrainingQueryOptions getTrainingQueryOptions = + new GetTrainingQueryOptions.Builder().projectId(PROJECT_ID).queryId(queryId).build(); + TrainingQuery getResponse = + service.getTrainingQuery(getTrainingQueryOptions).execute().getResult(); assertNotNull(getResponse); assertEquals(queryId, getResponse.queryId()); String updatedQuery = "new query" + UUID.randomUUID().toString(); - UpdateTrainingQueryOptions updateTrainingQueryOptions = new UpdateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(queryId) - .naturalLanguageQuery(updatedQuery) - .addExamples(trainingExample) - .build(); - TrainingQuery updateResponse = service.updateTrainingQuery(updateTrainingQueryOptions).execute().getResult(); + UpdateTrainingQueryOptions updateTrainingQueryOptions = + new UpdateTrainingQueryOptions.Builder() + .projectId(PROJECT_ID) + .queryId(queryId) + .naturalLanguageQuery(updatedQuery) + .addExamples(trainingExample) + .build(); + TrainingQuery updateResponse = + service.updateTrainingQuery(updateTrainingQueryOptions).execute().getResult(); assertNotNull(updateResponse); assertEquals(updatedQuery, updateResponse.naturalLanguageQuery()); } finally { - DeleteTrainingQueriesOptions deleteTrainingQueriesOptions = new DeleteTrainingQueriesOptions.Builder() - .projectId(PROJECT_ID) - .build(); + DeleteTrainingQueriesOptions deleteTrainingQueriesOptions = + new DeleteTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); service.deleteTrainingQueries(deleteTrainingQueriesOptions).execute(); - TrainingQuerySet listResponseAfterDelete - = service.listTrainingQueries(listTrainingQueriesOptions).execute().getResult(); + TrainingQuerySet listResponseAfterDelete = + service.listTrainingQueries(listTrainingQueriesOptions).execute().getResult(); assertEquals(0, listResponseAfterDelete.getQueries().size()); - DeleteDocumentOptions deleteDocumentOptions = new DeleteDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(documentId) - .xWatsonDiscoveryForce(true) - .build(); + DeleteDocumentOptions deleteDocumentOptions = + new DeleteDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .documentId(documentId) + .xWatsonDiscoveryForce(true) + .build(); + service.deleteDocument(deleteDocumentOptions).execute().getResult(); + } + } + + /** Test List Enrichments. */ + // @Test + public void testListEnrichments() { + ListEnrichmentsOptions listEnrichmentsOptions = + new ListEnrichmentsOptions.Builder().projectId(PROJECT_ID).build(); + Enrichments response = service.listEnrichments(listEnrichmentsOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getEnrichments().size() > 0); + } + + /** Test Create Enrichment. */ + // @Test + public void testCreateEnrichment() throws FileNotFoundException { + InputStream testFile = new FileInputStream(RESOURCE + "test.csv"); + + EnrichmentOptions enrichmentOptions = + new EnrichmentOptions.Builder() + .languages(new ArrayList()) + .addLanguages("en") + .entityType("keyword") + .build(); + + CreateEnrichment enrichmentObj = + new CreateEnrichment.Builder() + .name("Dictionary") + .description("test dictionary") + .type(CreateEnrichment.Type.DICTIONARY) + .options(enrichmentOptions) + .build(); + + CreateEnrichmentOptions createEnrichmentOptions = + new CreateEnrichmentOptions.Builder() + .enrichment(enrichmentObj) + .projectId(PROJECT_ID) + .file(testFile) + .build(); + Enrichment response = service.createEnrichment(createEnrichmentOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals("Dictionary")); + assertTrue(response.getDescription().equals("test dictionary")); + assertTrue(response.getType().equals("dictionary")); + assertTrue(response.getOptions().languages().size() == 1); + assertTrue(response.getOptions().languages().get(0).equals("en")); + assertTrue(response.getOptions().entityType().equals("keyword")); + + DeleteEnrichmentOptions deleteEnrichmentOptions = + new DeleteEnrichmentOptions.Builder() + .enrichmentId(response.getEnrichmentId()) + .projectId(PROJECT_ID) + .build(); + Response deleteEnrichmentResponse = + service.deleteEnrichment(deleteEnrichmentOptions).execute(); + + assertTrue(deleteEnrichmentResponse.getStatusCode() == 204); + } + + /** Test Get Enrichment. */ + // @Test + public void testGetEnrichment() throws FileNotFoundException { + // Create Enrichment + InputStream testFile = new FileInputStream(RESOURCE + "test.csv"); + + EnrichmentOptions enrichmentOptions = + new EnrichmentOptions.Builder() + .languages(new ArrayList()) + .addLanguages("en") + .entityType("keyword") + .build(); + + CreateEnrichment enrichmentObj = + new CreateEnrichment.Builder() + .name("Dictionary") + .description("test dictionary") + .type("dictionary") + .options(enrichmentOptions) + .build(); + + CreateEnrichmentOptions createEnrichmentOptions = + new CreateEnrichmentOptions.Builder() + .enrichment(enrichmentObj) + .projectId(PROJECT_ID) + .file(testFile) + .build(); + Enrichment response = service.createEnrichment(createEnrichmentOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals("Dictionary")); + assertTrue(response.getDescription().equals("test dictionary")); + assertTrue(response.getType().equals("dictionary")); + assertTrue(response.getOptions().languages().size() == 1); + assertTrue(response.getOptions().languages().get(0).equals("en")); + assertTrue(response.getOptions().entityType().equals("keyword")); + + // Get Enrichment + GetEnrichmentOptions getEnrichmentOptions = + new GetEnrichmentOptions.Builder() + .enrichmentId(response.getEnrichmentId()) + .projectId(PROJECT_ID) + .build(); + Enrichment getEnrichmentResponse = + service.getEnrichment(getEnrichmentOptions).execute().getResult(); + + assertNotNull(getEnrichmentResponse); + assertTrue(getEnrichmentOptions.enrichmentId().equals(response.getEnrichmentId())); + assertTrue(getEnrichmentResponse.getName().equals("Dictionary")); + assertTrue(getEnrichmentResponse.getDescription().equals("test dictionary")); + assertTrue(getEnrichmentResponse.getType().equals("dictionary")); + assertTrue(getEnrichmentResponse.getOptions().languages().size() == 1); + assertTrue(getEnrichmentResponse.getOptions().languages().get(0).equals("en")); + assertTrue(getEnrichmentResponse.getOptions().entityType().equals("keyword")); + + // Delete Enrichment + DeleteEnrichmentOptions deleteEnrichmentOptions = + new DeleteEnrichmentOptions.Builder() + .enrichmentId(response.getEnrichmentId()) + .projectId(PROJECT_ID) + .build(); + Response deleteEnrichmentResponse = + service.deleteEnrichment(deleteEnrichmentOptions).execute(); + + assertTrue(deleteEnrichmentResponse.getStatusCode() == 204); + } + + /** Test Update Enrichment. */ + // @Test + public void testUpdateEnrichment() throws FileNotFoundException { + // Create Enrichment + InputStream testFile = new FileInputStream(RESOURCE + "test.csv"); + + EnrichmentOptions enrichmentOptions = + new EnrichmentOptions.Builder() + .languages(new ArrayList()) + .addLanguages("en") + .entityType("keyword") + .build(); + + CreateEnrichment enrichmentObj = + new CreateEnrichment.Builder() + .name("Dictionary") + .description("test dictionary") + .type("dictionary") + .options(enrichmentOptions) + .build(); + + CreateEnrichmentOptions createEnrichmentOptions = + new CreateEnrichmentOptions.Builder() + .enrichment(enrichmentObj) + .projectId(PROJECT_ID) + .file(testFile) + .build(); + Enrichment response = service.createEnrichment(createEnrichmentOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals("Dictionary")); + assertTrue(response.getDescription().equals("test dictionary")); + assertTrue(response.getType().equals("dictionary")); + assertTrue(response.getOptions().languages().size() == 1); + assertTrue(response.getOptions().languages().get(0).equals("en")); + assertTrue(response.getOptions().entityType().equals("keyword")); + + // Get Enrichment + UpdateEnrichmentOptions updateEnrichmentOptions = + new UpdateEnrichmentOptions.Builder() + .enrichmentId(response.getEnrichmentId()) + .projectId(PROJECT_ID) + .name("Dictionary update") + .description("test dictionary update") + .build(); + Enrichment updateEnrichmentResponse = + service.updateEnrichment(updateEnrichmentOptions).execute().getResult(); + + assertNotNull(updateEnrichmentResponse); + assertTrue(updateEnrichmentResponse.getEnrichmentId().equals(response.getEnrichmentId())); + assertTrue(updateEnrichmentResponse.getName().equals("Dictionary update")); + assertTrue(updateEnrichmentResponse.getDescription().equals("test dictionary update")); + assertTrue(updateEnrichmentResponse.getType().equals("dictionary")); + assertTrue(updateEnrichmentResponse.getOptions().languages().size() == 1); + assertTrue(updateEnrichmentResponse.getOptions().languages().get(0).equals("en")); + assertTrue(updateEnrichmentResponse.getOptions().entityType().equals("keyword")); + + // Delete Enrichment + DeleteEnrichmentOptions deleteEnrichmentOptions = + new DeleteEnrichmentOptions.Builder() + .enrichmentId(response.getEnrichmentId()) + .projectId(PROJECT_ID) + .build(); + Response deleteEnrichmentResponse = + service.deleteEnrichment(deleteEnrichmentOptions).execute(); + + assertTrue(deleteEnrichmentResponse.getStatusCode() == 204); + } + + /** Test Delete Enrichment. */ + // @Test + public void testDeleteEnrichment() { + // Delete Enrichment + String enrichmentId = "{enrichmentId}"; + DeleteEnrichmentOptions deleteEnrichmentOptions = + new DeleteEnrichmentOptions.Builder() + .enrichmentId(enrichmentId) + .projectId(PROJECT_ID) + .build(); + Response deleteEnrichmentResponse = + service.deleteEnrichment(deleteEnrichmentOptions).execute(); + + assertTrue(deleteEnrichmentResponse.getStatusCode() == 204); + } + + /** Test List Projects. */ + // @Test + public void testListProjects() { + ListProjectsResponse response = service.listProjects().execute().getResult(); + + assertNotNull(response); + assertNotNull(response.getProjects()); + } + + /** Create Project. */ + // @Test + public void testCreateProject() { + // create project + CreateProjectOptions createProjectOptions = + new CreateProjectOptions.Builder() + .name("create project test java") + .type("document_retrieval") + .build(); + ProjectDetails response = service.createProject(createProjectOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals("create project test java")); + assertTrue(response.getType().equals("document_retrieval")); + + // delete project + DeleteProjectOptions deleteProjectOptions = + new DeleteProjectOptions.Builder().projectId(response.getProjectId()).build(); + Response deleteResponse = service.deleteProject(deleteProjectOptions).execute(); + + assertNotNull(deleteResponse); + assertTrue(deleteResponse.getStatusCode() == 204); + } + + /** Get Project. */ + // @Test + public void testGetProject() { + // Get projects + ListProjectsResponse projectsResponse = service.listProjects().execute().getResult(); + // Grab a project to test out + ProjectListDetails projectTest = projectsResponse.getProjects().get(0); + + GetProjectOptions getProjectOptions = + new GetProjectOptions.Builder().projectId(projectTest.getProjectId()).build(); + ProjectDetails response = service.getProject(getProjectOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals(projectTest.getName())); + } + + /** Update Project. */ + // @Test + public void testUpdateProject() { + // Get projects + ListProjectsResponse projectsResponse = service.listProjects().execute().getResult(); + // Grab a project to test out + ProjectListDetails projectTest = projectsResponse.getProjects().get(0); + + UpdateProjectOptions updateProjectOptions = + new UpdateProjectOptions.Builder() + .projectId(projectTest.getProjectId()) + .name("updated project name test") + .build(); + ProjectDetails response = service.updateProject(updateProjectOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals("updated project name test")); + + // Reset project name to original name. + updateProjectOptions = + new UpdateProjectOptions.Builder() + .projectId(projectTest.getProjectId()) + .name(projectTest.getName()) + .build(); + response = service.updateProject(updateProjectOptions).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getName().equals(projectTest.getName())); + } + + /** Delete Project. */ + // @Test + public void testDeleteProject() { + DeleteProjectOptions deleteProjectOptions = + new DeleteProjectOptions.Builder().projectId("{projectId}").build(); + Response deleteResponse = service.deleteProject(deleteProjectOptions).execute(); + + assertNotNull(deleteResponse); + assertTrue(deleteResponse.getStatusCode() == 204); + } + + /** Delete User Data. */ + // @Test + public void testDeleteUserData() { + DeleteUserDataOptions deleteUserDataOptions = + new DeleteUserDataOptions.Builder().customerId("{customerId}").build(); + Response deleteResponse = service.deleteUserData(deleteUserDataOptions).execute(); + + assertNotNull(deleteResponse); + assertTrue(deleteResponse.getStatusCode() == 204); + } + + /** Test query passages per document true. */ + @Test + public void TestQueryPassagesPerDocumentTrue() { + List Ids = new ArrayList<>(); + Ids.add(COLLECTION_ID); + QueryLargePassages queryLargePassages = + new QueryLargePassages.Builder().perDocument(true).build(); + + QueryOptions queryOptions = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .collectionIds(Ids) + .passages(queryLargePassages) + .query("text:IBM") + .count(2) + .build(); + QueryResponse queryResult = service.query(queryOptions).execute().getResult(); + assertNotNull(queryResult.getResults().get(0).getDocumentPassages().get(0).getPassageText()); + } + + /** Test query passages per document false. */ + @Test + public void TestQueryPassagesPerDocumentFalse() { + List Ids = new ArrayList<>(); + Ids.add(COLLECTION_ID); + QueryLargePassages queryLargePassages = + new QueryLargePassages.Builder().perDocument(false).build(); + + QueryOptions queryOptions = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .collectionIds(Ids) + .passages(queryLargePassages) + .query("text:IBM") + .count(2) + .build(); + QueryResponse queryResult = service.query(queryOptions).execute().getResult(); + assertNotNull(queryResult); + assertNotNull(queryResult.getPassages().get(0).getCollectionId()); + assertNotNull(queryResult.getPassages().get(0).getPassageText()); + assertNotNull(queryResult.getPassages().get(0).getDocumentId()); + } + + /** Test Analyze Document. */ + @Ignore + @Test + public void TestAnalyzeDocument() throws FileNotFoundException { + InputStream testFile = new FileInputStream(RESOURCE + "test-pdf.pdf"); + String metadata = "{ \"metadata\": \"value\" }"; + + AnalyzeDocumentOptions analyzeDocumentOptions = + new AnalyzeDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .file(testFile) + .filename("test-file") + .fileContentType(HttpMediaType.APPLICATION_PDF) + .metadata(metadata) + .build(); + AnalyzedDocument analyzedDocument = + service.analyzeDocument(analyzeDocumentOptions).execute().getResult(); + + assertNotNull(analyzedDocument); + } + + /** Test queryCollectionNotices. */ + @Test + public void TestQueryCollectionNotices() throws FileNotFoundException { + + QueryCollectionNoticesOptions queryCollectionNoticesOptions = + new QueryCollectionNoticesOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .naturalLanguageQuery("warning") + .build(); + QueryNoticesResponse queryNoticesResponse = + service.queryCollectionNotices(queryCollectionNoticesOptions).execute().getResult(); + + assertNotNull(queryNoticesResponse.getNotices()); + } + + /** Test deleteTrainingQuery. */ + @Test + public void TestDeleteTrainingQuery() throws FileNotFoundException { + + String queryId = ""; + String documentId = ""; + try { + // Create test document. + InputStream testFile = new FileInputStream(RESOURCE + "test-pdf.pdf"); + AddDocumentOptions addDocumentOptions = + new AddDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .file(testFile) + .filename("test-file") + .fileContentType(HttpMediaType.APPLICATION_PDF) + .xWatsonDiscoveryForce(true) + .build(); + DocumentAccepted addResponse = service.addDocument(addDocumentOptions).execute().getResult(); + + assertNotNull(addResponse); + documentId = addResponse.getDocumentId(); + + TrainingExample trainingExample = + new TrainingExample.Builder() + .collectionId(COLLECTION_ID) + .documentId(documentId) + .relevance(1L) + .build(); + + CreateTrainingQueryOptions createTrainingQueryOptions = + new CreateTrainingQueryOptions.Builder() + .projectId(PROJECT_ID) + .addExamples(trainingExample) + .naturalLanguageQuery("test query" + UUID.randomUUID().toString()) + .build(); + TrainingQuery createResponse = + service.createTrainingQuery(createTrainingQueryOptions).execute().getResult(); + queryId = createResponse.queryId(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteTrainingQueryOptions deleteTrainingQueryOptions = + new DeleteTrainingQueryOptions.Builder().projectId(PROJECT_ID).queryId(queryId).build(); + service.deleteTrainingQuery(deleteTrainingQueryOptions).execute().getResult(); + + DeleteDocumentOptions deleteDocumentOptions = + new DeleteDocumentOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .documentId(documentId) + .xWatsonDiscoveryForce(true) + .build(); service.deleteDocument(deleteDocumentOptions).execute().getResult(); } } + + /** + * Test document classifier operations. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws InterruptedException the interrupted exception + */ + // @Test + public void testDocumentClassifierOperations() throws IOException, InterruptedException { + InputStream testFile = new FileInputStream(RESOURCE + "classification_training.csv"); + + DocumentClassifierEnrichment documentClassifierEnrichment = + new DocumentClassifierEnrichment.Builder() + .enrichmentId("701db916-fc83-57ab-0000-00000000001e") + .addFields("text") + .addFields("body") + .build(); + + CreateDocumentClassifier documentClassifier = + new CreateDocumentClassifier.Builder() + .name("sdk-test") + .description("a deletable sdk test classifier") + .language("en") + .answerField("label_answer") + .addEnrichments(documentClassifierEnrichment) + .build(); + + CreateDocumentClassifierOptions createClassifierOptions = + new CreateDocumentClassifierOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .trainingData(testFile) + .testData(testFile) + .classifier(documentClassifier) + .build(); + + DocumentClassifier createResponse = + premiumService.createDocumentClassifier(createClassifierOptions).execute().getResult(); + + assertNotNull(createResponse.getClassifierId()); + String classifierId = createResponse.getClassifierId(); + + ListDocumentClassifiersOptions listDocumentClassifierOptions = + new ListDocumentClassifiersOptions.Builder().projectId(PREMIUM_PROJECT_ID).build(); + + DocumentClassifiers listResponse = + premiumService.listDocumentClassifiers(listDocumentClassifierOptions).execute().getResult(); + assertTrue(listResponse.getClassifiers().size() > 0); + + GetDocumentClassifierOptions getDocumentClassifierOptions = + new GetDocumentClassifierOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .build(); + + DocumentClassifier gotDocument = + premiumService.getDocumentClassifier(getDocumentClassifierOptions).execute().getResult(); + assertNotNull(gotDocument); + try { + String updatedName = "new-sdk-test"; + UpdateDocumentClassifier updateDocumentClassifier = + new UpdateDocumentClassifier.Builder().name("new-sdk-test").build(); + UpdateDocumentClassifierOptions updateDocumentClassifierOptions = + new UpdateDocumentClassifierOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .classifier(updateDocumentClassifier) + .build(); + + DocumentClassifier updateResponse = + premiumService + .updateDocumentClassifier(updateDocumentClassifierOptions) + .execute() + .getResult(); + + assertNotNull(updateResponse); + assertEquals(updatedName, updateResponse.getName()); + + String classifierModelName = "classifier model sdk test"; + CreateDocumentClassifierModelOptions createDocumentClassifierModelOptions = + new CreateDocumentClassifierModelOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .name(classifierModelName) + .learningRate(0.5) + .addL1RegularizationStrengths(0.0001) + .trainingMaxSteps(100000) + .build(); + DocumentClassifierModel createModelResponse = + premiumService + .createDocumentClassifierModel(createDocumentClassifierModelOptions) + .execute() + .getResult(); + assertNotNull(createModelResponse.getName()); + + ListDocumentClassifierModelsOptions listDocumentClassifierModelsOptions = + new ListDocumentClassifierModelsOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .build(); + + DocumentClassifierModels listModelsResponse = + premiumService + .listDocumentClassifierModels(listDocumentClassifierModelsOptions) + .execute() + .getResult(); + assertTrue(listModelsResponse.getModels().size() > 0); + String modelID = listModelsResponse.getModels().get(0).getModelId(); + assertNotNull(modelID); + + GetDocumentClassifierModelOptions getDocumentClassifierModelOptions = + new GetDocumentClassifierModelOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .modelId(modelID) + .build(); + + DocumentClassifierModel getModelResponse = + premiumService + .getDocumentClassifierModel(getDocumentClassifierModelOptions) + .execute() + .getResult(); + assertNotNull(getModelResponse.getName()); + + String updatedModelName = "new sdk test model"; + UpdateDocumentClassifierModelOptions updateDocumentClassifierModelOptions = + new UpdateDocumentClassifierModelOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .modelId(modelID) + .name(updatedModelName) + .build(); + + DocumentClassifierModel updateModelResponse = + premiumService + .updateDocumentClassifierModel(updateDocumentClassifierModelOptions) + .execute() + .getResult(); + assertEquals(updatedModelName, updateModelResponse.getName()); + + DeleteDocumentClassifierModelOptions deleteDocumentClassifierModelOptions = + new DeleteDocumentClassifierModelOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .modelId(modelID) + .build(); + Response deleteModelResponse = + premiumService + .deleteDocumentClassifierModel(deleteDocumentClassifierModelOptions) + .execute(); + + assertTrue(deleteModelResponse.getStatusCode() == 204); + + } finally { + DeleteDocumentClassifierOptions deleteDocumentClassifierOptions = + new DeleteDocumentClassifierOptions.Builder() + .projectId(PREMIUM_PROJECT_ID) + .classifierId(classifierId) + .build(); + Response deleteResponse = + premiumService.deleteDocumentClassifier(deleteDocumentClassifierOptions).execute(); + + assertTrue(deleteResponse.getStatusCode() == 204); + + testFile.close(); + } + } + + /** Test StopwordList operations. */ + @Test + public void testStopwordLists() { + GetStopwordListOptions getStopwordListOptions = + new GetStopwordListOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + StopWordList getResponse = + service.getStopwordList(getStopwordListOptions).execute().getResult(); + + assertEquals(0, getResponse.stopwords().size()); + + CreateStopwordListOptions createstopwordListOptions = + new CreateStopwordListOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .addStopwords("it") + .addStopwords("the") + .build(); + StopWordList createResponse = + service.createStopwordList(createstopwordListOptions).execute().getResult(); + + assertNotNull(createResponse); + assertEquals("it", createResponse.stopwords().get(0)); + assertEquals("the", createResponse.stopwords().get(1)); + + StopWordList getResponse2 = + service.getStopwordList(getStopwordListOptions).execute().getResult(); + assertEquals(2, getResponse2.stopwords().size()); + + DeleteStopwordListOptions deleteStopwordListOptions = + new DeleteStopwordListOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + Response deleteResponse = service.deleteStopwordList(deleteStopwordListOptions).execute(); + + assertTrue(deleteResponse.getStatusCode() == 204); + } + + /** Test ExpansionList operations. */ + @Test + public void testExpansionLists() { + ListExpansionsOptions listExpansionsOptions = + new ListExpansionsOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + Expansions getResponse = service.listExpansions(listExpansionsOptions).execute().getResult(); + + assertEquals(0, getResponse.expansions().size()); + + String expandedTerm1 = "International Business Machines"; + String expandedTerm2 = "Big Blue"; + Expansion expansion = + new Expansion.Builder() + .addInputTerms("IBM") + .addExpandedTerms(expandedTerm1) + .addExpandedTerms(expandedTerm2) + .build(); + + CreateExpansionsOptions createExpansionsOptions = + new CreateExpansionsOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .addExpansions(expansion) + .build(); + Expansions createResponse = + service.createExpansions(createExpansionsOptions).execute().getResult(); + + assertNotNull(createResponse); + assertEquals(expandedTerm1, createResponse.expansions().get(0).expandedTerms().get(0)); + assertEquals(expandedTerm2, createResponse.expansions().get(0).expandedTerms().get(1)); + + Expansions getResponse2 = service.listExpansions(listExpansionsOptions).execute().getResult(); + assertEquals(1, getResponse2.expansions().size()); + assertEquals(2, getResponse2.expansions().get(0).expandedTerms().size()); + + DeleteExpansionsOptions deleteExpansionOptions = + new DeleteExpansionsOptions.Builder() + .projectId(PROJECT_ID) + .collectionId(COLLECTION_ID) + .build(); + Response deleteResponse = service.deleteExpansions(deleteExpansionOptions).execute(); + + assertTrue(deleteResponse.getStatusCode() == 204); + } } diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java index 511e6fd2dda..f244f670ade 100644 --- a/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java @@ -1,883 +1,3398 @@ +/* + * (C) Copyright IBM Corp. 2019, 2024. + * + * 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; +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.RequestUtils; import com.ibm.watson.discovery.v2.model.AddDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzeDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzedDocument; +import com.ibm.watson.discovery.v2.model.ClassifierFederatedModel; +import com.ibm.watson.discovery.v2.model.CollectionDetails; +import com.ibm.watson.discovery.v2.model.CollectionEnrichment; import com.ibm.watson.discovery.v2.model.Completions; import com.ibm.watson.discovery.v2.model.ComponentSettingsResponse; +import com.ibm.watson.discovery.v2.model.CreateCollectionOptions; +import com.ibm.watson.discovery.v2.model.CreateDocumentClassifier; +import com.ibm.watson.discovery.v2.model.CreateDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.CreateDocumentClassifierOptions; +import com.ibm.watson.discovery.v2.model.CreateEnrichment; +import com.ibm.watson.discovery.v2.model.CreateEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.CreateExpansionsOptions; +import com.ibm.watson.discovery.v2.model.CreateProjectOptions; +import com.ibm.watson.discovery.v2.model.CreateStopwordListOptions; import com.ibm.watson.discovery.v2.model.CreateTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.DefaultQueryParams; +import com.ibm.watson.discovery.v2.model.DefaultQueryParamsPassages; +import com.ibm.watson.discovery.v2.model.DefaultQueryParamsSuggestedRefinements; +import com.ibm.watson.discovery.v2.model.DefaultQueryParamsTableResults; +import com.ibm.watson.discovery.v2.model.DeleteCollectionOptions; +import com.ibm.watson.discovery.v2.model.DeleteDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.DeleteDocumentClassifierOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentResponse; +import com.ibm.watson.discovery.v2.model.DeleteEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.DeleteExpansionsOptions; +import com.ibm.watson.discovery.v2.model.DeleteProjectOptions; +import com.ibm.watson.discovery.v2.model.DeleteStopwordListOptions; import com.ibm.watson.discovery.v2.model.DeleteTrainingQueriesOptions; +import com.ibm.watson.discovery.v2.model.DeleteTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.DeleteUserDataOptions; import com.ibm.watson.discovery.v2.model.DocumentAccepted; +import com.ibm.watson.discovery.v2.model.DocumentClassifier; +import com.ibm.watson.discovery.v2.model.DocumentClassifierEnrichment; +import com.ibm.watson.discovery.v2.model.DocumentClassifierModel; +import com.ibm.watson.discovery.v2.model.DocumentClassifierModels; +import com.ibm.watson.discovery.v2.model.DocumentClassifiers; +import com.ibm.watson.discovery.v2.model.DocumentDetails; +import com.ibm.watson.discovery.v2.model.Enrichment; +import com.ibm.watson.discovery.v2.model.EnrichmentOptions; +import com.ibm.watson.discovery.v2.model.Enrichments; +import com.ibm.watson.discovery.v2.model.Expansion; +import com.ibm.watson.discovery.v2.model.Expansions; import com.ibm.watson.discovery.v2.model.GetAutocompletionOptions; +import com.ibm.watson.discovery.v2.model.GetCollectionOptions; import com.ibm.watson.discovery.v2.model.GetComponentSettingsOptions; +import com.ibm.watson.discovery.v2.model.GetDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.GetDocumentClassifierOptions; +import com.ibm.watson.discovery.v2.model.GetDocumentOptions; +import com.ibm.watson.discovery.v2.model.GetEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.GetProjectOptions; +import com.ibm.watson.discovery.v2.model.GetStopwordListOptions; import com.ibm.watson.discovery.v2.model.GetTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.ListBatchesOptions; +import com.ibm.watson.discovery.v2.model.ListBatchesResponse; import com.ibm.watson.discovery.v2.model.ListCollectionsOptions; import com.ibm.watson.discovery.v2.model.ListCollectionsResponse; +import com.ibm.watson.discovery.v2.model.ListDocumentClassifierModelsOptions; +import com.ibm.watson.discovery.v2.model.ListDocumentClassifiersOptions; +import com.ibm.watson.discovery.v2.model.ListDocumentsOptions; +import com.ibm.watson.discovery.v2.model.ListDocumentsResponse; +import com.ibm.watson.discovery.v2.model.ListEnrichmentsOptions; +import com.ibm.watson.discovery.v2.model.ListExpansionsOptions; import com.ibm.watson.discovery.v2.model.ListFieldsOptions; import com.ibm.watson.discovery.v2.model.ListFieldsResponse; +import com.ibm.watson.discovery.v2.model.ListProjectsOptions; +import com.ibm.watson.discovery.v2.model.ListProjectsResponse; import com.ibm.watson.discovery.v2.model.ListTrainingQueriesOptions; +import com.ibm.watson.discovery.v2.model.ProjectDetails; +import com.ibm.watson.discovery.v2.model.PullBatchesOptions; +import com.ibm.watson.discovery.v2.model.PullBatchesResponse; +import com.ibm.watson.discovery.v2.model.PushBatchesOptions; +import com.ibm.watson.discovery.v2.model.QueryCollectionNoticesOptions; import com.ibm.watson.discovery.v2.model.QueryLargePassages; +import com.ibm.watson.discovery.v2.model.QueryLargeSimilar; import com.ibm.watson.discovery.v2.model.QueryLargeSuggestedRefinements; import com.ibm.watson.discovery.v2.model.QueryLargeTableResults; import com.ibm.watson.discovery.v2.model.QueryNoticesOptions; import com.ibm.watson.discovery.v2.model.QueryNoticesResponse; import com.ibm.watson.discovery.v2.model.QueryOptions; import com.ibm.watson.discovery.v2.model.QueryResponse; +import com.ibm.watson.discovery.v2.model.StopWordList; import com.ibm.watson.discovery.v2.model.TrainingExample; import com.ibm.watson.discovery.v2.model.TrainingQuery; import com.ibm.watson.discovery.v2.model.TrainingQuerySet; +import com.ibm.watson.discovery.v2.model.UpdateCollectionOptions; +import com.ibm.watson.discovery.v2.model.UpdateDocumentClassifier; +import com.ibm.watson.discovery.v2.model.UpdateDocumentClassifierModelOptions; +import com.ibm.watson.discovery.v2.model.UpdateDocumentClassifierOptions; import com.ibm.watson.discovery.v2.model.UpdateDocumentOptions; +import com.ibm.watson.discovery.v2.model.UpdateEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.UpdateProjectOptions; import com.ibm.watson.discovery.v2.model.UpdateTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.WebhookHeader; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the Discovery service. */ +public class DiscoveryTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Discovery discoveryService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // Set mock values for global params + String version = "testString"; + new Discovery(version, serviceName, null); + } -import java.io.FileInputStream; -import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; - -public class DiscoveryTest extends WatsonServiceUnitTest { - private static final String VERSION = "2019-11-22"; - private static final String RESOURCE = "src/test/resources/discovery/v2/"; - - private static final String PROJECT_ID = "project_id"; - private static final String COLLECTION_ID = "collection_id"; - private static final String FILENAME = "filename"; - private static final String FILE_CONTENT_TYPE = "application/pdf"; - private static final String METADATA = "metadata"; - private static final String NATURAL_LANGUAGE_QUERY = "natural_language_query"; - private static final String FILTER = "filter"; - private static final String DOCUMENT_ID = "document_id"; - private static final Long RELEVANCE = 1L; - private static final String FIELD = "field"; - private static final String PREFIX = "prefix"; - private static final Long COUNT = 2L; - private static final String QUERY_ID = "query_id"; - private static final Long MAX_PER_DOCUMENT = 3L; - private static final Long CHARACTERS = 4L; - private static final String QUERY = "query"; - private static final String AGGREGATION = "aggregation"; - private static final String RETURN = "return"; - private static final Long OFFSET = 5L; - private static final String SORT = "sort"; - private static final String NAME = "name"; - private static final Long MATCHING_RESULTS = 6L; - private static final String SUGGESTED_QUERY = "suggested_query"; - private static final String DOCUMENT_RETRIEVAL_SOURCE = "document_retrieval_source"; - private static final Double CONFIDENCE = 0.0; - private static final String PASSAGE_TEXT = "passage_text"; - private static final Long START_OFFSET = 7L; - private static final Long END_OFFSET = 8L; - private static final String TYPE = "type"; - private static final String DOCUMENT_RETRIEVAL_STRATEGY = "document_retrieval_strategy"; - private static final String TEXT = "text"; - private static final String TABLE_ID = "table_id"; - private static final String SOURCE_DOCUMENT_ID = "source_document_id"; - private static final String TABLE_HTML = "table_html"; - private static final Long TABLE_HTML_OFFSET = 9L; - private static final Long BEGIN = 10L; - private static final Long END = 11L; - private static final String CELL_ID = "cell_id"; - private static final Long ROW_INDEX_BEGIN = 12L; - private static final Long ROW_INDEX_END = 13L; - private static final Long COLUMN_INDEX_BEGIN = 14L; - private static final Long COLUMN_INDEX_END = 15L; - private static final String TEXT_NORMALIZED = "text_normalized"; - private static final String ID = "id"; - private static final String COMPLETION = "completion"; - private static final String NOTICE_ID = "notice_id"; - private static final String SEVERITY = "severity"; - private static final String STEP = "step"; - private static final String DESCRIPTION = "description"; - private static final Long RESULTS_PER_PAGE = 17L; - private static final String LABEL = "label"; - private static final String VISUALIZATION_TYPE = "visualization_type"; - private static final String STATUS = "status"; - - private InputStream testDocument; - private Date testDate; - private TrainingExample trainingExampleMock; - private QueryLargeTableResults queryLargeTableResults; - private QueryLargeSuggestedRefinements queryLargeSuggestedRefinements; - private QueryLargePassages queryLargePassages; - - private ListCollectionsResponse listCollectionsResponse; - private QueryResponse queryResponse; - private Completions completions; - private QueryNoticesResponse queryNoticesResponse; - private ListFieldsResponse listFieldsResponse; - private ComponentSettingsResponse componentSettingsResponse; - private DocumentAccepted documentAccepted; - private DeleteDocumentResponse deleteDocumentResponse; - private TrainingQuerySet trainingQuerySet; - private TrainingQuery trainingQuery; - - private Discovery service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new Discovery(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - // Create test models. - testDocument = new FileInputStream(RESOURCE + "test-pdf.pdf"); - String dateString = "1995-06-12T01:11:11.111+0000"; - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - testDate = dateFormat.parse(dateString); - trainingExampleMock = new TrainingExample.Builder() - .documentId(DOCUMENT_ID) - .collectionId(COLLECTION_ID) - .relevance(RELEVANCE) - .build(); - queryLargeTableResults = new QueryLargeTableResults.Builder().build(); - queryLargeSuggestedRefinements = new QueryLargeSuggestedRefinements.Builder().build(); - queryLargePassages = new QueryLargePassages.Builder().build(); - - // load mock responses - listCollectionsResponse - = loadFixture(RESOURCE + "list-collections-response.json", ListCollectionsResponse.class); - queryResponse = loadFixture(RESOURCE + "query-response.json", QueryResponse.class); - completions = loadFixture(RESOURCE + "completions.json", Completions.class); - queryNoticesResponse = loadFixture(RESOURCE + "query-notices-response.json", QueryNoticesResponse.class); - listFieldsResponse = loadFixture(RESOURCE + "list-fields-response.json", ListFieldsResponse.class); - componentSettingsResponse - = loadFixture(RESOURCE + "component-settings-response.json", ComponentSettingsResponse.class); - documentAccepted = loadFixture(RESOURCE + "document-accepted.json", DocumentAccepted.class); - deleteDocumentResponse - = loadFixture(RESOURCE + "delete-document-response.json", DeleteDocumentResponse.class); - trainingQuerySet = loadFixture(RESOURCE + "training-query-set.json", TrainingQuerySet.class); - trainingQuery = loadFixture(RESOURCE + "training-query.json", TrainingQuery.class); - } - - @Test - public void testConfigBasedConstructor() { - Discovery service = new Discovery(VERSION); - assertEquals(Authenticator.AUTHTYPE_BASIC, service.getAuthenticator().authenticationType()); - } - - @Test - public void testAddDocumentOptions() { - AddDocumentOptions options = new AddDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .file(testDocument) - .filename(FILENAME) - .fileContentType(FILE_CONTENT_TYPE) - .metadata(METADATA) - .xWatsonDiscoveryForce(true) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(testDocument, options.file()); - assertEquals(FILENAME, options.filename()); - assertEquals(FILE_CONTENT_TYPE, options.fileContentType()); - assertEquals(METADATA, options.metadata()); - assertTrue(options.xWatsonDiscoveryForce()); - } - - @Test - public void testCreateTrainingQueryOptions() { - List exampleList = new ArrayList<>(); - exampleList.add(trainingExampleMock); - - CreateTrainingQueryOptions options = new CreateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .filter(FILTER) - .examples(exampleList) - .addExamples(trainingExampleMock) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(FILTER, options.filter()); - assertEquals(2, options.examples().size()); - assertEquals(trainingExampleMock, options.examples().get(0)); + // Test the getter for the version global parameter + @Test + public void testGetVersion() throws Throwable { + assertEquals(discoveryService.getVersion(), "testString"); + } + + // Test the listProjects operation with a valid options model parameter + @Test + public void testListProjectsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"projects\": [{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"intelligent_document_processing\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15}]}"; + String listProjectsPath = "/v2/projects"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListProjectsOptions model + ListProjectsOptions listProjectsOptionsModel = new ListProjectsOptions(); + + // Invoke listProjects() with a valid options model and verify the result + Response response = + discoveryService.listProjects(listProjectsOptionsModel).execute(); + assertNotNull(response); + ListProjectsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listProjectsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listProjects operation with and without retries enabled + @Test + public void testListProjectsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListProjectsWOptions(); + + discoveryService.disableRetries(); + testListProjectsWOptions(); + } + + // Test the createProject operation with a valid options model parameter + @Test + public void testCreateProjectWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"intelligent_document_processing\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 0}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}"; + String createProjectPath = "/v2/projects"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the DefaultQueryParamsPassages model + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + + // Construct an instance of the DefaultQueryParamsTableResults model + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("0")) + .build(); + + // Construct an instance of the DefaultQueryParamsSuggestedRefinements model + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + + // Construct an instance of the DefaultQueryParams model + DefaultQueryParams defaultQueryParamsModel = + new DefaultQueryParams.Builder() + .collectionIds(java.util.Arrays.asList("testString")) + .passages(defaultQueryParamsPassagesModel) + .tableResults(defaultQueryParamsTableResultsModel) + .aggregation("testString") + .suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel) + .spellingSuggestions(true) + .highlight(true) + .count(Long.valueOf("26")) + .sort("testString") + .xReturn(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateProjectOptions model + CreateProjectOptions createProjectOptionsModel = + new CreateProjectOptions.Builder() + .name("testString") + .type("intelligent_document_processing") + .defaultQueryParameters(defaultQueryParamsModel) + .build(); + + // Invoke createProject() with a valid options model and verify the result + Response response = + discoveryService.createProject(createProjectOptionsModel).execute(); + assertNotNull(response); + ProjectDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createProjectPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createProject operation with and without retries enabled + @Test + public void testCreateProjectWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateProjectWOptions(); + + discoveryService.disableRetries(); + testCreateProjectWOptions(); + } + + // Test the createProject operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateProjectNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createProject(null).execute(); + } + + // Test the getProject operation with a valid options model parameter + @Test + public void testGetProjectWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"intelligent_document_processing\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 0}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}"; + String getProjectPath = "/v2/projects/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetProjectOptions model + GetProjectOptions getProjectOptionsModel = + new GetProjectOptions.Builder().projectId("testString").build(); + + // Invoke getProject() with a valid options model and verify the result + Response response = + discoveryService.getProject(getProjectOptionsModel).execute(); + assertNotNull(response); + ProjectDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getProjectPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getProject operation with and without retries enabled + @Test + public void testGetProjectWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetProjectWOptions(); + + discoveryService.disableRetries(); + testGetProjectWOptions(); + } + + // Test the getProject operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetProjectNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getProject(null).execute(); + } + + // Test the updateProject operation with a valid options model parameter + @Test + public void testUpdateProjectWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"intelligent_document_processing\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 0}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}"; + String updateProjectPath = "/v2/projects/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateProjectOptions model + UpdateProjectOptions updateProjectOptionsModel = + new UpdateProjectOptions.Builder().projectId("testString").name("testString").build(); + + // Invoke updateProject() with a valid options model and verify the result + Response response = + discoveryService.updateProject(updateProjectOptionsModel).execute(); + assertNotNull(response); + ProjectDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateProjectPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateProject operation with and without retries enabled + @Test + public void testUpdateProjectWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateProjectWOptions(); + + discoveryService.disableRetries(); + testUpdateProjectWOptions(); + } + + // Test the updateProject operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateProjectNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateProject(null).execute(); + } + + // Test the deleteProject operation with a valid options model parameter + @Test + public void testDeleteProjectWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteProjectPath = "/v2/projects/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteProjectOptions model + DeleteProjectOptions deleteProjectOptionsModel = + new DeleteProjectOptions.Builder().projectId("testString").build(); + + // Invoke deleteProject() with a valid options model and verify the result + Response response = discoveryService.deleteProject(deleteProjectOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteProjectPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteProject operation with and without retries enabled + @Test + public void testDeleteProjectWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteProjectWOptions(); + + discoveryService.disableRetries(); + testDeleteProjectWOptions(); + } + + // Test the deleteProject operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteProjectNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteProject(null).execute(); + } + + // Test the listFields operation with a valid options model parameter + @Test + public void testListFieldsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"fields\": [{\"field\": \"field\", \"type\": \"nested\", \"collection_id\": \"collectionId\"}]}"; + String listFieldsPath = "/v2/projects/testString/fields"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListFieldsOptions model + ListFieldsOptions listFieldsOptionsModel = + new ListFieldsOptions.Builder() + .projectId("testString") + .collectionIds(java.util.Arrays.asList("testString")) + .build(); + + // Invoke listFields() with a valid options model and verify the result + Response response = + discoveryService.listFields(listFieldsOptionsModel).execute(); + assertNotNull(response); + ListFieldsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listFieldsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals( + query.get("collection_ids"), RequestUtils.join(java.util.Arrays.asList("testString"), ",")); + } + + // Test the listFields operation with and without retries enabled + @Test + public void testListFieldsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListFieldsWOptions(); + + discoveryService.disableRetries(); + testListFieldsWOptions(); + } + + // Test the listFields operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListFieldsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listFields(null).execute(); + } + + // Test the listCollections operation with a valid options model parameter + @Test + public void testListCollectionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"collections\": [{\"collection_id\": \"collectionId\", \"name\": \"name\"}]}"; + String listCollectionsPath = "/v2/projects/testString/collections"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListCollectionsOptions model + ListCollectionsOptions listCollectionsOptionsModel = + new ListCollectionsOptions.Builder().projectId("testString").build(); + + // Invoke listCollections() with a valid options model and verify the result + Response response = + discoveryService.listCollections(listCollectionsOptionsModel).execute(); + assertNotNull(response); + ListCollectionsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCollectionsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listCollections operation with and without retries enabled + @Test + public void testListCollectionsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListCollectionsWOptions(); + + discoveryService.disableRetries(); + testListCollectionsWOptions(); + } + + // Test the listCollections operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listCollections(null).execute(); + } + + // Test the createCollection operation with a valid options model parameter + @Test + public void testCreateCollectionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"ocr_enabled\": false, \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"smart_document_understanding\": {\"enabled\": false, \"model\": \"custom\"}}"; + String createCollectionPath = "/v2/projects/testString/collections"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CollectionEnrichment model + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateCollectionOptions model + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .projectId("testString") + .name("testString") + .description("testString") + .language("en") + .ocrEnabled(false) + .enrichments(java.util.Arrays.asList(collectionEnrichmentModel)) + .build(); + + // Invoke createCollection() with a valid options model and verify the result + Response response = + discoveryService.createCollection(createCollectionOptionsModel).execute(); + assertNotNull(response); + CollectionDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCollectionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createCollection operation with and without retries enabled + @Test + public void testCreateCollectionWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateCollectionWOptions(); + + discoveryService.disableRetries(); + testCreateCollectionWOptions(); + } + + // Test the createCollection operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCollectionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createCollection(null).execute(); + } + + // Test the getCollection operation with a valid options model parameter + @Test + public void testGetCollectionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"ocr_enabled\": false, \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"smart_document_understanding\": {\"enabled\": false, \"model\": \"custom\"}}"; + String getCollectionPath = "/v2/projects/testString/collections/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCollectionOptions model + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke getCollection() with a valid options model and verify the result + Response response = + discoveryService.getCollection(getCollectionOptionsModel).execute(); + assertNotNull(response); + CollectionDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCollectionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getCollection operation with and without retries enabled + @Test + public void testGetCollectionWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetCollectionWOptions(); + + discoveryService.disableRetries(); + testGetCollectionWOptions(); + } + + // Test the getCollection operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getCollection(null).execute(); + } + + // Test the updateCollection operation with a valid options model parameter + @Test + public void testUpdateCollectionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"ocr_enabled\": false, \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"smart_document_understanding\": {\"enabled\": false, \"model\": \"custom\"}}"; + String updateCollectionPath = "/v2/projects/testString/collections/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CollectionEnrichment model + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the UpdateCollectionOptions model + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .name("testString") + .description("testString") + .ocrEnabled(false) + .enrichments(java.util.Arrays.asList(collectionEnrichmentModel)) + .build(); + + // Invoke updateCollection() with a valid options model and verify the result + Response response = + discoveryService.updateCollection(updateCollectionOptionsModel).execute(); + assertNotNull(response); + CollectionDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCollectionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateCollection operation with and without retries enabled + @Test + public void testUpdateCollectionWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateCollectionWOptions(); + + discoveryService.disableRetries(); + testUpdateCollectionWOptions(); + } + + // Test the updateCollection operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateCollection(null).execute(); + } + + // Test the deleteCollection operation with a valid options model parameter + @Test + public void testDeleteCollectionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteCollectionPath = "/v2/projects/testString/collections/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteCollectionOptions model + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke deleteCollection() with a valid options model and verify the result + Response response = + discoveryService.deleteCollection(deleteCollectionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCollectionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteCollection operation with and without retries enabled + @Test + public void testDeleteCollectionWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteCollectionWOptions(); + + discoveryService.disableRetries(); + testDeleteCollectionWOptions(); + } + + // Test the deleteCollection operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteCollection(null).execute(); + } + + // Test the listDocuments operation with a valid options model parameter + @Test + public void testListDocumentsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"matching_results\": 15, \"documents\": [{\"document_id\": \"documentId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"status\": \"available\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}], \"children\": {\"have_notices\": false, \"count\": 5}, \"filename\": \"filename\", \"file_type\": \"fileType\", \"sha256\": \"sha256\"}]}"; + String listDocumentsPath = "/v2/projects/testString/collections/testString/documents"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListDocumentsOptions model + ListDocumentsOptions listDocumentsOptionsModel = + new ListDocumentsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .count(Long.valueOf("1000")) + .status("testString") + .hasNotices(true) + .isParent(true) + .parentDocumentId("testString") + .sha256("testString") + .build(); + + // Invoke listDocuments() with a valid options model and verify the result + Response response = + discoveryService.listDocuments(listDocumentsOptionsModel).execute(); + assertNotNull(response); + ListDocumentsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDocumentsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("1000")); + assertEquals(query.get("status"), "testString"); + assertEquals(Boolean.valueOf(query.get("has_notices")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("is_parent")), Boolean.valueOf(true)); + assertEquals(query.get("parent_document_id"), "testString"); + assertEquals(query.get("sha256"), "testString"); + } + + // Test the listDocuments operation with and without retries enabled + @Test + public void testListDocumentsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListDocumentsWOptions(); + + discoveryService.disableRetries(); + testListDocumentsWOptions(); + } + + // Test the listDocuments operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDocumentsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listDocuments(null).execute(); + } + + // Test the addDocument operation with a valid options model parameter + @Test + public void testAddDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"processing\"}"; + String addDocumentPath = "/v2/projects/testString/collections/testString/documents"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the AddDocumentOptions model + AddDocumentOptions addDocumentOptionsModel = + new AddDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(false) + .build(); + + // Invoke addDocument() with a valid options model and verify the result + Response response = + discoveryService.addDocument(addDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentAccepted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addDocumentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the addDocument operation with and without retries enabled + @Test + public void testAddDocumentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testAddDocumentWOptions(); + + discoveryService.disableRetries(); + testAddDocumentWOptions(); + } + + // Test the addDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.addDocument(null).execute(); + } + + // Test the getDocument operation with a valid options model parameter + @Test + public void testGetDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"document_id\": \"documentId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"status\": \"available\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}], \"children\": {\"have_notices\": false, \"count\": 5}, \"filename\": \"filename\", \"file_type\": \"fileType\", \"sha256\": \"sha256\"}"; + String getDocumentPath = "/v2/projects/testString/collections/testString/documents/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetDocumentOptions model + GetDocumentOptions getDocumentOptionsModel = + new GetDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .build(); + + // Invoke getDocument() with a valid options model and verify the result + Response response = + discoveryService.getDocument(getDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDocumentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getDocument operation with and without retries enabled + @Test + public void testGetDocumentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetDocumentWOptions(); + + discoveryService.disableRetries(); + testGetDocumentWOptions(); + } + + // Test the getDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getDocument(null).execute(); + } + + // Test the updateDocument operation with a valid options model parameter + @Test + public void testUpdateDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"processing\"}"; + String updateDocumentPath = + "/v2/projects/testString/collections/testString/documents/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateDocumentOptions model + UpdateDocumentOptions updateDocumentOptionsModel = + new UpdateDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(false) + .build(); + + // Invoke updateDocument() with a valid options model and verify the result + Response response = + discoveryService.updateDocument(updateDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentAccepted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDocumentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateDocument operation with and without retries enabled + @Test + public void testUpdateDocumentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateDocumentWOptions(); + + discoveryService.disableRetries(); + testUpdateDocumentWOptions(); + } + + // Test the updateDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateDocument(null).execute(); + } + + // Test the deleteDocument operation with a valid options model parameter + @Test + public void testDeleteDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"deleted\"}"; + String deleteDocumentPath = + "/v2/projects/testString/collections/testString/documents/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteDocumentOptions model + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .xWatsonDiscoveryForce(false) + .build(); + + // Invoke deleteDocument() with a valid options model and verify the result + Response response = + discoveryService.deleteDocument(deleteDocumentOptionsModel).execute(); + assertNotNull(response); + DeleteDocumentResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDocumentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteDocument operation with and without retries enabled + @Test + public void testDeleteDocumentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteDocumentWOptions(); + + discoveryService.disableRetries(); + testDeleteDocumentWOptions(); + } + + // Test the deleteDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteDocument(null).execute(); + } + + // Test the query operation with a valid options model parameter + @Test + public void testQueryWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"document_id\": \"documentId\", \"metadata\": {\"anyKey\": \"anyValue\"}, \"result_metadata\": {\"document_retrieval_source\": \"search\", \"collection_id\": \"collectionId\", \"confidence\": 0}, \"document_passages\": [{\"passage_text\": \"passageText\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\", \"answers\": [{\"answer_text\": \"answerText\", \"start_offset\": 11, \"end_offset\": 9, \"confidence\": 0}]}]}], \"aggregations\": [{\"type\": \"term\", \"field\": \"field\", \"count\": 5, \"name\": \"name\", \"results\": [{\"key\": \"key\", \"matching_results\": 15, \"relevancy\": 9, \"total_matching_documents\": 22, \"estimated_matching_results\": 24, \"aggregations\": [{\"anyKey\": \"anyValue\"}]}]}], \"retrieval_details\": {\"document_retrieval_strategy\": \"untrained\"}, \"suggested_query\": \"suggestedQuery\", \"suggested_refinements\": [{\"text\": \"text\"}], \"table_results\": [{\"table_id\": \"tableId\", \"source_document_id\": \"sourceDocumentId\", \"collection_id\": \"collectionId\", \"table_html\": \"tableHtml\", \"table_html_offset\": 15, \"table\": {\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"section_title\": {\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}, \"title\": {\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}, \"table_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"row_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"column_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"key_value_pairs\": [{\"key\": {\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}, \"value\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}]}], \"body_cells\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14, \"row_header_ids\": [\"rowHeaderIds\"], \"row_header_texts\": [\"rowHeaderTexts\"], \"row_header_texts_normalized\": [\"rowHeaderTextsNormalized\"], \"column_header_ids\": [\"columnHeaderIds\"], \"column_header_texts\": [\"columnHeaderTexts\"], \"column_header_texts_normalized\": [\"columnHeaderTextsNormalized\"], \"attributes\": [{\"type\": \"type\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}], \"contexts\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}}], \"passages\": [{\"passage_text\": \"passageText\", \"passage_score\": 12, \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\", \"answers\": [{\"answer_text\": \"answerText\", \"start_offset\": 11, \"end_offset\": 9, \"confidence\": 0}]}]}"; + String queryPath = "/v2/projects/testString/query"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the QueryLargeTableResults model + QueryLargeTableResults queryLargeTableResultsModel = + new QueryLargeTableResults.Builder().enabled(true).count(Long.valueOf("26")).build(); + + // Construct an instance of the QueryLargeSuggestedRefinements model + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModel = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("1")).build(); + + // Construct an instance of the QueryLargePassages model + QueryLargePassages queryLargePassagesModel = + new QueryLargePassages.Builder() + .enabled(true) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .count(Long.valueOf("400")) + .characters(Long.valueOf("50")) + .findAnswers(false) + .maxAnswersPerPassage(Long.valueOf("1")) + .build(); + + // Construct an instance of the QueryLargeSimilar model + QueryLargeSimilar queryLargeSimilarModel = + new QueryLargeSimilar.Builder() + .enabled(false) + .documentIds(java.util.Arrays.asList("testString")) + .fields(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the QueryOptions model + QueryOptions queryOptionsModel = + new QueryOptions.Builder() + .projectId("testString") + .collectionIds(java.util.Arrays.asList("testString")) + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(java.util.Arrays.asList("testString")) + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .spellingSuggestions(true) + .tableResults(queryLargeTableResultsModel) + .suggestedRefinements(queryLargeSuggestedRefinementsModel) + .passages(queryLargePassagesModel) + .similar(queryLargeSimilarModel) + .build(); + + // Invoke query() with a valid options model and verify the result + Response response = discoveryService.query(queryOptionsModel).execute(); + assertNotNull(response); + QueryResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the query operation with and without retries enabled + @Test + public void testQueryWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testQueryWOptions(); + + discoveryService.disableRetries(); + testQueryWOptions(); + } + + // Test the query operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.query(null).execute(); + } + + // Test the getAutocompletion operation with a valid options model parameter + @Test + public void testGetAutocompletionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"completions\": [\"completions\"]}"; + String getAutocompletionPath = "/v2/projects/testString/autocompletion"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetAutocompletionOptions model + GetAutocompletionOptions getAutocompletionOptionsModel = + new GetAutocompletionOptions.Builder() + .projectId("testString") + .prefix("testString") + .collectionIds(java.util.Arrays.asList("testString")) + .field("testString") + .count(Long.valueOf("5")) + .build(); + + // Invoke getAutocompletion() with a valid options model and verify the result + Response response = + discoveryService.getAutocompletion(getAutocompletionOptionsModel).execute(); + assertNotNull(response); + Completions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAutocompletionPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("prefix"), "testString"); + assertEquals( + query.get("collection_ids"), RequestUtils.join(java.util.Arrays.asList("testString"), ",")); + assertEquals(query.get("field"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("5")); + } + + // Test the getAutocompletion operation with and without retries enabled + @Test + public void testGetAutocompletionWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetAutocompletionWOptions(); + + discoveryService.disableRetries(); + testGetAutocompletionWOptions(); + } + + // Test the getAutocompletion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAutocompletionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getAutocompletion(null).execute(); + } + + // Test the queryCollectionNotices operation with a valid options model parameter + @Test + public void testQueryCollectionNoticesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"matching_results\": 15, \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String queryCollectionNoticesPath = "/v2/projects/testString/collections/testString/notices"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the QueryCollectionNoticesOptions model + QueryCollectionNoticesOptions queryCollectionNoticesOptionsModel = + new QueryCollectionNoticesOptions.Builder() + .projectId("testString") + .collectionId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .count(Long.valueOf("10")) + .offset(Long.valueOf("26")) + .build(); + + // Invoke queryCollectionNotices() with a valid options model and verify the result + Response response = + discoveryService.queryCollectionNotices(queryCollectionNoticesOptionsModel).execute(); + assertNotNull(response); + QueryNoticesResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryCollectionNoticesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("query"), "testString"); + assertEquals(query.get("natural_language_query"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("10")); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("26")); + } + + // Test the queryCollectionNotices operation with and without retries enabled + @Test + public void testQueryCollectionNoticesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testQueryCollectionNoticesWOptions(); + + discoveryService.disableRetries(); + testQueryCollectionNoticesWOptions(); + } + + // Test the queryCollectionNotices operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryCollectionNoticesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.queryCollectionNotices(null).execute(); + } + + // Test the queryNotices operation with a valid options model parameter + @Test + public void testQueryNoticesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"matching_results\": 15, \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String queryNoticesPath = "/v2/projects/testString/notices"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the QueryNoticesOptions model + QueryNoticesOptions queryNoticesOptionsModel = + new QueryNoticesOptions.Builder() + .projectId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .count(Long.valueOf("10")) + .offset(Long.valueOf("26")) + .build(); + + // Invoke queryNotices() with a valid options model and verify the result + Response response = + discoveryService.queryNotices(queryNoticesOptionsModel).execute(); + assertNotNull(response); + QueryNoticesResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryNoticesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("query"), "testString"); + assertEquals(query.get("natural_language_query"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("10")); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("26")); + } + + // Test the queryNotices operation with and without retries enabled + @Test + public void testQueryNoticesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testQueryNoticesWOptions(); + + discoveryService.disableRetries(); + testQueryNoticesWOptions(); + } + + // Test the queryNotices operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoticesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.queryNotices(null).execute(); + } + + // Test the getStopwordList operation with a valid options model parameter + @Test + public void testGetStopwordListWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"stopwords\": [\"stopwords\"]}"; + String getStopwordListPath = "/v2/projects/testString/collections/testString/stopwords"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetStopwordListOptions model + GetStopwordListOptions getStopwordListOptionsModel = + new GetStopwordListOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke getStopwordList() with a valid options model and verify the result + Response response = + discoveryService.getStopwordList(getStopwordListOptionsModel).execute(); + assertNotNull(response); + StopWordList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getStopwordListPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getStopwordList operation with and without retries enabled + @Test + public void testGetStopwordListWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetStopwordListWOptions(); + + discoveryService.disableRetries(); + testGetStopwordListWOptions(); + } + + // Test the getStopwordList operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetStopwordListNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getStopwordList(null).execute(); + } + + // Test the createStopwordList operation with a valid options model parameter + @Test + public void testCreateStopwordListWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"stopwords\": [\"stopwords\"]}"; + String createStopwordListPath = "/v2/projects/testString/collections/testString/stopwords"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateStopwordListOptions model + CreateStopwordListOptions createStopwordListOptionsModel = + new CreateStopwordListOptions.Builder() + .projectId("testString") + .collectionId("testString") + .stopwords(java.util.Arrays.asList("testString")) + .build(); + + // Invoke createStopwordList() with a valid options model and verify the result + Response response = + discoveryService.createStopwordList(createStopwordListOptionsModel).execute(); + assertNotNull(response); + StopWordList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createStopwordListPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createStopwordList operation with and without retries enabled + @Test + public void testCreateStopwordListWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateStopwordListWOptions(); + + discoveryService.disableRetries(); + testCreateStopwordListWOptions(); + } + + // Test the createStopwordList operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateStopwordListNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createStopwordList(null).execute(); + } + + // Test the deleteStopwordList operation with a valid options model parameter + @Test + public void testDeleteStopwordListWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteStopwordListPath = "/v2/projects/testString/collections/testString/stopwords"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteStopwordListOptions model + DeleteStopwordListOptions deleteStopwordListOptionsModel = + new DeleteStopwordListOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke deleteStopwordList() with a valid options model and verify the result + Response response = + discoveryService.deleteStopwordList(deleteStopwordListOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteStopwordListPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteStopwordList operation with and without retries enabled + @Test + public void testDeleteStopwordListWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteStopwordListWOptions(); + + discoveryService.disableRetries(); + testDeleteStopwordListWOptions(); + } + + // Test the deleteStopwordList operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteStopwordListNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteStopwordList(null).execute(); + } + + // Test the listExpansions operation with a valid options model parameter + @Test + public void testListExpansionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"expansions\": [{\"input_terms\": [\"inputTerms\"], \"expanded_terms\": [\"expandedTerms\"]}]}"; + String listExpansionsPath = "/v2/projects/testString/collections/testString/expansions"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListExpansionsOptions model + ListExpansionsOptions listExpansionsOptionsModel = + new ListExpansionsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke listExpansions() with a valid options model and verify the result + Response response = + discoveryService.listExpansions(listExpansionsOptionsModel).execute(); + assertNotNull(response); + Expansions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listExpansionsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listExpansions operation with and without retries enabled + @Test + public void testListExpansionsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListExpansionsWOptions(); + + discoveryService.disableRetries(); + testListExpansionsWOptions(); + } + + // Test the listExpansions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExpansionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listExpansions(null).execute(); + } + + // Test the createExpansions operation with a valid options model parameter + @Test + public void testCreateExpansionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"expansions\": [{\"input_terms\": [\"inputTerms\"], \"expanded_terms\": [\"expandedTerms\"]}]}"; + String createExpansionsPath = "/v2/projects/testString/collections/testString/expansions"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the Expansion model + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(java.util.Arrays.asList("testString")) + .expandedTerms(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateExpansionsOptions model + CreateExpansionsOptions createExpansionsOptionsModel = + new CreateExpansionsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .expansions(java.util.Arrays.asList(expansionModel)) + .build(); + + // Invoke createExpansions() with a valid options model and verify the result + Response response = + discoveryService.createExpansions(createExpansionsOptionsModel).execute(); + assertNotNull(response); + Expansions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createExpansionsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createExpansions operation with and without retries enabled + @Test + public void testCreateExpansionsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateExpansionsWOptions(); + + discoveryService.disableRetries(); + testCreateExpansionsWOptions(); + } + + // Test the createExpansions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExpansionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createExpansions(null).execute(); + } + + // Test the deleteExpansions operation with a valid options model parameter + @Test + public void testDeleteExpansionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteExpansionsPath = "/v2/projects/testString/collections/testString/expansions"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteExpansionsOptions model + DeleteExpansionsOptions deleteExpansionsOptionsModel = + new DeleteExpansionsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke deleteExpansions() with a valid options model and verify the result + Response response = + discoveryService.deleteExpansions(deleteExpansionsOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteExpansionsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteExpansions operation with and without retries enabled + @Test + public void testDeleteExpansionsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteExpansionsWOptions(); + + discoveryService.disableRetries(); + testDeleteExpansionsWOptions(); + } + + // Test the deleteExpansions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExpansionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteExpansions(null).execute(); + } + + // Test the getComponentSettings operation with a valid options model parameter + @Test + public void testGetComponentSettingsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"fields_shown\": {\"body\": {\"use_passage\": true, \"field\": \"field\"}, \"title\": {\"field\": \"field\"}}, \"autocomplete\": true, \"structured_search\": true, \"results_per_page\": 14, \"aggregations\": [{\"name\": \"name\", \"label\": \"label\", \"multiple_selections_allowed\": false, \"visualization_type\": \"auto\"}]}"; + String getComponentSettingsPath = "/v2/projects/testString/component_settings"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetComponentSettingsOptions model + GetComponentSettingsOptions getComponentSettingsOptionsModel = + new GetComponentSettingsOptions.Builder().projectId("testString").build(); + + // Invoke getComponentSettings() with a valid options model and verify the result + Response response = + discoveryService.getComponentSettings(getComponentSettingsOptionsModel).execute(); + assertNotNull(response); + ComponentSettingsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getComponentSettingsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getComponentSettings operation with and without retries enabled + @Test + public void testGetComponentSettingsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetComponentSettingsWOptions(); + + discoveryService.disableRetries(); + testGetComponentSettingsWOptions(); + } + + // Test the getComponentSettings operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetComponentSettingsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getComponentSettings(null).execute(); + } + + // Test the listTrainingQueries operation with a valid options model parameter + @Test + public void testListTrainingQueriesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"queries\": [{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}]}"; + String listTrainingQueriesPath = "/v2/projects/testString/training_data/queries"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListTrainingQueriesOptions model + ListTrainingQueriesOptions listTrainingQueriesOptionsModel = + new ListTrainingQueriesOptions.Builder().projectId("testString").build(); + + // Invoke listTrainingQueries() with a valid options model and verify the result + Response response = + discoveryService.listTrainingQueries(listTrainingQueriesOptionsModel).execute(); + assertNotNull(response); + TrainingQuerySet responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listTrainingQueriesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listTrainingQueries operation with and without retries enabled + @Test + public void testListTrainingQueriesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListTrainingQueriesWOptions(); + + discoveryService.disableRetries(); + testListTrainingQueriesWOptions(); + } + + // Test the listTrainingQueries operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingQueriesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listTrainingQueries(null).execute(); + } + + // Test the deleteTrainingQueries operation with a valid options model parameter + @Test + public void testDeleteTrainingQueriesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteTrainingQueriesPath = "/v2/projects/testString/training_data/queries"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteTrainingQueriesOptions model + DeleteTrainingQueriesOptions deleteTrainingQueriesOptionsModel = + new DeleteTrainingQueriesOptions.Builder().projectId("testString").build(); + + // Invoke deleteTrainingQueries() with a valid options model and verify the result + Response response = + discoveryService.deleteTrainingQueries(deleteTrainingQueriesOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTrainingQueriesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteTrainingQueries operation with and without retries enabled + @Test + public void testDeleteTrainingQueriesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteTrainingQueriesWOptions(); + + discoveryService.disableRetries(); + testDeleteTrainingQueriesWOptions(); + } + + // Test the deleteTrainingQueries operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingQueriesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteTrainingQueries(null).execute(); + } + + // Test the createTrainingQuery operation with a valid options model parameter + @Test + public void testCreateTrainingQueryWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String createTrainingQueryPath = "/v2/projects/testString/training_data/queries"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the TrainingExample model + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + + // Construct an instance of the CreateTrainingQueryOptions model + CreateTrainingQueryOptions createTrainingQueryOptionsModel = + new CreateTrainingQueryOptions.Builder() + .projectId("testString") + .naturalLanguageQuery("testString") + .examples(java.util.Arrays.asList(trainingExampleModel)) + .filter("testString") + .build(); + + // Invoke createTrainingQuery() with a valid options model and verify the result + Response response = + discoveryService.createTrainingQuery(createTrainingQueryOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createTrainingQueryPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createTrainingQuery operation with and without retries enabled + @Test + public void testCreateTrainingQueryWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateTrainingQueryWOptions(); + + discoveryService.disableRetries(); + testCreateTrainingQueryWOptions(); + } + + // Test the createTrainingQuery operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTrainingQueryNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createTrainingQuery(null).execute(); + } + + // Test the getTrainingQuery operation with a valid options model parameter + @Test + public void testGetTrainingQueryWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String getTrainingQueryPath = "/v2/projects/testString/training_data/queries/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetTrainingQueryOptions model + GetTrainingQueryOptions getTrainingQueryOptionsModel = + new GetTrainingQueryOptions.Builder().projectId("testString").queryId("testString").build(); + + // Invoke getTrainingQuery() with a valid options model and verify the result + Response response = + discoveryService.getTrainingQuery(getTrainingQueryOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTrainingQueryPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getTrainingQuery operation with and without retries enabled + @Test + public void testGetTrainingQueryWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetTrainingQueryWOptions(); + + discoveryService.disableRetries(); + testGetTrainingQueryWOptions(); + } + + // Test the getTrainingQuery operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingQueryNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getTrainingQuery(null).execute(); + } + + // Test the updateTrainingQuery operation with a valid options model parameter + @Test + public void testUpdateTrainingQueryWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}"; + String updateTrainingQueryPath = "/v2/projects/testString/training_data/queries/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the TrainingExample model + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + + // Construct an instance of the UpdateTrainingQueryOptions model + UpdateTrainingQueryOptions updateTrainingQueryOptionsModel = + new UpdateTrainingQueryOptions.Builder() + .projectId("testString") + .queryId("testString") + .naturalLanguageQuery("testString") + .examples(java.util.Arrays.asList(trainingExampleModel)) + .filter("testString") + .build(); + + // Invoke updateTrainingQuery() with a valid options model and verify the result + Response response = + discoveryService.updateTrainingQuery(updateTrainingQueryOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateTrainingQueryPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateTrainingQuery operation with and without retries enabled + @Test + public void testUpdateTrainingQueryWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateTrainingQueryWOptions(); + + discoveryService.disableRetries(); + testUpdateTrainingQueryWOptions(); + } + + // Test the updateTrainingQuery operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateTrainingQueryNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateTrainingQuery(null).execute(); + } + + // Test the deleteTrainingQuery operation with a valid options model parameter + @Test + public void testDeleteTrainingQueryWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteTrainingQueryPath = "/v2/projects/testString/training_data/queries/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteTrainingQueryOptions model + DeleteTrainingQueryOptions deleteTrainingQueryOptionsModel = + new DeleteTrainingQueryOptions.Builder() + .projectId("testString") + .queryId("testString") + .build(); + + // Invoke deleteTrainingQuery() with a valid options model and verify the result + Response response = + discoveryService.deleteTrainingQuery(deleteTrainingQueryOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTrainingQueryPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteTrainingQuery operation with and without retries enabled + @Test + public void testDeleteTrainingQueryWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteTrainingQueryWOptions(); + + discoveryService.disableRetries(); + testDeleteTrainingQueryWOptions(); + } + + // Test the deleteTrainingQuery operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingQueryNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteTrainingQuery(null).execute(); + } + + // Test the listEnrichments operation with a valid options model parameter + @Test + public void testListEnrichmentsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\", \"classifier_id\": \"classifierId\", \"model_id\": \"modelId\", \"confidence_threshold\": 0, \"top_k\": 0, \"url\": \"url\", \"version\": \"2023-03-31\", \"secret\": \"secret\", \"headers\": {\"name\": \"name\", \"value\": \"value\"}, \"location_encoding\": \"`utf-16`\"}}]}"; + String listEnrichmentsPath = "/v2/projects/testString/enrichments"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListEnrichmentsOptions model + ListEnrichmentsOptions listEnrichmentsOptionsModel = + new ListEnrichmentsOptions.Builder().projectId("testString").build(); + + // Invoke listEnrichments() with a valid options model and verify the result + Response response = + discoveryService.listEnrichments(listEnrichmentsOptionsModel).execute(); + assertNotNull(response); + Enrichments responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listEnrichmentsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listEnrichments operation with and without retries enabled + @Test + public void testListEnrichmentsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListEnrichmentsWOptions(); + + discoveryService.disableRetries(); + testListEnrichmentsWOptions(); + } + + // Test the listEnrichments operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEnrichmentsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listEnrichments(null).execute(); + } + + // Test the createEnrichment operation with a valid options model parameter + @Test + public void testCreateEnrichmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\", \"classifier_id\": \"classifierId\", \"model_id\": \"modelId\", \"confidence_threshold\": 0, \"top_k\": 0, \"url\": \"url\", \"version\": \"2023-03-31\", \"secret\": \"secret\", \"headers\": {\"name\": \"name\", \"value\": \"value\"}, \"location_encoding\": \"`utf-16`\"}}"; + String createEnrichmentPath = "/v2/projects/testString/enrichments"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the EnrichmentOptions model + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(java.util.Arrays.asList("testString")) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .classifierId("testString") + .modelId("testString") + .confidenceThreshold(Double.valueOf("0")) + .topK(Long.valueOf("0")) + .url("testString") + .version("2023-03-31") + .secret("testString") + .headers(webhookHeaderModel) + .locationEncoding("`utf-16`") + .build(); + + // Construct an instance of the CreateEnrichment model + CreateEnrichment createEnrichmentModel = + new CreateEnrichment.Builder() + .name("testString") + .description("testString") + .type("classifier") + .options(enrichmentOptionsModel) + .build(); + + // Construct an instance of the CreateEnrichmentOptions model + CreateEnrichmentOptions createEnrichmentOptionsModel = + new CreateEnrichmentOptions.Builder() + .projectId("testString") + .enrichment(createEnrichmentModel) + .file(TestUtilities.createMockStream("This is a mock file.")) + .build(); + + // Invoke createEnrichment() with a valid options model and verify the result + Response response = + discoveryService.createEnrichment(createEnrichmentOptionsModel).execute(); + assertNotNull(response); + Enrichment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createEnrichmentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the createEnrichment operation with and without retries enabled @Test - public void testDeleteDocumentOptions() { - DeleteDocumentOptions options = new DeleteDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .xWatsonDiscoveryForce(true) - .build(); - options = options.newBuilder().build(); + public void testCreateEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateEnrichmentWOptions(); + + discoveryService.disableRetries(); + testCreateEnrichmentWOptions(); + } - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(DOCUMENT_ID, options.documentId()); - assertTrue(options.xWatsonDiscoveryForce()); + // Test the createEnrichment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEnrichmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createEnrichment(null).execute(); + } + + // Test the getEnrichment operation with a valid options model parameter + @Test + public void testGetEnrichmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\", \"classifier_id\": \"classifierId\", \"model_id\": \"modelId\", \"confidence_threshold\": 0, \"top_k\": 0, \"url\": \"url\", \"version\": \"2023-03-31\", \"secret\": \"secret\", \"headers\": {\"name\": \"name\", \"value\": \"value\"}, \"location_encoding\": \"`utf-16`\"}}"; + String getEnrichmentPath = "/v2/projects/testString/enrichments/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetEnrichmentOptions model + GetEnrichmentOptions getEnrichmentOptionsModel = + new GetEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); + + // Invoke getEnrichment() with a valid options model and verify the result + Response response = + discoveryService.getEnrichment(getEnrichmentOptionsModel).execute(); + assertNotNull(response); + Enrichment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getEnrichmentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the getEnrichment operation with and without retries enabled @Test - public void testDeleteTrainingQueryOptions() { - DeleteTrainingQueriesOptions options = new DeleteTrainingQueriesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - options = options.newBuilder().build(); + public void testGetEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetEnrichmentWOptions(); + + discoveryService.disableRetries(); + testGetEnrichmentWOptions(); + } + + // Test the getEnrichment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnrichmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getEnrichment(null).execute(); + } - assertEquals(PROJECT_ID, options.projectId()); + // Test the updateEnrichment operation with a valid options model parameter + @Test + public void testUpdateEnrichmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\", \"classifier_id\": \"classifierId\", \"model_id\": \"modelId\", \"confidence_threshold\": 0, \"top_k\": 0, \"url\": \"url\", \"version\": \"2023-03-31\", \"secret\": \"secret\", \"headers\": {\"name\": \"name\", \"value\": \"value\"}, \"location_encoding\": \"`utf-16`\"}}"; + String updateEnrichmentPath = "/v2/projects/testString/enrichments/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateEnrichmentOptions model + UpdateEnrichmentOptions updateEnrichmentOptionsModel = + new UpdateEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .name("testString") + .description("testString") + .build(); + + // Invoke updateEnrichment() with a valid options model and verify the result + Response response = + discoveryService.updateEnrichment(updateEnrichmentOptionsModel).execute(); + assertNotNull(response); + Enrichment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateEnrichmentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the updateEnrichment operation with and without retries enabled @Test - public void testGetAutocompletionOptions() { - List collectionIds = new ArrayList<>(); - collectionIds.add(COLLECTION_ID); + public void testUpdateEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateEnrichmentWOptions(); - GetAutocompletionOptions options = new GetAutocompletionOptions.Builder() - .projectId(PROJECT_ID) - .collectionIds(collectionIds) - .addCollectionIds(COLLECTION_ID) - .field(FIELD) - .prefix(PREFIX) - .count(COUNT) - .build(); - options = options.newBuilder().build(); + discoveryService.disableRetries(); + testUpdateEnrichmentWOptions(); + } + + // Test the updateEnrichment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnrichmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateEnrichment(null).execute(); + } - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(2, options.collectionIds().size()); - assertEquals(COLLECTION_ID, options.collectionIds().get(0)); - assertEquals(FIELD, options.field()); - assertEquals(PREFIX, options.prefix()); - assertEquals(COUNT, options.count()); + // Test the deleteEnrichment operation with a valid options model parameter + @Test + public void testDeleteEnrichmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteEnrichmentPath = "/v2/projects/testString/enrichments/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteEnrichmentOptions model + DeleteEnrichmentOptions deleteEnrichmentOptionsModel = + new DeleteEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); + + // Invoke deleteEnrichment() with a valid options model and verify the result + Response response = + discoveryService.deleteEnrichment(deleteEnrichmentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteEnrichmentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the deleteEnrichment operation with and without retries enabled @Test - public void testGetComponentSettingsOptions() { - GetComponentSettingsOptions options = new GetComponentSettingsOptions.Builder() - .projectId(PROJECT_ID) - .build(); - options = options.newBuilder().build(); + public void testDeleteEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteEnrichmentWOptions(); + + discoveryService.disableRetries(); + testDeleteEnrichmentWOptions(); + } - assertEquals(PROJECT_ID, options.projectId()); + // Test the deleteEnrichment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEnrichmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteEnrichment(null).execute(); + } + + // Test the listBatches operation with a valid options model parameter + @Test + public void testListBatchesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"batches\": [{\"batch_id\": \"batchId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"enrichment_id\": \"enrichmentId\"}]}"; + String listBatchesPath = "/v2/projects/testString/collections/testString/batches"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListBatchesOptions model + ListBatchesOptions listBatchesOptionsModel = + new ListBatchesOptions.Builder().projectId("testString").collectionId("testString").build(); + + // Invoke listBatches() with a valid options model and verify the result + Response response = + discoveryService.listBatches(listBatchesOptionsModel).execute(); + assertNotNull(response); + ListBatchesResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listBatchesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the listBatches operation with and without retries enabled @Test - public void testGetTrainingQueryOptions() { - GetTrainingQueryOptions options = new GetTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(QUERY_ID) - .build(); - options = options.newBuilder().build(); + public void testListBatchesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListBatchesWOptions(); + + discoveryService.disableRetries(); + testListBatchesWOptions(); + } + + // Test the listBatches operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListBatchesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listBatches(null).execute(); + } - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(QUERY_ID, options.queryId()); + // Test the pullBatches operation with a valid options model parameter + @Test + public void testPullBatchesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"file\": \"file\"}"; + String pullBatchesPath = "/v2/projects/testString/collections/testString/batches/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the PullBatchesOptions model + PullBatchesOptions pullBatchesOptionsModel = + new PullBatchesOptions.Builder() + .projectId("testString") + .collectionId("testString") + .batchId("testString") + .build(); + + // Invoke pullBatches() with a valid options model and verify the result + Response response = + discoveryService.pullBatches(pullBatchesOptionsModel).execute(); + assertNotNull(response); + PullBatchesResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, pullBatchesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the pullBatches operation with and without retries enabled @Test - public void testListCollectionsOptions() { - ListCollectionsOptions options = new ListCollectionsOptions.Builder() - .projectId(PROJECT_ID) - .build(); - options = options.newBuilder().build(); + public void testPullBatchesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testPullBatchesWOptions(); + + discoveryService.disableRetries(); + testPullBatchesWOptions(); + } + + // Test the pullBatches operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPullBatchesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.pullBatches(null).execute(); + } - assertEquals(PROJECT_ID, options.projectId()); + // Test the pushBatches operation with a valid options model parameter + @Test + public void testPushBatchesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "false"; + String pushBatchesPath = "/v2/projects/testString/collections/testString/batches/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + // Construct an instance of the PushBatchesOptions model + PushBatchesOptions pushBatchesOptionsModel = + new PushBatchesOptions.Builder() + .projectId("testString") + .collectionId("testString") + .batchId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .build(); + + // Invoke pushBatches() with a valid options model and verify the result + Response response = discoveryService.pushBatches(pushBatchesOptionsModel).execute(); + assertNotNull(response); + Boolean responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, pushBatchesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the pushBatches operation with and without retries enabled @Test - public void testListFieldsOptions() { - List collectionIds = new ArrayList<>(); - collectionIds.add(COLLECTION_ID); + public void testPushBatchesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testPushBatchesWOptions(); + + discoveryService.disableRetries(); + testPushBatchesWOptions(); + } - ListFieldsOptions options = new ListFieldsOptions.Builder() - .projectId(PROJECT_ID) - .collectionIds(collectionIds) - .addCollectionIds(COLLECTION_ID) - .build(); - options = options.newBuilder().build(); + // Test the pushBatches operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPushBatchesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.pushBatches(null).execute(); + } - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(2, options.collectionIds().size()); - assertEquals(COLLECTION_ID, options.collectionIds().get(0)); + // Test the listDocumentClassifiers operation with a valid options model parameter + @Test + public void testListDocumentClassifiersWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"classifiers\": [{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"recognized_fields\": [\"recognizedFields\"], \"answer_field\": \"answerField\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"federated_classification\": {\"field\": \"field\"}}]}"; + String listDocumentClassifiersPath = "/v2/projects/testString/document_classifiers"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListDocumentClassifiersOptions model + ListDocumentClassifiersOptions listDocumentClassifiersOptionsModel = + new ListDocumentClassifiersOptions.Builder().projectId("testString").build(); + + // Invoke listDocumentClassifiers() with a valid options model and verify the result + Response response = + discoveryService.listDocumentClassifiers(listDocumentClassifiersOptionsModel).execute(); + assertNotNull(response); + DocumentClassifiers responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDocumentClassifiersPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the listDocumentClassifiers operation with and without retries enabled @Test - public void testListTrainingQueriesOptions() { - ListTrainingQueriesOptions options = new ListTrainingQueriesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - options = options.newBuilder().build(); + public void testListDocumentClassifiersWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListDocumentClassifiersWOptions(); + + discoveryService.disableRetries(); + testListDocumentClassifiersWOptions(); + } + + // Test the listDocumentClassifiers operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDocumentClassifiersNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listDocumentClassifiers(null).execute(); + } - assertEquals(PROJECT_ID, options.projectId()); + // Test the createDocumentClassifier operation with a valid options model parameter + @Test + public void testCreateDocumentClassifierWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"recognized_fields\": [\"recognizedFields\"], \"answer_field\": \"answerField\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"federated_classification\": {\"field\": \"field\"}}"; + String createDocumentClassifierPath = "/v2/projects/testString/document_classifiers"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the DocumentClassifierEnrichment model + DocumentClassifierEnrichment documentClassifierEnrichmentModel = + new DocumentClassifierEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the ClassifierFederatedModel model + ClassifierFederatedModel classifierFederatedModelModel = + new ClassifierFederatedModel.Builder().field("testString").build(); + + // Construct an instance of the CreateDocumentClassifier model + CreateDocumentClassifier createDocumentClassifierModel = + new CreateDocumentClassifier.Builder() + .name("testString") + .description("testString") + .language("en") + .answerField("testString") + .enrichments(java.util.Arrays.asList(documentClassifierEnrichmentModel)) + .federatedClassification(classifierFederatedModelModel) + .build(); + + // Construct an instance of the CreateDocumentClassifierOptions model + CreateDocumentClassifierOptions createDocumentClassifierOptionsModel = + new CreateDocumentClassifierOptions.Builder() + .projectId("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .classifier(createDocumentClassifierModel) + .testData(TestUtilities.createMockStream("This is a mock file.")) + .build(); + + // Invoke createDocumentClassifier() with a valid options model and verify the result + Response response = + discoveryService.createDocumentClassifier(createDocumentClassifierOptionsModel).execute(); + assertNotNull(response); + DocumentClassifier responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createDocumentClassifierPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the createDocumentClassifier operation with and without retries enabled @Test - public void testQueryLargePassages() { - List fields = new ArrayList<>(); - fields.add(FIELD); + public void testCreateDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateDocumentClassifierWOptions(); - QueryLargePassages queryLargePassages = new QueryLargePassages.Builder() - .enabled(true) - .perDocument(true) - .maxPerDocument(MAX_PER_DOCUMENT) - .fields(fields) - .addFields(FIELD) - .count(COUNT) - .characters(CHARACTERS) - .build(); - queryLargePassages = queryLargePassages.newBuilder().build(); + discoveryService.disableRetries(); + testCreateDocumentClassifierWOptions(); + } - assertTrue(queryLargePassages.enabled()); - assertTrue(queryLargePassages.perDocument()); - assertEquals(MAX_PER_DOCUMENT, queryLargePassages.maxPerDocument()); - assertEquals(2, queryLargePassages.fields().size()); - assertEquals(FIELD, queryLargePassages.fields().get(0)); - assertEquals(COUNT, queryLargePassages.count()); - assertEquals(CHARACTERS, queryLargePassages.characters()); - } - - @Test - public void testQueryLargeSuggestedRefinements() { - QueryLargeSuggestedRefinements queryLargeSuggestedRefinements = new QueryLargeSuggestedRefinements.Builder() - .enabled(true) - .count(COUNT) - .build(); - queryLargeSuggestedRefinements = queryLargeSuggestedRefinements.newBuilder().build(); + // Test the createDocumentClassifier operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDocumentClassifierNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createDocumentClassifier(null).execute(); + } - assertTrue(queryLargeSuggestedRefinements.enabled()); - assertEquals(COUNT, queryLargeSuggestedRefinements.count()); + // Test the getDocumentClassifier operation with a valid options model parameter + @Test + public void testGetDocumentClassifierWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"recognized_fields\": [\"recognizedFields\"], \"answer_field\": \"answerField\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"federated_classification\": {\"field\": \"field\"}}"; + String getDocumentClassifierPath = "/v2/projects/testString/document_classifiers/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetDocumentClassifierOptions model + GetDocumentClassifierOptions getDocumentClassifierOptionsModel = + new GetDocumentClassifierOptions.Builder() + .projectId("testString") + .classifierId("testString") + .build(); + + // Invoke getDocumentClassifier() with a valid options model and verify the result + Response response = + discoveryService.getDocumentClassifier(getDocumentClassifierOptionsModel).execute(); + assertNotNull(response); + DocumentClassifier responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDocumentClassifierPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the getDocumentClassifier operation with and without retries enabled @Test - public void testQueryLargeTableResults() { - QueryLargeTableResults queryLargeTableResults = new QueryLargeTableResults.Builder() - .enabled(true) - .count(COUNT) - .build(); - queryLargeTableResults = queryLargeTableResults.newBuilder().build(); - - assertTrue(queryLargeTableResults.enabled()); - assertEquals(COUNT, queryLargeTableResults.count()); - } - - @Test - public void testQueryNoticesOptions() { - QueryNoticesOptions options = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .filter(FILTER) - .query(QUERY) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .count(COUNT) - .offset(OFFSET) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(FILTER, options.filter()); - assertEquals(QUERY, options.query()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(COUNT, options.count()); - assertEquals(OFFSET, options.offset()); - } - - @Test - public void testQueryOptions() { - List collectionIds = new ArrayList<>(); - collectionIds.add(COLLECTION_ID); - List returnList = new ArrayList<>(); - returnList.add(RETURN); - - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .collectionIds(collectionIds) - .addCollectionIds(COLLECTION_ID) - .filter(FILTER) - .query(QUERY) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .aggregation(AGGREGATION) - .count(COUNT) - .xReturn(returnList) - .addReturnField(RETURN) - .offset(OFFSET) - .sort(SORT) - .highlight(true) - .spellingSuggestions(true) - .tableResults(queryLargeTableResults) - .suggestedRefinements(queryLargeSuggestedRefinements) - .passages(queryLargePassages) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(FILTER, options.filter()); - assertEquals(QUERY, options.query()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(AGGREGATION, options.aggregation()); - assertEquals(COUNT, options.count()); - assertEquals(2, options.xReturn().size()); - assertEquals(RETURN, options.xReturn().get(0)); - assertEquals(OFFSET, options.offset()); - assertEquals(SORT, options.sort()); - assertTrue(options.highlight()); - assertTrue(options.spellingSuggestions()); - assertEquals(queryLargeTableResults, options.tableResults()); - assertEquals(queryLargeSuggestedRefinements, options.suggestedRefinements()); - assertEquals(queryLargePassages, options.passages()); - } - - @Test - public void testTrainingExample() { - TrainingExample trainingExample = new TrainingExample.Builder() - .documentId(DOCUMENT_ID) - .collectionId(COLLECTION_ID) - .relevance(RELEVANCE) - .created(testDate) - .updated(testDate) - .build(); - trainingExample = trainingExample.newBuilder().build(); - - assertEquals(DOCUMENT_ID, trainingExample.documentId()); - assertEquals(COLLECTION_ID, trainingExample.collectionId()); - assertEquals(RELEVANCE, trainingExample.relevance()); - assertEquals(testDate, trainingExample.created()); - assertEquals(testDate, trainingExample.updated()); - } - - @Test - public void testTrainingQuery() { - List exampleList = new ArrayList<>(); - exampleList.add(trainingExampleMock); - - TrainingQuery trainingQuery = new TrainingQuery.Builder() - .queryId(QUERY_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .filter(FILTER) - .created(testDate) - .updated(testDate) - .examples(exampleList) - .addExamples(trainingExampleMock) - .build(); - trainingQuery = trainingQuery.newBuilder().build(); - - assertEquals(QUERY_ID, trainingQuery.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, trainingQuery.naturalLanguageQuery()); - assertEquals(FILTER, trainingQuery.filter()); - assertEquals(testDate, trainingQuery.created()); - assertEquals(testDate, trainingQuery.updated()); - assertEquals(2, trainingQuery.examples().size()); - assertEquals(trainingExampleMock, trainingQuery.examples().get(0)); - } - - @Test - public void testUpdateDocumentOptions() { - UpdateDocumentOptions options = new UpdateDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .file(testDocument) - .filename(FILENAME) - .fileContentType(FILE_CONTENT_TYPE) - .metadata(METADATA) - .xWatsonDiscoveryForce(true) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(testDocument, options.file()); - assertEquals(FILENAME, options.filename()); - assertEquals(FILE_CONTENT_TYPE, options.fileContentType()); - assertEquals(METADATA, options.metadata()); - assertTrue(options.xWatsonDiscoveryForce()); - } - - @Test - public void testUpdateTrainingQueryOptions() { - List exampleList = new ArrayList<>(); - exampleList.add(trainingExampleMock); - - UpdateTrainingQueryOptions options = new UpdateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(QUERY_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .filter(FILTER) - .examples(exampleList) - .addExamples(trainingExampleMock) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(FILTER, options.filter()); - assertEquals(2, options.examples().size()); - assertEquals(trainingExampleMock, options.examples().get(0)); - } - - @Test - public void testListCollections() { - server.enqueue(jsonResponse(listCollectionsResponse)); - - ListCollectionsOptions options = new ListCollectionsOptions.Builder() - .projectId(PROJECT_ID) - .build(); - ListCollectionsResponse response = service.listCollections(options).execute().getResult(); - - assertEquals(COLLECTION_ID, response.getCollections().get(0).getCollectionId()); - assertEquals(NAME, response.getCollections().get(0).getName()); - } - - @Test - public void testQuery() { - server.enqueue(jsonResponse(queryResponse)); - - QueryOptions options = new QueryOptions.Builder() - .projectId(PROJECT_ID) - .build(); - QueryResponse response = service.query(options).execute().getResult(); - - assertEquals(MATCHING_RESULTS, response.getMatchingResults()); - assertEquals(DOCUMENT_ID, response.getResults().get(0).getDocumentId()); - assertEquals(DOCUMENT_RETRIEVAL_SOURCE, - response.getResults().get(0).getResultMetadata().getDocumentRetrievalSource()); - assertEquals(COLLECTION_ID, response.getResults().get(0).getResultMetadata().getCollectionId()); - assertEquals(CONFIDENCE, response.getResults().get(0).getResultMetadata().getConfidence()); - assertEquals(PASSAGE_TEXT, response.getResults().get(0).getDocumentPassages().get(0).getPassageText()); - assertEquals(START_OFFSET, response.getResults().get(0).getDocumentPassages().get(0).getStartOffset()); - assertEquals(END_OFFSET, response.getResults().get(0).getDocumentPassages().get(0).getEndOffset()); - assertEquals(FIELD, response.getResults().get(0).getDocumentPassages().get(0).getField()); - assertEquals(DOCUMENT_RETRIEVAL_STRATEGY, response.getRetrievalDetails().getDocumentRetrievalStrategy()); - assertEquals(SUGGESTED_QUERY, response.getSuggestedQuery()); - assertEquals(TEXT, response.getSuggestedRefinements().get(0).getText()); - assertEquals(TABLE_ID, response.getTableResults().get(0).getTableId()); - assertEquals(SOURCE_DOCUMENT_ID, response.getTableResults().get(0).getSourceDocumentId()); - assertEquals(COLLECTION_ID, response.getTableResults().get(0).getCollectionId()); - assertEquals(TABLE_HTML, response.getTableResults().get(0).getTableHtml()); - assertEquals(TABLE_HTML_OFFSET, response.getTableResults().get(0).getTableHtmlOffset()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getText()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getSectionTitle().getText()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getSectionTitle().getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getSectionTitle().getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getTitle().getText()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getTitle().getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getTitle().getLocation().getEnd()); - assertEquals(CELL_ID, response.getTableResults().get(0).getTable().getTableHeaders().get(0).getCellId()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getTableHeaders().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getTableHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTableResults().get(0).getTable().getTableHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getTableHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getTableHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getCellId()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getCellId()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getKey().getCellId()); - assertEquals(BEGIN, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getKey().getLocation().getBegin()); - assertEquals(END, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getKey().getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getKey().getText()); - assertEquals(CELL_ID, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getValue().get(0).getCellId()); - assertEquals(BEGIN, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getValue().get(0).getLocation() - .getBegin()); - assertEquals(END, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getValue().get(0).getLocation() - .getEnd()); - assertEquals(TEXT, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getValue().get(0).getText()); - assertEquals(CELL_ID, response.getTableResults().get(0).getTable().getBodyCells().get(0).getCellId()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getBodyCells().get(0).getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getBodyCells().get(0).getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getBodyCells().get(0).getText()); - assertEquals(ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowIndexEnd()); - assertEquals(COLUMN_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnIndexBegin()); - assertEquals(COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnIndexEnd()); - assertEquals(ID, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowHeaderIds().get(0).getId()); - assertEquals(TEXT, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowHeaderTexts().get(0).getText()); - assertEquals(TEXT_NORMALIZED, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowHeaderTextsNormalized().get(0) - .getTextNormalized()); - assertEquals(ID, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnHeaderIds().get(0).getId()); - assertEquals(TEXT, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnHeaderTexts().get(0).getText()); - assertEquals(TEXT_NORMALIZED, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0) - .getTextNormalized()); - assertEquals(TYPE, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getAttributes().get(0).getLocation() - .getBegin()); - assertEquals(END, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getAttributes().get(0).getLocation() - .getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getContexts().get(0).getText()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getContexts().get(0).getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getContexts().get(0).getLocation().getEnd()); - } - - @Test - public void testGetAutocompletion() { - server.enqueue(jsonResponse(completions)); - - GetAutocompletionOptions options = new GetAutocompletionOptions.Builder() - .projectId(PROJECT_ID) - .prefix(PREFIX) - .build(); - Completions response = service.getAutocompletion(options).execute().getResult(); - - assertEquals(COMPLETION, response.getCompletions().get(0)); - } - - @Test - public void testQueryNotices() { - server.enqueue(jsonResponse(queryNoticesResponse)); - - QueryNoticesOptions options = new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - QueryNoticesResponse response = service.queryNotices(options).execute().getResult(); - - assertEquals(MATCHING_RESULTS, response.getMatchingResults()); - assertEquals(NOTICE_ID, response.getNotices().get(0).getNoticeId()); - assertEquals(testDate, response.getNotices().get(0).getCreated()); - assertEquals(DOCUMENT_ID, response.getNotices().get(0).getDocumentId()); - assertEquals(COLLECTION_ID, response.getNotices().get(0).getCollectionId()); - assertEquals(QUERY_ID, response.getNotices().get(0).getQueryId()); - assertEquals(SEVERITY, response.getNotices().get(0).getSeverity()); - assertEquals(STEP, response.getNotices().get(0).getStep()); - assertEquals(DESCRIPTION, response.getNotices().get(0).getDescription()); - } - - @Test - public void testListFields() { - server.enqueue(jsonResponse(listFieldsResponse)); - - ListFieldsOptions options = new ListFieldsOptions.Builder() - .projectId(PROJECT_ID) - .build(); - ListFieldsResponse response = service.listFields(options).execute().getResult(); - - assertEquals(FIELD, response.getFields().get(0).getField()); - assertEquals(TYPE, response.getFields().get(0).getType()); - assertEquals(COLLECTION_ID, response.getFields().get(0).getCollectionId()); - } - - @Test - public void testGetComponentSettings() { - server.enqueue(jsonResponse(componentSettingsResponse)); + public void testGetDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetDocumentClassifierWOptions(); - GetComponentSettingsOptions options = new GetComponentSettingsOptions.Builder() - .projectId(PROJECT_ID) - .build(); - ComponentSettingsResponse response = service.getComponentSettings(options).execute().getResult(); + discoveryService.disableRetries(); + testGetDocumentClassifierWOptions(); + } - assertTrue(response.getFieldsShown().getBody().isUsePassage()); - assertEquals(FIELD, response.getFieldsShown().getBody().getField()); - assertEquals(FIELD, response.getFieldsShown().getTitle().getField()); - assertTrue(response.isAutocomplete()); - assertTrue(response.isStructuredSearch()); - assertEquals(RESULTS_PER_PAGE, response.getResultsPerPage()); - assertEquals(NAME, response.getAggregations().get(0).getName()); - assertEquals(LABEL, response.getAggregations().get(0).getLabel()); - assertTrue(response.getAggregations().get(0).isMultipleSelectionsAllowed()); - assertEquals(VISUALIZATION_TYPE, response.getAggregations().get(0).getVisualizationType()); + // Test the getDocumentClassifier operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentClassifierNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.getDocumentClassifier(null).execute(); } + // Test the updateDocumentClassifier operation with a valid options model parameter @Test - public void testAddDocument() { - server.enqueue(jsonResponse(documentAccepted)); + public void testUpdateDocumentClassifierWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"language\": \"en\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}], \"recognized_fields\": [\"recognizedFields\"], \"answer_field\": \"answerField\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"federated_classification\": {\"field\": \"field\"}}"; + String updateDocumentClassifierPath = "/v2/projects/testString/document_classifiers/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateDocumentClassifier model + UpdateDocumentClassifier updateDocumentClassifierModel = + new UpdateDocumentClassifier.Builder().name("testString").description("testString").build(); + + // Construct an instance of the UpdateDocumentClassifierOptions model + UpdateDocumentClassifierOptions updateDocumentClassifierOptionsModel = + new UpdateDocumentClassifierOptions.Builder() + .projectId("testString") + .classifierId("testString") + .classifier(updateDocumentClassifierModel) + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .testData(TestUtilities.createMockStream("This is a mock file.")) + .build(); + + // Invoke updateDocumentClassifier() with a valid options model and verify the result + Response response = + discoveryService.updateDocumentClassifier(updateDocumentClassifierOptionsModel).execute(); + assertNotNull(response); + DocumentClassifier responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDocumentClassifierPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateDocumentClassifier operation with and without retries enabled + @Test + public void testUpdateDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateDocumentClassifierWOptions(); + + discoveryService.disableRetries(); + testUpdateDocumentClassifierWOptions(); + } - AddDocumentOptions options = new AddDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .file(testDocument) - .filename(FILENAME) - .build(); - DocumentAccepted response = service.addDocument(options).execute().getResult(); + // Test the updateDocumentClassifier operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentClassifierNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateDocumentClassifier(null).execute(); + } - assertEquals(DOCUMENT_ID, response.getDocumentId()); - assertEquals(STATUS, response.getStatus()); + // Test the deleteDocumentClassifier operation with a valid options model parameter + @Test + public void testDeleteDocumentClassifierWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteDocumentClassifierPath = "/v2/projects/testString/document_classifiers/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteDocumentClassifierOptions model + DeleteDocumentClassifierOptions deleteDocumentClassifierOptionsModel = + new DeleteDocumentClassifierOptions.Builder() + .projectId("testString") + .classifierId("testString") + .build(); + + // Invoke deleteDocumentClassifier() with a valid options model and verify the result + Response response = + discoveryService.deleteDocumentClassifier(deleteDocumentClassifierOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDocumentClassifierPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the deleteDocumentClassifier operation with and without retries enabled @Test - public void testUpdateDocument() { - server.enqueue(jsonResponse(documentAccepted)); + public void testDeleteDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteDocumentClassifierWOptions(); + + discoveryService.disableRetries(); + testDeleteDocumentClassifierWOptions(); + } - UpdateDocumentOptions options = new UpdateDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .file(testDocument) - .filename(FILENAME) - .build(); - DocumentAccepted response = service.updateDocument(options).execute().getResult(); + // Test the deleteDocumentClassifier operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentClassifierNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteDocumentClassifier(null).execute(); + } - assertEquals(DOCUMENT_ID, response.getDocumentId()); - assertEquals(STATUS, response.getStatus()); + // Test the listDocumentClassifierModels operation with a valid options model parameter + @Test + public void testListDocumentClassifierModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"models\": [{\"model_id\": \"modelId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"status\": \"training\", \"evaluation\": {\"micro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"macro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"per_class\": [{\"name\": \"name\", \"precision\": 0, \"recall\": 0, \"f1\": 0}]}, \"enrichment_id\": \"enrichmentId\", \"deployed_at\": \"2019-01-01T12:00:00.000Z\"}]}"; + String listDocumentClassifierModelsPath = + "/v2/projects/testString/document_classifiers/testString/models"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListDocumentClassifierModelsOptions model + ListDocumentClassifierModelsOptions listDocumentClassifierModelsOptionsModel = + new ListDocumentClassifierModelsOptions.Builder() + .projectId("testString") + .classifierId("testString") + .build(); + + // Invoke listDocumentClassifierModels() with a valid options model and verify the result + Response response = + discoveryService + .listDocumentClassifierModels(listDocumentClassifierModelsOptionsModel) + .execute(); + assertNotNull(response); + DocumentClassifierModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDocumentClassifierModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the listDocumentClassifierModels operation with and without retries enabled @Test - public void testDeleteDocument() { - server.enqueue(jsonResponse(deleteDocumentResponse)); + public void testListDocumentClassifierModelsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListDocumentClassifierModelsWOptions(); + + discoveryService.disableRetries(); + testListDocumentClassifierModelsWOptions(); + } - DeleteDocumentOptions options = new DeleteDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .build(); - DeleteDocumentResponse response = service.deleteDocument(options).execute().getResult(); + // Test the listDocumentClassifierModels operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDocumentClassifierModelsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.listDocumentClassifierModels(null).execute(); + } - assertEquals(DOCUMENT_ID, response.getDocumentId()); - assertEquals(STATUS, response.getStatus()); + // Test the createDocumentClassifierModel operation with a valid options model parameter + @Test + public void testCreateDocumentClassifierModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"model_id\": \"modelId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"status\": \"training\", \"evaluation\": {\"micro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"macro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"per_class\": [{\"name\": \"name\", \"precision\": 0, \"recall\": 0, \"f1\": 0}]}, \"enrichment_id\": \"enrichmentId\", \"deployed_at\": \"2019-01-01T12:00:00.000Z\"}"; + String createDocumentClassifierModelPath = + "/v2/projects/testString/document_classifiers/testString/models"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateDocumentClassifierModelOptions model + CreateDocumentClassifierModelOptions createDocumentClassifierModelOptionsModel = + new CreateDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .name("testString") + .description("testString") + .learningRate(Double.valueOf("0.1")) + .l1RegularizationStrengths(java.util.Arrays.asList(Double.valueOf("1.0E-6"))) + .l2RegularizationStrengths(java.util.Arrays.asList(Double.valueOf("1.0E-6"))) + .trainingMaxSteps(Long.valueOf("10000000")) + .improvementRatio(Double.valueOf("0.000010")) + .build(); + + // Invoke createDocumentClassifierModel() with a valid options model and verify the result + Response response = + discoveryService + .createDocumentClassifierModel(createDocumentClassifierModelOptionsModel) + .execute(); + assertNotNull(response); + DocumentClassifierModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createDocumentClassifierModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the createDocumentClassifierModel operation with and without retries enabled @Test - public void testListTrainingQueries() { - server.enqueue(jsonResponse(trainingQuerySet)); + public void testCreateDocumentClassifierModelWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateDocumentClassifierModelWOptions(); + + discoveryService.disableRetries(); + testCreateDocumentClassifierModelWOptions(); + } - ListTrainingQueriesOptions options = new ListTrainingQueriesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - TrainingQuerySet response = service.listTrainingQueries(options).execute().getResult(); + // Test the createDocumentClassifierModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDocumentClassifierModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.createDocumentClassifierModel(null).execute(); + } - assertEquals(QUERY_ID, response.getQueries().get(0).queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.getQueries().get(0).naturalLanguageQuery()); - assertEquals(FILTER, response.getQueries().get(0).filter()); - assertEquals(testDate, response.getQueries().get(0).created()); - assertEquals(testDate, response.getQueries().get(0).updated()); - assertEquals(DOCUMENT_ID, response.getQueries().get(0).examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.getQueries().get(0).examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.getQueries().get(0).examples().get(0).relevance()); - assertEquals(testDate, response.getQueries().get(0).examples().get(0).created()); - assertEquals(testDate, response.getQueries().get(0).examples().get(0).updated()); + // Test the getDocumentClassifierModel operation with a valid options model parameter + @Test + public void testGetDocumentClassifierModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"model_id\": \"modelId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"status\": \"training\", \"evaluation\": {\"micro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"macro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"per_class\": [{\"name\": \"name\", \"precision\": 0, \"recall\": 0, \"f1\": 0}]}, \"enrichment_id\": \"enrichmentId\", \"deployed_at\": \"2019-01-01T12:00:00.000Z\"}"; + String getDocumentClassifierModelPath = + "/v2/projects/testString/document_classifiers/testString/models/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetDocumentClassifierModelOptions model + GetDocumentClassifierModelOptions getDocumentClassifierModelOptionsModel = + new GetDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .modelId("testString") + .build(); + + // Invoke getDocumentClassifierModel() with a valid options model and verify the result + Response response = + discoveryService + .getDocumentClassifierModel(getDocumentClassifierModelOptionsModel) + .execute(); + assertNotNull(response); + DocumentClassifierModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDocumentClassifierModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the getDocumentClassifierModel operation with and without retries enabled @Test - public void testDeleteTrainingQueries() throws InterruptedException { + public void testGetDocumentClassifierModelWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetDocumentClassifierModelWOptions(); + + discoveryService.disableRetries(); + testGetDocumentClassifierModelWOptions(); + } + + // Test the getDocumentClassifierModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentClassifierModelNoOptions() throws Throwable { server.enqueue(new MockResponse()); + discoveryService.getDocumentClassifierModel(null).execute(); + } - DeleteTrainingQueriesOptions options = new DeleteTrainingQueriesOptions.Builder() - .projectId(PROJECT_ID) - .build(); - service.deleteTrainingQueries(options).execute(); + // Test the updateDocumentClassifierModel operation with a valid options model parameter + @Test + public void testUpdateDocumentClassifierModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"model_id\": \"modelId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"training_data_file\": \"trainingDataFile\", \"test_data_file\": \"testDataFile\", \"status\": \"training\", \"evaluation\": {\"micro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"macro_average\": {\"precision\": 0, \"recall\": 0, \"f1\": 0}, \"per_class\": [{\"name\": \"name\", \"precision\": 0, \"recall\": 0, \"f1\": 0}]}, \"enrichment_id\": \"enrichmentId\", \"deployed_at\": \"2019-01-01T12:00:00.000Z\"}"; + String updateDocumentClassifierModelPath = + "/v2/projects/testString/document_classifiers/testString/models/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateDocumentClassifierModelOptions model + UpdateDocumentClassifierModelOptions updateDocumentClassifierModelOptionsModel = + new UpdateDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .modelId("testString") + .name("testString") + .description("testString") + .build(); + + // Invoke updateDocumentClassifierModel() with a valid options model and verify the result + Response response = + discoveryService + .updateDocumentClassifierModel(updateDocumentClassifierModelOptionsModel) + .execute(); + assertNotNull(response); + DocumentClassifierModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDocumentClassifierModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateDocumentClassifierModel operation with and without retries enabled + @Test + public void testUpdateDocumentClassifierModelWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateDocumentClassifierModelWOptions(); + + discoveryService.disableRetries(); + testUpdateDocumentClassifierModelWOptions(); + } + + // Test the updateDocumentClassifierModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentClassifierModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.updateDocumentClassifierModel(null).execute(); + } - assertEquals("DELETE", request.getMethod()); + // Test the deleteDocumentClassifierModel operation with a valid options model parameter + @Test + public void testDeleteDocumentClassifierModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteDocumentClassifierModelPath = + "/v2/projects/testString/document_classifiers/testString/models/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteDocumentClassifierModelOptions model + DeleteDocumentClassifierModelOptions deleteDocumentClassifierModelOptionsModel = + new DeleteDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .modelId("testString") + .build(); + + // Invoke deleteDocumentClassifierModel() with a valid options model and verify the result + Response response = + discoveryService + .deleteDocumentClassifierModel(deleteDocumentClassifierModelOptionsModel) + .execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDocumentClassifierModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); } + // Test the deleteDocumentClassifierModel operation with and without retries enabled @Test - public void testCreateTrainingQuery() { - server.enqueue(jsonResponse(trainingQuery)); + public void testDeleteDocumentClassifierModelWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteDocumentClassifierModelWOptions(); - CreateTrainingQueryOptions options = new CreateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .addExamples(trainingExampleMock) - .build(); - TrainingQuery response = service.createTrainingQuery(options).execute().getResult(); + discoveryService.disableRetries(); + testDeleteDocumentClassifierModelWOptions(); + } - assertEquals(QUERY_ID, response.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.naturalLanguageQuery()); - assertEquals(FILTER, response.filter()); - assertEquals(testDate, response.created()); - assertEquals(testDate, response.updated()); - assertEquals(DOCUMENT_ID, response.examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.examples().get(0).relevance()); - assertEquals(testDate, response.examples().get(0).created()); - assertEquals(testDate, response.examples().get(0).updated()); + // Test the deleteDocumentClassifierModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentClassifierModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteDocumentClassifierModel(null).execute(); } + // Test the analyzeDocument operation with a valid options model parameter @Test - public void testGetTrainingQuery() { - server.enqueue(jsonResponse(trainingQuery)); + public void testAnalyzeDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}], \"result\": {\"metadata\": {\"anyKey\": \"anyValue\"}}}"; + String analyzeDocumentPath = "/v2/projects/testString/collections/testString/analyze"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the AnalyzeDocumentOptions model + AnalyzeDocumentOptions analyzeDocumentOptionsModel = + new AnalyzeDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + + // Invoke analyzeDocument() with a valid options model and verify the result + Response response = + discoveryService.analyzeDocument(analyzeDocumentOptionsModel).execute(); + assertNotNull(response); + AnalyzedDocument responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, analyzeDocumentPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } - GetTrainingQueryOptions options = new GetTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(QUERY_ID) - .build(); - TrainingQuery response = service.getTrainingQuery(options).execute().getResult(); + // Test the analyzeDocument operation with and without retries enabled + @Test + public void testAnalyzeDocumentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testAnalyzeDocumentWOptions(); - assertEquals(QUERY_ID, response.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.naturalLanguageQuery()); - assertEquals(FILTER, response.filter()); - assertEquals(testDate, response.created()); - assertEquals(testDate, response.updated()); - assertEquals(DOCUMENT_ID, response.examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.examples().get(0).relevance()); - assertEquals(testDate, response.examples().get(0).created()); - assertEquals(testDate, response.examples().get(0).updated()); + discoveryService.disableRetries(); + testAnalyzeDocumentWOptions(); } + // Test the analyzeDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.analyzeDocument(null).execute(); + } + + // Test the deleteUserData operation with a valid options model parameter + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteUserDataPath = "/v2/user_data"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke deleteUserData() with a valid options model and verify the result + Response response = discoveryService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + } + + // Test the deleteUserData operation with and without retries enabled @Test - public void testUpdateTrainingQuery() { - server.enqueue(jsonResponse(trainingQuery)); + public void testDeleteUserDataWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteUserDataWOptions(); + + discoveryService.disableRetries(); + testDeleteUserDataWOptions(); + } + + // Test the deleteUserData operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + discoveryService.deleteUserData(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + discoveryService = null; + } - UpdateTrainingQueryOptions options = new UpdateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(QUERY_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .addExamples(trainingExampleMock) - .build(); - TrainingQuery response = service.updateTrainingQuery(options).execute().getResult(); + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; - assertEquals(QUERY_ID, response.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.naturalLanguageQuery()); - assertEquals(FILTER, response.filter()); - assertEquals(testDate, response.created()); - assertEquals(testDate, response.updated()); - assertEquals(DOCUMENT_ID, response.examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.examples().get(0).relevance()); - assertEquals(testDate, response.examples().get(0).created()); - assertEquals(testDate, response.examples().get(0).updated()); + final Authenticator authenticator = new NoAuthAuthenticator(); + discoveryService = new Discovery(version, serviceName, authenticator); + String url = server.url("/").toString(); + discoveryService.setServiceUrl(url); } } diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AddDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AddDocumentOptionsTest.java new file mode 100644 index 00000000000..ddf0870d4bd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AddDocumentOptionsTest.java @@ -0,0 +1,59 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddDocumentOptions model. */ +public class AddDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddDocumentOptions() throws Throwable { + AddDocumentOptions addDocumentOptionsModel = + new AddDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(false) + .build(); + assertEquals(addDocumentOptionsModel.projectId(), "testString"); + assertEquals(addDocumentOptionsModel.collectionId(), "testString"); + assertEquals( + IOUtils.toString(addDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addDocumentOptionsModel.filename(), "testString"); + assertEquals(addDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(addDocumentOptionsModel.metadata(), "testString"); + assertEquals(addDocumentOptionsModel.xWatsonDiscoveryForce(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDocumentOptionsError() throws Throwable { + new AddDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptionsTest.java new file mode 100644 index 00000000000..b33d816f5b6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzeDocumentOptions model. */ +public class AnalyzeDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzeDocumentOptions() throws Throwable { + AnalyzeDocumentOptions analyzeDocumentOptionsModel = + new AnalyzeDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + assertEquals(analyzeDocumentOptionsModel.projectId(), "testString"); + assertEquals(analyzeDocumentOptionsModel.collectionId(), "testString"); + assertEquals( + IOUtils.toString(analyzeDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(analyzeDocumentOptionsModel.filename(), "testString"); + assertEquals(analyzeDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(analyzeDocumentOptionsModel.metadata(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeDocumentOptionsError() throws Throwable { + new AnalyzeDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedDocumentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedDocumentTest.java new file mode 100644 index 00000000000..e964ee1f25d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedDocumentTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzedDocument model. */ +public class AnalyzedDocumentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzedDocument() throws Throwable { + AnalyzedDocument analyzedDocumentModel = new AnalyzedDocument(); + assertNull(analyzedDocumentModel.getNotices()); + assertNull(analyzedDocumentModel.getResult()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedResultTest.java new file mode 100644 index 00000000000..ff705a6d2e1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedResultTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzedResult model. */ +public class AnalyzedResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzedResult() throws Throwable { + AnalyzedResult analyzedResultModel = new AnalyzedResult(); + assertNull(analyzedResultModel.getMetadata()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/BatchDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/BatchDetailsTest.java new file mode 100644 index 00000000000..5c1dcff29df --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/BatchDetailsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BatchDetails model. */ +public class BatchDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDetails() throws Throwable { + BatchDetails batchDetailsModel = new BatchDetails(); + assertNull(batchDetailsModel.getEnrichmentId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ClassifierFederatedModelTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ClassifierFederatedModelTest.java new file mode 100644 index 00000000000..3b02c8b1556 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ClassifierFederatedModelTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifierFederatedModel model. */ +public class ClassifierFederatedModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifierFederatedModel() throws Throwable { + ClassifierFederatedModel classifierFederatedModelModel = + new ClassifierFederatedModel.Builder().field("testString").build(); + assertEquals(classifierFederatedModelModel.field(), "testString"); + + String json = TestUtilities.serialize(classifierFederatedModelModel); + + ClassifierFederatedModel classifierFederatedModelModelNew = + TestUtilities.deserialize(json, ClassifierFederatedModel.class); + assertTrue(classifierFederatedModelModelNew instanceof ClassifierFederatedModel); + assertEquals(classifierFederatedModelModelNew.field(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifierFederatedModelError() throws Throwable { + new ClassifierFederatedModel.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ClassifierModelEvaluationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ClassifierModelEvaluationTest.java new file mode 100644 index 00000000000..ce148790036 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ClassifierModelEvaluationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifierModelEvaluation model. */ +public class ClassifierModelEvaluationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifierModelEvaluation() throws Throwable { + ClassifierModelEvaluation classifierModelEvaluationModel = new ClassifierModelEvaluation(); + assertNull(classifierModelEvaluationModel.getMicroAverage()); + assertNull(classifierModelEvaluationModel.getMacroAverage()); + assertNull(classifierModelEvaluationModel.getPerClass()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsSmartDocumentUnderstandingTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsSmartDocumentUnderstandingTest.java new file mode 100644 index 00000000000..622b530d096 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsSmartDocumentUnderstandingTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionDetailsSmartDocumentUnderstanding model. */ +public class CollectionDetailsSmartDocumentUnderstandingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionDetailsSmartDocumentUnderstanding() throws Throwable { + CollectionDetailsSmartDocumentUnderstanding collectionDetailsSmartDocumentUnderstandingModel = + new CollectionDetailsSmartDocumentUnderstanding.Builder() + .enabled(true) + .model("custom") + .build(); + assertEquals(collectionDetailsSmartDocumentUnderstandingModel.enabled(), Boolean.valueOf(true)); + assertEquals(collectionDetailsSmartDocumentUnderstandingModel.model(), "custom"); + + String json = TestUtilities.serialize(collectionDetailsSmartDocumentUnderstandingModel); + + CollectionDetailsSmartDocumentUnderstanding + collectionDetailsSmartDocumentUnderstandingModelNew = + TestUtilities.deserialize(json, CollectionDetailsSmartDocumentUnderstanding.class); + assertTrue( + collectionDetailsSmartDocumentUnderstandingModelNew + instanceof CollectionDetailsSmartDocumentUnderstanding); + assertEquals( + collectionDetailsSmartDocumentUnderstandingModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(collectionDetailsSmartDocumentUnderstandingModelNew.model(), "custom"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsTest.java new file mode 100644 index 00000000000..a7b54f3e0a1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionDetails model. */ +public class CollectionDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionDetails() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals(collectionEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + CollectionDetails collectionDetailsModel = + new CollectionDetails.Builder() + .name("testString") + .description("testString") + .language("en") + .ocrEnabled(false) + .enrichments(java.util.Arrays.asList(collectionEnrichmentModel)) + .build(); + assertEquals(collectionDetailsModel.name(), "testString"); + assertEquals(collectionDetailsModel.description(), "testString"); + assertEquals(collectionDetailsModel.language(), "en"); + assertEquals(collectionDetailsModel.ocrEnabled(), Boolean.valueOf(false)); + assertEquals( + collectionDetailsModel.enrichments(), java.util.Arrays.asList(collectionEnrichmentModel)); + + String json = TestUtilities.serialize(collectionDetailsModel); + + CollectionDetails collectionDetailsModelNew = + TestUtilities.deserialize(json, CollectionDetails.class); + assertTrue(collectionDetailsModelNew instanceof CollectionDetails); + assertEquals(collectionDetailsModelNew.name(), "testString"); + assertEquals(collectionDetailsModelNew.description(), "testString"); + assertEquals(collectionDetailsModelNew.language(), "en"); + assertEquals(collectionDetailsModelNew.ocrEnabled(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCollectionDetailsError() throws Throwable { + new CollectionDetails.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionEnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionEnrichmentTest.java new file mode 100644 index 00000000000..9be55e83af2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionEnrichmentTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionEnrichment model. */ +public class CollectionEnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionEnrichment() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals(collectionEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(collectionEnrichmentModel); + + CollectionEnrichment collectionEnrichmentModelNew = + TestUtilities.deserialize(json, CollectionEnrichment.class); + assertTrue(collectionEnrichmentModelNew instanceof CollectionEnrichment); + assertEquals(collectionEnrichmentModelNew.enrichmentId(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionTest.java new file mode 100644 index 00000000000..0c6f2e02d08 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Collection model. */ +public class CollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollection() throws Throwable { + Collection collectionModel = new Collection(); + assertNull(collectionModel.getName()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CompletionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CompletionsTest.java new file mode 100644 index 00000000000..dc199076bad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CompletionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Completions model. */ +public class CompletionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCompletions() throws Throwable { + Completions completionsModel = new Completions(); + assertNull(completionsModel.getCompletions()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregationTest.java new file mode 100644 index 00000000000..7c55dca445e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregationTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsAggregation model. */ +public class ComponentSettingsAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsAggregation() throws Throwable { + ComponentSettingsAggregation componentSettingsAggregationModel = + new ComponentSettingsAggregation(); + assertNull(componentSettingsAggregationModel.getName()); + assertNull(componentSettingsAggregationModel.getLabel()); + assertNull(componentSettingsAggregationModel.isMultipleSelectionsAllowed()); + assertNull(componentSettingsAggregationModel.getVisualizationType()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBodyTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBodyTest.java new file mode 100644 index 00000000000..2fdac048013 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBodyTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsFieldsShownBody model. */ +public class ComponentSettingsFieldsShownBodyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsFieldsShownBody() throws Throwable { + ComponentSettingsFieldsShownBody componentSettingsFieldsShownBodyModel = + new ComponentSettingsFieldsShownBody(); + assertNull(componentSettingsFieldsShownBodyModel.isUsePassage()); + assertNull(componentSettingsFieldsShownBodyModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTest.java new file mode 100644 index 00000000000..542c3b111ad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsFieldsShown model. */ +public class ComponentSettingsFieldsShownTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsFieldsShown() throws Throwable { + ComponentSettingsFieldsShown componentSettingsFieldsShownModel = + new ComponentSettingsFieldsShown(); + assertNull(componentSettingsFieldsShownModel.getBody()); + assertNull(componentSettingsFieldsShownModel.getTitle()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitleTest.java new file mode 100644 index 00000000000..ae57721543a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitleTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsFieldsShownTitle model. */ +public class ComponentSettingsFieldsShownTitleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsFieldsShownTitle() throws Throwable { + ComponentSettingsFieldsShownTitle componentSettingsFieldsShownTitleModel = + new ComponentSettingsFieldsShownTitle(); + assertNull(componentSettingsFieldsShownTitleModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponseTest.java new file mode 100644 index 00000000000..cf632f92abd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsResponse model. */ +public class ComponentSettingsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsResponse() throws Throwable { + ComponentSettingsResponse componentSettingsResponseModel = new ComponentSettingsResponse(); + assertNull(componentSettingsResponseModel.getFieldsShown()); + assertNull(componentSettingsResponseModel.isAutocomplete()); + assertNull(componentSettingsResponseModel.isStructuredSearch()); + assertNull(componentSettingsResponseModel.getResultsPerPage()); + assertNull(componentSettingsResponseModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptionsTest.java new file mode 100644 index 00000000000..e23dbac3389 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptionsTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCollectionOptions model. */ +public class CreateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCollectionOptions() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals(collectionEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .projectId("testString") + .name("testString") + .description("testString") + .language("en") + .ocrEnabled(false) + .enrichments(java.util.Arrays.asList(collectionEnrichmentModel)) + .build(); + assertEquals(createCollectionOptionsModel.projectId(), "testString"); + assertEquals(createCollectionOptionsModel.name(), "testString"); + assertEquals(createCollectionOptionsModel.description(), "testString"); + assertEquals(createCollectionOptionsModel.language(), "en"); + assertEquals(createCollectionOptionsModel.ocrEnabled(), Boolean.valueOf(false)); + assertEquals( + createCollectionOptionsModel.enrichments(), + java.util.Arrays.asList(collectionEnrichmentModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCollectionOptionsError() throws Throwable { + new CreateCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierModelOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierModelOptionsTest.java new file mode 100644 index 00000000000..41a42bb835e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierModelOptionsTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateDocumentClassifierModelOptions model. */ +public class CreateDocumentClassifierModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateDocumentClassifierModelOptions() throws Throwable { + CreateDocumentClassifierModelOptions createDocumentClassifierModelOptionsModel = + new CreateDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .name("testString") + .description("testString") + .learningRate(Double.valueOf("0.1")) + .l1RegularizationStrengths(java.util.Arrays.asList(Double.valueOf("1.0E-6"))) + .l2RegularizationStrengths(java.util.Arrays.asList(Double.valueOf("1.0E-6"))) + .trainingMaxSteps(Long.valueOf("10000000")) + .improvementRatio(Double.valueOf("0.000010")) + .build(); + assertEquals(createDocumentClassifierModelOptionsModel.projectId(), "testString"); + assertEquals(createDocumentClassifierModelOptionsModel.classifierId(), "testString"); + assertEquals(createDocumentClassifierModelOptionsModel.name(), "testString"); + assertEquals(createDocumentClassifierModelOptionsModel.description(), "testString"); + assertEquals(createDocumentClassifierModelOptionsModel.learningRate(), Double.valueOf("0.1")); + assertEquals( + createDocumentClassifierModelOptionsModel.l1RegularizationStrengths(), + java.util.Arrays.asList(Double.valueOf("1.0E-6"))); + assertEquals( + createDocumentClassifierModelOptionsModel.l2RegularizationStrengths(), + java.util.Arrays.asList(Double.valueOf("1.0E-6"))); + assertEquals( + createDocumentClassifierModelOptionsModel.trainingMaxSteps(), Long.valueOf("10000000")); + assertEquals( + createDocumentClassifierModelOptionsModel.improvementRatio(), Double.valueOf("0.000010")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDocumentClassifierModelOptionsError() throws Throwable { + new CreateDocumentClassifierModelOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierOptionsTest.java new file mode 100644 index 00000000000..c765ea2c8d9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierOptionsTest.java @@ -0,0 +1,86 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateDocumentClassifierOptions model. */ +public class CreateDocumentClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateDocumentClassifierOptions() throws Throwable { + DocumentClassifierEnrichment documentClassifierEnrichmentModel = + new DocumentClassifierEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(documentClassifierEnrichmentModel.enrichmentId(), "testString"); + assertEquals(documentClassifierEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + ClassifierFederatedModel classifierFederatedModelModel = + new ClassifierFederatedModel.Builder().field("testString").build(); + assertEquals(classifierFederatedModelModel.field(), "testString"); + + CreateDocumentClassifier createDocumentClassifierModel = + new CreateDocumentClassifier.Builder() + .name("testString") + .description("testString") + .language("en") + .answerField("testString") + .enrichments(java.util.Arrays.asList(documentClassifierEnrichmentModel)) + .federatedClassification(classifierFederatedModelModel) + .build(); + assertEquals(createDocumentClassifierModel.name(), "testString"); + assertEquals(createDocumentClassifierModel.description(), "testString"); + assertEquals(createDocumentClassifierModel.language(), "en"); + assertEquals(createDocumentClassifierModel.answerField(), "testString"); + assertEquals( + createDocumentClassifierModel.enrichments(), + java.util.Arrays.asList(documentClassifierEnrichmentModel)); + assertEquals( + createDocumentClassifierModel.federatedClassification(), classifierFederatedModelModel); + + CreateDocumentClassifierOptions createDocumentClassifierOptionsModel = + new CreateDocumentClassifierOptions.Builder() + .projectId("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .classifier(createDocumentClassifierModel) + .testData(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals(createDocumentClassifierOptionsModel.projectId(), "testString"); + assertEquals( + IOUtils.toString(createDocumentClassifierOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createDocumentClassifierOptionsModel.classifier(), createDocumentClassifierModel); + assertEquals( + IOUtils.toString(createDocumentClassifierOptionsModel.testData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDocumentClassifierOptionsError() throws Throwable { + new CreateDocumentClassifierOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierTest.java new file mode 100644 index 00000000000..fa991bd2a42 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateDocumentClassifierTest.java @@ -0,0 +1,82 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateDocumentClassifier model. */ +public class CreateDocumentClassifierTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateDocumentClassifier() throws Throwable { + DocumentClassifierEnrichment documentClassifierEnrichmentModel = + new DocumentClassifierEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(documentClassifierEnrichmentModel.enrichmentId(), "testString"); + assertEquals(documentClassifierEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + ClassifierFederatedModel classifierFederatedModelModel = + new ClassifierFederatedModel.Builder().field("testString").build(); + assertEquals(classifierFederatedModelModel.field(), "testString"); + + CreateDocumentClassifier createDocumentClassifierModel = + new CreateDocumentClassifier.Builder() + .name("testString") + .description("testString") + .language("en") + .answerField("testString") + .enrichments(java.util.Arrays.asList(documentClassifierEnrichmentModel)) + .federatedClassification(classifierFederatedModelModel) + .build(); + assertEquals(createDocumentClassifierModel.name(), "testString"); + assertEquals(createDocumentClassifierModel.description(), "testString"); + assertEquals(createDocumentClassifierModel.language(), "en"); + assertEquals(createDocumentClassifierModel.answerField(), "testString"); + assertEquals( + createDocumentClassifierModel.enrichments(), + java.util.Arrays.asList(documentClassifierEnrichmentModel)); + assertEquals( + createDocumentClassifierModel.federatedClassification(), classifierFederatedModelModel); + + String json = TestUtilities.serialize(createDocumentClassifierModel); + + CreateDocumentClassifier createDocumentClassifierModelNew = + TestUtilities.deserialize(json, CreateDocumentClassifier.class); + assertTrue(createDocumentClassifierModelNew instanceof CreateDocumentClassifier); + assertEquals(createDocumentClassifierModelNew.name(), "testString"); + assertEquals(createDocumentClassifierModelNew.description(), "testString"); + assertEquals(createDocumentClassifierModelNew.language(), "en"); + assertEquals(createDocumentClassifierModelNew.answerField(), "testString"); + assertEquals( + createDocumentClassifierModelNew.federatedClassification().toString(), + classifierFederatedModelModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDocumentClassifierError() throws Throwable { + new CreateDocumentClassifier.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptionsTest.java new file mode 100644 index 00000000000..23a6d709aa1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptionsTest.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEnrichmentOptions model. */ +public class CreateEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEnrichmentOptions() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(java.util.Arrays.asList("testString")) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .classifierId("testString") + .modelId("testString") + .confidenceThreshold(Double.valueOf("0")) + .topK(Long.valueOf("0")) + .url("testString") + .version("2023-03-31") + .secret("testString") + .headers(webhookHeaderModel) + .locationEncoding("`utf-16`") + .build(); + assertEquals(enrichmentOptionsModel.languages(), java.util.Arrays.asList("testString")); + assertEquals(enrichmentOptionsModel.entityType(), "testString"); + assertEquals(enrichmentOptionsModel.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModel.resultField(), "testString"); + assertEquals(enrichmentOptionsModel.classifierId(), "testString"); + assertEquals(enrichmentOptionsModel.modelId(), "testString"); + assertEquals(enrichmentOptionsModel.confidenceThreshold(), Double.valueOf("0")); + assertEquals(enrichmentOptionsModel.topK(), Long.valueOf("0")); + assertEquals(enrichmentOptionsModel.url(), "testString"); + assertEquals(enrichmentOptionsModel.version(), "2023-03-31"); + assertEquals(enrichmentOptionsModel.secret(), "testString"); + assertEquals(enrichmentOptionsModel.headers(), webhookHeaderModel); + assertEquals(enrichmentOptionsModel.locationEncoding(), "`utf-16`"); + + CreateEnrichment createEnrichmentModel = + new CreateEnrichment.Builder() + .name("testString") + .description("testString") + .type("classifier") + .options(enrichmentOptionsModel) + .build(); + assertEquals(createEnrichmentModel.name(), "testString"); + assertEquals(createEnrichmentModel.description(), "testString"); + assertEquals(createEnrichmentModel.type(), "classifier"); + assertEquals(createEnrichmentModel.options(), enrichmentOptionsModel); + + CreateEnrichmentOptions createEnrichmentOptionsModel = + new CreateEnrichmentOptions.Builder() + .projectId("testString") + .enrichment(createEnrichmentModel) + .file(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals(createEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(createEnrichmentOptionsModel.enrichment(), createEnrichmentModel); + assertEquals( + IOUtils.toString(createEnrichmentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEnrichmentOptionsError() throws Throwable { + new CreateEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentTest.java new file mode 100644 index 00000000000..d098c9bb5d7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentTest.java @@ -0,0 +1,90 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEnrichment model. */ +public class CreateEnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEnrichment() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(java.util.Arrays.asList("testString")) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .classifierId("testString") + .modelId("testString") + .confidenceThreshold(Double.valueOf("0")) + .topK(Long.valueOf("0")) + .url("testString") + .version("2023-03-31") + .secret("testString") + .headers(webhookHeaderModel) + .locationEncoding("`utf-16`") + .build(); + assertEquals(enrichmentOptionsModel.languages(), java.util.Arrays.asList("testString")); + assertEquals(enrichmentOptionsModel.entityType(), "testString"); + assertEquals(enrichmentOptionsModel.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModel.resultField(), "testString"); + assertEquals(enrichmentOptionsModel.classifierId(), "testString"); + assertEquals(enrichmentOptionsModel.modelId(), "testString"); + assertEquals(enrichmentOptionsModel.confidenceThreshold(), Double.valueOf("0")); + assertEquals(enrichmentOptionsModel.topK(), Long.valueOf("0")); + assertEquals(enrichmentOptionsModel.url(), "testString"); + assertEquals(enrichmentOptionsModel.version(), "2023-03-31"); + assertEquals(enrichmentOptionsModel.secret(), "testString"); + assertEquals(enrichmentOptionsModel.headers(), webhookHeaderModel); + assertEquals(enrichmentOptionsModel.locationEncoding(), "`utf-16`"); + + CreateEnrichment createEnrichmentModel = + new CreateEnrichment.Builder() + .name("testString") + .description("testString") + .type("classifier") + .options(enrichmentOptionsModel) + .build(); + assertEquals(createEnrichmentModel.name(), "testString"); + assertEquals(createEnrichmentModel.description(), "testString"); + assertEquals(createEnrichmentModel.type(), "classifier"); + assertEquals(createEnrichmentModel.options(), enrichmentOptionsModel); + + String json = TestUtilities.serialize(createEnrichmentModel); + + CreateEnrichment createEnrichmentModelNew = + TestUtilities.deserialize(json, CreateEnrichment.class); + assertTrue(createEnrichmentModelNew instanceof CreateEnrichment); + assertEquals(createEnrichmentModelNew.name(), "testString"); + assertEquals(createEnrichmentModelNew.description(), "testString"); + assertEquals(createEnrichmentModelNew.type(), "classifier"); + assertEquals(createEnrichmentModelNew.options().toString(), enrichmentOptionsModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateExpansionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateExpansionsOptionsTest.java new file mode 100644 index 00000000000..dadd61f9f0e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateExpansionsOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateExpansionsOptions model. */ +public class CreateExpansionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateExpansionsOptions() throws Throwable { + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(java.util.Arrays.asList("testString")) + .expandedTerms(java.util.Arrays.asList("testString")) + .build(); + assertEquals(expansionModel.inputTerms(), java.util.Arrays.asList("testString")); + assertEquals(expansionModel.expandedTerms(), java.util.Arrays.asList("testString")); + + CreateExpansionsOptions createExpansionsOptionsModel = + new CreateExpansionsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .expansions(java.util.Arrays.asList(expansionModel)) + .build(); + assertEquals(createExpansionsOptionsModel.projectId(), "testString"); + assertEquals(createExpansionsOptionsModel.collectionId(), "testString"); + assertEquals( + createExpansionsOptionsModel.expansions(), java.util.Arrays.asList(expansionModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExpansionsOptionsError() throws Throwable { + new CreateExpansionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateProjectOptionsTest.java new file mode 100644 index 00000000000..23b9bb51516 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateProjectOptionsTest.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateProjectOptions model. */ +public class CreateProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateProjectOptions() throws Throwable { + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsPassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.fields(), java.util.Arrays.asList("testString")); + assertEquals(defaultQueryParamsPassagesModel.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.maxPerDocument(), Long.valueOf("26")); + + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("0")) + .build(); + assertEquals(defaultQueryParamsTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModel.perDocument(), Long.valueOf("0")); + + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.count(), Long.valueOf("26")); + + DefaultQueryParams defaultQueryParamsModel = + new DefaultQueryParams.Builder() + .collectionIds(java.util.Arrays.asList("testString")) + .passages(defaultQueryParamsPassagesModel) + .tableResults(defaultQueryParamsTableResultsModel) + .aggregation("testString") + .suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel) + .spellingSuggestions(true) + .highlight(true) + .count(Long.valueOf("26")) + .sort("testString") + .xReturn(java.util.Arrays.asList("testString")) + .build(); + assertEquals(defaultQueryParamsModel.collectionIds(), java.util.Arrays.asList("testString")); + assertEquals(defaultQueryParamsModel.passages(), defaultQueryParamsPassagesModel); + assertEquals(defaultQueryParamsModel.tableResults(), defaultQueryParamsTableResultsModel); + assertEquals(defaultQueryParamsModel.aggregation(), "testString"); + assertEquals( + defaultQueryParamsModel.suggestedRefinements(), + defaultQueryParamsSuggestedRefinementsModel); + assertEquals(defaultQueryParamsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.highlight(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsModel.sort(), "testString"); + assertEquals(defaultQueryParamsModel.xReturn(), java.util.Arrays.asList("testString")); + + CreateProjectOptions createProjectOptionsModel = + new CreateProjectOptions.Builder() + .name("testString") + .type("intelligent_document_processing") + .defaultQueryParameters(defaultQueryParamsModel) + .build(); + assertEquals(createProjectOptionsModel.name(), "testString"); + assertEquals(createProjectOptionsModel.type(), "intelligent_document_processing"); + assertEquals(createProjectOptionsModel.defaultQueryParameters(), defaultQueryParamsModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateProjectOptionsError() throws Throwable { + new CreateProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateStopwordListOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateStopwordListOptionsTest.java new file mode 100644 index 00000000000..5a9d05e5f03 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateStopwordListOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateStopwordListOptions model. */ +public class CreateStopwordListOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateStopwordListOptions() throws Throwable { + CreateStopwordListOptions createStopwordListOptionsModel = + new CreateStopwordListOptions.Builder() + .projectId("testString") + .collectionId("testString") + .stopwords(java.util.Arrays.asList("testString")) + .build(); + assertEquals(createStopwordListOptionsModel.projectId(), "testString"); + assertEquals(createStopwordListOptionsModel.collectionId(), "testString"); + assertEquals(createStopwordListOptionsModel.stopwords(), java.util.Arrays.asList("testString")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateStopwordListOptionsError() throws Throwable { + new CreateStopwordListOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..68d10de5fb3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateTrainingQueryOptions model. */ +public class CreateTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTrainingQueryOptions() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + CreateTrainingQueryOptions createTrainingQueryOptionsModel = + new CreateTrainingQueryOptions.Builder() + .projectId("testString") + .naturalLanguageQuery("testString") + .examples(java.util.Arrays.asList(trainingExampleModel)) + .filter("testString") + .build(); + assertEquals(createTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(createTrainingQueryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals( + createTrainingQueryOptionsModel.examples(), java.util.Arrays.asList(trainingExampleModel)); + assertEquals(createTrainingQueryOptionsModel.filter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTrainingQueryOptionsError() throws Throwable { + new CreateTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassagesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassagesTest.java new file mode 100644 index 00000000000..5aabe9277fd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassagesTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParamsPassages model. */ +public class DefaultQueryParamsPassagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParamsPassages() throws Throwable { + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsPassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.fields(), java.util.Arrays.asList("testString")); + assertEquals(defaultQueryParamsPassagesModel.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.maxPerDocument(), Long.valueOf("26")); + + String json = TestUtilities.serialize(defaultQueryParamsPassagesModel); + + DefaultQueryParamsPassages defaultQueryParamsPassagesModelNew = + TestUtilities.deserialize(json, DefaultQueryParamsPassages.class); + assertTrue(defaultQueryParamsPassagesModelNew instanceof DefaultQueryParamsPassages); + assertEquals(defaultQueryParamsPassagesModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModelNew.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModelNew.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModelNew.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModelNew.maxPerDocument(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinementsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinementsTest.java new file mode 100644 index 00000000000..a2e29f25abd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinementsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParamsSuggestedRefinements model. */ +public class DefaultQueryParamsSuggestedRefinementsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParamsSuggestedRefinements() throws Throwable { + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.count(), Long.valueOf("26")); + + String json = TestUtilities.serialize(defaultQueryParamsSuggestedRefinementsModel); + + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModelNew = + TestUtilities.deserialize(json, DefaultQueryParamsSuggestedRefinements.class); + assertTrue( + defaultQueryParamsSuggestedRefinementsModelNew + instanceof DefaultQueryParamsSuggestedRefinements); + assertEquals(defaultQueryParamsSuggestedRefinementsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModelNew.count(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResultsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResultsTest.java new file mode 100644 index 00000000000..bb44b589492 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResultsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParamsTableResults model. */ +public class DefaultQueryParamsTableResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParamsTableResults() throws Throwable { + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("0")) + .build(); + assertEquals(defaultQueryParamsTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModel.perDocument(), Long.valueOf("0")); + + String json = TestUtilities.serialize(defaultQueryParamsTableResultsModel); + + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModelNew = + TestUtilities.deserialize(json, DefaultQueryParamsTableResults.class); + assertTrue(defaultQueryParamsTableResultsModelNew instanceof DefaultQueryParamsTableResults); + assertEquals(defaultQueryParamsTableResultsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModelNew.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModelNew.perDocument(), Long.valueOf("0")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTest.java new file mode 100644 index 00000000000..4a477aa6be6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTest.java @@ -0,0 +1,113 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParams model. */ +public class DefaultQueryParamsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParams() throws Throwable { + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsPassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.fields(), java.util.Arrays.asList("testString")); + assertEquals(defaultQueryParamsPassagesModel.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.maxPerDocument(), Long.valueOf("26")); + + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("0")) + .build(); + assertEquals(defaultQueryParamsTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModel.perDocument(), Long.valueOf("0")); + + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.count(), Long.valueOf("26")); + + DefaultQueryParams defaultQueryParamsModel = + new DefaultQueryParams.Builder() + .collectionIds(java.util.Arrays.asList("testString")) + .passages(defaultQueryParamsPassagesModel) + .tableResults(defaultQueryParamsTableResultsModel) + .aggregation("testString") + .suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel) + .spellingSuggestions(true) + .highlight(true) + .count(Long.valueOf("26")) + .sort("testString") + .xReturn(java.util.Arrays.asList("testString")) + .build(); + assertEquals(defaultQueryParamsModel.collectionIds(), java.util.Arrays.asList("testString")); + assertEquals(defaultQueryParamsModel.passages(), defaultQueryParamsPassagesModel); + assertEquals(defaultQueryParamsModel.tableResults(), defaultQueryParamsTableResultsModel); + assertEquals(defaultQueryParamsModel.aggregation(), "testString"); + assertEquals( + defaultQueryParamsModel.suggestedRefinements(), + defaultQueryParamsSuggestedRefinementsModel); + assertEquals(defaultQueryParamsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.highlight(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsModel.sort(), "testString"); + assertEquals(defaultQueryParamsModel.xReturn(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(defaultQueryParamsModel); + + DefaultQueryParams defaultQueryParamsModelNew = + TestUtilities.deserialize(json, DefaultQueryParams.class); + assertTrue(defaultQueryParamsModelNew instanceof DefaultQueryParams); + assertEquals( + defaultQueryParamsModelNew.passages().toString(), + defaultQueryParamsPassagesModel.toString()); + assertEquals( + defaultQueryParamsModelNew.tableResults().toString(), + defaultQueryParamsTableResultsModel.toString()); + assertEquals(defaultQueryParamsModelNew.aggregation(), "testString"); + assertEquals( + defaultQueryParamsModelNew.suggestedRefinements().toString(), + defaultQueryParamsSuggestedRefinementsModel.toString()); + assertEquals(defaultQueryParamsModelNew.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModelNew.highlight(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModelNew.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsModelNew.sort(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptionsTest.java new file mode 100644 index 00000000000..ca7118f4e5c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCollectionOptions model. */ +public class DeleteCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCollectionOptions() throws Throwable { + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteCollectionOptionsModel.projectId(), "testString"); + assertEquals(deleteCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionOptionsError() throws Throwable { + new DeleteCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierModelOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierModelOptionsTest.java new file mode 100644 index 00000000000..52b9a08bcd7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentClassifierModelOptions model. */ +public class DeleteDocumentClassifierModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentClassifierModelOptions() throws Throwable { + DeleteDocumentClassifierModelOptions deleteDocumentClassifierModelOptionsModel = + new DeleteDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .modelId("testString") + .build(); + assertEquals(deleteDocumentClassifierModelOptionsModel.projectId(), "testString"); + assertEquals(deleteDocumentClassifierModelOptionsModel.classifierId(), "testString"); + assertEquals(deleteDocumentClassifierModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentClassifierModelOptionsError() throws Throwable { + new DeleteDocumentClassifierModelOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierOptionsTest.java new file mode 100644 index 00000000000..72583ef710a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentClassifierOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentClassifierOptions model. */ +public class DeleteDocumentClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentClassifierOptions() throws Throwable { + DeleteDocumentClassifierOptions deleteDocumentClassifierOptionsModel = + new DeleteDocumentClassifierOptions.Builder() + .projectId("testString") + .classifierId("testString") + .build(); + assertEquals(deleteDocumentClassifierOptionsModel.projectId(), "testString"); + assertEquals(deleteDocumentClassifierOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentClassifierOptionsError() throws Throwable { + new DeleteDocumentClassifierOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptionsTest.java new file mode 100644 index 00000000000..60ea41d91bd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentOptions model. */ +public class DeleteDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentOptions() throws Throwable { + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .xWatsonDiscoveryForce(false) + .build(); + assertEquals(deleteDocumentOptionsModel.projectId(), "testString"); + assertEquals(deleteDocumentOptionsModel.collectionId(), "testString"); + assertEquals(deleteDocumentOptionsModel.documentId(), "testString"); + assertEquals(deleteDocumentOptionsModel.xWatsonDiscoveryForce(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentOptionsError() throws Throwable { + new DeleteDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponseTest.java new file mode 100644 index 00000000000..36c8d72d86c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentResponse model. */ +public class DeleteDocumentResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentResponse() throws Throwable { + DeleteDocumentResponse deleteDocumentResponseModel = new DeleteDocumentResponse(); + assertNull(deleteDocumentResponseModel.getDocumentId()); + assertNull(deleteDocumentResponseModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptionsTest.java new file mode 100644 index 00000000000..cb0e5863094 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteEnrichmentOptions model. */ +public class DeleteEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteEnrichmentOptions() throws Throwable { + DeleteEnrichmentOptions deleteEnrichmentOptionsModel = + new DeleteEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); + assertEquals(deleteEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(deleteEnrichmentOptionsModel.enrichmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEnrichmentOptionsError() throws Throwable { + new DeleteEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteExpansionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteExpansionsOptionsTest.java new file mode 100644 index 00000000000..60cd206c2a5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteExpansionsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteExpansionsOptions model. */ +public class DeleteExpansionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteExpansionsOptions() throws Throwable { + DeleteExpansionsOptions deleteExpansionsOptionsModel = + new DeleteExpansionsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteExpansionsOptionsModel.projectId(), "testString"); + assertEquals(deleteExpansionsOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExpansionsOptionsError() throws Throwable { + new DeleteExpansionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptionsTest.java new file mode 100644 index 00000000000..8e3f7ab64f0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteProjectOptions model. */ +public class DeleteProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteProjectOptions() throws Throwable { + DeleteProjectOptions deleteProjectOptionsModel = + new DeleteProjectOptions.Builder().projectId("testString").build(); + assertEquals(deleteProjectOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteProjectOptionsError() throws Throwable { + new DeleteProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteStopwordListOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteStopwordListOptionsTest.java new file mode 100644 index 00000000000..138c595917b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteStopwordListOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteStopwordListOptions model. */ +public class DeleteStopwordListOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteStopwordListOptions() throws Throwable { + DeleteStopwordListOptions deleteStopwordListOptionsModel = + new DeleteStopwordListOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteStopwordListOptionsModel.projectId(), "testString"); + assertEquals(deleteStopwordListOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteStopwordListOptionsError() throws Throwable { + new DeleteStopwordListOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptionsTest.java new file mode 100644 index 00000000000..305cd243ea1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteTrainingQueriesOptions model. */ +public class DeleteTrainingQueriesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTrainingQueriesOptions() throws Throwable { + DeleteTrainingQueriesOptions deleteTrainingQueriesOptionsModel = + new DeleteTrainingQueriesOptions.Builder().projectId("testString").build(); + assertEquals(deleteTrainingQueriesOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingQueriesOptionsError() throws Throwable { + new DeleteTrainingQueriesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..93521bcb4d3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueryOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteTrainingQueryOptions model. */ +public class DeleteTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTrainingQueryOptions() throws Throwable { + DeleteTrainingQueryOptions deleteTrainingQueryOptionsModel = + new DeleteTrainingQueryOptions.Builder() + .projectId("testString") + .queryId("testString") + .build(); + assertEquals(deleteTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(deleteTrainingQueryOptionsModel.queryId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingQueryOptionsError() throws Throwable { + new DeleteTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..6a438e77c35 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAcceptedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAcceptedTest.java new file mode 100644 index 00000000000..81ba8672f59 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAcceptedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentAccepted model. */ +public class DocumentAcceptedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentAccepted() throws Throwable { + DocumentAccepted documentAcceptedModel = new DocumentAccepted(); + assertNull(documentAcceptedModel.getDocumentId()); + assertNull(documentAcceptedModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAttributeTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAttributeTest.java new file mode 100644 index 00000000000..407e14dfba9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAttributeTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentAttribute model. */ +public class DocumentAttributeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentAttribute() throws Throwable { + DocumentAttribute documentAttributeModel = new DocumentAttribute(); + assertNull(documentAttributeModel.getType()); + assertNull(documentAttributeModel.getText()); + assertNull(documentAttributeModel.getLocation()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierEnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierEnrichmentTest.java new file mode 100644 index 00000000000..e4f08b91ea6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierEnrichmentTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentClassifierEnrichment model. */ +public class DocumentClassifierEnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentClassifierEnrichment() throws Throwable { + DocumentClassifierEnrichment documentClassifierEnrichmentModel = + new DocumentClassifierEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(documentClassifierEnrichmentModel.enrichmentId(), "testString"); + assertEquals(documentClassifierEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(documentClassifierEnrichmentModel); + + DocumentClassifierEnrichment documentClassifierEnrichmentModelNew = + TestUtilities.deserialize(json, DocumentClassifierEnrichment.class); + assertTrue(documentClassifierEnrichmentModelNew instanceof DocumentClassifierEnrichment); + assertEquals(documentClassifierEnrichmentModelNew.enrichmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDocumentClassifierEnrichmentError() throws Throwable { + new DocumentClassifierEnrichment.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModelTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModelTest.java new file mode 100644 index 00000000000..877d27b8904 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModelTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentClassifierModel model. */ +public class DocumentClassifierModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentClassifierModel() throws Throwable { + DocumentClassifierModel documentClassifierModelModel = new DocumentClassifierModel(); + assertNull(documentClassifierModelModel.getName()); + assertNull(documentClassifierModelModel.getDescription()); + assertNull(documentClassifierModelModel.getTrainingDataFile()); + assertNull(documentClassifierModelModel.getTestDataFile()); + assertNull(documentClassifierModelModel.getStatus()); + assertNull(documentClassifierModelModel.getEvaluation()); + assertNull(documentClassifierModelModel.getEnrichmentId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModelsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModelsTest.java new file mode 100644 index 00000000000..261a87afefc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentClassifierModels model. */ +public class DocumentClassifierModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentClassifierModels() throws Throwable { + DocumentClassifierModels documentClassifierModelsModel = new DocumentClassifierModels(); + assertNull(documentClassifierModelsModel.getModels()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierTest.java new file mode 100644 index 00000000000..dc2d0fe9886 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifierTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentClassifier model. */ +public class DocumentClassifierTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentClassifier() throws Throwable { + DocumentClassifier documentClassifierModel = new DocumentClassifier(); + assertNull(documentClassifierModel.getName()); + assertNull(documentClassifierModel.getDescription()); + assertNull(documentClassifierModel.getLanguage()); + assertNull(documentClassifierModel.getEnrichments()); + assertNull(documentClassifierModel.getRecognizedFields()); + assertNull(documentClassifierModel.getAnswerField()); + assertNull(documentClassifierModel.getTrainingDataFile()); + assertNull(documentClassifierModel.getTestDataFile()); + assertNull(documentClassifierModel.getFederatedClassification()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifiersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifiersTest.java new file mode 100644 index 00000000000..b6e2fe7323d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentClassifiersTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentClassifiers model. */ +public class DocumentClassifiersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentClassifiers() throws Throwable { + DocumentClassifiers documentClassifiersModel = new DocumentClassifiers(); + assertNull(documentClassifiersModel.getClassifiers()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentDetailsChildrenTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentDetailsChildrenTest.java new file mode 100644 index 00000000000..a065bca88cf --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentDetailsChildrenTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentDetailsChildren model. */ +public class DocumentDetailsChildrenTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentDetailsChildren() throws Throwable { + DocumentDetailsChildren documentDetailsChildrenModel = new DocumentDetailsChildren(); + assertNull(documentDetailsChildrenModel.isHaveNotices()); + assertNull(documentDetailsChildrenModel.getCount()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentDetailsTest.java new file mode 100644 index 00000000000..94a48d87da2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentDetailsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentDetails model. */ +public class DocumentDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentDetails() throws Throwable { + DocumentDetails documentDetailsModel = new DocumentDetails(); + assertNull(documentDetailsModel.getStatus()); + assertNull(documentDetailsModel.getNotices()); + assertNull(documentDetailsModel.getChildren()); + assertNull(documentDetailsModel.getFilename()); + assertNull(documentDetailsModel.getFileType()); + assertNull(documentDetailsModel.getSha256()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentOptionsTest.java new file mode 100644 index 00000000000..11814ad1e86 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentOptionsTest.java @@ -0,0 +1,86 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichmentOptions model. */ +public class EnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichmentOptions() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(java.util.Arrays.asList("testString")) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .classifierId("testString") + .modelId("testString") + .confidenceThreshold(Double.valueOf("0")) + .topK(Long.valueOf("0")) + .url("testString") + .version("2023-03-31") + .secret("testString") + .headers(webhookHeaderModel) + .locationEncoding("`utf-16`") + .build(); + assertEquals(enrichmentOptionsModel.languages(), java.util.Arrays.asList("testString")); + assertEquals(enrichmentOptionsModel.entityType(), "testString"); + assertEquals(enrichmentOptionsModel.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModel.resultField(), "testString"); + assertEquals(enrichmentOptionsModel.classifierId(), "testString"); + assertEquals(enrichmentOptionsModel.modelId(), "testString"); + assertEquals(enrichmentOptionsModel.confidenceThreshold(), Double.valueOf("0")); + assertEquals(enrichmentOptionsModel.topK(), Long.valueOf("0")); + assertEquals(enrichmentOptionsModel.url(), "testString"); + assertEquals(enrichmentOptionsModel.version(), "2023-03-31"); + assertEquals(enrichmentOptionsModel.secret(), "testString"); + assertEquals(enrichmentOptionsModel.headers(), webhookHeaderModel); + assertEquals(enrichmentOptionsModel.locationEncoding(), "`utf-16`"); + + String json = TestUtilities.serialize(enrichmentOptionsModel); + + EnrichmentOptions enrichmentOptionsModelNew = + TestUtilities.deserialize(json, EnrichmentOptions.class); + assertTrue(enrichmentOptionsModelNew instanceof EnrichmentOptions); + assertEquals(enrichmentOptionsModelNew.entityType(), "testString"); + assertEquals(enrichmentOptionsModelNew.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModelNew.resultField(), "testString"); + assertEquals(enrichmentOptionsModelNew.classifierId(), "testString"); + assertEquals(enrichmentOptionsModelNew.modelId(), "testString"); + assertEquals(enrichmentOptionsModelNew.confidenceThreshold(), Double.valueOf("0")); + assertEquals(enrichmentOptionsModelNew.topK(), Long.valueOf("0")); + assertEquals(enrichmentOptionsModelNew.url(), "testString"); + assertEquals(enrichmentOptionsModelNew.version(), "2023-03-31"); + assertEquals(enrichmentOptionsModelNew.secret(), "testString"); + assertEquals(enrichmentOptionsModelNew.headers().toString(), webhookHeaderModel.toString()); + assertEquals(enrichmentOptionsModelNew.locationEncoding(), "`utf-16`"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentTest.java new file mode 100644 index 00000000000..0917d5f64ab --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Enrichment model. */ +public class EnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichment() throws Throwable { + Enrichment enrichmentModel = new Enrichment(); + assertNull(enrichmentModel.getName()); + assertNull(enrichmentModel.getDescription()); + assertNull(enrichmentModel.getType()); + assertNull(enrichmentModel.getOptions()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentsTest.java new file mode 100644 index 00000000000..fa30fe0a77e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Enrichments model. */ +public class EnrichmentsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichments() throws Throwable { + Enrichments enrichmentsModel = new Enrichments(); + assertNull(enrichmentsModel.getEnrichments()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ExpansionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ExpansionTest.java new file mode 100644 index 00000000000..047be406b5c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ExpansionTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Expansion model. */ +public class ExpansionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExpansion() throws Throwable { + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(java.util.Arrays.asList("testString")) + .expandedTerms(java.util.Arrays.asList("testString")) + .build(); + assertEquals(expansionModel.inputTerms(), java.util.Arrays.asList("testString")); + assertEquals(expansionModel.expandedTerms(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(expansionModel); + + Expansion expansionModelNew = TestUtilities.deserialize(json, Expansion.class); + assertTrue(expansionModelNew instanceof Expansion); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExpansionError() throws Throwable { + new Expansion.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ExpansionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ExpansionsTest.java new file mode 100644 index 00000000000..a01a0afce21 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ExpansionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Expansions model. */ +public class ExpansionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExpansions() throws Throwable { + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(java.util.Arrays.asList("testString")) + .expandedTerms(java.util.Arrays.asList("testString")) + .build(); + assertEquals(expansionModel.inputTerms(), java.util.Arrays.asList("testString")); + assertEquals(expansionModel.expandedTerms(), java.util.Arrays.asList("testString")); + + Expansions expansionsModel = + new Expansions.Builder().expansions(java.util.Arrays.asList(expansionModel)).build(); + assertEquals(expansionsModel.expansions(), java.util.Arrays.asList(expansionModel)); + + String json = TestUtilities.serialize(expansionsModel); + + Expansions expansionsModelNew = TestUtilities.deserialize(json, Expansions.class); + assertTrue(expansionsModelNew instanceof Expansions); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExpansionsError() throws Throwable { + new Expansions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/FieldTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/FieldTest.java new file mode 100644 index 00000000000..f03b656056b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/FieldTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Field model. */ +public class FieldTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testField() throws Throwable { + Field fieldModel = new Field(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptionsTest.java new file mode 100644 index 00000000000..bcb47fa3ca3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAutocompletionOptions model. */ +public class GetAutocompletionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAutocompletionOptions() throws Throwable { + GetAutocompletionOptions getAutocompletionOptionsModel = + new GetAutocompletionOptions.Builder() + .projectId("testString") + .prefix("testString") + .collectionIds(java.util.Arrays.asList("testString")) + .field("testString") + .count(Long.valueOf("5")) + .build(); + assertEquals(getAutocompletionOptionsModel.projectId(), "testString"); + assertEquals(getAutocompletionOptionsModel.prefix(), "testString"); + assertEquals( + getAutocompletionOptionsModel.collectionIds(), java.util.Arrays.asList("testString")); + assertEquals(getAutocompletionOptionsModel.field(), "testString"); + assertEquals(getAutocompletionOptionsModel.count(), Long.valueOf("5")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAutocompletionOptionsError() throws Throwable { + new GetAutocompletionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetCollectionOptionsTest.java new file mode 100644 index 00000000000..e7b928aadc4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetCollectionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCollectionOptions model. */ +public class GetCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCollectionOptions() throws Throwable { + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(getCollectionOptionsModel.projectId(), "testString"); + assertEquals(getCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionOptionsError() throws Throwable { + new GetCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptionsTest.java new file mode 100644 index 00000000000..a79b461c38f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetComponentSettingsOptions model. */ +public class GetComponentSettingsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetComponentSettingsOptions() throws Throwable { + GetComponentSettingsOptions getComponentSettingsOptionsModel = + new GetComponentSettingsOptions.Builder().projectId("testString").build(); + assertEquals(getComponentSettingsOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetComponentSettingsOptionsError() throws Throwable { + new GetComponentSettingsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierModelOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierModelOptionsTest.java new file mode 100644 index 00000000000..933dbab22f7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDocumentClassifierModelOptions model. */ +public class GetDocumentClassifierModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDocumentClassifierModelOptions() throws Throwable { + GetDocumentClassifierModelOptions getDocumentClassifierModelOptionsModel = + new GetDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .modelId("testString") + .build(); + assertEquals(getDocumentClassifierModelOptionsModel.projectId(), "testString"); + assertEquals(getDocumentClassifierModelOptionsModel.classifierId(), "testString"); + assertEquals(getDocumentClassifierModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentClassifierModelOptionsError() throws Throwable { + new GetDocumentClassifierModelOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierOptionsTest.java new file mode 100644 index 00000000000..c1e88c69f94 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentClassifierOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDocumentClassifierOptions model. */ +public class GetDocumentClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDocumentClassifierOptions() throws Throwable { + GetDocumentClassifierOptions getDocumentClassifierOptionsModel = + new GetDocumentClassifierOptions.Builder() + .projectId("testString") + .classifierId("testString") + .build(); + assertEquals(getDocumentClassifierOptionsModel.projectId(), "testString"); + assertEquals(getDocumentClassifierOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentClassifierOptionsError() throws Throwable { + new GetDocumentClassifierOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentOptionsTest.java new file mode 100644 index 00000000000..eb755803a90 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetDocumentOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDocumentOptions model. */ +public class GetDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDocumentOptions() throws Throwable { + GetDocumentOptions getDocumentOptionsModel = + new GetDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .build(); + assertEquals(getDocumentOptionsModel.projectId(), "testString"); + assertEquals(getDocumentOptionsModel.collectionId(), "testString"); + assertEquals(getDocumentOptionsModel.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentOptionsError() throws Throwable { + new GetDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptionsTest.java new file mode 100644 index 00000000000..c6231fde743 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetEnrichmentOptions model. */ +public class GetEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetEnrichmentOptions() throws Throwable { + GetEnrichmentOptions getEnrichmentOptionsModel = + new GetEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); + assertEquals(getEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(getEnrichmentOptionsModel.enrichmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnrichmentOptionsError() throws Throwable { + new GetEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetProjectOptionsTest.java new file mode 100644 index 00000000000..bca7bac326d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetProjectOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetProjectOptions model. */ +public class GetProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetProjectOptions() throws Throwable { + GetProjectOptions getProjectOptionsModel = + new GetProjectOptions.Builder().projectId("testString").build(); + assertEquals(getProjectOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetProjectOptionsError() throws Throwable { + new GetProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetStopwordListOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetStopwordListOptionsTest.java new file mode 100644 index 00000000000..fd5eac5f073 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetStopwordListOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetStopwordListOptions model. */ +public class GetStopwordListOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetStopwordListOptions() throws Throwable { + GetStopwordListOptions getStopwordListOptionsModel = + new GetStopwordListOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(getStopwordListOptionsModel.projectId(), "testString"); + assertEquals(getStopwordListOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetStopwordListOptionsError() throws Throwable { + new GetStopwordListOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..49d3cf2a688 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTrainingQueryOptions model. */ +public class GetTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTrainingQueryOptions() throws Throwable { + GetTrainingQueryOptions getTrainingQueryOptionsModel = + new GetTrainingQueryOptions.Builder().projectId("testString").queryId("testString").build(); + assertEquals(getTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(getTrainingQueryOptionsModel.queryId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingQueryOptionsError() throws Throwable { + new GetTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListBatchesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListBatchesOptionsTest.java new file mode 100644 index 00000000000..eaa058224c9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListBatchesOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListBatchesOptions model. */ +public class ListBatchesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListBatchesOptions() throws Throwable { + ListBatchesOptions listBatchesOptionsModel = + new ListBatchesOptions.Builder().projectId("testString").collectionId("testString").build(); + assertEquals(listBatchesOptionsModel.projectId(), "testString"); + assertEquals(listBatchesOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListBatchesOptionsError() throws Throwable { + new ListBatchesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListBatchesResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListBatchesResponseTest.java new file mode 100644 index 00000000000..8e60ce09282 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListBatchesResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListBatchesResponse model. */ +public class ListBatchesResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListBatchesResponse() throws Throwable { + ListBatchesResponse listBatchesResponseModel = new ListBatchesResponse(); + assertNull(listBatchesResponseModel.getBatches()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptionsTest.java new file mode 100644 index 00000000000..f8f76b0e482 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsOptions model. */ +public class ListCollectionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsOptions() throws Throwable { + ListCollectionsOptions listCollectionsOptionsModel = + new ListCollectionsOptions.Builder().projectId("testString").build(); + assertEquals(listCollectionsOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionsOptionsError() throws Throwable { + new ListCollectionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponseTest.java new file mode 100644 index 00000000000..e6c84f0e7e2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsResponse model. */ +public class ListCollectionsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsResponse() throws Throwable { + ListCollectionsResponse listCollectionsResponseModel = new ListCollectionsResponse(); + assertNull(listCollectionsResponseModel.getCollections()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifierModelsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifierModelsOptionsTest.java new file mode 100644 index 00000000000..515df581d62 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifierModelsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDocumentClassifierModelsOptions model. */ +public class ListDocumentClassifierModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDocumentClassifierModelsOptions() throws Throwable { + ListDocumentClassifierModelsOptions listDocumentClassifierModelsOptionsModel = + new ListDocumentClassifierModelsOptions.Builder() + .projectId("testString") + .classifierId("testString") + .build(); + assertEquals(listDocumentClassifierModelsOptionsModel.projectId(), "testString"); + assertEquals(listDocumentClassifierModelsOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDocumentClassifierModelsOptionsError() throws Throwable { + new ListDocumentClassifierModelsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifiersOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifiersOptionsTest.java new file mode 100644 index 00000000000..bf12cebbbc1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentClassifiersOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDocumentClassifiersOptions model. */ +public class ListDocumentClassifiersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDocumentClassifiersOptions() throws Throwable { + ListDocumentClassifiersOptions listDocumentClassifiersOptionsModel = + new ListDocumentClassifiersOptions.Builder().projectId("testString").build(); + assertEquals(listDocumentClassifiersOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDocumentClassifiersOptionsError() throws Throwable { + new ListDocumentClassifiersOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentsOptionsTest.java new file mode 100644 index 00000000000..6470919a81f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentsOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2022, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDocumentsOptions model. */ +public class ListDocumentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDocumentsOptions() throws Throwable { + ListDocumentsOptions listDocumentsOptionsModel = + new ListDocumentsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .count(Long.valueOf("1000")) + .status("testString") + .hasNotices(true) + .isParent(true) + .parentDocumentId("testString") + .sha256("testString") + .build(); + assertEquals(listDocumentsOptionsModel.projectId(), "testString"); + assertEquals(listDocumentsOptionsModel.collectionId(), "testString"); + assertEquals(listDocumentsOptionsModel.count(), Long.valueOf("1000")); + assertEquals(listDocumentsOptionsModel.status(), "testString"); + assertEquals(listDocumentsOptionsModel.hasNotices(), Boolean.valueOf(true)); + assertEquals(listDocumentsOptionsModel.isParent(), Boolean.valueOf(true)); + assertEquals(listDocumentsOptionsModel.parentDocumentId(), "testString"); + assertEquals(listDocumentsOptionsModel.sha256(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDocumentsOptionsError() throws Throwable { + new ListDocumentsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentsResponseTest.java new file mode 100644 index 00000000000..579e4bd51bd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListDocumentsResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDocumentsResponse model. */ +public class ListDocumentsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDocumentsResponse() throws Throwable { + ListDocumentsResponse listDocumentsResponseModel = new ListDocumentsResponse(); + assertNull(listDocumentsResponseModel.getMatchingResults()); + assertNull(listDocumentsResponseModel.getDocuments()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptionsTest.java new file mode 100644 index 00000000000..1351210c48f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEnrichmentsOptions model. */ +public class ListEnrichmentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEnrichmentsOptions() throws Throwable { + ListEnrichmentsOptions listEnrichmentsOptionsModel = + new ListEnrichmentsOptions.Builder().projectId("testString").build(); + assertEquals(listEnrichmentsOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEnrichmentsOptionsError() throws Throwable { + new ListEnrichmentsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListExpansionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListExpansionsOptionsTest.java new file mode 100644 index 00000000000..4e9e783d495 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListExpansionsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListExpansionsOptions model. */ +public class ListExpansionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListExpansionsOptions() throws Throwable { + ListExpansionsOptions listExpansionsOptionsModel = + new ListExpansionsOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(listExpansionsOptionsModel.projectId(), "testString"); + assertEquals(listExpansionsOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExpansionsOptionsError() throws Throwable { + new ListExpansionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsOptionsTest.java new file mode 100644 index 00000000000..b9df54fab2d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListFieldsOptions model. */ +public class ListFieldsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListFieldsOptions() throws Throwable { + ListFieldsOptions listFieldsOptionsModel = + new ListFieldsOptions.Builder() + .projectId("testString") + .collectionIds(java.util.Arrays.asList("testString")) + .build(); + assertEquals(listFieldsOptionsModel.projectId(), "testString"); + assertEquals(listFieldsOptionsModel.collectionIds(), java.util.Arrays.asList("testString")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListFieldsOptionsError() throws Throwable { + new ListFieldsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsResponseTest.java new file mode 100644 index 00000000000..2a806ec1beb --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListFieldsResponse model. */ +public class ListFieldsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListFieldsResponse() throws Throwable { + ListFieldsResponse listFieldsResponseModel = new ListFieldsResponse(); + assertNull(listFieldsResponseModel.getFields()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsOptionsTest.java new file mode 100644 index 00000000000..8714d67e7e7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListProjectsOptions model. */ +public class ListProjectsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListProjectsOptions() throws Throwable { + ListProjectsOptions listProjectsOptionsModel = new ListProjectsOptions(); + assertNotNull(listProjectsOptionsModel); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsResponseTest.java new file mode 100644 index 00000000000..d4554029e5a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListProjectsResponse model. */ +public class ListProjectsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListProjectsResponse() throws Throwable { + ListProjectsResponse listProjectsResponseModel = new ListProjectsResponse(); + assertNull(listProjectsResponseModel.getProjects()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptionsTest.java new file mode 100644 index 00000000000..1c7369fe48a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListTrainingQueriesOptions model. */ +public class ListTrainingQueriesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListTrainingQueriesOptions() throws Throwable { + ListTrainingQueriesOptions listTrainingQueriesOptionsModel = + new ListTrainingQueriesOptions.Builder().projectId("testString").build(); + assertEquals(listTrainingQueriesOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingQueriesOptionsError() throws Throwable { + new ListTrainingQueriesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMacroAverageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMacroAverageTest.java new file mode 100644 index 00000000000..c4245aa7127 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMacroAverageTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ModelEvaluationMacroAverage model. */ +public class ModelEvaluationMacroAverageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testModelEvaluationMacroAverage() throws Throwable { + ModelEvaluationMacroAverage modelEvaluationMacroAverageModel = + new ModelEvaluationMacroAverage(); + assertNull(modelEvaluationMacroAverageModel.getPrecision()); + assertNull(modelEvaluationMacroAverageModel.getRecall()); + assertNull(modelEvaluationMacroAverageModel.getF1()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMicroAverageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMicroAverageTest.java new file mode 100644 index 00000000000..00fe7fcdf41 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ModelEvaluationMicroAverageTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ModelEvaluationMicroAverage model. */ +public class ModelEvaluationMicroAverageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testModelEvaluationMicroAverage() throws Throwable { + ModelEvaluationMicroAverage modelEvaluationMicroAverageModel = + new ModelEvaluationMicroAverage(); + assertNull(modelEvaluationMicroAverageModel.getPrecision()); + assertNull(modelEvaluationMicroAverageModel.getRecall()); + assertNull(modelEvaluationMicroAverageModel.getF1()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/NoticeTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/NoticeTest.java new file mode 100644 index 00000000000..056e74902cf --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/NoticeTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Notice model. */ +public class NoticeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNotice() throws Throwable { + Notice noticeModel = new Notice(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PerClassModelEvaluationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PerClassModelEvaluationTest.java new file mode 100644 index 00000000000..7cd66246eaa --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PerClassModelEvaluationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PerClassModelEvaluation model. */ +public class PerClassModelEvaluationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPerClassModelEvaluation() throws Throwable { + PerClassModelEvaluation perClassModelEvaluationModel = new PerClassModelEvaluation(); + assertNull(perClassModelEvaluationModel.getName()); + assertNull(perClassModelEvaluationModel.getPrecision()); + assertNull(perClassModelEvaluationModel.getRecall()); + assertNull(perClassModelEvaluationModel.getF1()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectDetailsTest.java new file mode 100644 index 00000000000..4e2f6e0a0fe --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectDetailsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProjectDetails model. */ +public class ProjectDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProjectDetails() throws Throwable { + ProjectDetails projectDetailsModel = new ProjectDetails(); + assertNull(projectDetailsModel.getName()); + assertNull(projectDetailsModel.getType()); + assertNull(projectDetailsModel.getDefaultQueryParameters()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatusTest.java new file mode 100644 index 00000000000..a5003e9472a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatusTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProjectListDetailsRelevancyTrainingStatus model. */ +public class ProjectListDetailsRelevancyTrainingStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProjectListDetailsRelevancyTrainingStatus() throws Throwable { + ProjectListDetailsRelevancyTrainingStatus projectListDetailsRelevancyTrainingStatusModel = + new ProjectListDetailsRelevancyTrainingStatus(); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getDataUpdated()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getTotalExamples()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isSufficientLabelDiversity()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isProcessing()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isMinimumExamplesAdded()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getSuccessfullyTrained()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isAvailable()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getNotices()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isMinimumQueriesAdded()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsTest.java new file mode 100644 index 00000000000..aed1e77eb0e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProjectListDetails model. */ +public class ProjectListDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProjectListDetails() throws Throwable { + ProjectListDetails projectListDetailsModel = new ProjectListDetails(); + assertNull(projectListDetailsModel.getName()); + assertNull(projectListDetailsModel.getType()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PullBatchesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PullBatchesOptionsTest.java new file mode 100644 index 00000000000..6f434b72ac8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PullBatchesOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PullBatchesOptions model. */ +public class PullBatchesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPullBatchesOptions() throws Throwable { + PullBatchesOptions pullBatchesOptionsModel = + new PullBatchesOptions.Builder() + .projectId("testString") + .collectionId("testString") + .batchId("testString") + .build(); + assertEquals(pullBatchesOptionsModel.projectId(), "testString"); + assertEquals(pullBatchesOptionsModel.collectionId(), "testString"); + assertEquals(pullBatchesOptionsModel.batchId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPullBatchesOptionsError() throws Throwable { + new PullBatchesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PullBatchesResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PullBatchesResponseTest.java new file mode 100644 index 00000000000..e219749c1ea --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PullBatchesResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PullBatchesResponse model. */ +public class PullBatchesResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPullBatchesResponse() throws Throwable { + PullBatchesResponse pullBatchesResponseModel = new PullBatchesResponse(); + assertNull(pullBatchesResponseModel.getFile()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PushBatchesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PushBatchesOptionsTest.java new file mode 100644 index 00000000000..3926863a99f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/PushBatchesOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the PushBatchesOptions model. */ +public class PushBatchesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPushBatchesOptions() throws Throwable { + PushBatchesOptions pushBatchesOptionsModel = + new PushBatchesOptions.Builder() + .projectId("testString") + .collectionId("testString") + .batchId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .build(); + assertEquals(pushBatchesOptionsModel.projectId(), "testString"); + assertEquals(pushBatchesOptionsModel.collectionId(), "testString"); + assertEquals(pushBatchesOptionsModel.batchId(), "testString"); + assertEquals( + IOUtils.toString(pushBatchesOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(pushBatchesOptionsModel.filename(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPushBatchesOptionsError() throws Throwable { + new PushBatchesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryCalculationAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryCalculationAggregationTest.java new file mode 100644 index 00000000000..8187bebeede --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryCalculationAggregationTest.java @@ -0,0 +1,39 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryCalculationAggregation model. */ +public class QueryAggregationQueryCalculationAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryCalculationAggregation() throws Throwable { + QueryAggregationQueryCalculationAggregation queryAggregationQueryCalculationAggregationModel = + new QueryAggregationQueryCalculationAggregation(); + assertNull(queryAggregationQueryCalculationAggregationModel.getType()); + assertNull(queryAggregationQueryCalculationAggregationModel.getField()); + assertNull(queryAggregationQueryCalculationAggregationModel.getValue()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryFilterAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryFilterAggregationTest.java new file mode 100644 index 00000000000..87545f9549d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryFilterAggregationTest.java @@ -0,0 +1,40 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryFilterAggregation model. */ +public class QueryAggregationQueryFilterAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryFilterAggregation() throws Throwable { + QueryAggregationQueryFilterAggregation queryAggregationQueryFilterAggregationModel = + new QueryAggregationQueryFilterAggregation(); + assertNull(queryAggregationQueryFilterAggregationModel.getType()); + assertNull(queryAggregationQueryFilterAggregationModel.getMatch()); + assertNull(queryAggregationQueryFilterAggregationModel.getMatchingResults()); + assertNull(queryAggregationQueryFilterAggregationModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryGroupByAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryGroupByAggregationTest.java new file mode 100644 index 00000000000..cfb0241496f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryGroupByAggregationTest.java @@ -0,0 +1,38 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryGroupByAggregation model. */ +public class QueryAggregationQueryGroupByAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryGroupByAggregation() throws Throwable { + QueryAggregationQueryGroupByAggregation queryAggregationQueryGroupByAggregationModel = + new QueryAggregationQueryGroupByAggregation(); + assertNull(queryAggregationQueryGroupByAggregationModel.getType()); + assertNull(queryAggregationQueryGroupByAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryHistogramAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryHistogramAggregationTest.java new file mode 100644 index 00000000000..3539f1e44c9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryHistogramAggregationTest.java @@ -0,0 +1,41 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryHistogramAggregation model. */ +public class QueryAggregationQueryHistogramAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryHistogramAggregation() throws Throwable { + QueryAggregationQueryHistogramAggregation queryAggregationQueryHistogramAggregationModel = + new QueryAggregationQueryHistogramAggregation(); + assertNull(queryAggregationQueryHistogramAggregationModel.getType()); + assertNull(queryAggregationQueryHistogramAggregationModel.getField()); + assertNull(queryAggregationQueryHistogramAggregationModel.getInterval()); + assertNull(queryAggregationQueryHistogramAggregationModel.getName()); + assertNull(queryAggregationQueryHistogramAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryNestedAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryNestedAggregationTest.java new file mode 100644 index 00000000000..c5c141a6e42 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryNestedAggregationTest.java @@ -0,0 +1,40 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryNestedAggregation model. */ +public class QueryAggregationQueryNestedAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryNestedAggregation() throws Throwable { + QueryAggregationQueryNestedAggregation queryAggregationQueryNestedAggregationModel = + new QueryAggregationQueryNestedAggregation(); + assertNull(queryAggregationQueryNestedAggregationModel.getType()); + assertNull(queryAggregationQueryNestedAggregationModel.getPath()); + assertNull(queryAggregationQueryNestedAggregationModel.getMatchingResults()); + assertNull(queryAggregationQueryNestedAggregationModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryPairAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryPairAggregationTest.java new file mode 100644 index 00000000000..1e4532094ab --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryPairAggregationTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryPairAggregation model. */ +public class QueryAggregationQueryPairAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryPairAggregation() throws Throwable { + QueryAggregationQueryPairAggregation queryAggregationQueryPairAggregationModel = + new QueryAggregationQueryPairAggregation(); + assertNull(queryAggregationQueryPairAggregationModel.getType()); + assertNull(queryAggregationQueryPairAggregationModel.getFirst()); + assertNull(queryAggregationQueryPairAggregationModel.getSecond()); + assertNull(queryAggregationQueryPairAggregationModel.isShowEstimatedMatchingResults()); + assertNull(queryAggregationQueryPairAggregationModel.isShowTotalMatchingDocuments()); + assertNull(queryAggregationQueryPairAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTermAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTermAggregationTest.java new file mode 100644 index 00000000000..d31bad0ea2a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTermAggregationTest.java @@ -0,0 +1,41 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryTermAggregation model. */ +public class QueryAggregationQueryTermAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryTermAggregation() throws Throwable { + QueryAggregationQueryTermAggregation queryAggregationQueryTermAggregationModel = + new QueryAggregationQueryTermAggregation(); + assertNull(queryAggregationQueryTermAggregationModel.getType()); + assertNull(queryAggregationQueryTermAggregationModel.getField()); + assertNull(queryAggregationQueryTermAggregationModel.getCount()); + assertNull(queryAggregationQueryTermAggregationModel.getName()); + assertNull(queryAggregationQueryTermAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTimesliceAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTimesliceAggregationTest.java new file mode 100644 index 00000000000..37a38cfe512 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTimesliceAggregationTest.java @@ -0,0 +1,41 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryTimesliceAggregation model. */ +public class QueryAggregationQueryTimesliceAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryTimesliceAggregation() throws Throwable { + QueryAggregationQueryTimesliceAggregation queryAggregationQueryTimesliceAggregationModel = + new QueryAggregationQueryTimesliceAggregation(); + assertNull(queryAggregationQueryTimesliceAggregationModel.getType()); + assertNull(queryAggregationQueryTimesliceAggregationModel.getField()); + assertNull(queryAggregationQueryTimesliceAggregationModel.getInterval()); + assertNull(queryAggregationQueryTimesliceAggregationModel.getName()); + assertNull(queryAggregationQueryTimesliceAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopHitsAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopHitsAggregationTest.java new file mode 100644 index 00000000000..4774366d6d1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopHitsAggregationTest.java @@ -0,0 +1,40 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryTopHitsAggregation model. */ +public class QueryAggregationQueryTopHitsAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryTopHitsAggregation() throws Throwable { + QueryAggregationQueryTopHitsAggregation queryAggregationQueryTopHitsAggregationModel = + new QueryAggregationQueryTopHitsAggregation(); + assertNull(queryAggregationQueryTopHitsAggregationModel.getType()); + assertNull(queryAggregationQueryTopHitsAggregationModel.getSize()); + assertNull(queryAggregationQueryTopHitsAggregationModel.getName()); + assertNull(queryAggregationQueryTopHitsAggregationModel.getHits()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopicAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopicAggregationTest.java new file mode 100644 index 00000000000..bca90b751d8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTopicAggregationTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryTopicAggregation model. */ +public class QueryAggregationQueryTopicAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryTopicAggregation() throws Throwable { + QueryAggregationQueryTopicAggregation queryAggregationQueryTopicAggregationModel = + new QueryAggregationQueryTopicAggregation(); + assertNull(queryAggregationQueryTopicAggregationModel.getType()); + assertNull(queryAggregationQueryTopicAggregationModel.getFacet()); + assertNull(queryAggregationQueryTopicAggregationModel.getTimeSegments()); + assertNull(queryAggregationQueryTopicAggregationModel.isShowEstimatedMatchingResults()); + assertNull(queryAggregationQueryTopicAggregationModel.isShowTotalMatchingDocuments()); + assertNull(queryAggregationQueryTopicAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTrendAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTrendAggregationTest.java new file mode 100644 index 00000000000..49ef539c6e5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationQueryTrendAggregationTest.java @@ -0,0 +1,42 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregationQueryTrendAggregation model. */ +public class QueryAggregationQueryTrendAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryAggregationQueryTrendAggregation() throws Throwable { + QueryAggregationQueryTrendAggregation queryAggregationQueryTrendAggregationModel = + new QueryAggregationQueryTrendAggregation(); + assertNull(queryAggregationQueryTrendAggregationModel.getType()); + assertNull(queryAggregationQueryTrendAggregationModel.getFacet()); + assertNull(queryAggregationQueryTrendAggregationModel.getTimeSegments()); + assertNull(queryAggregationQueryTrendAggregationModel.isShowEstimatedMatchingResults()); + assertNull(queryAggregationQueryTrendAggregationModel.isShowTotalMatchingDocuments()); + assertNull(queryAggregationQueryTrendAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationTest.java new file mode 100644 index 00000000000..f80d8082bd6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregation model. */ +public class QueryAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testQueryAggregation() throws Throwable { + QueryAggregation queryAggregationModel = new QueryAggregation(); + assertNotNull(queryAggregationModel); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryCollectionNoticesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryCollectionNoticesOptionsTest.java new file mode 100644 index 00000000000..684595c32ab --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryCollectionNoticesOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryCollectionNoticesOptions model. */ +public class QueryCollectionNoticesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryCollectionNoticesOptions() throws Throwable { + QueryCollectionNoticesOptions queryCollectionNoticesOptionsModel = + new QueryCollectionNoticesOptions.Builder() + .projectId("testString") + .collectionId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .count(Long.valueOf("10")) + .offset(Long.valueOf("26")) + .build(); + assertEquals(queryCollectionNoticesOptionsModel.projectId(), "testString"); + assertEquals(queryCollectionNoticesOptionsModel.collectionId(), "testString"); + assertEquals(queryCollectionNoticesOptionsModel.filter(), "testString"); + assertEquals(queryCollectionNoticesOptionsModel.query(), "testString"); + assertEquals(queryCollectionNoticesOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryCollectionNoticesOptionsModel.count(), Long.valueOf("10")); + assertEquals(queryCollectionNoticesOptionsModel.offset(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryCollectionNoticesOptionsError() throws Throwable { + new QueryCollectionNoticesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResultTest.java new file mode 100644 index 00000000000..bffa73c93c5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResultTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryGroupByAggregationResult model. */ +public class QueryGroupByAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryGroupByAggregationResult() throws Throwable { + QueryGroupByAggregationResult queryGroupByAggregationResultModel = + new QueryGroupByAggregationResult(); + assertNull(queryGroupByAggregationResultModel.getKey()); + assertNull(queryGroupByAggregationResultModel.getMatchingResults()); + assertNull(queryGroupByAggregationResultModel.getRelevancy()); + assertNull(queryGroupByAggregationResultModel.getTotalMatchingDocuments()); + assertNull(queryGroupByAggregationResultModel.getEstimatedMatchingResults()); + assertNull(queryGroupByAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResultTest.java new file mode 100644 index 00000000000..3969522405b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryHistogramAggregationResult model. */ +public class QueryHistogramAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryHistogramAggregationResult() throws Throwable { + QueryHistogramAggregationResult queryHistogramAggregationResultModel = + new QueryHistogramAggregationResult(); + assertNull(queryHistogramAggregationResultModel.getKey()); + assertNull(queryHistogramAggregationResultModel.getMatchingResults()); + assertNull(queryHistogramAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargePassagesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargePassagesTest.java new file mode 100644 index 00000000000..0f0ba4b037a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargePassagesTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargePassages model. */ +public class QueryLargePassagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargePassages() throws Throwable { + QueryLargePassages queryLargePassagesModel = + new QueryLargePassages.Builder() + .enabled(true) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .count(Long.valueOf("400")) + .characters(Long.valueOf("50")) + .findAnswers(false) + .maxAnswersPerPassage(Long.valueOf("1")) + .build(); + assertEquals(queryLargePassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.maxPerDocument(), Long.valueOf("26")); + assertEquals(queryLargePassagesModel.fields(), java.util.Arrays.asList("testString")); + assertEquals(queryLargePassagesModel.count(), Long.valueOf("400")); + assertEquals(queryLargePassagesModel.characters(), Long.valueOf("50")); + assertEquals(queryLargePassagesModel.findAnswers(), Boolean.valueOf(false)); + assertEquals(queryLargePassagesModel.maxAnswersPerPassage(), Long.valueOf("1")); + + String json = TestUtilities.serialize(queryLargePassagesModel); + + QueryLargePassages queryLargePassagesModelNew = + TestUtilities.deserialize(json, QueryLargePassages.class); + assertTrue(queryLargePassagesModelNew instanceof QueryLargePassages); + assertEquals(queryLargePassagesModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModelNew.perDocument(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModelNew.maxPerDocument(), Long.valueOf("26")); + assertEquals(queryLargePassagesModelNew.count(), Long.valueOf("400")); + assertEquals(queryLargePassagesModelNew.characters(), Long.valueOf("50")); + assertEquals(queryLargePassagesModelNew.findAnswers(), Boolean.valueOf(false)); + assertEquals(queryLargePassagesModelNew.maxAnswersPerPassage(), Long.valueOf("1")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSimilarTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSimilarTest.java new file mode 100644 index 00000000000..1042caa59b2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSimilarTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargeSimilar model. */ +public class QueryLargeSimilarTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargeSimilar() throws Throwable { + QueryLargeSimilar queryLargeSimilarModel = + new QueryLargeSimilar.Builder() + .enabled(false) + .documentIds(java.util.Arrays.asList("testString")) + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(queryLargeSimilarModel.enabled(), Boolean.valueOf(false)); + assertEquals(queryLargeSimilarModel.documentIds(), java.util.Arrays.asList("testString")); + assertEquals(queryLargeSimilarModel.fields(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(queryLargeSimilarModel); + + QueryLargeSimilar queryLargeSimilarModelNew = + TestUtilities.deserialize(json, QueryLargeSimilar.class); + assertTrue(queryLargeSimilarModelNew instanceof QueryLargeSimilar); + assertEquals(queryLargeSimilarModelNew.enabled(), Boolean.valueOf(false)); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinementsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinementsTest.java new file mode 100644 index 00000000000..09ebb92dd85 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinementsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargeSuggestedRefinements model. */ +public class QueryLargeSuggestedRefinementsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargeSuggestedRefinements() throws Throwable { + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModel = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("1")).build(); + assertEquals(queryLargeSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeSuggestedRefinementsModel.count(), Long.valueOf("1")); + + String json = TestUtilities.serialize(queryLargeSuggestedRefinementsModel); + + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModelNew = + TestUtilities.deserialize(json, QueryLargeSuggestedRefinements.class); + assertTrue(queryLargeSuggestedRefinementsModelNew instanceof QueryLargeSuggestedRefinements); + assertEquals(queryLargeSuggestedRefinementsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeSuggestedRefinementsModelNew.count(), Long.valueOf("1")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResultsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResultsTest.java new file mode 100644 index 00000000000..37f037d84ec --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResultsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargeTableResults model. */ +public class QueryLargeTableResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargeTableResults() throws Throwable { + QueryLargeTableResults queryLargeTableResultsModel = + new QueryLargeTableResults.Builder().enabled(true).count(Long.valueOf("26")).build(); + assertEquals(queryLargeTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeTableResultsModel.count(), Long.valueOf("26")); + + String json = TestUtilities.serialize(queryLargeTableResultsModel); + + QueryLargeTableResults queryLargeTableResultsModelNew = + TestUtilities.deserialize(json, QueryLargeTableResults.class); + assertTrue(queryLargeTableResultsModelNew instanceof QueryLargeTableResults); + assertEquals(queryLargeTableResultsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeTableResultsModelNew.count(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptionsTest.java new file mode 100644 index 00000000000..829c88ce0f3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesOptions model. */ +public class QueryNoticesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesOptions() throws Throwable { + QueryNoticesOptions queryNoticesOptionsModel = + new QueryNoticesOptions.Builder() + .projectId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .count(Long.valueOf("10")) + .offset(Long.valueOf("26")) + .build(); + assertEquals(queryNoticesOptionsModel.projectId(), "testString"); + assertEquals(queryNoticesOptionsModel.filter(), "testString"); + assertEquals(queryNoticesOptionsModel.query(), "testString"); + assertEquals(queryNoticesOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryNoticesOptionsModel.count(), Long.valueOf("10")); + assertEquals(queryNoticesOptionsModel.offset(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoticesOptionsError() throws Throwable { + new QueryNoticesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponseTest.java new file mode 100644 index 00000000000..62a8db72078 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesResponse model. */ +public class QueryNoticesResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesResponse() throws Throwable { + QueryNoticesResponse queryNoticesResponseModel = new QueryNoticesResponse(); + assertNull(queryNoticesResponseModel.getMatchingResults()); + assertNull(queryNoticesResponseModel.getNotices()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryOptionsTest.java new file mode 100644 index 00000000000..ab05a516f70 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryOptionsTest.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryOptions model. */ +public class QueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryOptions() throws Throwable { + QueryLargeTableResults queryLargeTableResultsModel = + new QueryLargeTableResults.Builder().enabled(true).count(Long.valueOf("26")).build(); + assertEquals(queryLargeTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeTableResultsModel.count(), Long.valueOf("26")); + + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModel = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("1")).build(); + assertEquals(queryLargeSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeSuggestedRefinementsModel.count(), Long.valueOf("1")); + + QueryLargePassages queryLargePassagesModel = + new QueryLargePassages.Builder() + .enabled(true) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .fields(java.util.Arrays.asList("testString")) + .count(Long.valueOf("400")) + .characters(Long.valueOf("50")) + .findAnswers(false) + .maxAnswersPerPassage(Long.valueOf("1")) + .build(); + assertEquals(queryLargePassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.maxPerDocument(), Long.valueOf("26")); + assertEquals(queryLargePassagesModel.fields(), java.util.Arrays.asList("testString")); + assertEquals(queryLargePassagesModel.count(), Long.valueOf("400")); + assertEquals(queryLargePassagesModel.characters(), Long.valueOf("50")); + assertEquals(queryLargePassagesModel.findAnswers(), Boolean.valueOf(false)); + assertEquals(queryLargePassagesModel.maxAnswersPerPassage(), Long.valueOf("1")); + + QueryLargeSimilar queryLargeSimilarModel = + new QueryLargeSimilar.Builder() + .enabled(false) + .documentIds(java.util.Arrays.asList("testString")) + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(queryLargeSimilarModel.enabled(), Boolean.valueOf(false)); + assertEquals(queryLargeSimilarModel.documentIds(), java.util.Arrays.asList("testString")); + assertEquals(queryLargeSimilarModel.fields(), java.util.Arrays.asList("testString")); + + QueryOptions queryOptionsModel = + new QueryOptions.Builder() + .projectId("testString") + .collectionIds(java.util.Arrays.asList("testString")) + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(java.util.Arrays.asList("testString")) + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .spellingSuggestions(true) + .tableResults(queryLargeTableResultsModel) + .suggestedRefinements(queryLargeSuggestedRefinementsModel) + .passages(queryLargePassagesModel) + .similar(queryLargeSimilarModel) + .build(); + assertEquals(queryOptionsModel.projectId(), "testString"); + assertEquals(queryOptionsModel.collectionIds(), java.util.Arrays.asList("testString")); + assertEquals(queryOptionsModel.filter(), "testString"); + assertEquals(queryOptionsModel.query(), "testString"); + assertEquals(queryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryOptionsModel.aggregation(), "testString"); + assertEquals(queryOptionsModel.count(), Long.valueOf("26")); + assertEquals(queryOptionsModel.xReturn(), java.util.Arrays.asList("testString")); + assertEquals(queryOptionsModel.offset(), Long.valueOf("26")); + assertEquals(queryOptionsModel.sort(), "testString"); + assertEquals(queryOptionsModel.highlight(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.tableResults(), queryLargeTableResultsModel); + assertEquals(queryOptionsModel.suggestedRefinements(), queryLargeSuggestedRefinementsModel); + assertEquals(queryOptionsModel.passages(), queryLargePassagesModel); + assertEquals(queryOptionsModel.similar(), queryLargeSimilarModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryOptionsError() throws Throwable { + new QueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryPairAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryPairAggregationResultTest.java new file mode 100644 index 00000000000..d192978f120 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryPairAggregationResultTest.java @@ -0,0 +1,36 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryPairAggregationResult model. */ +public class QueryPairAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryPairAggregationResult() throws Throwable { + QueryPairAggregationResult queryPairAggregationResultModel = new QueryPairAggregationResult(); + assertNull(queryPairAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponsePassageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponsePassageTest.java new file mode 100644 index 00000000000..42a130237b0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponsePassageTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResponsePassage model. */ +public class QueryResponsePassageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResponsePassage() throws Throwable { + QueryResponsePassage queryResponsePassageModel = new QueryResponsePassage(); + assertNull(queryResponsePassageModel.getPassageText()); + assertNull(queryResponsePassageModel.getPassageScore()); + assertNull(queryResponsePassageModel.getDocumentId()); + assertNull(queryResponsePassageModel.getCollectionId()); + assertNull(queryResponsePassageModel.getStartOffset()); + assertNull(queryResponsePassageModel.getEndOffset()); + assertNull(queryResponsePassageModel.getField()); + assertNull(queryResponsePassageModel.getAnswers()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponseTest.java new file mode 100644 index 00000000000..2e14fce1fe2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponseTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResponse model. */ +public class QueryResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResponse() throws Throwable { + QueryResponse queryResponseModel = new QueryResponse(); + assertNull(queryResponseModel.getMatchingResults()); + assertNull(queryResponseModel.getResults()); + assertNull(queryResponseModel.getAggregations()); + assertNull(queryResponseModel.getRetrievalDetails()); + assertNull(queryResponseModel.getSuggestedQuery()); + assertNull(queryResponseModel.getSuggestedRefinements()); + assertNull(queryResponseModel.getTableResults()); + assertNull(queryResponseModel.getPassages()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultMetadataTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultMetadataTest.java new file mode 100644 index 00000000000..801c9922f5d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultMetadataTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResultMetadata model. */ +public class QueryResultMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResultMetadata() throws Throwable { + QueryResultMetadata queryResultMetadataModel = new QueryResultMetadata(); + assertNull(queryResultMetadataModel.getDocumentRetrievalSource()); + assertNull(queryResultMetadataModel.getCollectionId()); + assertNull(queryResultMetadataModel.getConfidence()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultPassageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultPassageTest.java new file mode 100644 index 00000000000..642055a0baf --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultPassageTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResultPassage model. */ +public class QueryResultPassageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResultPassage() throws Throwable { + QueryResultPassage queryResultPassageModel = new QueryResultPassage(); + assertNull(queryResultPassageModel.getPassageText()); + assertNull(queryResultPassageModel.getStartOffset()); + assertNull(queryResultPassageModel.getEndOffset()); + assertNull(queryResultPassageModel.getField()); + assertNull(queryResultPassageModel.getAnswers()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultTest.java new file mode 100644 index 00000000000..610d64845ad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResult model. */ +public class QueryResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResult() throws Throwable { + QueryResult queryResultModel = new QueryResult(); + assertNull(queryResultModel.getDocumentId()); + assertNull(queryResultModel.getMetadata()); + assertNull(queryResultModel.getResultMetadata()); + assertNull(queryResultModel.getDocumentPassages()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinementTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinementTest.java new file mode 100644 index 00000000000..77f813593b2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinementTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QuerySuggestedRefinement model. */ +public class QuerySuggestedRefinementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQuerySuggestedRefinement() throws Throwable { + QuerySuggestedRefinement querySuggestedRefinementModel = new QuerySuggestedRefinement(); + assertNull(querySuggestedRefinementModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTableResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTableResultTest.java new file mode 100644 index 00000000000..ffa96e7bf6a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTableResultTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTableResult model. */ +public class QueryTableResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTableResult() throws Throwable { + QueryTableResult queryTableResultModel = new QueryTableResult(); + assertNull(queryTableResultModel.getTableId()); + assertNull(queryTableResultModel.getSourceDocumentId()); + assertNull(queryTableResultModel.getCollectionId()); + assertNull(queryTableResultModel.getTableHtml()); + assertNull(queryTableResultModel.getTableHtmlOffset()); + assertNull(queryTableResultModel.getTable()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResultTest.java new file mode 100644 index 00000000000..e2558ec4138 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResultTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTermAggregationResult model. */ +public class QueryTermAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTermAggregationResult() throws Throwable { + QueryTermAggregationResult queryTermAggregationResultModel = new QueryTermAggregationResult(); + assertNull(queryTermAggregationResultModel.getKey()); + assertNull(queryTermAggregationResultModel.getMatchingResults()); + assertNull(queryTermAggregationResultModel.getRelevancy()); + assertNull(queryTermAggregationResultModel.getTotalMatchingDocuments()); + assertNull(queryTermAggregationResultModel.getEstimatedMatchingResults()); + assertNull(queryTermAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResultTest.java new file mode 100644 index 00000000000..62489288624 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTimesliceAggregationResult model. */ +public class QueryTimesliceAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTimesliceAggregationResult() throws Throwable { + QueryTimesliceAggregationResult queryTimesliceAggregationResultModel = + new QueryTimesliceAggregationResult(); + assertNull(queryTimesliceAggregationResultModel.getKeyAsString()); + assertNull(queryTimesliceAggregationResultModel.getKey()); + assertNull(queryTimesliceAggregationResultModel.getMatchingResults()); + assertNull(queryTimesliceAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResultTest.java new file mode 100644 index 00000000000..a39a8e0de41 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTopHitsAggregationResult model. */ +public class QueryTopHitsAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTopHitsAggregationResult() throws Throwable { + QueryTopHitsAggregationResult queryTopHitsAggregationResultModel = + new QueryTopHitsAggregationResult(); + assertNull(queryTopHitsAggregationResultModel.getMatchingResults()); + assertNull(queryTopHitsAggregationResultModel.getHits()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopicAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopicAggregationResultTest.java new file mode 100644 index 00000000000..fabf1fae235 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopicAggregationResultTest.java @@ -0,0 +1,37 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTopicAggregationResult model. */ +public class QueryTopicAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTopicAggregationResult() throws Throwable { + QueryTopicAggregationResult queryTopicAggregationResultModel = + new QueryTopicAggregationResult(); + assertNull(queryTopicAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTrendAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTrendAggregationResultTest.java new file mode 100644 index 00000000000..a60f42e5538 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTrendAggregationResultTest.java @@ -0,0 +1,37 @@ +/* + * (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 + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTrendAggregationResult model. */ +public class QueryTrendAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTrendAggregationResult() throws Throwable { + QueryTrendAggregationResult queryTrendAggregationResultModel = + new QueryTrendAggregationResult(); + assertNull(queryTrendAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ResultPassageAnswerTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ResultPassageAnswerTest.java new file mode 100644 index 00000000000..6a8e3321398 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ResultPassageAnswerTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResultPassageAnswer model. */ +public class ResultPassageAnswerTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResultPassageAnswer() throws Throwable { + ResultPassageAnswer resultPassageAnswerModel = new ResultPassageAnswer(); + assertNull(resultPassageAnswerModel.getAnswerText()); + assertNull(resultPassageAnswerModel.getStartOffset()); + assertNull(resultPassageAnswerModel.getEndOffset()); + assertNull(resultPassageAnswerModel.getConfidence()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/RetrievalDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/RetrievalDetailsTest.java new file mode 100644 index 00000000000..645bb7f0759 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/RetrievalDetailsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RetrievalDetails model. */ +public class RetrievalDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRetrievalDetails() throws Throwable { + RetrievalDetails retrievalDetailsModel = new RetrievalDetails(); + assertNull(retrievalDetailsModel.getDocumentRetrievalStrategy()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/StopWordListTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/StopWordListTest.java new file mode 100644 index 00000000000..968cdb2d717 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/StopWordListTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StopWordList model. */ +public class StopWordListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStopWordList() throws Throwable { + StopWordList stopWordListModel = + new StopWordList.Builder().stopwords(java.util.Arrays.asList("testString")).build(); + assertEquals(stopWordListModel.stopwords(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(stopWordListModel); + + StopWordList stopWordListModelNew = TestUtilities.deserialize(json, StopWordList.class); + assertTrue(stopWordListModelNew instanceof StopWordList); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testStopWordListError() throws Throwable { + new StopWordList.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableBodyCellsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableBodyCellsTest.java new file mode 100644 index 00000000000..d565cb0df2c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableBodyCellsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableBodyCells model. */ +public class TableBodyCellsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableBodyCells() throws Throwable { + TableBodyCells tableBodyCellsModel = new TableBodyCells(); + assertNull(tableBodyCellsModel.getCellId()); + assertNull(tableBodyCellsModel.getLocation()); + assertNull(tableBodyCellsModel.getText()); + assertNull(tableBodyCellsModel.getRowIndexBegin()); + assertNull(tableBodyCellsModel.getRowIndexEnd()); + assertNull(tableBodyCellsModel.getColumnIndexBegin()); + assertNull(tableBodyCellsModel.getColumnIndexEnd()); + assertNull(tableBodyCellsModel.getRowHeaderIds()); + assertNull(tableBodyCellsModel.getRowHeaderTexts()); + assertNull(tableBodyCellsModel.getRowHeaderTextsNormalized()); + assertNull(tableBodyCellsModel.getColumnHeaderIds()); + assertNull(tableBodyCellsModel.getColumnHeaderTexts()); + assertNull(tableBodyCellsModel.getColumnHeaderTextsNormalized()); + assertNull(tableBodyCellsModel.getAttributes()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellKeyTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellKeyTest.java new file mode 100644 index 00000000000..00bda19b030 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellKeyTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableCellKey model. */ +public class TableCellKeyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableCellKey() throws Throwable { + TableCellKey tableCellKeyModel = new TableCellKey(); + assertNull(tableCellKeyModel.getCellId()); + assertNull(tableCellKeyModel.getLocation()); + assertNull(tableCellKeyModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellValuesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellValuesTest.java new file mode 100644 index 00000000000..d2d50e39940 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellValuesTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableCellValues model. */ +public class TableCellValuesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableCellValues() throws Throwable { + TableCellValues tableCellValuesModel = new TableCellValues(); + assertNull(tableCellValuesModel.getCellId()); + assertNull(tableCellValuesModel.getLocation()); + assertNull(tableCellValuesModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIdsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIdsTest.java new file mode 100644 index 00000000000..9a8270c209d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIdsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaderIds model. */ +public class TableColumnHeaderIdsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaderIds() throws Throwable { + TableColumnHeaderIds tableColumnHeaderIdsModel = new TableColumnHeaderIds(); + assertNull(tableColumnHeaderIdsModel.getId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalizedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalizedTest.java new file mode 100644 index 00000000000..f9cf3b1b57f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalizedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaderTextsNormalized model. */ +public class TableColumnHeaderTextsNormalizedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaderTextsNormalized() throws Throwable { + TableColumnHeaderTextsNormalized tableColumnHeaderTextsNormalizedModel = + new TableColumnHeaderTextsNormalized(); + assertNull(tableColumnHeaderTextsNormalizedModel.getTextNormalized()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsTest.java new file mode 100644 index 00000000000..4825af8ea78 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaderTexts model. */ +public class TableColumnHeaderTextsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaderTexts() throws Throwable { + TableColumnHeaderTexts tableColumnHeaderTextsModel = new TableColumnHeaderTexts(); + assertNull(tableColumnHeaderTextsModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeadersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeadersTest.java new file mode 100644 index 00000000000..e6c27cd0586 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeadersTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaders model. */ +public class TableColumnHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaders() throws Throwable { + TableColumnHeaders tableColumnHeadersModel = new TableColumnHeaders(); + assertNull(tableColumnHeadersModel.getCellId()); + assertNull(tableColumnHeadersModel.getLocation()); + assertNull(tableColumnHeadersModel.getText()); + assertNull(tableColumnHeadersModel.getTextNormalized()); + assertNull(tableColumnHeadersModel.getRowIndexBegin()); + assertNull(tableColumnHeadersModel.getRowIndexEnd()); + assertNull(tableColumnHeadersModel.getColumnIndexBegin()); + assertNull(tableColumnHeadersModel.getColumnIndexEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableElementLocationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableElementLocationTest.java new file mode 100644 index 00000000000..1281314f7c0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableElementLocationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableElementLocation model. */ +public class TableElementLocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableElementLocation() throws Throwable { + TableElementLocation tableElementLocationModel = new TableElementLocation(); + assertNull(tableElementLocationModel.getBegin()); + assertNull(tableElementLocationModel.getEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableHeadersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableHeadersTest.java new file mode 100644 index 00000000000..421caf3cf92 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableHeadersTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableHeaders model. */ +public class TableHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableHeaders() throws Throwable { + TableHeaders tableHeadersModel = new TableHeaders(); + assertNull(tableHeadersModel.getCellId()); + assertNull(tableHeadersModel.getLocation()); + assertNull(tableHeadersModel.getText()); + assertNull(tableHeadersModel.getRowIndexBegin()); + assertNull(tableHeadersModel.getRowIndexEnd()); + assertNull(tableHeadersModel.getColumnIndexBegin()); + assertNull(tableHeadersModel.getColumnIndexEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairsTest.java new file mode 100644 index 00000000000..f135fd6eee5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableKeyValuePairs model. */ +public class TableKeyValuePairsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableKeyValuePairs() throws Throwable { + TableKeyValuePairs tableKeyValuePairsModel = new TableKeyValuePairs(); + assertNull(tableKeyValuePairsModel.getKey()); + assertNull(tableKeyValuePairsModel.getValue()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableResultTableTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableResultTableTest.java new file mode 100644 index 00000000000..92fafcb72b3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableResultTableTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableResultTable model. */ +public class TableResultTableTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableResultTable() throws Throwable { + TableResultTable tableResultTableModel = new TableResultTable(); + assertNull(tableResultTableModel.getLocation()); + assertNull(tableResultTableModel.getText()); + assertNull(tableResultTableModel.getSectionTitle()); + assertNull(tableResultTableModel.getTitle()); + assertNull(tableResultTableModel.getTableHeaders()); + assertNull(tableResultTableModel.getRowHeaders()); + assertNull(tableResultTableModel.getColumnHeaders()); + assertNull(tableResultTableModel.getKeyValuePairs()); + assertNull(tableResultTableModel.getBodyCells()); + assertNull(tableResultTableModel.getContexts()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIdsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIdsTest.java new file mode 100644 index 00000000000..26f26df9808 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIdsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaderIds model. */ +public class TableRowHeaderIdsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaderIds() throws Throwable { + TableRowHeaderIds tableRowHeaderIdsModel = new TableRowHeaderIds(); + assertNull(tableRowHeaderIdsModel.getId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalizedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalizedTest.java new file mode 100644 index 00000000000..b2b88c2cc29 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalizedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaderTextsNormalized model. */ +public class TableRowHeaderTextsNormalizedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaderTextsNormalized() throws Throwable { + TableRowHeaderTextsNormalized tableRowHeaderTextsNormalizedModel = + new TableRowHeaderTextsNormalized(); + assertNull(tableRowHeaderTextsNormalizedModel.getTextNormalized()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsTest.java new file mode 100644 index 00000000000..bef2e76bdf4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaderTexts model. */ +public class TableRowHeaderTextsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaderTexts() throws Throwable { + TableRowHeaderTexts tableRowHeaderTextsModel = new TableRowHeaderTexts(); + assertNull(tableRowHeaderTextsModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeadersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeadersTest.java new file mode 100644 index 00000000000..968715bac59 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeadersTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaders model. */ +public class TableRowHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaders() throws Throwable { + TableRowHeaders tableRowHeadersModel = new TableRowHeaders(); + assertNull(tableRowHeadersModel.getCellId()); + assertNull(tableRowHeadersModel.getLocation()); + assertNull(tableRowHeadersModel.getText()); + assertNull(tableRowHeadersModel.getTextNormalized()); + assertNull(tableRowHeadersModel.getRowIndexBegin()); + assertNull(tableRowHeadersModel.getRowIndexEnd()); + assertNull(tableRowHeadersModel.getColumnIndexBegin()); + assertNull(tableRowHeadersModel.getColumnIndexEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableTextLocationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableTextLocationTest.java new file mode 100644 index 00000000000..aaa0971aba8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableTextLocationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableTextLocation model. */ +public class TableTextLocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableTextLocation() throws Throwable { + TableTextLocation tableTextLocationModel = new TableTextLocation(); + assertNull(tableTextLocationModel.getText()); + assertNull(tableTextLocationModel.getLocation()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingExampleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingExampleTest.java new file mode 100644 index 00000000000..1e177f0baa3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingExampleTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingExample model. */ +public class TrainingExampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingExample() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + String json = TestUtilities.serialize(trainingExampleModel); + + TrainingExample trainingExampleModelNew = + TestUtilities.deserialize(json, TrainingExample.class); + assertTrue(trainingExampleModelNew instanceof TrainingExample); + assertEquals(trainingExampleModelNew.documentId(), "testString"); + assertEquals(trainingExampleModelNew.collectionId(), "testString"); + assertEquals(trainingExampleModelNew.relevance(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainingExampleError() throws Throwable { + new TrainingExample.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQuerySetTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQuerySetTest.java new file mode 100644 index 00000000000..e7f6e3b0de6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQuerySetTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingQuerySet model. */ +public class TrainingQuerySetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingQuerySet() throws Throwable { + TrainingQuerySet trainingQuerySetModel = new TrainingQuerySet(); + assertNull(trainingQuerySetModel.getQueries()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQueryTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQueryTest.java new file mode 100644 index 00000000000..f8c0371fbff --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQueryTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingQuery model. */ +public class TrainingQueryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingQuery() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + TrainingQuery trainingQueryModel = + new TrainingQuery.Builder() + .naturalLanguageQuery("testString") + .filter("testString") + .examples(java.util.Arrays.asList(trainingExampleModel)) + .build(); + assertEquals(trainingQueryModel.naturalLanguageQuery(), "testString"); + assertEquals(trainingQueryModel.filter(), "testString"); + assertEquals(trainingQueryModel.examples(), java.util.Arrays.asList(trainingExampleModel)); + + String json = TestUtilities.serialize(trainingQueryModel); + + TrainingQuery trainingQueryModelNew = TestUtilities.deserialize(json, TrainingQuery.class); + assertTrue(trainingQueryModelNew instanceof TrainingQuery); + assertEquals(trainingQueryModelNew.naturalLanguageQuery(), "testString"); + assertEquals(trainingQueryModelNew.filter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainingQueryError() throws Throwable { + new TrainingQuery.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptionsTest.java new file mode 100644 index 00000000000..d0950f752f9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptionsTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCollectionOptions model. */ +public class UpdateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCollectionOptions() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(java.util.Arrays.asList("testString")) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals(collectionEnrichmentModel.fields(), java.util.Arrays.asList("testString")); + + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .name("testString") + .description("testString") + .ocrEnabled(false) + .enrichments(java.util.Arrays.asList(collectionEnrichmentModel)) + .build(); + assertEquals(updateCollectionOptionsModel.projectId(), "testString"); + assertEquals(updateCollectionOptionsModel.collectionId(), "testString"); + assertEquals(updateCollectionOptionsModel.name(), "testString"); + assertEquals(updateCollectionOptionsModel.description(), "testString"); + assertEquals(updateCollectionOptionsModel.ocrEnabled(), Boolean.valueOf(false)); + assertEquals( + updateCollectionOptionsModel.enrichments(), + java.util.Arrays.asList(collectionEnrichmentModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionOptionsError() throws Throwable { + new UpdateCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierModelOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierModelOptionsTest.java new file mode 100644 index 00000000000..3798a12716b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierModelOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDocumentClassifierModelOptions model. */ +public class UpdateDocumentClassifierModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDocumentClassifierModelOptions() throws Throwable { + UpdateDocumentClassifierModelOptions updateDocumentClassifierModelOptionsModel = + new UpdateDocumentClassifierModelOptions.Builder() + .projectId("testString") + .classifierId("testString") + .modelId("testString") + .name("testString") + .description("testString") + .build(); + assertEquals(updateDocumentClassifierModelOptionsModel.projectId(), "testString"); + assertEquals(updateDocumentClassifierModelOptionsModel.classifierId(), "testString"); + assertEquals(updateDocumentClassifierModelOptionsModel.modelId(), "testString"); + assertEquals(updateDocumentClassifierModelOptionsModel.name(), "testString"); + assertEquals(updateDocumentClassifierModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentClassifierModelOptionsError() throws Throwable { + new UpdateDocumentClassifierModelOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierOptionsTest.java new file mode 100644 index 00000000000..7fe636f4cb0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierOptionsTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDocumentClassifierOptions model. */ +public class UpdateDocumentClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDocumentClassifierOptions() throws Throwable { + UpdateDocumentClassifier updateDocumentClassifierModel = + new UpdateDocumentClassifier.Builder().name("testString").description("testString").build(); + assertEquals(updateDocumentClassifierModel.name(), "testString"); + assertEquals(updateDocumentClassifierModel.description(), "testString"); + + UpdateDocumentClassifierOptions updateDocumentClassifierOptionsModel = + new UpdateDocumentClassifierOptions.Builder() + .projectId("testString") + .classifierId("testString") + .classifier(updateDocumentClassifierModel) + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .testData(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals(updateDocumentClassifierOptionsModel.projectId(), "testString"); + assertEquals(updateDocumentClassifierOptionsModel.classifierId(), "testString"); + assertEquals(updateDocumentClassifierOptionsModel.classifier(), updateDocumentClassifierModel); + assertEquals( + IOUtils.toString(updateDocumentClassifierOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals( + IOUtils.toString(updateDocumentClassifierOptionsModel.testData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentClassifierOptionsError() throws Throwable { + new UpdateDocumentClassifierOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierTest.java new file mode 100644 index 00000000000..964d9776dbd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentClassifierTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDocumentClassifier model. */ +public class UpdateDocumentClassifierTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDocumentClassifier() throws Throwable { + UpdateDocumentClassifier updateDocumentClassifierModel = + new UpdateDocumentClassifier.Builder().name("testString").description("testString").build(); + assertEquals(updateDocumentClassifierModel.name(), "testString"); + assertEquals(updateDocumentClassifierModel.description(), "testString"); + + String json = TestUtilities.serialize(updateDocumentClassifierModel); + + UpdateDocumentClassifier updateDocumentClassifierModelNew = + TestUtilities.deserialize(json, UpdateDocumentClassifier.class); + assertTrue(updateDocumentClassifierModelNew instanceof UpdateDocumentClassifier); + assertEquals(updateDocumentClassifierModelNew.name(), "testString"); + assertEquals(updateDocumentClassifierModelNew.description(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptionsTest.java new file mode 100644 index 00000000000..6b87ff466b6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDocumentOptions model. */ +public class UpdateDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDocumentOptions() throws Throwable { + UpdateDocumentOptions updateDocumentOptionsModel = + new UpdateDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(false) + .build(); + assertEquals(updateDocumentOptionsModel.projectId(), "testString"); + assertEquals(updateDocumentOptionsModel.collectionId(), "testString"); + assertEquals(updateDocumentOptionsModel.documentId(), "testString"); + assertEquals( + IOUtils.toString(updateDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateDocumentOptionsModel.filename(), "testString"); + assertEquals(updateDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(updateDocumentOptionsModel.metadata(), "testString"); + assertEquals(updateDocumentOptionsModel.xWatsonDiscoveryForce(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentOptionsError() throws Throwable { + new UpdateDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptionsTest.java new file mode 100644 index 00000000000..62aac59ab78 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEnrichmentOptions model. */ +public class UpdateEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEnrichmentOptions() throws Throwable { + UpdateEnrichmentOptions updateEnrichmentOptionsModel = + new UpdateEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .name("testString") + .description("testString") + .build(); + assertEquals(updateEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(updateEnrichmentOptionsModel.enrichmentId(), "testString"); + assertEquals(updateEnrichmentOptionsModel.name(), "testString"); + assertEquals(updateEnrichmentOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnrichmentOptionsError() throws Throwable { + new UpdateEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptionsTest.java new file mode 100644 index 00000000000..a51e52f0e33 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateProjectOptions model. */ +public class UpdateProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateProjectOptions() throws Throwable { + UpdateProjectOptions updateProjectOptionsModel = + new UpdateProjectOptions.Builder().projectId("testString").name("testString").build(); + assertEquals(updateProjectOptionsModel.projectId(), "testString"); + assertEquals(updateProjectOptionsModel.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateProjectOptionsError() throws Throwable { + new UpdateProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..b95372b7ae8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptionsTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateTrainingQueryOptions model. */ +public class UpdateTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateTrainingQueryOptions() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + UpdateTrainingQueryOptions updateTrainingQueryOptionsModel = + new UpdateTrainingQueryOptions.Builder() + .projectId("testString") + .queryId("testString") + .naturalLanguageQuery("testString") + .examples(java.util.Arrays.asList(trainingExampleModel)) + .filter("testString") + .build(); + assertEquals(updateTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(updateTrainingQueryOptionsModel.queryId(), "testString"); + assertEquals(updateTrainingQueryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals( + updateTrainingQueryOptionsModel.examples(), java.util.Arrays.asList(trainingExampleModel)); + assertEquals(updateTrainingQueryOptionsModel.filter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateTrainingQueryOptionsError() throws Throwable { + new UpdateTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/WebhookHeaderTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/WebhookHeaderTest.java new file mode 100644 index 00000000000..acb0e2b8fa7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/WebhookHeaderTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * 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 static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WebhookHeader model. */ +public class WebhookHeaderTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWebhookHeader() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + String json = TestUtilities.serialize(webhookHeaderModel); + + WebhookHeader webhookHeaderModelNew = TestUtilities.deserialize(json, WebhookHeader.class); + assertTrue(webhookHeaderModelNew instanceof WebhookHeader); + assertEquals(webhookHeaderModelNew.name(), "testString"); + assertEquals(webhookHeaderModelNew.value(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWebhookHeaderError() throws Throwable { + new WebhookHeader.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/testng.xml b/discovery/src/test/java/com/ibm/watson/discovery/v2/testng.xml new file mode 100644 index 00000000000..1f27edab14f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/utils/TestUtilities.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/utils/TestUtilities.java new file mode 100644 index 00000000000..7cecabfd8f5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/utils/TestUtilities.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} diff --git a/discovery/src/test/resources/discovery/v1/add_training_example_resp.json b/discovery/src/test/resources/discovery/v1/add_training_example_resp.json deleted file mode 100644 index bc3d3cd680f..00000000000 --- a/discovery/src/test/resources/discovery/v1/add_training_example_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "document_id": "mock_docid", - "relevance": 0 -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/add_training_query_resp.json b/discovery/src/test/resources/discovery/v1/add_training_query_resp.json deleted file mode 100644 index cf268ea13c8..00000000000 --- a/discovery/src/test/resources/discovery/v1/add_training_query_resp.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "query_id": "mock_queryid", - "natural_language_query": "Example query", - "examples": [ - { - "document_id": "mock_docid", - "relevance": 0 - } - ] -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/create_coll_resp.json b/discovery/src/test/resources/discovery/v1/create_coll_resp.json deleted file mode 100644 index 6d811a6ea50..00000000000 --- a/discovery/src/test/resources/discovery/v1/create_coll_resp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "test_collection", - "description": "My test collection for doc", - "created": "2016-12-14T03:20:28.739Z", - "updated": "2016-12-14T03:20:28.739Z", - "status": "available", - "configuration_id": "c84c21d0-ac94-42bf-b619-7d277f325fdc" -} diff --git a/discovery/src/test/resources/discovery/v1/create_conf_resp.json b/discovery/src/test/resources/discovery/v1/create_conf_resp.json deleted file mode 100644 index e5067c71761..00000000000 --- a/discovery/src/test/resources/discovery/v1/create_conf_resp.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "configuration_id": "2e079259-7dd2-40a9-998f-3e716f5a7b88", - "name": "doc-config", - "description": "this is a demo configuration", - "created": "2016-12-14T02:33:34.396Z", - "updated": "2016-12-14T02:33:34.396Z", - "conversions": { - "word": { - "heading": { - "fonts": [ - { - "level": 1, - "min_size": 24, - "bold": false, - "italic": false - }, - { - "level": 2, - "min_size": 18, - "max_size": 23, - "bold": true, - "italic": false - }, - { - "level": 3, - "min_size": 14, - "max_size": 17, - "bold": false, - "italic": false - }, - { - "level": 4, - "min_size": 13, - "max_size": 13, - "bold": true, - "italic": false - } - ], - "styles": [ - { - "level": 1, - "names": [ - "pullout heading", - "pulloutheading", - "header" - ] - }, - { - "level": 2, - "names": [ - "subtitle" - ] - } - ] - } - }, - "pdf": { - "heading": { - "fonts": [ - { - "level": 1, - "min_size": 24, - "max_size": 80 - }, - { - "level": 2, - "min_size": 18, - "max_size": 24, - "bold": false, - "italic": false - }, - { - "level": 2, - "min_size": 18, - "max_size": 24, - "bold": true - }, - { - "level": 3, - "min_size": 13, - "max_size": 18, - "bold": false, - "italic": false - }, - { - "level": 3, - "min_size": 13, - "max_size": 18, - "bold": true - }, - { - "level": 4, - "min_size": 11, - "max_size": 13, - "bold": false, - "italic": false - } - ] - } - }, - "html": { - "exclude_tags_completely": [ - "script", - "sup" - ], - "exclude_tags_keep_content": [ - "font", - "em", - "span" - ], - "exclude_content": { - "xpaths": [] - }, - "keep_content": { - "xpaths": [] - }, - "exclude_tag_attributes": [ - "EVENT_ACTIONS" - ] - }, - "json_normalizations": [] - }, - "enrichments": [ - { - "destination_field": "enriched_text", - "source_field": "text", - "enrichment": "alchemy_language", - "options": { - "extract": [ - "keyword", - "entity", - "doc-sentiment", - "taxonomy", - "concept", - "relation" - ], - "sentiment": true, - "quotations": true - } - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/create_doc_resp.json b/discovery/src/test/resources/discovery/v1/create_doc_resp.json deleted file mode 100644 index f89b8a20406..00000000000 --- a/discovery/src/test/resources/discovery/v1/create_doc_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "document_id": "8691f0dd-7181-45b7-81de-5cb16206b3a1", - "status": "pending" -} diff --git a/discovery/src/test/resources/discovery/v1/create_env_resp.json b/discovery/src/test/resources/discovery/v1/create_env_resp.json deleted file mode 100644 index 5b0109a68d9..00000000000 --- a/discovery/src/test/resources/discovery/v1/create_env_resp.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "environment_id": "9e21069a-8bc1-475e-a1d3-2121c49ef060", - "name": "my_environment", - "description": "My Discovery environment", - "created": "2016-12-14T17:32:41.593Z", - "updated": "2016-12-14T17:32:41.593Z", - "status": "pending", - "read_only": false, - "index_capacity": { - "disk_usage": { - "used_bytes": 0, - "total_bytes": 1073741824, - "used": "0 KB", - "total": "1024 MB", - "percent_used": 0 - }, - "memory_usage": { - "used_bytes": 0, - "total_bytes": 0, - "used": "0 KB", - "total": "0 KB", - "percent_used": 0 - } - } -} diff --git a/discovery/src/test/resources/discovery/v1/create_event_resp.json b/discovery/src/test/resources/discovery/v1/create_event_resp.json deleted file mode 100644 index 7d5a3ef391b..00000000000 --- a/discovery/src/test/resources/discovery/v1/create_event_resp.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "click", - "data": { - "environment_id": "mock_envid", - "session_token": "mock_session_token", - "client_timestamp": "2016-12-14T17:32:41.593Z", - "display_rank": 1, - "collection_id": "mock_collid", - "document_id": "mock_docid", - "query_id": "mock_queryid" - } -} diff --git a/discovery/src/test/resources/discovery/v1/credentials_resp.json b/discovery/src/test/resources/discovery/v1/credentials_resp.json deleted file mode 100644 index 358c4bbd58b..00000000000 --- a/discovery/src/test/resources/discovery/v1/credentials_resp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "credential_id" : "00000d8c-0000-00e8-ba89-0ed5f89f718b", - "source_type" : "salesforce", - "credential_details" : { - "credential_type" : "username_password", - "url" : "login.salesforce.com", - "username" : "user@email.address" - } -} diff --git a/discovery/src/test/resources/discovery/v1/delete_coll_resp.json b/discovery/src/test/resources/discovery/v1/delete_coll_resp.json deleted file mode 100644 index 5a5203844be..00000000000 --- a/discovery/src/test/resources/discovery/v1/delete_coll_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "collection_id": "44e29a9a-47e3-4acd-874b-c7cbe04043f1", - "status": "deleted" -} diff --git a/discovery/src/test/resources/discovery/v1/delete_conf_resp.json b/discovery/src/test/resources/discovery/v1/delete_conf_resp.json deleted file mode 100644 index 81d69519c50..00000000000 --- a/discovery/src/test/resources/discovery/v1/delete_conf_resp.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "configuration_id": "448e3545-51ca-4530-a03b-6ff282ceac2e", - "status": "deleted", - "notices": [ - { - "notice_id": "configuration_in_use", - "created": "2016-09-28T12:34:00.000Z", - "severity": "warning", - "description": "The configuration was deleted, but it is referenced by one or more collections." - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/delete_credentials_resp.json b/discovery/src/test/resources/discovery/v1/delete_credentials_resp.json deleted file mode 100644 index a585f793f95..00000000000 --- a/discovery/src/test/resources/discovery/v1/delete_credentials_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "credential_id": "448e3545-51ca-4530-a03b-6ff282ceac2e", - "status": "deleted" -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/delete_doc_resp.json b/discovery/src/test/resources/discovery/v1/delete_doc_resp.json deleted file mode 100644 index 6aeba34b3a0..00000000000 --- a/discovery/src/test/resources/discovery/v1/delete_doc_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "document_id": "8691f0dd-7181-45b7-81de-5cb16206b3a1", - "status": "deleted" -} diff --git a/discovery/src/test/resources/discovery/v1/delete_env_resp.json b/discovery/src/test/resources/discovery/v1/delete_env_resp.json deleted file mode 100644 index 53df6cea614..00000000000 --- a/discovery/src/test/resources/discovery/v1/delete_env_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "environment_id": "{environment_id}", - "status": "deleted" -} diff --git a/discovery/src/test/resources/discovery/v1/delete_gateway_resp.json b/discovery/src/test/resources/discovery/v1/delete_gateway_resp.json deleted file mode 100644 index 05565564d51..00000000000 --- a/discovery/src/test/resources/discovery/v1/delete_gateway_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "gateway_id": "8691f0dd-7181-45b7-81de-5cb16206b3a1", - "status": "deleted" -} diff --git a/discovery/src/test/resources/discovery/v1/expansions_resp.json b/discovery/src/test/resources/discovery/v1/expansions_resp.json deleted file mode 100644 index 3456f883d6f..00000000000 --- a/discovery/src/test/resources/discovery/v1/expansions_resp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "expansions": [ - { - "input_terms": [ - "weekday", - "week day" - ], - "expanded_terms": [ - "monday", - "tuesday", - "wednesday", - "thursday", - "friday" - ] - }, - { - "input_terms": [ - "weekend", - "week end" - ], - "expanded_terms": [ - "saturday", - "sunday" - ] - } - ] -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/gateway_resp.json b/discovery/src/test/resources/discovery/v1/gateway_resp.json deleted file mode 100644 index 59a8c308449..00000000000 --- a/discovery/src/test/resources/discovery/v1/gateway_resp.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "gateway_id": "gateway_id", - "name": "name", - "status": "connected", - "token": "token", - "token_id": "token_id" -} diff --git a/discovery/src/test/resources/discovery/v1/get_coll1_resp.json b/discovery/src/test/resources/discovery/v1/get_coll1_resp.json deleted file mode 100644 index aa9b74f432c..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_coll1_resp.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "collection_id": "44e29a9a-47e3-4acd-874b-c7cbe04043f1", - "name": "test_collection", - "created": "2016-12-14T18:42:25.324Z", - "updated": "2016-12-14T18:42:25.324Z", - "status": "available", - "configuration_id": "e8b9d793-b163-452a-9373-bce07efb510b", - "language": "en_us", - "document_counts": { - "available": 1000, - "processing": 20, - "failed": 180 - } -} diff --git a/discovery/src/test/resources/discovery/v1/get_coll_resp.json b/discovery/src/test/resources/discovery/v1/get_coll_resp.json deleted file mode 100644 index 3428eddeba7..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_coll_resp.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "collections": [ - { - "collection_id": "44e29a9a-47e3-4acd-874b-c7cbe04043f1", - "name": "test_collection", - "created": "2016-12-14T18:42:25.324Z", - "updated": "2016-12-14T18:42:25.324Z", - "status": "available", - "configuration_id": "e8b9d793-b163-452a-9373-bce07efb510b", - "language": "en_us" - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/get_conf_resp.json b/discovery/src/test/resources/discovery/v1/get_conf_resp.json deleted file mode 100644 index 1c38c4bca7a..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_conf_resp.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "configuration_id": "2e079259-7dd2-40a9-998f-3e716f5a7b88", - "name": "doc-config", - "description": "this is a demo configuration", - "created": "2016-11-03T02:33:34.396Z", - "updated": "2016-11-03T02:33:34.396Z", - "conversions": { - "word": { - "heading": { - "fonts": [ - { - "level": 1, - "min_size": 24, - "bold": false, - "italic": false - }, - { - "level": 2, - "min_size": 18, - "max_size": 23, - "bold": true, - "italic": false - }, - { - "level": 3, - "min_size": 14, - "max_size": 17, - "bold": false, - "italic": false - }, - { - "level": 4, - "min_size": 13, - "max_size": 13, - "bold": true, - "italic": false - } - ], - "styles": [ - { - "level": 1, - "names": [ - "pullout heading", - "pulloutheading", - "header" - ] - }, - { - "level": 2, - "names": [ - "subtitle" - ] - } - ] - } - }, - "pdf": { - "heading": { - "fonts": [ - { - "level": 1, - "min_size": 24, - "max_size": 80 - }, - { - "level": 2, - "min_size": 18, - "max_size": 24, - "bold": false, - "italic": false - }, - { - "level": 2, - "min_size": 18, - "max_size": 24, - "bold": true - }, - { - "level": 3, - "min_size": 13, - "max_size": 18, - "bold": false, - "italic": false - }, - { - "level": 3, - "min_size": 13, - "max_size": 18, - "bold": true - }, - { - "level": 4, - "min_size": 11, - "max_size": 13, - "bold": false, - "italic": false - } - ] - } - }, - "html": { - "exclude_tags_completely": [ - "script", - "sup" - ], - "exclude_tags_keep_content": [ - "font", - "em", - "span" - ], - "exclude_content": { - "xpaths": [] - }, - "keep_content": { - "xpaths": [] - }, - "exclude_tag_attributes": [ - "EVENT_ACTIONS" - ] - }, - "json_normalizations": [] - }, - "enrichments": [ - { - "destination_field": "enriched_text", - "source_field": "text", - "enrichment": "alchemy_language", - "options": { - "extract": [ - "keyword", - "entity", - "doc-sentiment", - "taxonomy", - "concept", - "relation" - ], - "sentiment": true, - "quotations": true - } - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/get_confs_resp.json b/discovery/src/test/resources/discovery/v1/get_confs_resp.json deleted file mode 100644 index 50083f93f81..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_confs_resp.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "configurations": [ - { - "configuration_id": "210081cb-796f-463d-ab88-a07595f452a9", - "name": "default-config", - "description": "This is a test configuration.", - "created": "2016-11-01T17:47:30.678Z", - "updated": "2016-11-01T17:47:30.678Z" - }, - { - "configuration_id": "448e3545-51ca-4530-a03b-6ff282ceac2e", - "name": "democonfig", - "description": "this is a demo configuration", - "created": "2016-12-14T18:42:25.324Z", - "updated": "2016-12-14T18:42:25.324Z" - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/get_doc_resp.json b/discovery/src/test/resources/discovery/v1/get_doc_resp.json deleted file mode 100644 index 36626fafa3b..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_doc_resp.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "document_id": "8691f0dd-7181-45b7-81de-5cb16206b3a1", - "configuration_id": "e8b9d793-b163-452a-9373-bce07efb510b", - "created": "2016-11-02T18:42:25.324Z", - "updated": "2016-11-03T09:02:41.585Z", - "status": "pending", - "notices": [ - { - "notice_id": "index_342", - "severity": "warning", - "step": "indexing", - "description": "DANGER, WILL ROBINSON!" - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/get_env_resp.json b/discovery/src/test/resources/discovery/v1/get_env_resp.json deleted file mode 100644 index 65afb765910..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_env_resp.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "environment_id": "448e3545-51ca-4530-a03b-6ff282ceac2e", - "name": "my_environment", - "description": "My environment", - "created": "2016-12-14T17:32:41.593Z", - "updated": "2016-12-14T17:32:41.593Z", - "status": "resizing", - "index_capacity": { - "disk_usage": { - "used_bytes": 0, - "total_bytes": 1073741824, - "used": "0 KB", - "total": "1024 MB", - "percent_used": 0 - }, - "memory_usage": { - "used_bytes": 140266264, - "total_bytes": 518979584, - "used": "133.77 MB", - "total": "494.94 MB", - "percent_used": 27.03 - } - }, - "requested_size": "LT", - "search_status": { - "scope": "environment", - "status": "TRAINING", - "status_description": "The environment is training.", - "last_trained": "2016-12-14T17:32:41.593Z" - } -} diff --git a/discovery/src/test/resources/discovery/v1/get_envs_resp.json b/discovery/src/test/resources/discovery/v1/get_envs_resp.json deleted file mode 100644 index bd3076b111c..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_envs_resp.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "environments": [ - { - "environment_id": "448e3545-51ca-4530-a03b-6ff282ceac2e", - "name": "my_environment", - "description": "My environment", - "created": "2016-12-14T17:32:41.593Z", - "updated": "2016-12-14T17:32:41.593Z", - "status": "available", - "index_capacity": { - "disk_usage": { - "used_bytes": 0, - "total_bytes": 1073741824, - "used": "0 KB", - "total": "1024 MB", - "percent_used": 0 - }, - "memory_usage": { - "used_bytes": 137456520, - "total_bytes": 518979584, - "used": "131.09 MB", - "total": "494.94 MB", - "percent_used": 26.49 - } - } - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/get_training_data_resp.json b/discovery/src/test/resources/discovery/v1/get_training_data_resp.json deleted file mode 100644 index cf268ea13c8..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_training_data_resp.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "query_id": "mock_queryid", - "natural_language_query": "Example query", - "examples": [ - { - "document_id": "mock_docid", - "relevance": 0 - } - ] -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/get_training_example_resp.json b/discovery/src/test/resources/discovery/v1/get_training_example_resp.json deleted file mode 100644 index bc3d3cd680f..00000000000 --- a/discovery/src/test/resources/discovery/v1/get_training_example_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "document_id": "mock_docid", - "relevance": 0 -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/issue517.json b/discovery/src/test/resources/discovery/v1/issue517.json deleted file mode 100644 index 5c4ee81a99b..00000000000 --- a/discovery/src/test/resources/discovery/v1/issue517.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "my_config", - "conversions": { - "json_normalizations": [ - { - "operation": "copy", - "source_field": "some_field", - "destination_field": "other_field" - } - ] - } -} diff --git a/discovery/src/test/resources/discovery/v1/issue518.json b/discovery/src/test/resources/discovery/v1/issue518.json deleted file mode 100644 index 2e32c2ac4f7..00000000000 --- a/discovery/src/test/resources/discovery/v1/issue518.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "configuration_id": "448e3545-51ca-4530-a03b-6ff282ceac2e", - "name": "IBM News", - "created": "2015-08-24T18:42:25.324Z", - "updated": "2015-08-24T18:42:25.324Z", - "description": "A configuration useful for ingesting IBM press releases.", - "conversions": { - "html": { - "exclude_tags_keep_content": [ - "span" - ], - "exclude_content": { - "xpaths": [ - "/home" - ] - } - }, - "json_normalizations": [ - { - "operation": "move", - "source_field": "extracted_metadata.title", - "destination_field": "metadata.title" - }, - { - "operation": "move", - "source_field": "extracted_metadata.author", - "destination_field": "metadata.author" - }, - { - "operation": "remove", - "source_field": "extracted_metadata" - } - ] - }, - "enrichments": [ - { - "source_field": "text", - "destination_field": "alchemy_enriched_text", - "enrichment": "alchemy_language", - "options": { - "extract": [ - "keyword" - ], - "showSourceText": true - } - }, - { - "source_field": "alchemy_enriched_text.text", - "destination_field": "sire_enriched_text", - "enrichment": "alchemy_language", - "options": { - "extract": [ - "typed-rels" - ], - "model": "ie-en-news" - } - } - ], - "normalizations": [ - { - "operation": "move", - "source_field": "metadata.title", - "destination_field": "title" - }, - { - "operation": "copy", - "source_field": "metadata.author", - "destination_field": "author" - }, - { - "operation": "merge", - "source_field": "alchemy_enriched_text.language", - "destination_field": "language" - }, - { - "operation": "remove", - "source_field": "html" - }, - { - "operation": "remove_nulls" - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/list_credentials_resp.json b/discovery/src/test/resources/discovery/v1/list_credentials_resp.json deleted file mode 100644 index 50af9a38006..00000000000 --- a/discovery/src/test/resources/discovery/v1/list_credentials_resp.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "credentials" : [ { - "credential_id" : "00000d8c-0000-00e8-ba89-0ed5f89f718b", - "source_type" : "salesforce", - "credential_details" : { - "credential_type" : "username_password", - "url" : "login.salesforce.com", - "username" : "user@email.address" - } - }, { - "credential_id" : "00000d8c-0000-00e8-ba89-0ed5f89f111c", - "source_type" : "box", - "credential_details" : { - "credential_type" : "oauth2", - "client_id" : "1234567899bz7micz6x6p5zfnycw98e3", - "enterprise_id" : "000000001" - } - }, { - "credential_id" : "00000d8c-0000-00e8-ba22-0ed5f89f999d", - "source_type" : "sharepoint", - "credential_details" : { - "credential_type" : "saml", - "organization_url" : "https://site001.sharepointonline.com", - "site_collection_path" : "/sites/TestSite1", - "username" : "userA@sharepointonline.com" - } - } ] -} diff --git a/discovery/src/test/resources/discovery/v1/list_fields_resp.json b/discovery/src/test/resources/discovery/v1/list_fields_resp.json deleted file mode 100644 index 2a34d013a75..00000000000 --- a/discovery/src/test/resources/discovery/v1/list_fields_resp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "fields": [ - { - "field": "field", - "type": "string" - } - ] -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/list_gateways_resp.json b/discovery/src/test/resources/discovery/v1/list_gateways_resp.json deleted file mode 100644 index 58f2a9a384b..00000000000 --- a/discovery/src/test/resources/discovery/v1/list_gateways_resp.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "gateways": [ - { - "gateway_id": "gateway_id_1", - "name": "name", - "status": "connected", - "token": "token", - "token_id": "token_id" - }, - { - "gateway_id": "gateway_id_2", - "name": "name", - "status": "connected", - "token": "token", - "token_id": "token_id" - }, - ] -} diff --git a/discovery/src/test/resources/discovery/v1/list_training_data_resp.json b/discovery/src/test/resources/discovery/v1/list_training_data_resp.json deleted file mode 100644 index 503353e69bd..00000000000 --- a/discovery/src/test/resources/discovery/v1/list_training_data_resp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "environment_id": "mock_envid", - "collection_id": "mock_confid", - "queries": [ - { - "query_id": "mock_queryid", - "natural_language_query": "Example query", - "examples": [ - { - "document_id": "mock_docid", - "relevance": 0 - } - ] - } - ] -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/list_training_examples_resp.json b/discovery/src/test/resources/discovery/v1/list_training_examples_resp.json deleted file mode 100644 index cdfd587bf69..00000000000 --- a/discovery/src/test/resources/discovery/v1/list_training_examples_resp.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "examples": [ - { - "document_id": "mock_docid", - "relevance": 0, - "cross_reference": "cross_reference" - } - ] -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/listfields_coll_resp.json b/discovery/src/test/resources/discovery/v1/listfields_coll_resp.json deleted file mode 100644 index dc45c39a1b2..00000000000 --- a/discovery/src/test/resources/discovery/v1/listfields_coll_resp.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fields": [ - { - "field": "warnings", - "type": "nested" - }, - { - "field": "warnings.properties.description", - "type": "string" - }, - { - "field": "warnings.properties.phase", - "type": "string" - }, - { - "field": "warnings.properties.warning_id", - "type": "string" - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/log_query_resp.json b/discovery/src/test/resources/discovery/v1/log_query_resp.json deleted file mode 100644 index 8d7eb2d5f08..00000000000 --- a/discovery/src/test/resources/discovery/v1/log_query_resp.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "matching_results": 2, - "results": [ - { - "environment_id": "mock_envid", - "customer_id": "", - "natural_language_query": "Who beat Ken Jennings in Jeopardy!", - "document_results": { - "results": [], - "count": 0 - }, - "created_timestamp": "2018-07-16T18:27:26.433", - "query_id": "mock_queryid", - "session_token": "mock_session_token", - "event_type": "query" - }, - { - "environment_id": "mock_envid", - "customer_id": "", - "document_results": { - "results": [ - { - "position": 1, - "document_id": "mock_docid", - "score": 1.0, - "collection_id": "mock_collid" - }, - { - "position": 2, - "document_id": "mock_docid", - "score": 1.0, - "collection_id": "mock_collid" - } - ], - "count": 2 - }, - "created_timestamp": "2018-07-19T11:10:32.243", - "query_id": "mock_queryid", - "session_token": "mock_session_token", - "event_type": "query" - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/metric_resp.json b/discovery/src/test/resources/discovery/v1/metric_resp.json deleted file mode 100644 index 012289e7a4c..00000000000 --- a/discovery/src/test/resources/discovery/v1/metric_resp.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "aggregations": [ - { - "interval": "1d", - "event_type": "click", - "results": [ - { - "key_as_string": "2018-08-05T20:00:00.000", - "key": 1533513600000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-06T20:00:00.000", - "key": 1533600000000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-07T20:00:00.000", - "key": 1533686400000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-08T20:00:00.000", - "key": 1533772800000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-09T20:00:00.000", - "key": 1533859200000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-10T20:00:00.000", - "key": 1533945600000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-11T20:00:00.000", - "key": 1534032000000, - "event_rate": 0.0 - }, - { - "key_as_string": "2018-08-12T20:00:00.000", - "key": 1534118400000, - "event_rate": 0.09090909090909091 - } - ] - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/metric_token_resp.json b/discovery/src/test/resources/discovery/v1/metric_token_resp.json deleted file mode 100644 index 19f33e21d81..00000000000 --- a/discovery/src/test/resources/discovery/v1/metric_token_resp.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "aggregations": [ - { - "event_type": "click", - "results": [ - { - "key": "beat", - "matching_results": 117, - "event_rate": 0.0 - }, - { - "key": "in", - "matching_results": 117, - "event_rate": 0.0 - }, - { - "key": "jennings", - "matching_results": 117, - "event_rate": 0.0 - }, - { - "key": "jeopardy", - "matching_results": 117, - "event_rate": 0.0 - }, - { - "key": "ken", - "matching_results": 117, - "event_rate": 0.0 - }, - { - "key": "who", - "matching_results": 117, - "event_rate": 0.0 - }, - { - "key": "watson", - "matching_results": 3, - "event_rate": 0.0 - }, - { - "key": "1", - "matching_results": 2, - "event_rate": 0.5 - }, - { - "key": "field", - "matching_results": 2, - "event_rate": 0.5 - }, - { - "key": "number", - "matching_results": 2, - "event_rate": 0.5 - } - ] - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/passages_test_doc_1.json b/discovery/src/test/resources/discovery/v1/passages_test_doc_1.json deleted file mode 100644 index c065af80ae5..00000000000 --- a/discovery/src/test/resources/discovery/v1/passages_test_doc_1.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text": "Celgene and IBM Watson Health Forge Collaboration Designed to Transform Patient Safety Monitoring\nCelgene Corporation and IBM Watson Health today announced a collaboration to co-develop IBM Watson for Patient Safety, a new offering that aims to enhance pharmacovigilance methods used to collect, assess, monitor, and report adverse drug reactions. The new offering will run on the Watson Health Cloud." -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/passages_test_doc_2.json b/discovery/src/test/resources/discovery/v1/passages_test_doc_2.json deleted file mode 100644 index 3dde183fe61..00000000000 --- a/discovery/src/test/resources/discovery/v1/passages_test_doc_2.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text": "Slack, IBM Partner to Bring Watson to Developers\nIBM and Slack are partnering to bring Watson to Slack’s global community of developers and enterprise users. Drawing on the power of Slack’s digital workplace and the cognitive computing capabilities of Watson, developers will be able to create more offerings — including bots and other conversational inferences — that will transform the platform’s user experience. Developers can easily access the range of Watson services -- such as Conversation, Sentiment Analysis or speech APIs -- and build powerful new tools for the platform with this enhanced cognitive functionality." -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/query1_resp.json b/discovery/src/test/resources/discovery/v1/query1_resp.json deleted file mode 100644 index af8303c5054..00000000000 --- a/discovery/src/test/resources/discovery/v1/query1_resp.json +++ /dev/null @@ -1,536 +0,0 @@ -{ - "matching_results": 4, - "results": [ - { - "id": "4f70a05d-6ef2-4a46-be87-380724995af8", - "score": 1, - "extracted_metadata": { - "title": "Celgene and IBM Watson Health Forge Collaboration Designed to Transform Patient Safety Monitoring" - }, - "html": "\n\n Celgene and IBM Watson Health Forge Collaboration Designed to Transform Patient Safety Monitoring\n\n\n\n\n

Published: Tue, 01 Nov 2016 08:32:23 GMT

\n

Celgene Corporation and IBM Watson Health today announced a collaboration to co-develop IBM Watson for Patient Safety, a new offering that aims to enhance pharmacovigilance methods used to collect, assess, monitor, and report adverse drug reactions. The new offering will run on the Watson Health Cloud.

\n

URL: http://www.ibm.com/press/us/en/pressrelease/50927.wss

\n\n\n", - "text": "Celgene and IBM Watson Health Forge Collaboration Designed to Transform Patient Safety Monitoring\n\nPublished: Tue, 01 Nov 2016 08:32:23 GMT\n\nCelgene Corporation and IBM Watson Health today announced a collaboration to co-develop IBM Watson for Patient Safety, a new offering that aims to enhance pharmacovigilance methods used to collect, assess, monitor, and report adverse drug reactions. The new offering will run on the Watson Health Cloud.\n\nURL: http://www.ibm.com/press/us/en/pressrelease/50927.wss", - "enriched_text": { - "status": "OK", - "language": "english", - "docSentiment": { - "type": "positive", - "score": 0.349018, - "mixed": true - }, - "concepts": [ - { - "text": "Adverse drug reaction", - "relevance": 0.97198, - "knowledgeGraph": { - "typeHierarchy": "/adverse events/adverse drug reaction" - }, - "dbpedia": "http://dbpedia.org/resource/Adverse_drug_reaction", - "freebase": "http://rdf.freebase.com/ns/m.04p93k" - }, - { - "text": "Pharmacovigilance", - "relevance": 0.57362, - "knowledgeGraph": { - "typeHierarchy": "/directors/pharmacovigilance" - }, - "dbpedia": "http://dbpedia.org/resource/Pharmacovigilance", - "freebase": "http://rdf.freebase.com/ns/m.04lmfb" - }, - { - "text": "Thomas J. Watson", - "relevance": 0.507165, - "knowledgeGraph": { - "typeHierarchy": "/people/thomas j. watson" - }, - "dbpedia": "http://dbpedia.org/resource/Thomas_J._Watson", - "freebase": "http://rdf.freebase.com/ns/m.07qkt", - "yago": "http://yago-knowledge.org/resource/Thomas_J._Watson" - }, - { - "text": "Illness", - "relevance": 0.497042, - "knowledgeGraph": { - "typeHierarchy": "/issues/conditions/circumstances/illness" - }, - "dbpedia": "http://dbpedia.org/resource/Illness", - "freebase": "http://rdf.freebase.com/ns/m.01jwdy" - }, - { - "text": "Lotus Software", - "relevance": 0.482834, - "knowledgeGraph": { - "typeHierarchy": "/products/materials/software/lotus software" - }, - "website": "http://www.ibm.com/software/lotus", - "dbpedia": "http://dbpedia.org/resource/Lotus_Software", - "freebase": "http://rdf.freebase.com/ns/m.0q4jd", - "opencyc": "http://sw.opencyc.org/concept/Mx4rvViJIZwpEbGdrcN5Y29ycA", - "yago": "http://yago-knowledge.org/resource/Lotus_Software" - }, - { - "text": "Pharmacology", - "relevance": 0.441008, - "knowledgeGraph": { - "typeHierarchy": "/fields/pharmacology" - }, - "dbpedia": "http://dbpedia.org/resource/Pharmacology", - "freebase": "http://rdf.freebase.com/ns/m.062p_", - "opencyc": "http://sw.opencyc.org/concept/Mx4rwQFiYJwpEbGdrcN5Y29ycA" - }, - { - "text": "Thomas J. Watson Research Center", - "relevance": 0.4094, - "knowledgeGraph": { - "typeHierarchy": "/organizations/research centers/thomas j. watson research center" - }, - "dbpedia": "http://dbpedia.org/resource/Thomas_J._Watson_Research_Center", - "freebase": "http://rdf.freebase.com/ns/m.04zkt5", - "yago": "http://yago-knowledge.org/resource/Thomas_J._Watson_Research_Center" - } - ], - "entities": [ - { - "type": "Company", - "relevance": 0.939431, - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson health" - }, - "sentiment": { - "type": "positive", - "score": 0.394824, - "mixed": false - }, - "count": 1, - "text": "IBM Watson Health" - }, - { - "type": "Facility", - "relevance": 0.936844, - "knowledgeGraph": { - "typeHierarchy": "/people/watson health forge" - }, - "sentiment": { - "type": "positive", - "score": 0.450045, - "mixed": false - }, - "count": 1, - "text": "Watson Health Forge" - }, - { - "type": "Facility", - "relevance": 0.900379, - "knowledgeGraph": { - "typeHierarchy": "/people/watson health cloud" - }, - "sentiment": { - "type": "positive", - "score": 0.793685, - "mixed": false - }, - "count": 1, - "text": "Watson Health Cloud" - }, - { - "type": "Company", - "relevance": 0.847945, - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson" - }, - "sentiment": { - "type": "positive", - "score": 0.394824, - "mixed": false - }, - "count": 1, - "text": "IBM Watson" - }, - { - "type": "JobTitle", - "relevance": 0.688245, - "knowledgeGraph": { - "typeHierarchy": "/issues/patient safety/transform patient safety monitoring" - }, - "sentiment": { - "type": "positive", - "score": 0.450045, - "mixed": false - }, - "count": 1, - "text": "Transform Patient Safety Monitoring" - }, - { - "type": "Company", - "relevance": 0.514877, - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm" - }, - "sentiment": { - "type": "positive", - "score": 0.450045, - "mixed": false - }, - "count": 1, - "text": "IBM", - "disambiguated": { - "subType": [ - "SoftwareLicense", - "OperatingSystemDeveloper", - "ProcessorManufacturer", - "SoftwareDeveloper", - "CompanyFounder", - "ProgrammingLanguageDesigner", - "ProgrammingLanguageDeveloper" - ], - "name": "IBM", - "website": "http://www.ibm.com/", - "dbpedia": "http://dbpedia.org/resource/IBM", - "freebase": "http://rdf.freebase.com/ns/m.03sc8", - "opencyc": "http://sw.opencyc.org/concept/Mx4rvViMoJwpEbGdrcN5Y29ycA", - "yago": "http://yago-knowledge.org/resource/IBM", - "crunchbase": "http://www.crunchbase.com/company/ibm" - } - }, - { - "type": "Company", - "relevance": 0.332536, - "knowledgeGraph": { - "typeHierarchy": "/companies/organizations/celgene corporation" - }, - "sentiment": { - "type": "positive", - "score": 0.394824, - "mixed": false - }, - "count": 1, - "text": "Celgene Corporation", - "disambiguated": { - "subType": [ - "VentureFundedCompany" - ], - "name": "Celgene", - "website": "http://www.celgene.com/", - "dbpedia": "http://dbpedia.org/resource/Celgene", - "freebase": "http://rdf.freebase.com/ns/m.0898kv", - "opencyc": "http://sw.opencyc.org/concept/Mx4rvZdBy5wpEbGdrcN5Y29ycA", - "yago": "http://yago-knowledge.org/resource/Celgene" - } - }, - { - "type": "Person", - "relevance": 0.307186, - "knowledgeGraph": { - "typeHierarchy": "/companies/organizations/celgene" - }, - "sentiment": { - "type": "positive", - "score": 0.450045, - "mixed": false - }, - "count": 1, - "text": "Celgene" - } - ], - "relations": [ - { - "sentence": " Celgene Corporation and IBM Watson Health today announced a collaboration to co-develop IBM Watson for Patient Safety, a new offering that aims to enhance pharmacovigilance methods used to collect, assess, monitor, and report adverse drug reactions.", - "subject": { - "text": "Celgene Corporation and IBM Watson Health today", - "entities": [ - { - "type": "Company", - "text": "Celgene Corporation", - "knowledgeGraph": { - "typeHierarchy": "/companies/organizations/celgene corporation" - }, - "disambiguated": { - "subType": [ - "Organization", - "Company", - "VentureFundedCompany" - ], - "name": "Celgene", - "website": "http://www.celgene.com/", - "dbpedia": "http://dbpedia.org/resource/Celgene", - "freebase": "http://rdf.freebase.com/ns/m.0898kv", - "opencyc": "http://sw.opencyc.org/concept/Mx4rvZdBy5wpEbGdrcN5Y29ycA", - "yago": "http://yago-knowledge.org/resource/Celgene" - } - }, - { - "type": "Company", - "text": "IBM Watson Health", - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson health" - } - } - ], - "keywords": [ - { - "text": "IBM Watson Health", - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson health" - } - }, - { - "text": "Celgene Corporation", - "knowledgeGraph": { - "typeHierarchy": "/companies/organizations/celgene corporation" - } - } - ] - }, - "action": { - "text": "announced", - "lemmatized": "announce", - "verb": { - "text": "announce", - "tense": "past" - } - }, - "object": { - "text": "a collaboration to co-develop IBM Watson for Patient Safety, a new offering that aims to enhance pharmacovigilance methods used to collect, assess, monitor, and report adverse drug reactions", - "sentiment": { - "type": "positive", - "score": 0.576836, - "mixed": false - }, - "entities": [ - { - "type": "Company", - "text": "IBM Watson", - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson" - } - } - ], - "keywords": [ - { - "text": "adverse drug reactions", - "knowledgeGraph": { - "typeHierarchy": "/adverse events/adverse drug reactions" - } - }, - { - "text": "pharmacovigilance methods", - "knowledgeGraph": { - "typeHierarchy": "/tools/resources/materials/methods/pharmacovigilance methods" - } - }, - { - "text": "IBM Watson", - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson" - } - }, - { - "text": "Patient Safety", - "knowledgeGraph": { - "typeHierarchy": "/issues/patient safety" - } - } - ] - } - }, - { - "sentence": " Celgene Corporation and IBM Watson Health today announced a collaboration to co-develop IBM Watson for Patient Safety, a new offering that aims to enhance pharmacovigilance methods used to collect, assess, monitor, and report adverse drug reactions.", - "subject": { - "text": "a new offering", - "sentiment": { - "type": "positive", - "score": 0.639534, - "mixed": false - }, - "keywords": [ - { - "text": "new offering" - } - ] - }, - "action": { - "text": "aims", - "lemmatized": "aim", - "verb": { - "text": "aim", - "tense": "present" - } - }, - "object": { - "text": "to enhance pharmacovigilance methods used to collect", - "keywords": [ - { - "text": "pharmacovigilance methods", - "knowledgeGraph": { - "typeHierarchy": "/tools/resources/materials/methods/pharmacovigilance methods" - } - } - ] - } - }, - { - "sentence": " The new offering will run on the Watson Health Cloud.", - "subject": { - "text": "The new offering", - "sentiment": { - "type": "positive", - "score": 0.451284, - "mixed": false - }, - "keywords": [ - { - "text": "new offering" - } - ] - }, - "action": { - "text": "will run", - "lemmatized": "will run", - "verb": { - "text": "run", - "tense": "future" - } - }, - "location": { - "text": "on the Watson Health Cloud", - "entities": [ - { - "type": "Facility", - "text": "Watson Health Cloud", - "knowledgeGraph": { - "typeHierarchy": "/people/watson health cloud" - } - } - ] - } - } - ], - "taxonomy": [ - { - "label": "/health and fitness", - "score": 0.613225, - "confident": false - }, - { - "label": "/business and industrial/company/bankruptcy", - "score": 0.413686, - "confident": false - }, - { - "confident": false, - "label": "/technology and computing", - "score": 0.325571 - } - ], - "keywords": [ - { - "knowledgeGraph": { - "typeHierarchy": "/organizations/companies/ibm/ibm watson health" - }, - "relevance": 0.944488, - "sentiment": { - "score": 0.422434, - "type": "positive", - "mixed": false - }, - "text": "IBM Watson Health" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/people/watson health forge" - }, - "relevance": 0.666311, - "sentiment": { - "score": 0.450045, - "type": "positive", - "mixed": false - }, - "text": "Watson Health Forge" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/people/watson health cloud" - }, - "relevance": 0.531944, - "sentiment": { - "score": 0.793685, - "type": "positive", - "mixed": false - }, - "text": "Watson Health Cloud" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/issues/patient safety/transform patient safety" - }, - "relevance": 0.47957, - "sentiment": { - "score": 0.450045, - "type": "positive", - "mixed": false - }, - "text": "Transform Patient Safety" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/adverse events/adverse drug reactions" - }, - "relevance": 0.445181, - "sentiment": { - "type": "neutral", - "mixed": false - }, - "text": "adverse drug reactions" - }, - { - "relevance": 0.400895, - "sentiment": { - "score": 0.644874, - "type": "positive", - "mixed": false - }, - "text": "new offering" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/activities/services/applications/collaboration/collaboration designed" - }, - "relevance": 0.301433, - "sentiment": { - "score": 0.450045, - "type": "positive", - "mixed": false - }, - "text": "Collaboration Designed" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/tools/resources/materials/methods/pharmacovigilance methods" - }, - "relevance": 0.27876, - "sentiment": { - "score": 0.496064, - "type": "positive", - "mixed": false - }, - "text": "pharmacovigilance methods" - }, - { - "knowledgeGraph": { - "typeHierarchy": "/companies/organizations/celgene corporation" - }, - "relevance": 0.220786, - "sentiment": { - "score": 0.394824, - "type": "positive", - "mixed": false - }, - "text": "Celgene Corporation" - } - ] - } - } - ], - "retrieval_details": { - "document_retrieval_strategy": "relevancy_training" - } -} diff --git a/discovery/src/test/resources/discovery/v1/stopwords.txt b/discovery/src/test/resources/discovery/v1/stopwords.txt deleted file mode 100644 index 20089a6d716..00000000000 --- a/discovery/src/test/resources/discovery/v1/stopwords.txt +++ /dev/null @@ -1,35 +0,0 @@ -| US English default stopword list - -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -such -that -the -their -then -there -these -they -this -to -was -will -with diff --git a/discovery/src/test/resources/discovery/v1/test-config.json b/discovery/src/test/resources/discovery/v1/test-config.json deleted file mode 100644 index 120e8b6da26..00000000000 --- a/discovery/src/test/resources/discovery/v1/test-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "watson_developer_cloud_config" -} diff --git a/discovery/src/test/resources/discovery/v1/token_dict_status_resp.json b/discovery/src/test/resources/discovery/v1/token_dict_status_resp.json deleted file mode 100644 index d6555602405..00000000000 --- a/discovery/src/test/resources/discovery/v1/token_dict_status_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status" : "active", - "type" : "tokenization_dictionary" -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/token_dict_status_resp_stopwords.json b/discovery/src/test/resources/discovery/v1/token_dict_status_resp_stopwords.json deleted file mode 100644 index 1d08a5d7605..00000000000 --- a/discovery/src/test/resources/discovery/v1/token_dict_status_resp_stopwords.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status" : "active", - "type" : "stopwords" -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v1/update_conf_resp.json b/discovery/src/test/resources/discovery/v1/update_conf_resp.json deleted file mode 100644 index 97ea6fdfb57..00000000000 --- a/discovery/src/test/resources/discovery/v1/update_conf_resp.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "name": "new-config", - "description": "this is an updated configuration", - "conversions": { - "word": { - "heading": { - "fonts": [ - { - "level": 1, - "min_size": 24, - "bold": false, - "italic": false - }, - { - "level": 2, - "min_size": 18, - "max_size": 23, - "bold": true, - "italic": false - }, - { - "level": 3, - "min_size": 14, - "max_size": 17, - "bold": false, - "italic": false - }, - { - "level": 4, - "min_size": 13, - "max_size": 13, - "bold": true, - "italic": false - } - ], - "styles": [ - { - "level": 1, - "names": [ - "pullout heading", - "pulloutheading", - "header" - ] - }, - { - "level": 2, - "names": [ - "subtitle" - ] - } - ] - } - }, - "pdf": { - "heading": { - "fonts": [ - { - "level": 1, - "min_size": 24, - "max_size": 80 - }, - { - "level": 2, - "min_size": 18, - "max_size": 24, - "bold": false, - "italic": false - }, - { - "level": 2, - "min_size": 18, - "max_size": 24, - "bold": true - }, - { - "level": 3, - "min_size": 13, - "max_size": 18, - "bold": false, - "italic": false - }, - { - "level": 3, - "min_size": 13, - "max_size": 18, - "bold": true - }, - { - "level": 4, - "min_size": 11, - "max_size": 13, - "bold": false, - "italic": false - } - ] - } - }, - "html": { - "exclude_tags_completely": [ - "script", - "sup" - ], - "exclude_tags_keep_content": [ - "font", - "em", - "span" - ], - "exclude_content": { - "xpaths": [] - }, - "keep_content": { - "xpaths": [] - }, - "exclude_tag_attributes": [ - "EVENT_ACTIONS" - ] - }, - "json_normalizations": [] - }, - "enrichments": [ - { - "destination_field": "enriched_text", - "source_field": "text", - "enrichment": "alchemy_language", - "options": { - "extract": [ - "keyword", - "entity", - "doc-sentiment", - "taxonomy", - "concept", - "relation" - ], - "sentiment": true, - "quotations": true - } - } - ] -} diff --git a/discovery/src/test/resources/discovery/v1/update_doc_resp.json b/discovery/src/test/resources/discovery/v1/update_doc_resp.json deleted file mode 100644 index bd8a195c28c..00000000000 --- a/discovery/src/test/resources/discovery/v1/update_doc_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "document_id": "8691f0dd-7181-45b7-81de-5cb16206b3a1", - "status": "available" -} diff --git a/discovery/src/test/resources/discovery/v1/update_env_resp.json b/discovery/src/test/resources/discovery/v1/update_env_resp.json deleted file mode 100644 index 7a7f7e9c186..00000000000 --- a/discovery/src/test/resources/discovery/v1/update_env_resp.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "environment_id": "9e21069a-8bc1-475e-a1d3-2121c49ef060", - "name": "Andrea_environment", - "description": "Dev environment for Andrea", - "created": "2016-12-13T17:42:23.067Z", - "updated": "2016-12-14T08:22:05.231Z", - "status": "available", - "index_capacity": { - "disk_usage": { - "used_bytes": 0, - "total_bytes": 1073741824, - "used": "0 KB", - "total": "1024 MB", - "percent_used": 0 - }, - "memory_usage": { - "used_bytes": 139035968, - "total_bytes": 518979584, - "used": "132.6 MB", - "total": "494.94 MB", - "percent_used": 26.79 - } - } -} diff --git a/discovery/src/test/resources/discovery/v1/update_training_example_resp.json b/discovery/src/test/resources/discovery/v1/update_training_example_resp.json deleted file mode 100644 index 68a65bd2934..00000000000 --- a/discovery/src/test/resources/discovery/v1/update_training_example_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "document_id": "mock_docid", - "relevance": 100 -} \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v2/classification_training.csv b/discovery/src/test/resources/discovery/v2/classification_training.csv new file mode 100644 index 00000000000..5046e9f09ae --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/classification_training.csv @@ -0,0 +1,31 @@ +claim_id,date,claim_product_line,claim_product,client_segment,client_location,client_sex,client_age,body,label_answer +0,2016/1/1,Tea,lemon tea,Not Member,Manhattan,Male,20,The straw was peeled off from the juice pack.,package_container +1,2016/1/2,Ice cream,vanilla ice cream,Silver Card Member,Queens,Female,20,"I got some ice cream for my children, but there was something like a piece of thread inside the cup.",contamination_tampering +2,2016/1/2,Jelly,apple jelly,Silver Card Member,Brooklyn,Male,40,I could only find 11 cups in the 12-pack.,amount.shortage +3,2016/1/2,Juice,orange juice,Silver Card Member,Bronx,Female,50,There was a stain on the package that seemed to be caused by a leak. Is it safe to drink?,package_container.leak +4,2016/1/3,Chocolate,milk chocolate,Silver Card Member,Manhattan,Male,30,I love the ads for the new milk chocolate. Could you tell me the name of the actor in the commercial?,ads +5,2016/1/3,Ice cream,vanilla ice cream,Silver Card Member,Bronx,Female,20,The cup looked like it was already opened. Is it safe?,prank +6,2016/1/3,Ice cream,chocolate ice cream,Silver Card Member,Manhattan,Male,40,It was a little more sour than when I ate it before.,other +7,2016/1/4,Jelly,mint jelly,Golden Card Member,Queens,Female,20, I could only find 10 cups in the dozen pack.,amount.shortage +8,2016/1/4,Juice,orange juice,Golden Card Member,Brooklyn,Male,20,Leaking (from the hole for the straw),package_container +9,2016/1/5,Pastry,pastry,Silver Card Member,Queens,Female,30,"It is before the expiration date, but the pastry was moldy. Isn't this a problem?",change_of_properties +10,2016/1/5,Muffin,muffin,Silver Card Member,Manhattan,Male,30,"I bought muffins for my children, but when I checked carefully, the bag looked like it was already opened.",prank +11,2016/1/7,Ice cream,vanilla ice cream,Not Member,Bronx,Female,40,"The expiration date for the ice cream was passed, but is it okay to eat?",expiration_date +12,2016/1/7,Chocolate,chocolate,Silver Card Member,Manhattan,Male,50,"In a dozen-pack of chocolate, I could only find 9 pieces.",amount.shortage +13,2016/1/8,Ice cream,vanilla ice cream,Silver Card Member,Queens,Female,60,"I frequently buy vanilla ice cream from ABCDE confectionery company, but this time there were one cup missing from the half dozen pack.",amount.shortage +14,2016/1/8,Ice cream,chocolate ice cream,Silver Card Member,Brooklyn,Male,70,The inside of the cup was dirty.,package_container.dirt +15,2016/1/8,Minerals,minerals,Silver Card Member,Bronx,Female,40,Don't you think the bottle is bigger than it needs to be? It seems like such a waste.,package_container +16,2016/1/8,Pastry,pastry,Silver Card Member,Manhattan,Male,20,"I bought pastry at my local store yesterday, but it tasted sour. The date hasn't expired yet.",other +17,2016/1/9,Jelly,mint jelly,Silver Card Member,Bronx,Female,50,I frequently buy jelly made by ABCDE confectionery company. Could you please tell me what additives you are using?,ingredient.additives +18,2016/1/10,Juice,orange juice,Golden Card Member,Manhattan,Male,30,I found a dark clump in the bottle.,package_container +19,2016/1/10,Chocolate,chocolate muffin,Golden Card Member,Queens,Female,30,The bag was already torn. Is it okay to eat?,package_container.torn +20,2016/1/10,Jelly,mint jelly,Silver Card Member,Brooklyn,Male,40,I felt that there was a sour taste. Is it just me?,other +21,2016/1/11,Jelly,mint jelly,Silver Card Member,Bronx,Female,50,"I bought some mint jelly, but it was empty inside.",amount.empty +22,2016/1/11,Ice cream,chocolate ice cream,Not Member,Manhattan,Male,50,I have a milk allergy. Is this safe to eat?,ingredient.allergy +23,2016/1/11,Pastry,pastry,Silver Card Member,Bronx,Female,60,Do you use soy beans as an ingredient?,other +24,2016/1/11,Jelly,mint jelly,Silver Card Member,Manhattan,Male,60,There were only 10 cups in the dozen pack.,amount.shortage +25,2016/1/11,Juice,orange juice,Silver Card Member,Queens,Female,20,Orange juice leaked from the top.,package_container.leak +26,2016/1/11,Minerals,minerals,Silver Card Member,Brooklyn,Male,20, I wish that you could see through the bottle to know how much is left.,package_container +27,2016/1/12,Minerals,minerals,Silver Card Member,Bronx,Female,50,I can't open up the bottle since the cap is on too tight.,package_container +28,2016/1/12,Jelly,mint jelly,Silver Card Member,Manhattan,Male,60,"I bought jelly yesterday, but it had a sour odor. Should I bring it back to the store?",other +29,2016/1/13,Ice cream,vanilla ice cream,Golden Card Member,Manhattan,Female,70,Is this safe to eat? My wife is allergic to milk.,ingredient.allergy \ No newline at end of file diff --git a/discovery/src/test/resources/discovery/v2/test.csv b/discovery/src/test/resources/discovery/v2/test.csv new file mode 100644 index 00000000000..dc7d5a85f17 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/test.csv @@ -0,0 +1,3 @@ +engine,gasket,carburetor,piston,valves +racing,stock,open,indy,drag +flag,checkered,green,caution,yellow,red \ No newline at end of file diff --git a/docker/pom.xml b/docker/pom.xml index 100f31dd9ec..a63603eac15 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -17,7 +17,7 @@ com.ibm.watson ibm-watson - 8.3.1 + 16.2.0 diff --git a/examples/README.md b/examples/README.md index ca086f32ef3..20eaac5b8f8 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,4 +6,4 @@ This example shows you how to use the Java SDK. To run the example you need to install the dependencies - $ gradle assemble + $ mvn install diff --git a/examples/build.gradle b/examples/build.gradle deleted file mode 100644 index 7bb82dfd8e2..00000000000 --- a/examples/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url = "https://repo.maven.apache.org/maven2" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') -} - -dependencies { - compile 'com.ibm.watson:ibm-watson:8.3.1' -} diff --git a/examples/pom.xml b/examples/pom.xml new file mode 100644 index 00000000000..5c03eb8d8ff --- /dev/null +++ b/examples/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + com.ibm.watson + examples + 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + + com.ibm.watson + ibm-watson + 9.3.0 + + + \ No newline at end of file diff --git a/examples/src/main/java/com/ibm/watson/assistant/v1/AssistantExample.java b/examples/src/main/java/com/ibm/watson/assistant/v1/AssistantExample.java index baeaa869ef8..bc80ca4330a 100644 --- a/examples/src/main/java/com/ibm/watson/assistant/v1/AssistantExample.java +++ b/examples/src/main/java/com/ibm/watson/assistant/v1/AssistantExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2021. * * 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 @@ -12,22 +12,20 @@ */ package com.ibm.watson.assistant.v1; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.http.ServiceCallback; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.assistant.v1.model.InputData; +import com.ibm.watson.assistant.v1.model.MessageInput; import com.ibm.watson.assistant.v1.model.MessageOptions; import com.ibm.watson.assistant.v1.model.MessageResponse; -import com.ibm.watson.assistant.v1.model.OutputData; -import com.ibm.cloud.sdk.core.http.Response; -import com.ibm.cloud.sdk.core.http.ServiceCallback; -import com.ibm.cloud.sdk.core.service.security.IamOptions; import io.reactivex.Single; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; /** - * Example of how to call the Assisant message method synchronously, - * asynchronously, and using RxJava. + * Example of how to call the Assisant message method synchronously, asynchronously, and using + * RxJava. * * @version v1-experimental */ @@ -39,38 +37,39 @@ public static void main(String[] args) throws Exception { MessageInput input = new MessageInput(); input.setText("Hi"); - MessageOptions options = new MessageOptions.Builder("") - .input(input) - .build(); + MessageOptions options = new MessageOptions.Builder("").input(input).build(); // sync MessageResponse response = service.message(options).execute().getResult(); System.out.println(response); // async - service.message(options).enqueue(new ServiceCallback() { - @Override - public void onResponse(Response response) { - System.out.println(response.getResult()); - } + service + .message(options) + .enqueue( + new ServiceCallback() { + @Override + public void onResponse(Response response) { + System.out.println(response.getResult()); + } - @Override - public void onFailure(Exception e) { - } - }); + @Override + public void onFailure(Exception e) {} + }); // RxJava - Single> observableRequest = service.message(options).reactiveRequest(); + Single> observableRequest = + service.message(options).reactiveRequest(); observableRequest .subscribeOn(Schedulers.single()) - .subscribe(new Consumer>() { - @Override - public void accept(Response response) throws Exception { - System.out.println(response.getResult()); - } - }); + .subscribe( + new Consumer>() { + @Override + public void accept(Response response) throws Exception { + System.out.println(response.getResult()); + } + }); Thread.sleep(5000); } - } diff --git a/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/AssistantToneAnalyzerIntegrationExample.java b/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/AssistantToneAnalyzerIntegrationExample.java deleted file mode 100644 index 2df66034e25..00000000000 --- a/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/AssistantToneAnalyzerIntegrationExample.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.assistant.v1.tone_analyzer_integration; - -import java.util.HashMap; -import java.util.Map; - -import com.ibm.watson.assistant.v1.Assistant; -import com.ibm.watson.assistant.v1.model.Context; -import com.ibm.watson.assistant.v1.model.InputData; -import com.ibm.watson.assistant.v1.model.MessageOptions; -import com.ibm.watson.assistant.v1.model.MessageResponse; -import com.ibm.watson.tone_analyzer.v3.ToneAnalyzer; -import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.tone_analyzer.v3.model.ToneOptions; -import com.ibm.cloud.sdk.core.http.Response; -import com.ibm.cloud.sdk.core.http.ServiceCallback; - -/** - * Example of how to integrate the Watson Assistant and Tone Analyzer services. - */ -public class AssistantToneAnalyzerIntegrationExample { - - public static void main(String[] args) throws Exception { - - // instantiate the assistant service - Authenticator assistantAuthenticator = new IamAuthenticator(""); - Assistant assistantService = new Assistant("2019-02-28", assistantAuthenticator); - - // instantiate the tone analyzer service - Authenticator toneAuthenticator = new IamAuthenticator(""); - ToneAnalyzer toneService = new ToneAnalyzer("2017-09-21", toneAuthenticator); - - // workspace id - String workspaceId = ""; - - // maintain history in the context variable - will add a history variable to - // each of the emotion, social - // and language tones - boolean maintainHistory = false; - - /** - * Input for the Assistant service: text (String): an input string (the user's conversation turn) and context - * (Context): any context that needs to be maintained - either added by the client app or passed in the - * response from the Assistant service on the previous conversation turn. - */ - String text = "I am happy"; - Context context = null; - - // UPDATE CONTEXT HERE IF CONTINUING AN ONGOING CONVERSATION - // set local context variable to the context from the last response from the - // Assistant Service - // (see the getContext() method of the MessageResponse class in - // com.ibm.watson.developer_cloud.assistant.v1.model) - - // async call to Tone Analyzer - ToneOptions toneOptions = new ToneOptions.Builder() - .text(input) - .build(); - toneService.tone(toneOptions).enqueue(new ServiceCallback() { - @Override - public void onResponse(Response toneResponsePayload) { - - // update context with the tone data returned by the Tone Analyzer - context = ToneDetection.updateUserTone(context, toneResponsePayload.getResult(), maintainHistory); - - // create input for message - MessageInput input = new MessageInput(); - input.setText(text); - - // call Assistant Service with the input and tone-aware context - MessageOptions messageOptions = new MessageOptions.Builder(workspaceId) - .input(input) - .context(context) - .build(); - assistantService.message(messageOptions).enqueue(new ServiceCallback() { - @Override - public void onResponse(Response response) { - System.out.println(response.getResult()); - } - - @Override - public void onFailure(Exception e) { - } - }); - } - - @Override - public void onFailure(Exception e) { - } - }); - } -} diff --git a/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java b/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java deleted file mode 100644 index 475a0586183..00000000000 --- a/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.assistant.v1.tone_analyzer_integration; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.tone_analyzer.v3.model.ToneCategory; -import com.ibm.watson.tone_analyzer.v3.model.ToneScore; - -/** - * ToneDetection. - */ -public class ToneDetection { - - /** - * Thresholds for identifying meaningful tones returned by the Watson Tone Analyzer. Current values are based on the - * recommendations made by the Watson Tone Analyzer at - * https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe These thresholds can be - * adjusted to client/domain requirements. - */ - private static final Double PRIMARY_EMOTION_SCORE_THRESHOLD = 0.5; - private static final Double LANGUAGE_HIGH_SCORE_THRESHOLD = 0.75; - private static final Double LANGUAGE_NO_SCORE_THRESHOLD = 0.0; - private static final Double SOCIAL_HIGH_SCORE_THRESHOLD = 0.75; - private static final Double SOCIAL_LOW_SCORE_THRESHOLD = 0.25; - - /** - * Instantiates a new tone detection. - */ - private ToneDetection() { - } - - /** - * Labels for the tone categories returned by the Watson Tone Analyzer. - */ - private static final String EMOTION_TONE_LABEL = "emotion_tone"; - private static final String LANGUAGE_TONE_LABEL = "language_tone"; - private static final String SOCIAL_TONE_LABEL = "social_tone"; - - /** - * updateUserTone processes the Tone Analyzer payload to pull out the emotion, language and social tones, and identify - * the meaningful tones (i.e., those tones that meet the specified thresholds). The assistantPayload json object is - * updated to include these tones. - * - * @param context the context - * @param toneAnalyzerPayload json object returned by the Watson Tone Analyzer Service - * @param maintainHistory the maintain history - * @return the map - * @returns assistantPayload where the user object has been updated with tone information from the - * toneAnalyzerPayload - */ - public static Map updateUserTone(Context context, ToneAnalysis toneAnalyzerPayload, - boolean maintainHistory) { - - List emotionTone = new ArrayList(); - List languageTone = new ArrayList(); - List socialTone = new ArrayList(); - - // If the context doesn't already contain the user object, initialize it - if (context.containsKey("user") != null) { - context.put("user", initUser()); - } - - // For convenience sake, define a variable for the user object to - @SuppressWarnings("unchecked") - Map user = (Map) context.get("user"); - - if (toneAnalyzerPayload != null && toneAnalyzerPayload.getDocumentTone() != null) { - List tones = toneAnalyzerPayload.getDocumentTone().getToneCategories(); - for (ToneCategory tone : tones) { - if (tone.getCategoryId().equals(EMOTION_TONE_LABEL)) { - emotionTone = tone.getTones(); - } - if (tone.getCategoryId().equals(LANGUAGE_TONE_LABEL)) { - languageTone = tone.getTones(); - } - if (tone.getCategoryId().equals(SOCIAL_TONE_LABEL)) { - socialTone = tone.getTones(); - } - } - - updateEmotionTone(user, emotionTone, maintainHistory); - updateLanguageTone(user, languageTone, maintainHistory); - updateSocialTone(user, socialTone, maintainHistory); - - } - - context.put("user", user); - return user; - } - - /** - * initUser initializes a user containing tone data (from the Watson Tone Analyzer). - * - * @return the map - * @returns user with the emotion, language and social tones. The current tone identifies the tone for a specific - * conversation turn, and the history provides the conversation for all tones up to the current tone for - * an assistant instance with a user. - */ - public static Map initUser() { - - Map user = new HashMap(); - Map tone = new HashMap(); - - Map emotionTone = new HashMap(); - emotionTone.put("current", null); - - Map socialTone = new HashMap(); - socialTone.put("current", null); - - Map languageTone = new HashMap(); - languageTone.put("current", null); - - tone.put("emotion", emotionTone); - tone.put("social", socialTone); - tone.put("language", languageTone); - - user.put("tone", tone); - - return user; - } - - /** - * updateEmotionTone updates the user emotion tone with the primary emotion - the emotion tone that has a score - * greater than or equal to the EMOTION_SCORE_THRESHOLD; otherwise primary emotion will be 'neutral'. - * - * @param user a json object representing user information (tone) to be used in conversing with the Assistant - * Service - * @param emotionTone a json object containing the emotion tones in the payload returned by the Tone Analyzer - */ - @SuppressWarnings("unchecked") - private static void updateEmotionTone(Map user, List emotionTone, - boolean maintainHistory) { - - Double maxScore = 0.0; - String primaryEmotion = null; - Double primaryEmotionScore = null; - - for (ToneScore tone : emotionTone) { - if (tone.getScore() > maxScore) { - maxScore = tone.getScore(); - primaryEmotion = tone.getToneName().toLowerCase(); - primaryEmotionScore = tone.getScore(); - } - } - - if (maxScore <= PRIMARY_EMOTION_SCORE_THRESHOLD) { - primaryEmotion = "neutral"; - primaryEmotionScore = null; - } - - // update user emotion tone - Map emotion = (Map) ((Map) (user.get("tone"))).get("emotion"); - emotion.put("current", primaryEmotion); - - if (maintainHistory) { - List> history = new ArrayList>(); - if (emotion.get("history") != null) { - history = (List>) emotion.get("history"); - } - - Map emotionHistoryObject = new HashMap(); - emotionHistoryObject.put("tone_name", primaryEmotion); - emotionHistoryObject.put("score", primaryEmotionScore); - history.add(emotionHistoryObject); - - emotion.put("history", history); - } - } - - /** - * updateLanguageTone updates the user with the language tones interpreted based on the specified thresholds. - * - * @param user a json object representing user information (tone) to be used in conversing with the Assistant - * Service - * @param languageTone a json object containing the language tones in the payload returned by the Tone Analyzer - */ - @SuppressWarnings("unchecked") - private static void updateLanguageTone(Map user, List languageTone, - boolean maintainHistory) { - - List currentLanguage = new ArrayList(); - Map currentLanguageObject = new HashMap(); - - // Process each language tone and determine if it is high or low - for (ToneScore tone : languageTone) { - if (tone.getScore() >= LANGUAGE_HIGH_SCORE_THRESHOLD) { - currentLanguage.add(tone.getToneName().toLowerCase() + "_high"); - currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase()); - currentLanguageObject.put("score", tone.getScore()); - currentLanguageObject.put("interpretation", "likely high"); - } else if (tone.getScore() <= LANGUAGE_NO_SCORE_THRESHOLD) { - currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase()); - currentLanguageObject.put("score", tone.getScore()); - currentLanguageObject.put("interpretation", "no evidence"); - } else { - currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase()); - currentLanguageObject.put("score", tone.getScore()); - currentLanguageObject.put("interpretation", "likely medium"); - } - } - - // update user language tone - Map language = (Map) ((Map) user.get("tone")).get("language"); - - // the current language pulled from tone - language.put("current", currentLanguage); - - // if history needs to be maintained - if (maintainHistory) { - List> history = new ArrayList>(); - if (language.get("history") != null) { - history = (List>) language.get("history"); - } - history.add(currentLanguageObject); - language.put("history", history); - } - } - - /** - * updateSocialTone updates the user with the social tones interpreted based on the specified thresholds. - * - * @param user a json object representing user information (tone) to be used in conversing with the Assistant - * Service - * @param socialTone a json object containing the social tones in the payload returned by the Tone Analyzer - * @param maintainHistory the maintain history - */ - @SuppressWarnings("unchecked") - public static void updateSocialTone(Map user, List socialTone, boolean maintainHistory) { - - List currentSocial = new ArrayList(); - Map currentSocialObject = new HashMap(); - - for (ToneScore tone : socialTone) { - if (tone.getScore() >= SOCIAL_HIGH_SCORE_THRESHOLD) { - currentSocial.add(tone.getToneName().toLowerCase() + "_high"); - currentSocialObject.put("tone_name", tone.getToneName().toLowerCase()); - currentSocialObject.put("score", tone.getScore()); - currentSocialObject.put("interpretation", "likely high"); - } else if (tone.getScore() <= SOCIAL_LOW_SCORE_THRESHOLD) { - currentSocial.add(tone.getToneName().toLowerCase() + "_low"); - currentSocialObject.put("tone_name", tone.getToneName().toLowerCase()); - currentSocialObject.put("score", tone.getScore()); - currentSocialObject.put("interpretation", "likely low"); - } else { - currentSocialObject.put("tone_name", tone.getToneName().toLowerCase()); - currentSocialObject.put("score", tone.getScore()); - currentSocialObject.put("interpretation", "likely medium"); - } - } - - // update user language tone - Map social = (Map) ((Map) user.get("tone")).get("social"); - social.put("current", currentSocial); - - // if history needs to be maintained - if (maintainHistory) { - List> history = new ArrayList>(); - if (social.get("history") != null) { - history = (List>) social.get("history"); - } - history.add(currentSocialObject); - social.put("history", history); - } - } -} diff --git a/examples/src/main/java/com/ibm/watson/discovery/v1/DiscoveryQueryExample.java b/examples/src/main/java/com/ibm/watson/discovery/v1/DiscoveryQueryExample.java index 3ed04f1e2da..efb7746e98d 100644 --- a/examples/src/main/java/com/ibm/watson/discovery/v1/DiscoveryQueryExample.java +++ b/examples/src/main/java/com/ibm/watson/discovery/v1/DiscoveryQueryExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2022. * * 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 @@ -12,8 +12,9 @@ */ package com.ibm.watson.discovery.v1; -import java.io.ByteArrayInputStream; -import java.io.InputStream; +import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.discovery.v1.model.AddDocumentOptions; import com.ibm.watson.discovery.v1.model.Collection; import com.ibm.watson.discovery.v1.model.Configuration; @@ -32,13 +33,10 @@ import com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse; import com.ibm.watson.discovery.v1.model.QueryOptions; import com.ibm.watson.discovery.v1.model.QueryResponse; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; +import java.io.ByteArrayInputStream; +import java.io.InputStream; -/** - * End-to-end example for querying Discovery. - */ +/** End-to-end example for querying Discovery. */ public class DiscoveryQueryExample { private static final String DEFAULT_CONFIG_NAME = "Default Configuration"; @@ -51,12 +49,13 @@ public static void main(String[] args) { String collectionId = null; String documentId = null; - //See if an environment already exists + // See if an environment already exists System.out.println("Check if environment exists"); ListEnvironmentsOptions listOptions = new ListEnvironmentsOptions.Builder().build(); - ListEnvironmentsResponse listResponse = discovery.listEnvironments(listOptions).execute().getResult(); + ListEnvironmentsResponse listResponse = + discovery.listEnvironments(listOptions).execute().getResult(); for (Environment environment : listResponse.getEnvironments()) { - //look for an existing environment that isn't read only + // look for an existing environment that isn't read only if (!environment.isReadOnly()) { environmentId = environment.getEnvironmentId(); System.out.println("Found existing environment ID: " + environmentId); @@ -66,22 +65,25 @@ public static void main(String[] args) { if (environmentId == null) { System.out.println("No environment found, creating new one..."); - //no environment found, create a new one (assuming we are a FREE plan) + // no environment found, create a new one (assuming we are a FREE plan) String environmentName = "watson_developer_cloud_test_environment"; - CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder() - .name(environmentName) - .size(0L) /* FREE */ - .build(); + CreateEnvironmentOptions createOptions = + new CreateEnvironmentOptions.Builder() + .name(environmentName) + .size(String.valueOf(0L)) /* FREE */ + .build(); Environment createResponse = discovery.createEnvironment(createOptions).execute().getResult(); environmentId = createResponse.getEnvironmentId(); System.out.println("Created new environment ID: " + environmentId); - //wait for environment to be ready + // wait for environment to be ready System.out.println("Waiting for environment to be ready..."); boolean environmentReady = false; while (!environmentReady) { - GetEnvironmentOptions getEnvironmentOptions = new GetEnvironmentOptions.Builder(environmentId).build(); - Environment getEnvironmentResponse = discovery.getEnvironment(getEnvironmentOptions).execute().getResult(); + GetEnvironmentOptions getEnvironmentOptions = + new GetEnvironmentOptions.Builder(environmentId).build(); + Environment getEnvironmentResponse = + discovery.getEnvironment(getEnvironmentOptions).execute().getResult(); environmentReady = getEnvironmentResponse.getStatus().equals(Environment.Status.ACTIVE); try { if (!environmentReady) { @@ -94,35 +96,40 @@ public static void main(String[] args) { System.out.println("Environment Ready!"); } - //find the default configuration + // find the default configuration System.out.println("Finding the default configuration"); - ListConfigurationsOptions listConfigsOptions = new ListConfigurationsOptions.Builder(environmentId).build(); - ListConfigurationsResponse listConfigsResponse = discovery.listConfigurations(listConfigsOptions).execute() - .getResult(); + ListConfigurationsOptions listConfigsOptions = + new ListConfigurationsOptions.Builder(environmentId).build(); + ListConfigurationsResponse listConfigsResponse = + discovery.listConfigurations(listConfigsOptions).execute().getResult(); for (Configuration configuration : listConfigsResponse.getConfigurations()) { - if (configuration.getName().equals(DEFAULT_CONFIG_NAME)) { - configurationId = configuration.getConfigurationId(); + if (configuration.name().equals(DEFAULT_CONFIG_NAME)) { + configurationId = configuration.configurationId(); System.out.println("Found default configuration ID: " + configurationId); break; } } - //create a new collection + // create a new collection System.out.println("Creating a new collection..."); String collectionName = "my_watson_developer_cloud_collection"; - CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder(environmentId, collectionName) - .configurationId(configurationId) - .build(); - Collection collection = discovery.createCollection(createCollectionOptions).execute().getResult(); + CreateCollectionOptions createCollectionOptions = + new CreateCollectionOptions.Builder(environmentId, collectionName) + .configurationId(configurationId) + .build(); + Collection collection = + discovery.createCollection(createCollectionOptions).execute().getResult(); collectionId = collection.getCollectionId(); System.out.println("Created a collection ID: " + collectionId); - //wait for the collection to be "available" + // wait for the collection to be "available" System.out.println("Waiting for collection to be ready..."); boolean collectionReady = false; while (!collectionReady) { - GetCollectionOptions getCollectionOptions = new GetCollectionOptions.Builder(environmentId, collectionId).build(); - Collection getCollectionResponse = discovery.getCollection(getCollectionOptions).execute().getResult(); + GetCollectionOptions getCollectionOptions = + new GetCollectionOptions.Builder(environmentId, collectionId).build(); + Collection getCollectionResponse = + discovery.getCollection(getCollectionOptions).execute().getResult(); collectionReady = getCollectionResponse.getStatus().equals(Collection.Status.ACTIVE); try { if (!collectionReady) { @@ -134,25 +141,27 @@ public static void main(String[] args) { } System.out.println("Collection Ready!"); - //add a document + // add a document System.out.println("Creating a new document..."); String documentJson = "{\"field\":\"value\"}"; InputStream documentStream = new ByteArrayInputStream(documentJson.getBytes()); - AddDocumentOptions.Builder createDocumentBuilder = new AddDocumentOptions.Builder(environmentId, collectionId); + AddDocumentOptions.Builder createDocumentBuilder = + new AddDocumentOptions.Builder(environmentId, collectionId); createDocumentBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - DocumentAccepted createDocumentResponse = discovery.addDocument(createDocumentBuilder.build()).execute() - .getResult(); + DocumentAccepted createDocumentResponse = + discovery.addDocument(createDocumentBuilder.build()).execute().getResult(); documentId = createDocumentResponse.getDocumentId(); System.out.println("Created a document ID: " + documentId); - //wait for document to be ready + // wait for document to be ready System.out.println("Waiting for document to be ready..."); boolean documentReady = false; while (!documentReady) { - GetDocumentStatusOptions getDocumentStatusOptions = new GetDocumentStatusOptions.Builder(environmentId, - collectionId, documentId).build(); - DocumentStatus getDocumentResponse = discovery.getDocumentStatus(getDocumentStatusOptions).execute().getResult(); + GetDocumentStatusOptions getDocumentStatusOptions = + new GetDocumentStatusOptions.Builder(environmentId, collectionId, documentId).build(); + DocumentStatus getDocumentResponse = + discovery.getDocumentStatus(getDocumentStatusOptions).execute().getResult(); documentReady = !getDocumentResponse.getStatus().equals(DocumentStatus.Status.PROCESSING); try { if (!documentReady) { @@ -164,19 +173,20 @@ public static void main(String[] args) { } System.out.println("Document Ready!"); - //query document + // query document System.out.println("Querying the collection..."); QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); queryBuilder.query("field:value"); QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute().getResult(); - //print out the results + // print out the results System.out.println("Query Results:"); System.out.println(queryResponse); - //cleanup the collection created + // cleanup the collection created System.out.println("Deleting the collection..."); - DeleteCollectionOptions deleteOptions = new DeleteCollectionOptions.Builder(environmentId, collectionId).build(); + DeleteCollectionOptions deleteOptions = + new DeleteCollectionOptions.Builder(environmentId, collectionId).build(); discovery.deleteCollection(deleteOptions).execute(); System.out.println("Collection deleted!"); diff --git a/examples/src/main/java/com/ibm/watson/discovery/v2/DiscoveryV2Example.java b/examples/src/main/java/com/ibm/watson/discovery/v2/DiscoveryV2Example.java index 989c79b195e..2c0ec9d8eec 100644 --- a/examples/src/main/java/com/ibm/watson/discovery/v2/DiscoveryV2Example.java +++ b/examples/src/main/java/com/ibm/watson/discovery/v2/DiscoveryV2Example.java @@ -1,13 +1,13 @@ +package com.ibm.watson.discovery.v2; + import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator; -import com.ibm.watson.discovery.v2.Discovery; import com.ibm.watson.discovery.v2.model.AddDocumentOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentOptions; import com.ibm.watson.discovery.v2.model.DocumentAccepted; import com.ibm.watson.discovery.v2.model.QueryOptions; import com.ibm.watson.discovery.v2.model.QueryResponse; import com.ibm.watson.discovery.v2.model.QueryResult; - import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -19,30 +19,35 @@ public static void main(String[] args) throws IOException { Discovery service = new Discovery("2019-11-22", authenticator); service.setServiceUrl("{url}"); - // This example assumes you have a project and collection set up which can accept documents. Paste those + // This example assumes you have a project and collection set up which can accept documents. + // Paste those // IDs below. String projectId = ""; String collectionId = ""; // Add a new document to our collection. Fill in the file path with the file you want to send. InputStream file = new FileInputStream(""); - AddDocumentOptions addDocumentOptions = new AddDocumentOptions.Builder() - .projectId(projectId) - .collectionId(collectionId) - .file(file) - .filename("example-file") - //.fileContentType(HttpMediaType.APPLICATION_PDF) // Fill in the content type of your chosen file here! - .build(); + AddDocumentOptions addDocumentOptions = + new AddDocumentOptions.Builder() + .projectId(projectId) + .collectionId(collectionId) + .file(file) + .filename("example-file") + // .fileContentType(HttpMediaType.APPLICATION_PDF) // Fill in the content type of your + // chosen file here! + .build(); DocumentAccepted addResponse = service.addDocument(addDocumentOptions).execute().getResult(); String documentId = addResponse.getDocumentId(); // Query your collection with the new document inside. - QueryOptions queryOptoins = new QueryOptions.Builder() - .projectId(projectId) - .addCollectionIds(collectionId) - .naturalLanguageQuery("Watson") // Feel free to replace this to query something different. - .build(); - QueryResponse queryResponse = service.query(options).execute().getResult(); + QueryOptions queryOptions = + new QueryOptions.Builder() + .projectId(projectId) + .addCollectionIds(collectionId) + .naturalLanguageQuery( + "Watson") // Feel free to replace this to query something different. + .build(); + QueryResponse queryResponse = service.query(queryOptions).execute().getResult(); System.out.println(queryResponse.getMatchingResults() + " results were returned by the query!"); @@ -54,11 +59,12 @@ public static void main(String[] args) throws IOException { } // Delete our uploaded document from the collection. - DeleteDocumentOptions deleteDocumentOptions = new DeleteDocumentOptions.Builder() - .projectId(projectId) - .collectionId(collectionId) - .documentId(documentId) - .build(); + DeleteDocumentOptions deleteDocumentOptions = + new DeleteDocumentOptions.Builder() + .projectId(projectId) + .collectionId(collectionId) + .documentId(documentId) + .build(); service.deleteDocument(deleteDocumentOptions).execute(); } } diff --git a/examples/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslatorExample.java b/examples/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslatorExample.java index aab17dd28b6..8f6268688f2 100644 --- a/examples/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslatorExample.java +++ b/examples/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslatorExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2021. * * 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 @@ -16,24 +16,18 @@ import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.language_translator.v3.model.TranslateOptions; import com.ibm.watson.language_translator.v3.model.TranslationResult; -import com.ibm.watson.language_translator.v3.util.Language; -/** - * Example of how to translate a sentence from English to Spanish. - */ +/** Example of how to translate a sentence from English to Spanish. */ public class LanguageTranslatorExample { public static void main(String[] args) { Authenticator authenticator = new IamAuthenticator(""); LanguageTranslator service = new LanguageTranslator("2018-05-01", authenticator); - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText(text) - .modelId("en-es") - .build(); + TranslateOptions translateOptions = + new TranslateOptions.Builder().addText("text").modelId("en-es").build(); TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); System.out.println(translationResult); } - } diff --git a/examples/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierExample.java b/examples/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierExample.java deleted file mode 100644 index f12977e93cd..00000000000 --- a/examples/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierExample.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (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.natural_language_classifier.v1; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.natural_language_classifier.v1.model.Classification; - -public class NaturalLanguageClassifierExample { - - public static void main(String[] args) { - Authenticator authenticator = new IamAuthenticator(""); - NaturalLanguageClassifier service = new NaturalLanguageClassifier(authenticator); - - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId("") - .text("Is it sunny?") - .build(); - Classification classification = service.classify(classifyOptions).execute().getResult(); - - System.out.println(classification); - } - -} diff --git a/examples/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsExample.java b/examples/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsExample.java deleted file mode 100644 index cf637927b3c..00000000000 --- a/examples/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsExample.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (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.personality_insights.v3; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.personality_insights.v3.model.Profile; -import com.ibm.watson.personality_insights.v3.model.ProfileOptions; - -public class PersonalityInsightsExample { - - public static void main(String[] args) { - Authenticator authenticator = new IamAuthenticator(""); - PersonalityInsights service = new PersonalityInsights("2017-10-13", authenticator); - - String text = "Call me Ishmael. Some years ago-never mind how long " - + "precisely-having little or no money in my purse, and nothing " - + "particular to interest me on shore, I thought I would sail about " - + "a little and see the watery part of the world. It is a way " - + "I have of driving off the spleen and regulating the circulation. " - + "Whenever I find myself growing grim about the mouth; whenever it " - + "is a damp, drizzly November in my soul; whenever I find myself " - + "involuntarily pausing before coffin warehouses, and bringing up " - + "the rear of every funeral I meet; and especially whenever my " - + "hypos get such an upper hand of me, that it requires a strong " - + "moral principle to prevent me from deliberately stepping into " - + "the street, and methodically knocking people's hats off-then, " - + "I account it high time to get to sea as soon as I can."; - - ProfileOptions options = new ProfileOptions.Builder() - .text(text) - .build(); - Profile profile = service.profile(options).execute().getResult(); - - System.out.println(profile); - } -} diff --git a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/CustomizationExample.java b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/CustomizationExample.java index 65cec647469..c58afd5724c 100755 --- a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/CustomizationExample.java +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/CustomizationExample.java @@ -13,6 +13,8 @@ package com.ibm.watson.speech_to_text.v1; import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.speech_to_text.v1.model.AddCorpusOptions; import com.ibm.watson.speech_to_text.v1.model.AddWordOptions; import com.ibm.watson.speech_to_text.v1.model.Corpora; @@ -28,19 +30,16 @@ import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; import com.ibm.watson.speech_to_text.v1.model.TrainLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.Words; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; - import java.io.File; import java.io.FileNotFoundException; -/** - * Example of how to create and use a custom language model. - */ +/** Example of how to create and use a custom language model. */ public class CustomizationExample { - private static final String AUDIO_FILE = "speech-to-text/src/test/resources/speech_to_text/cap047.wav"; - private static final String CORPUS_FILE = "speech-to-text/src/test/resources/speech_to_text/corpus1.txt"; + private static final String AUDIO_FILE = + "speech-to-text/src/test/resources/speech_to_text/cap047.wav"; + private static final String CORPUS_FILE = + "speech-to-text/src/test/resources/speech_to_text/corpus1.txt"; /** * The main method. @@ -53,38 +52,44 @@ public static void main(String[] args) throws InterruptedException, FileNotFound SpeechToText service = new SpeechToText(authenticator); // Create language model - CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder() - .name("IEEE-permanent") - .baseModelName("en-US_BroadbandModel") - .description("My customization") - .build(); + CreateLanguageModelOptions createOptions = + new CreateLanguageModelOptions.Builder() + .name("IEEE-permanent") + .baseModelName("en-US_BroadbandModel") + .description("My customization") + .build(); LanguageModel myModel = service.createLanguageModel(createOptions).execute().getResult(); String id = myModel.getCustomizationId(); try { // Add a corpus file to the model - AddCorpusOptions addOptions = new AddCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .corpusFile(new File(CORPUS_FILE)) - .allowOverwrite(false) - .build(); + AddCorpusOptions addOptions = + new AddCorpusOptions.Builder() + .customizationId(id) + .corpusName("corpus-1") + .corpusFile(new File(CORPUS_FILE)) + .allowOverwrite(false) + .build(); service.addCorpus(addOptions).execute().getResult(); // Get corpus status - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .build(); - for (int x = 0; x < 30 && !service.getCorpus(getOptions).execute().getResult().getStatus().equals( - Corpus.Status.ANALYZED); x++) { + GetCorpusOptions getOptions = + new GetCorpusOptions.Builder().customizationId(id).corpusName("corpus-1").build(); + for (int x = 0; + x < 30 + && !service + .getCorpus(getOptions) + .execute() + .getResult() + .getStatus() + .equals(Corpus.Status.ANALYZED); + x++) { Thread.sleep(5000); } // Get all corpora - ListCorporaOptions listCorporaOptions = new ListCorporaOptions.Builder() - .customizationId(id) - .build(); + ListCorporaOptions listCorporaOptions = + new ListCorporaOptions.Builder().customizationId(id).build(); Corpora corpora = service.listCorpora(listCorporaOptions).execute().getResult(); System.out.println(corpora); @@ -93,85 +98,93 @@ public static void main(String[] args) throws InterruptedException, FileNotFound System.out.println(corpus); // Now add some user words to the custom model - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("IEEE") - .word("IEEE") - .displayAs("IEEE") - .addSoundsLike("I. triple E.") - .build()).execute(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("hhonors") - .word("hhonors") - .displayAs("IEEE") - .addSoundsLike("H. honors") - .addSoundsLike("Hilton honors") - .build()).execute(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("IEEE") + .word("IEEE") + .displayAs("IEEE") + .addSoundsLike("I. triple E.") + .build()) + .execute(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("hhonors") + .word("hhonors") + .displayAs("IEEE") + .addSoundsLike("H. honors") + .addSoundsLike("Hilton honors") + .build()) + .execute(); // Display all words in the words resource (OOVs from the corpus and // new words just added) in ascending alphabetical order - ListWordsOptions listWordsAlphabeticalOptions = new ListWordsOptions.Builder() - .customizationId(id) - .wordType(ListWordsOptions.WordType.ALL) - .build(); + ListWordsOptions listWordsAlphabeticalOptions = + new ListWordsOptions.Builder() + .customizationId(id) + .wordType(ListWordsOptions.WordType.ALL) + .build(); Words words = service.listWords(listWordsAlphabeticalOptions).execute().getResult(); System.out.println("\nASCENDING ALPHABETICAL ORDER:"); System.out.println(words); // Then display all words in the words resource in descending order // by count - ListWordsOptions listWordsCountOptions = new ListWordsOptions.Builder() - .customizationId(id) - .wordType(ListWordsOptions.WordType.ALL) - .sort("-" + ListWordsOptions.Sort.COUNT) - .build(); + ListWordsOptions listWordsCountOptions = + new ListWordsOptions.Builder() + .customizationId(id) + .wordType(ListWordsOptions.WordType.ALL) + .sort("-" + ListWordsOptions.Sort.COUNT) + .build(); words = service.listWords(listWordsCountOptions).execute().getResult(); System.out.println("\nDESCENDING ORDER BY COUNT:"); System.out.println(words); // Now start training of the model - TrainLanguageModelOptions trainOptions = new TrainLanguageModelOptions.Builder() - .customizationId(id) - .wordTypeToAdd(TrainLanguageModelOptions.WordTypeToAdd.ALL) - .build(); + TrainLanguageModelOptions trainOptions = + new TrainLanguageModelOptions.Builder() + .customizationId(id) + .wordTypeToAdd(TrainLanguageModelOptions.WordTypeToAdd.ALL) + .build(); service.trainLanguageModel(trainOptions).execute(); for (int x = 0; x < 30 && !myModel.getStatus().equals(LanguageModel.Status.AVAILABLE); x++) { - GetLanguageModelOptions getLanguageModelOptions = new GetLanguageModelOptions.Builder() - .customizationId(id) - .build(); + GetLanguageModelOptions getLanguageModelOptions = + new GetLanguageModelOptions.Builder().customizationId(id).build(); myModel = service.getLanguageModel(getLanguageModelOptions).execute().getResult(); Thread.sleep(10000); } File audio = new File(AUDIO_FILE); - RecognizeOptions recognizeOptionsWithModel = new RecognizeOptions.Builder() - .model(RecognizeOptions.Model.EN_US_BROADBANDMODEL) - .customizationId(id) - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); - RecognizeOptions recognizeOptionsWithoutModel = new RecognizeOptions.Builder() - .model(RecognizeOptions.Model.EN_US_BROADBANDMODEL) - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); + RecognizeOptions recognizeOptionsWithModel = + new RecognizeOptions.Builder() + .model(RecognizeOptions.Model.EN_US_BROADBANDMODEL) + .customizationId(id) + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .build(); + RecognizeOptions recognizeOptionsWithoutModel = + new RecognizeOptions.Builder() + .model(RecognizeOptions.Model.EN_US_BROADBANDMODEL) + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .build(); // First decode WITHOUT the custom model - SpeechRecognitionResults transcript = service.recognize(recognizeOptionsWithoutModel).execute().getResult(); + SpeechRecognitionResults transcript = + service.recognize(recognizeOptionsWithoutModel).execute().getResult(); System.out.println(transcript); // Now decode with the custom model transcript = service.recognize(recognizeOptionsWithModel).execute().getResult(); System.out.println(transcript); } finally { - DeleteLanguageModelOptions deleteOptions = new DeleteLanguageModelOptions.Builder() - .customizationId(id) - .build(); + DeleteLanguageModelOptions deleteOptions = + new DeleteLanguageModelOptions.Builder().customizationId(id).build(); service.deleteLanguageModel(deleteOptions).execute(); } - } - } diff --git a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/MicrophoneWithWebSocketsExample.java b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/MicrophoneWithWebSocketsExample.java index 8bbbfdd6db6..d0abae02a50 100644 --- a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/MicrophoneWithWebSocketsExample.java +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/MicrophoneWithWebSocketsExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -12,22 +12,19 @@ */ package com.ibm.watson.speech_to_text.v1; +import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.IamAuthenticator; +import com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions; +import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; +import com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.TargetDataLine; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback; - -/** - * Recognize microphone input speech continuously using WebSockets. - */ +/** Recognize microphone input speech continuously using WebSockets. */ public class MicrophoneWithWebSocketsExample { /** @@ -56,21 +53,24 @@ public static void main(final String[] args) throws Exception { AudioInputStream audio = new AudioInputStream(line); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .interimResults(true) - .timestamps(true) - .wordConfidence(true) - //.inactivityTimeout(5) // use this to stop listening when the speaker pauses, i.e. for 5s - .contentType(HttpMediaType.AUDIO_RAW + ";rate=" + sampleRate) - .build(); + RecognizeWithWebsocketsOptions options = + new RecognizeWithWebsocketsOptions.Builder() + .audio(audio) + .timestamps(true) + .wordConfidence(true) + // .inactivityTimeout(5) // use this to stop listening when the speaker pauses, i.e. for + // 5s + .contentType(HttpMediaType.AUDIO_RAW + ";rate=" + sampleRate) + .build(); - service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - System.out.println(speechResults); - } - }); + service.recognizeUsingWebSocket( + options, + new BaseRecognizeCallback() { + @Override + public void onTranscription(SpeechRecognitionResults speechResults) { + System.out.println(speechResults); + } + }); System.out.println("Listening to your voice for the next 30s..."); Thread.sleep(30 * 1000); diff --git a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsExample.java b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsExample.java index 0329cd14003..1c1ad4301ed 100644 --- a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsExample.java +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -12,17 +12,16 @@ */ package com.ibm.watson.speech_to_text.v1; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; +import com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; import com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /** * Recognize using WebSockets a sample wav file and print the transcript into the console output. @@ -36,23 +35,25 @@ public static void main(String[] args) throws FileNotFoundException, Interrupted FileInputStream audio = new FileInputStream("src/test/resources/speech_to_text/sample1.wav"); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .interimResults(true) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); - - service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - System.out.println(speechResults); - } - - @Override - public void onDisconnected() { - lock.countDown(); - } - }); + RecognizeWithWebsocketsOptions options = + new RecognizeWithWebsocketsOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .build(); + + service.recognizeUsingWebSocket( + options, + new BaseRecognizeCallback() { + @Override + public void onTranscription(SpeechRecognitionResults speechResults) { + System.out.println(speechResults); + } + + @Override + public void onDisconnected() { + lock.countDown(); + } + }); lock.await(1, TimeUnit.MINUTES); } diff --git a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java index 9dfc091e28e..11065523135 100644 --- a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -12,18 +12,18 @@ */ package com.ibm.watson.speech_to_text.v1; -import com.ibm.cloud.sdk.core.util.GsonSingleton; import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; +import com.ibm.cloud.sdk.core.util.GsonSingleton; import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; +import com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions; import com.ibm.watson.speech_to_text.v1.model.SpeakerLabelsResult; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionAlternative; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResult; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; import com.ibm.watson.speech_to_text.v1.model.SpeechTimestamp; import com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback; - import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; @@ -84,9 +84,7 @@ public void updateFrom(SpeakerLabelsResult speakerLabel) { } } - /** - * The Class Utterance. - */ + /** The Class Utterance. */ public static class Utterance { private Integer speaker; private String transcript = ""; @@ -103,16 +101,12 @@ public Utterance(final Integer speaker, final String transcript) { } } - /** - * The Class RecoTokens. - */ + /** The Class RecoTokens. */ public static class RecoTokens { private Map recoTokenMap; - /** - * Instantiates a new reco tokens. - */ + /** Instantiates a new reco tokens. */ public RecoTokens() { recoTokenMap = new LinkedHashMap(); } @@ -126,7 +120,7 @@ public void add(SpeechRecognitionResults speechResults) { if (speechResults.getResults() != null) for (int i = 0; i < speechResults.getResults().size(); i++) { SpeechRecognitionResult transcript = speechResults.getResults().get(i); - if (transcript.isFinalResults()) { + if (transcript.isXFinal()) { SpeechRecognitionAlternative speechAlternative = transcript.getAlternatives().get(0); for (int ts = 0; ts < speechAlternative.getTimestamps().size(); ts++) { @@ -139,7 +133,6 @@ public void add(SpeechRecognitionResults speechResults) { for (int i = 0; i < speechResults.getSpeakerLabels().size(); i++) { add(speechResults.getSpeakerLabels().get(i)); } - } /** @@ -171,7 +164,7 @@ public void add(SpeakerLabelsResult speakerLabel) { recoToken.updateFrom(speakerLabel); } - if (speakerLabel.isFinalResults()) { + if (speakerLabel.isXFinal()) { markTokensBeforeAsFinal(speakerLabel.getFrom()); report(); cleanFinal(); @@ -182,14 +175,11 @@ private void markTokensBeforeAsFinal(Float from) { Map recoTokenMap = new LinkedHashMap<>(); for (RecoToken rt : recoTokenMap.values()) { - if (rt.startTime <= from) - rt.spLabelIsFinal = true; + if (rt.startTime <= from) rt.spLabelIsFinal = true; } } - /** - * Report. - */ + /** Report. */ public void report() { List uttterances = new ArrayList(); Utterance currentUtterance = new Utterance(0, ""); @@ -215,7 +205,6 @@ private void cleanFinal() { } } } - } private static CountDownLatch lock = new CountDownLatch(1); @@ -228,33 +217,35 @@ private void cleanFinal() { * @throws InterruptedException the interrupted exception */ public static void main(String[] args) throws FileNotFoundException, InterruptedException { - FileInputStream audio = new FileInputStream("src/test/resources/speech_to_text/twospeakers.wav"); + FileInputStream audio = + new FileInputStream("src/test/resources/speech_to_text/twospeakers.wav"); Authenticator authenticator = new IamAuthenticator(""); SpeechToText service = new SpeechToText(authenticator); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .interimResults(true) - .speakerLabels(true) - .model(RecognizeOptions.Model.EN_US_NARROWBANDMODEL) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); + RecognizeWithWebsocketsOptions options = + new RecognizeWithWebsocketsOptions.Builder() + .audio(audio) + .speakerLabels(true) + .model(RecognizeOptions.Model.EN_US_NARROWBANDMODEL) + .contentType(HttpMediaType.AUDIO_WAV) + .build(); RecoTokens recoTokens = new RecoTokens(); - service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - recoTokens.add(speechResults); - } + service.recognizeUsingWebSocket( + options, + new BaseRecognizeCallback() { + @Override + public void onTranscription(SpeechRecognitionResults speechResults) { + recoTokens.add(speechResults); + } - @Override - public void onDisconnected() { - lock.countDown(); - } - }); + @Override + public void onDisconnected() { + lock.countDown(); + } + }); lock.await(1, TimeUnit.MINUTES); } - } diff --git a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToTextExample.java b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToTextExample.java index 6e1866dc495..04d5f07b71c 100644 --- a/examples/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToTextExample.java +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToTextExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2022. * * 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 @@ -12,17 +12,17 @@ */ package com.ibm.watson.speech_to_text.v1; -import java.io.File; -import java.io.FileNotFoundException; - +import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; +import java.io.File; +import java.io.FileNotFoundException; /** - * Recognize a sample wav file and print the transcript into the console output. Make sure you are using UTF-8 to print - * messages; otherwise, you will see question marks. + * Recognize a sample wav file and print the transcript into the console output. Make sure you are + * using UTF-8 to print messages; otherwise, you will see question marks. */ public class SpeechToTextExample { @@ -31,10 +31,8 @@ public static void main(String[] args) throws FileNotFoundException { SpeechToText service = new SpeechToText(authenticator); File audio = new File("src/test/resources/speech_to_text/sample1.wav"); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .contentType(RecognizeOptions.ContentType.AUDIO_WAV) - .build(); + RecognizeOptions options = + new RecognizeOptions.Builder().audio(audio).contentType(HttpMediaType.AUDIO_WAV).build(); SpeechRecognitionResults transcript = service.recognize(options).execute().getResult(); System.out.println(transcript); diff --git a/examples/src/main/java/com/ibm/watson/text_to_speech/v1/CustomizationExample.java b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/CustomizationExample.java index 1e428310586..51c15cb580a 100755 --- a/examples/src/main/java/com/ibm/watson/text_to_speech/v1/CustomizationExample.java +++ b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/CustomizationExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2021. * * 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 @@ -12,25 +12,25 @@ */ package com.ibm.watson.text_to_speech.v1; +import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteVoiceModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CustomModel; +import com.ibm.watson.text_to_speech.v1.model.CustomModels; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.text_to_speech.v1.model.ListVoiceModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomModelsOptions; import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; import com.ibm.watson.text_to_speech.v1.model.Translation; -import com.ibm.watson.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.text_to_speech.v1.model.VoiceModels; +import com.ibm.watson.text_to_speech.v1.model.UpdateCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.Word; import com.ibm.watson.text_to_speech.v1.model.Words; import com.ibm.watson.text_to_speech.v1.util.WaveUtils; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -46,104 +46,107 @@ public static void main(String[] args) throws IOException { TextToSpeech service = new TextToSpeech(authenticator); // create custom voice model. - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name("my model") - .language("en-US") - .description("the model for testing") - .build(); - VoiceModel customVoiceModel = service.createVoiceModel(createOptions).execute().getResult(); + CreateCustomModelOptions createOptions = + new CreateCustomModelOptions.Builder() + .name("my model") + .language("en-US") + .description("the model for testing") + .build(); + CustomModel customVoiceModel = service.createCustomModel(createOptions).execute().getResult(); System.out.println(customVoiceModel); // list custom voice models for US English. - ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder() - .language("en-US") - .build(); - VoiceModels customVoiceModels = service.listVoiceModels(listOptions).execute().getResult(); + ListCustomModelsOptions listOptions = + new ListCustomModelsOptions.Builder().language("en-US").build(); + CustomModels customVoiceModels = service.listCustomModels(listOptions).execute().getResult(); System.out.println(customVoiceModels); // update custom voice model. String newName = "my updated model"; - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .name(newName) - .description("the updated model for testing") - .build(); - service.updateVoiceModel(updateOptions).execute(); + UpdateCustomModelOptions updateOptions = + new UpdateCustomModelOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .name(newName) + .description("the updated model for testing") + .build(); + service.updateCustomModel(updateOptions).execute(); // list custom voice models regardless of language. - customVoiceModels = service.listVoiceModels().execute().getResult(); + customVoiceModels = service.listCustomModels().execute().getResult(); System.out.println(customVoiceModels); // create multiple custom word translations - Word word1 = new Word.Builder() - .word("hodor") - .translation("hold the door") - .build(); - Word word2 = new Word.Builder() - .word("plz") - .translation("please") - .build(); + Word word1 = new Word.Builder().word("hodor").translation("hold the door").build(); + Word word2 = new Word.Builder().word("plz").translation("please").build(); List words = Arrays.asList(word1, word2); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .words(words) - .build(); + AddWordsOptions addOptions = + new AddWordsOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .words(words) + .build(); service.addWords(addOptions).execute(); // create a single custom word translation - AddWordOptions addWordOptions = new AddWordOptions.Builder() - .word("nat") - .translation("and that") - .customizationId(customVoiceModel.getCustomizationId()) - .build(); + AddWordOptions addWordOptions = + new AddWordOptions.Builder() + .word("nat") + .translation("and that") + .customizationId(customVoiceModel.getCustomizationId()) + .build(); service.addWord(addWordOptions).execute(); // get custom word translations - ListWordsOptions listWordsOptions = new ListWordsOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .build(); + ListWordsOptions listWordsOptions = + new ListWordsOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .build(); Words customWords = service.listWords(listWordsOptions).execute().getResult(); System.out.println(customWords); // get custom word translation - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .word("hodor") - .build(); + GetWordOptions getOptions = + new GetWordOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .word("hodor") + .build(); Translation translation = service.getWord(getOptions).execute().getResult(); System.out.println(translation); // synthesize with custom voice model String text = "plz hodor"; - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_MICHAELVOICE) - .accept(SynthesizeOptions.Accept.AUDIO_WAV) - .customizationId(customVoiceModel.getCustomizationId()) - .build(); + SynthesizeOptions synthesizeOptions = + new SynthesizeOptions.Builder() + .text(text) + .voice(SynthesizeOptions.Voice.EN_US_MICHAELVOICE) + .accept(HttpMediaType.AUDIO_WAV) + .customizationId(customVoiceModel.getCustomizationId()) + .build(); InputStream in = service.synthesize(synthesizeOptions).execute().getResult(); writeToFile(WaveUtils.reWriteWaveHeader(in), new File("output.wav")); // delete custom words with object and string - DeleteWordOptions deleteOptions1 = new DeleteWordOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .word(word1.getWord()) - .build(); + DeleteWordOptions deleteOptions1 = + new DeleteWordOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .word(word1.word()) + .build(); service.deleteWord(deleteOptions1).execute(); - DeleteWordOptions deleteOptions2 = new DeleteWordOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .word(word2.getWord()) - .build(); + DeleteWordOptions deleteOptions2 = + new DeleteWordOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .word(word2.word()) + .build(); service.deleteWord(deleteOptions2).execute(); // delete custom voice model - DeleteVoiceModelOptions deleteOptions = new DeleteVoiceModelOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .build(); - service.deleteVoiceModel(deleteOptions).execute(); + DeleteCustomModelOptions deleteOptions = + new DeleteCustomModelOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .build(); + service.deleteCustomModel(deleteOptions).execute(); // list custom voice models regardless of language. - customVoiceModels = service.listVoiceModels().execute().getResult(); + customVoiceModels = service.listCustomModels().execute().getResult(); System.out.println(customVoiceModels); } @@ -161,5 +164,4 @@ private static void writeToFile(InputStream in, File file) { e.printStackTrace(); } } - } diff --git a/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeechExample.java b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeechExample.java index 0fae24778d9..97adc0d5a4e 100644 --- a/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeechExample.java +++ b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeechExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -14,7 +14,7 @@ import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voices; +import com.ibm.watson.text_to_speech.v1.model.Voices; public class TextToSpeechExample { @@ -25,5 +25,4 @@ public static void main(String[] args) { Voices voices = service.listVoices().execute().getResult(); System.out.println(voices); } - } diff --git a/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java index 59843b61421..1a040ec319c 100644 --- a/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java +++ b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2021. * * 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 @@ -12,29 +12,27 @@ */ package com.ibm.watson.text_to_speech.v1; +import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.language_translator.v2.model.TranslationResult; -import com.ibm.watson.language_translator.v2.LanguageTranslator; -import com.ibm.watson.language_translator.v2.model.TranslateOptions; -import com.ibm.watson.language_translator.v2.util.Language; +import com.ibm.watson.language_translator.v3.LanguageTranslator; +import com.ibm.watson.language_translator.v3.model.TranslateOptions; +import com.ibm.watson.language_translator.v3.model.TranslationResult; +import com.ibm.watson.language_translator.v3.util.Language; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; import com.ibm.watson.text_to_speech.v1.util.WaveUtils; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -/** - * Translate from English to Spanish and synthesize that as a WAV file. - */ +/** Translate from English to Spanish and synthesize that as a WAV file. */ public class TranslateAndSynthesizeExample { public static void main(String[] args) throws IOException { Authenticator ltAuthenticator = new IamAuthenticator(""); - LanguageTranslator translator = new LanguageTranslator(ltAuthenticator); + LanguageTranslator translator = new LanguageTranslator("2019-11-22", ltAuthenticator); Authenticator ttsAuthenticator = new IamAuthenticator(""); TextToSpeech synthesizer = new TextToSpeech(ttsAuthenticator); @@ -42,27 +40,28 @@ public static void main(String[] args) throws IOException { String text = "Greetings from Watson Developer Cloud"; // translate - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText(text) - .source(Language.ENGLISH) - .target(Language.SPANISH) - .build(); - TranslationResult translationResult = translator.translate(translateOptions).execute().getResult(); + TranslateOptions translateOptions = + new TranslateOptions.Builder() + .addText(text) + .source(Language.ENGLISH) + .target(Language.SPANISH) + .build(); + TranslationResult translationResult = + translator.translate(translateOptions).execute().getResult(); String translation = translationResult.getTranslations().get(0).getTranslation(); // synthesize - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(translation) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(SynthesizeOptions.Accept.AUDIO_WAV) - .build(); + SynthesizeOptions synthesizeOptions = + new SynthesizeOptions.Builder() + .text(translation) + .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) + .accept(HttpMediaType.AUDIO_WAV) + .build(); InputStream in = synthesizer.synthesize(synthesizeOptions).execute().getResult(); writeToFile(WaveUtils.reWriteWaveHeader(in), new File("output.wav")); } - /** - * Write the input stream to a file. - */ + /** Write the input stream to a file. */ private static void writeToFile(InputStream in, File file) { try { OutputStream out = new FileOutputStream(file); diff --git a/examples/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerChatExample.java b/examples/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerChatExample.java deleted file mode 100644 index 85e6189e0e3..00000000000 --- a/examples/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerChatExample.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (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.tone_analyzer.v3; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.tone_analyzer.v3.model.Utterance; -import com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses; - -import java.util.ArrayList; -import java.util.List; - -public class ToneAnalyzerChatExample { - - public static void main(String[] args) { - Authenticator authenticator = new IamAuthenticator(""); - ToneAnalyzer service = new ToneAnalyzer("2017-09-21", authenticator); - - String[] texts = { - "My charger isn't working.", - "Thanks for reaching out. Can you give me some more detail about the issue?", - "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" - + " charging. The charging icon comes on, but it stays on even when I take the charger out. " - + "Which is ridiculous, it's brand new.", - "I'm sorry you're having issues with charging. What kind of charger are you using?" - }; - - List utterances = new ArrayList<>(); - for (int i = 0; i < texts.length; i++) { - Utterance utterance = new Utterance.Builder() - .text(texts[i]) - .build(); - utterances.add(utterance); - } - ToneChatOptions toneChatOptions = new ToneChatOptions.Builder() - .utterances(utterances) - .build(); - - // Call the service - UtteranceAnalyses utterancesTone = service.toneChat(toneChatOptions).execute().getResult(); - System.out.println(utterancesTone); - } -} diff --git a/examples/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerExample.java b/examples/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerExample.java deleted file mode 100644 index 2ec4c7452be..00000000000 --- a/examples/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerExample.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.tone_analyzer.v3; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.tone_analyzer.v3.model.ToneOptions; - -public class ToneAnalyzerExample { - - public static void main(String[] args) { - Authenticator authenticator = new IamAuthenticator(""); - ToneAnalyzer service = new ToneAnalyzer("2017-09-21", authenticator); - - String text = "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! " - + "We need to acknowledge and fix our sales challenges. " - + "We can’t blame the economy for our lack of execution! " + "We are missing critical sales opportunities. " - + "Our product is in no way inferior to the competitor products. " - + "Our clients are hungry for analytical tools to improve their " - + "business outcomes. Economy has nothing to do with it."; - - // Call the service and get the tone - ToneOptions toneOptions = new ToneOptions.Builder() - .text(text) - .build(); - ToneAnalysis tone = service.tone(toneOptions).execute().getResult(); - System.out.println(tone); - - } -} diff --git a/examples/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionExample.java b/examples/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionExample.java deleted file mode 100644 index 2b0799c4524..00000000000 --- a/examples/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionExample.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v3; - -import java.io.File; -import java.io.FileNotFoundException; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.visual_recognition.v3.model.Classifier; -import com.ibm.watson.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.UpdateClassifierOptions; - -public class VisualRecognitionExample { - - public static void main(String[] args) throws FileNotFoundException { - Authenticator authenticator = new IamAuthenticator(""); - VisualRecognition service = new VisualRecognition(VERSION, authenticator); - - System.out.println("Classify an image"); - ClassifyOptions options = new ClassifyOptions.Builder() - .imagesFile(new File("src/test/resources/visual_recognition/car.png")) - .imagesFilename("car.png") - .build(); - ClassifiedImages result = service.classify(options).execute().getResult(); - System.out.println(result); - - System.out.println("Create a classifier with positive and negative images"); - CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder() - .name("foo") - .addClass("car", new File("src/test/resources/visual_recognition/car_positive.zip")) - .addClass("baseball", new File("src/test/resources/visual_recognition/baseball_positive.zip")) - .negativeExamples(new File("src/test/resources/visual_recognition/negative.zip")) - .build(); - Classifier foo = service.createClassifier(createOptions).execute().getResult(); - System.out.println(foo); - - System.out.println("Classify using the 'Car' classifier"); - options = new ClassifyOptions.Builder() - .imagesFile(new File("src/test/resources/visual_recognition/car.png")) - .imagesFilename("car.png") - .addClassifierId(foo.getClassifierId()) - .build(); - result = service.classify(options).execute().getResult(); - System.out.println(result); - - System.out.println("Update a classifier with more positive images"); - UpdateClassifierOptions updateOptions = new UpdateClassifierOptions.Builder() - .classifierId(foo.getClassifierId()) - .addClass("car", new File("src/test/resources/visual_recognition/car_positive.zip")) - .build(); - Classifier updatedFoo = service.updateClassifier(updateOptions).execute().getResult(); - System.out.println(updatedFoo); - } -} diff --git a/examples/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionV4Example.java b/examples/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionV4Example.java deleted file mode 100644 index 3435b56249b..00000000000 --- a/examples/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionV4Example.java +++ /dev/null @@ -1,94 +0,0 @@ -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.visual_recognition.v4.VisualRecognition; -import com.ibm.watson.visual_recognition.v4.model.AddImageTrainingDataOptions; -import com.ibm.watson.visual_recognition.v4.model.AddImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeResponse; -import com.ibm.watson.visual_recognition.v4.model.BaseObject; -import com.ibm.watson.visual_recognition.v4.model.Collection; -import com.ibm.watson.visual_recognition.v4.model.CreateCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.GetCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.ImageDetailsList; -import com.ibm.watson.visual_recognition.v4.model.Location; -import com.ibm.watson.visual_recognition.v4.model.TrainOptions; - -public class VisualRecognitionExample { - - public static void main(String[] args) throws FileNotFoundException { - Authenticator authenticator = new IamAuthenticator("{iam_api_key}"); - VisualRecognition service = new VisualRecognition("2019-02-11", authenticator); - - // create a new collection - CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder() - .name("example-collection") - .build(); - Collection exampleCollection = service.createCollection(createCollectionOptions).execute().getResult(); - String exampleCollectionId = exampleCollection.getCollectionId(); - - // add some images to the new collection - AddImagesOptions addImagesOptions = new AddImagesOptions.Builder() - .addImagesFile("{zip_file_of_images}") - .collectionId(exampleCollectionId) - .build(); - ImageDetailsList imageDetailsList = service.addImages(addImagesOptions).execute().getResult(); - - // get image ID of one of your uploaded images for later - String imageId = imageDetailsList.getImages().get(0).getImageId(); - - // add some training data with the location of the object you want to identify - // replace these location values with something that makes sense for your image - Location location = new Location.Builder() - .top(0L) - .left(1L) - .width(2L) - .height(3L) - .build(); - BaseObject baseObject = new BaseObject.Builder() - .object("{training_object_name}") - .location(location) - .build(); - AddImageTrainingDataOptions addTrainingDataOptions = new AddImageTrainingDataOptions.Builder() - .collectionId(exampleCollectionId) - .addObjects(baseObject) - .imageId(imageId) - .build(); - service.addImageTrainingData(addTrainingDataOptions).execute(); - - // train the collection - TrainOptions trainOptions = new TrainOptions.Builder() - .collectionId(exampleCollectionId) - .build(); - service.train(trainOptions).execute().getResult(); - - // wait until the collection is trained to test it out - GetCollectionOptions getCollectionOptions = new GetCollectionOptions.Builder() - .collectionId(exampleCollectionId) - .build(); - Collection retrievedCollection = service.getCollection(getCollectionOptions).execute().getResult(); - while (!retrievedCollection.getTrainingStatus().objects().ready()) { - Thread.sleep(5000); - retrievedCollection = service.getCollection(getCollectionOptions).execute().getResult(); - } - - // analyze an image at a URL - String imageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/American_Eskimo_Dog" + - ".jpg/1280px-American_Eskimo_Dog.jpg" - AnalyzeOptions options = new AnalyzeOptions.Builder() - .addImageUrl(imageUrl) - .addColectionId(exampleCollectionId) - .addFeature(AnalyzeOptions.Features.OBJECTS) - .build(); - AnalyzeResponse response = service.analyze(options).execute().getResult(); - - // print out results! - System.out.println(response); - - // clean up collection - DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder() - .collectionId(exampleCollectionId) - .build(); - service.deleteCollection(deleteCollectionOptions).execute(); - } -} diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 430f3ea2b1a..00000000000 --- a/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -version=8.3.1 -group=com.ibm.watson - diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 0a377fa12ab..00000000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 8f1d143bbe3..00000000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Feb 19 12:15:28 EST 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-all.zip diff --git a/gradlew b/gradlew deleted file mode 100755 index cccdd3d517f..00000000000 --- a/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index f9553162f12..00000000000 --- a/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/ibm-watson/build.gradle b/ibm-watson/build.gradle deleted file mode 100644 index e5713257209..00000000000 --- a/ibm-watson/build.gradle +++ /dev/null @@ -1,104 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar - archives shadowJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyleTest { - ignoreFailures = false -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -task testJar(type: Jar) { - classifier = 'tests' - from sourceSets.test.output -} - -configurations { - tests -} - -artifacts { - tests testJar -} - -dependencies { - compile project(':assistant') - compile project(':common') - compile project(':compare-comply') - compile project(':discovery') - compile project(':language-translator') - compile project(':natural-language-classifier') - compile project(':natural-language-understanding') - compile project(':personality-insights') - compile project(':speech-to-text') - compile project(':text-to-speech') - compile project(':tone-analyzer') - compile project(':visual-recognition') - - signature 'org.codehaus.mojo.signature:java17:1.0@signature' - -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/ibm-watson/gradle.properties b/ibm-watson/gradle.properties deleted file mode 100644 index 1c7f02f4796..00000000000 --- a/ibm-watson/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:ibm-watson -ARTIFACT_ID=ibm-watson -NAME=IBM Watson Java SDK -DESCRIPTION=Java client library to use the IBM Watson APIs \ No newline at end of file diff --git a/ibm-watson/pom.xml b/ibm-watson/pom.xml new file mode 100644 index 00000000000..328f10acb34 --- /dev/null +++ b/ibm-watson/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + ibm-watson + jar + IBM Watson Java SDK + + Java client library to use the IBM Watson APIs + + + + com.ibm.watson + assistant + ${project.version} + compile + + + com.ibm.watson + common + ${project.version} + compile + + + com.ibm.watson + discovery + ${project.version} + compile + + + com.ibm.watson + natural-language-understanding + ${project.version} + compile + + + com.ibm.watson + speech-to-text + ${project.version} + compile + + + com.ibm.watson + text-to-speech + ${project.version} + compile + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + diff --git a/language-translator/README.md b/language-translator/README.md deleted file mode 100644 index f69bdd6d266..00000000000 --- a/language-translator/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Language Translator - -## Installation - -##### Maven - -```xml - - com.ibm.watson - language-translator - 8.3.1 - -``` - -##### Gradle - -```gradle -'com.ibm.watson:language-translator:8.3.1' -``` - -## Usage - -Select a domain, then identify or select the language of text, and then translate the text from one supported language to another. -Example: Translate 'hello' from English to Spanish using the [Language Translator][language_translator] service. - -```java -Authenticator authenticator = new IamAuthenticator(""); -LanguageTranslator service = new LanguageTranslator("2018-05-01", authenticator); - -TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello") - .source(Language.ENGLISH) - .target(Language.SPANISH) - .build(); -TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); - -System.out.println(translationResult); -``` - -[language_translator]: https://cloud.ibm.com/docs/language-translator?topic=language-translator-about diff --git a/language-translator/build.gradle b/language-translator/build.gradle deleted file mode 100644 index e63b7d64fa9..00000000000 --- a/language-translator/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/language-translator/gradle.properties b/language-translator/gradle.properties deleted file mode 100644 index b2c74ffc3a2..00000000000 --- a/language-translator/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:language-translator -ARTIFACT_ID=language-translator -NAME=IBM Watson Java SDK - Language Translator -DESCRIPTION=Java client library to use the IBM Language Translator API \ No newline at end of file diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java deleted file mode 100644 index 0c19006f7ec..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java +++ /dev/null @@ -1,540 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.language_translator.v3.model.CreateModelOptions; -import com.ibm.watson.language_translator.v3.model.DeleteDocumentOptions; -import com.ibm.watson.language_translator.v3.model.DeleteModelOptions; -import com.ibm.watson.language_translator.v3.model.DeleteModelResult; -import com.ibm.watson.language_translator.v3.model.DocumentList; -import com.ibm.watson.language_translator.v3.model.DocumentStatus; -import com.ibm.watson.language_translator.v3.model.GetDocumentStatusOptions; -import com.ibm.watson.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.language_translator.v3.model.GetTranslatedDocumentOptions; -import com.ibm.watson.language_translator.v3.model.IdentifiableLanguages; -import com.ibm.watson.language_translator.v3.model.IdentifiedLanguages; -import com.ibm.watson.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.language_translator.v3.model.ListDocumentsOptions; -import com.ibm.watson.language_translator.v3.model.ListIdentifiableLanguagesOptions; -import com.ibm.watson.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.language_translator.v3.model.TranslateDocumentOptions; -import com.ibm.watson.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.language_translator.v3.model.TranslationModel; -import com.ibm.watson.language_translator.v3.model.TranslationModels; -import com.ibm.watson.language_translator.v3.model.TranslationResult; -import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; -import okhttp3.MultipartBody; - -/** - * IBM Watson™ Language Translator translates text from one language to another. The service offers multiple IBM - * provided translation models that you can customize based on your unique terminology and language. Use Language - * Translator to take news from across the globe and present it in your language, communicate with your customers in - * their own language, and more. - * - * @version v3 - * @see Language Translator - */ -public class LanguageTranslator extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "language_translator"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/language-translator/api"; - - private String versionDate; - - /** - * Constructs a new `LanguageTranslator` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public LanguageTranslator(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `LanguageTranslator` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public LanguageTranslator(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `LanguageTranslator` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public LanguageTranslator(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `LanguageTranslator` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public LanguageTranslator(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Translate. - * - * Translates the input text from the source language to the target language. - * - * @param translateOptions the {@link TranslateOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationResult} - */ - public ServiceCall translate(TranslateOptions translateOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(translateOptions, - "translateOptions cannot be null"); - String[] pathSegments = { "v3/translate" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "translate"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.add("text", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(translateOptions.text())); - if (translateOptions.modelId() != null) { - contentJson.addProperty("model_id", translateOptions.modelId()); - } - if (translateOptions.source() != null) { - contentJson.addProperty("source", translateOptions.source()); - } - if (translateOptions.target() != null) { - contentJson.addProperty("target", translateOptions.target()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List identifiable languages. - * - * Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es` - * for Spanish) and name of each language. - * - * @param listIdentifiableLanguagesOptions the {@link ListIdentifiableLanguagesOptions} containing the options for the - * call - * @return a {@link ServiceCall} with a response type of {@link IdentifiableLanguages} - */ - public ServiceCall listIdentifiableLanguages( - ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) { - String[] pathSegments = { "v3/identifiable_languages" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listIdentifiableLanguages"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listIdentifiableLanguagesOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List identifiable languages. - * - * Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es` - * for Spanish) and name of each language. - * - * @return a {@link ServiceCall} with a response type of {@link IdentifiableLanguages} - */ - public ServiceCall listIdentifiableLanguages() { - return listIdentifiableLanguages(null); - } - - /** - * Identify language. - * - * Identifies the language of the input text. - * - * @param identifyOptions the {@link IdentifyOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IdentifiedLanguages} - */ - public ServiceCall identify(IdentifyOptions identifyOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(identifyOptions, - "identifyOptions cannot be null"); - String[] pathSegments = { "v3/identify" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "identify"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.bodyContent(identifyOptions.text(), "text/plain"); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List models. - * - * Lists available translation models. - * - * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationModels} - */ - public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = { "v3/models" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listModels"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listModelsOptions != null) { - if (listModelsOptions.source() != null) { - builder.query("source", listModelsOptions.source()); - } - if (listModelsOptions.target() != null) { - builder.query("target", listModelsOptions.target()); - } - if (listModelsOptions.xDefault() != null) { - builder.query("default", String.valueOf(listModelsOptions.xDefault())); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List models. - * - * Lists available translation models. - * - * @return a {@link ServiceCall} with a response type of {@link TranslationModels} - */ - public ServiceCall listModels() { - return listModels(null); - } - - /** - * Create model. - * - * Uploads Translation Memory eXchange (TMX) files to customize a translation model. - * - * You can either customize a model with a forced glossary or with a corpus that contains parallel sentences. To - * create a model that is customized with a parallel corpus and a forced glossary, proceed in two steps: - * customize with a parallel corpus first and then customize the resulting model with a glossary. Depending on the - * type of customization and the size of the uploaded corpora, training can range from minutes for a glossary to - * several hours for a large parallel corpus. You can upload a single forced glossary file and this file must be less - * than 10 MB. You can upload multiple parallel corpora tmx files. The cumulative file size of all uploaded - * files is limited to 250 MB. To successfully train with a parallel corpus you must have at least 5,000 - * parallel sentences in your corpus. - * - * You can have a maximum of 10 custom models per language pair. - * - * @param createModelOptions the {@link CreateModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationModel} - */ - public ServiceCall createModel(CreateModelOptions createModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createModelOptions, - "createModelOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((createModelOptions.forcedGlossary() != null) || (createModelOptions - .parallelCorpus() != null), "At least one of forcedGlossary or parallelCorpus must be supplied."); - String[] pathSegments = { "v3/models" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "createModel"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("base_model_id", createModelOptions.baseModelId()); - if (createModelOptions.name() != null) { - builder.query("name", createModelOptions.name()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (createModelOptions.forcedGlossary() != null) { - okhttp3.RequestBody forcedGlossaryBody = RequestUtils.inputStreamBody(createModelOptions.forcedGlossary(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("forced_glossary", "filename", forcedGlossaryBody); - } - if (createModelOptions.parallelCorpus() != null) { - okhttp3.RequestBody parallelCorpusBody = RequestUtils.inputStreamBody(createModelOptions.parallelCorpus(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("parallel_corpus", "filename", parallelCorpusBody); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete model. - * - * Deletes a custom translation model. - * - * @param deleteModelOptions the {@link DeleteModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteModelResult} - */ - public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteModelOptions, - "deleteModelOptions cannot be null"); - String[] pathSegments = { "v3/models" }; - String[] pathParameters = { deleteModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "deleteModel"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get model details. - * - * Gets information about a translation model, including training status for custom models. Use this API call to poll - * the status of your customization request. A successfully completed training will have a status of `available`. - * - * @param getModelOptions the {@link GetModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationModel} - */ - public ServiceCall getModel(GetModelOptions getModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getModelOptions, - "getModelOptions cannot be null"); - String[] pathSegments = { "v3/models" }; - String[] pathParameters = { getModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "getModel"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List documents. - * - * Lists documents that have been submitted for translation. - * - * @param listDocumentsOptions the {@link ListDocumentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentList} - */ - public ServiceCall listDocuments(ListDocumentsOptions listDocumentsOptions) { - String[] pathSegments = { "v3/documents" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listDocuments"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listDocumentsOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List documents. - * - * Lists documents that have been submitted for translation. - * - * @return a {@link ServiceCall} with a response type of {@link DocumentList} - */ - public ServiceCall listDocuments() { - return listDocuments(null); - } - - /** - * Translate document. - * - * Submit a document for translation. You can submit the document contents in the `file` parameter, or you can - * reference a previously submitted document by document ID. - * - * @param translateDocumentOptions the {@link TranslateDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentStatus} - */ - public ServiceCall translateDocument(TranslateDocumentOptions translateDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(translateDocumentOptions, - "translateDocumentOptions cannot be null"); - String[] pathSegments = { "v3/documents" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "translateDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody(translateDocumentOptions.file(), - translateDocumentOptions.fileContentType()); - multipartBuilder.addFormDataPart("file", translateDocumentOptions.filename(), fileBody); - if (translateDocumentOptions.modelId() != null) { - multipartBuilder.addFormDataPart("model_id", translateDocumentOptions.modelId()); - } - if (translateDocumentOptions.source() != null) { - multipartBuilder.addFormDataPart("source", translateDocumentOptions.source()); - } - if (translateDocumentOptions.target() != null) { - multipartBuilder.addFormDataPart("target", translateDocumentOptions.target()); - } - if (translateDocumentOptions.documentId() != null) { - multipartBuilder.addFormDataPart("document_id", translateDocumentOptions.documentId()); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get document status. - * - * Gets the translation status of a document. - * - * @param getDocumentStatusOptions the {@link GetDocumentStatusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentStatus} - */ - public ServiceCall getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentStatusOptions, - "getDocumentStatusOptions cannot be null"); - String[] pathSegments = { "v3/documents" }; - String[] pathParameters = { getDocumentStatusOptions.documentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "getDocumentStatus"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete document. - * - * Deletes a document. - * - * @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteDocument(DeleteDocumentOptions deleteDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDocumentOptions, - "deleteDocumentOptions cannot be null"); - String[] pathSegments = { "v3/documents" }; - String[] pathParameters = { deleteDocumentOptions.documentId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "deleteDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get translated document. - * - * Gets the translated document associated with the given document ID. - * - * @param getTranslatedDocumentOptions the {@link GetTranslatedDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} - */ - public ServiceCall getTranslatedDocument(GetTranslatedDocumentOptions getTranslatedDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getTranslatedDocumentOptions, - "getTranslatedDocumentOptions cannot be null"); - String[] pathSegments = { "v3/documents", "translated_document" }; - String[] pathParameters = { getTranslatedDocumentOptions.documentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "getTranslatedDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - if (getTranslatedDocumentOptions.accept() != null) { - builder.header("Accept", getTranslatedDocumentOptions.accept()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java deleted file mode 100644 index bc423624a9e..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.language_translator.v3.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 createModel options. - */ -public class CreateModelOptions extends GenericModel { - - protected String baseModelId; - protected InputStream forcedGlossary; - protected InputStream parallelCorpus; - protected String name; - - /** - * Builder. - */ - public static class Builder { - private String baseModelId; - private InputStream forcedGlossary; - private InputStream parallelCorpus; - private String name; - - private Builder(CreateModelOptions createModelOptions) { - this.baseModelId = createModelOptions.baseModelId; - this.forcedGlossary = createModelOptions.forcedGlossary; - this.parallelCorpus = createModelOptions.parallelCorpus; - this.name = createModelOptions.name; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param baseModelId the baseModelId - */ - public Builder(String baseModelId) { - this.baseModelId = baseModelId; - } - - /** - * Builds a CreateModelOptions. - * - * @return the createModelOptions - */ - public CreateModelOptions build() { - return new CreateModelOptions(this); - } - - /** - * Set the baseModelId. - * - * @param baseModelId the baseModelId - * @return the CreateModelOptions builder - */ - public Builder baseModelId(String baseModelId) { - this.baseModelId = baseModelId; - return this; - } - - /** - * Set the forcedGlossary. - * - * @param forcedGlossary the forcedGlossary - * @return the CreateModelOptions builder - */ - public Builder forcedGlossary(InputStream forcedGlossary) { - this.forcedGlossary = forcedGlossary; - return this; - } - - /** - * Set the parallelCorpus. - * - * @param parallelCorpus the parallelCorpus - * @return the CreateModelOptions builder - */ - public Builder parallelCorpus(InputStream parallelCorpus) { - this.parallelCorpus = parallelCorpus; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateModelOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the forcedGlossary. - * - * @param forcedGlossary the forcedGlossary - * @return the CreateModelOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder forcedGlossary(File forcedGlossary) throws FileNotFoundException { - this.forcedGlossary = new FileInputStream(forcedGlossary); - return this; - } - - /** - * Set the parallelCorpus. - * - * @param parallelCorpus the parallelCorpus - * @return the CreateModelOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder parallelCorpus(File parallelCorpus) throws FileNotFoundException { - this.parallelCorpus = new FileInputStream(parallelCorpus); - return this; - } - } - - protected CreateModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.baseModelId, - "baseModelId cannot be null"); - baseModelId = builder.baseModelId; - forcedGlossary = builder.forcedGlossary; - parallelCorpus = builder.parallelCorpus; - name = builder.name; - } - - /** - * New builder. - * - * @return a CreateModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the baseModelId. - * - * The model ID of the model to use as the base for customization. To see available models, use the `List models` - * method. Usually all IBM provided models are customizable. In addition, all your models that have been created via - * parallel corpus customization, can be further customized with a forced glossary. - * - * @return the baseModelId - */ - public String baseModelId() { - return baseModelId; - } - - /** - * Gets the forcedGlossary. - * - * A TMX file with your customizations. The customizations in the file completely overwrite the domain translaton - * data, including high frequency or high confidence phrase translations. You can upload only one glossary with a file - * size less than 10 MB per call. A forced glossary should contain single words or short phrases. - * - * @return the forcedGlossary - */ - public InputStream forcedGlossary() { - return forcedGlossary; - } - - /** - * Gets the parallelCorpus. - * - * A TMX file with parallel sentences for source and target language. You can upload multiple parallel_corpus files in - * one request. All uploaded parallel_corpus files combined, your parallel corpus must contain at least 5,000 parallel - * sentences to train successfully. - * - * @return the parallelCorpus - */ - public InputStream parallelCorpus() { - return parallelCorpus; - } - - /** - * Gets the name. - * - * An optional model name that you can use to identify the model. Valid characters are letters, numbers, dashes, - * underscores, spaces and apostrophes. The maximum length is 32 characters. - * - * @return the name - */ - public String name() { - return name; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java deleted file mode 100644 index cb2790fc104..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteDocument options. - */ -public class DeleteDocumentOptions extends GenericModel { - - protected String documentId; - - /** - * Builder. - */ - public static class Builder { - private String documentId; - - private Builder(DeleteDocumentOptions deleteDocumentOptions) { - this.documentId = deleteDocumentOptions.documentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param documentId the documentId - */ - public Builder(String documentId) { - this.documentId = documentId; - } - - /** - * Builds a DeleteDocumentOptions. - * - * @return the deleteDocumentOptions - */ - public DeleteDocumentOptions build() { - return new DeleteDocumentOptions(this); - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the DeleteDocumentOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - } - - protected DeleteDocumentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.documentId, - "documentId cannot be empty"); - documentId = builder.documentId; - } - - /** - * New builder. - * - * @return a DeleteDocumentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the documentId. - * - * Document ID of the document to delete. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java deleted file mode 100644 index 7fcc2deb623..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteModel options. - */ -public class DeleteModelOptions extends GenericModel { - - protected String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(DeleteModelOptions deleteModelOptions) { - this.modelId = deleteModelOptions.modelId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param modelId the modelId - */ - public Builder(String modelId) { - this.modelId = modelId; - } - - /** - * Builds a DeleteModelOptions. - * - * @return the deleteModelOptions - */ - public DeleteModelOptions build() { - return new DeleteModelOptions(this); - } - - /** - * Set the modelId. - * - * @param modelId the modelId - * @return the DeleteModelOptions builder - */ - public Builder modelId(String modelId) { - this.modelId = modelId; - return this; - } - } - - protected DeleteModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, - "modelId cannot be empty"); - modelId = builder.modelId; - } - - /** - * New builder. - * - * @return a DeleteModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the modelId. - * - * Model ID of the model to delete. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java deleted file mode 100644 index 2190c0c1cdb..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * DeleteModelResult. - */ -public class DeleteModelResult extends GenericModel { - - protected String status; - - /** - * Gets the status. - * - * "OK" indicates that the model was successfully deleted. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java deleted file mode 100644 index 7da0da94eea..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * DocumentList. - */ -public class DocumentList extends GenericModel { - - protected List documents; - - /** - * Gets the documents. - * - * An array of all previously submitted documents. - * - * @return the documents - */ - public List getDocuments() { - return documents; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java deleted file mode 100644 index 778acc17b83..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Document information, including translation status. - */ -public class DocumentStatus extends GenericModel { - - /** - * The status of the translation job associated with a submitted document. - */ - public interface Status { - /** processing. */ - String PROCESSING = "processing"; - /** available. */ - String AVAILABLE = "available"; - /** failed. */ - String FAILED = "failed"; - } - - @SerializedName("document_id") - protected String documentId; - protected String filename; - protected String status; - @SerializedName("model_id") - protected String modelId; - @SerializedName("base_model_id") - protected String baseModelId; - protected String source; - protected String target; - protected Date created; - protected Date completed; - @SerializedName("word_count") - protected Long wordCount; - @SerializedName("character_count") - protected Long characterCount; - - /** - * Gets the documentId. - * - * System generated ID identifying a document being translated using one specific translation model. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the filename. - * - * filename from the submission (if it was missing in the multipart-form, 'noname.' is - * used. - * - * @return the filename - */ - public String getFilename() { - return filename; - } - - /** - * Gets the status. - * - * The status of the translation job associated with a submitted document. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the modelId. - * - * A globally unique string that identifies the underlying model that is used for translation. - * - * @return the modelId - */ - public String getModelId() { - return modelId; - } - - /** - * Gets the baseModelId. - * - * Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be - * absent or an empty string. - * - * @return the baseModelId - */ - public String getBaseModelId() { - return baseModelId; - } - - /** - * Gets the source. - * - * Translation source language code. - * - * @return the source - */ - public String getSource() { - return source; - } - - /** - * Gets the target. - * - * Translation target language code. - * - * @return the target - */ - public String getTarget() { - return target; - } - - /** - * Gets the created. - * - * The time when the document was submitted. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the completed. - * - * The time when the translation completed. - * - * @return the completed - */ - public Date getCompleted() { - return completed; - } - - /** - * Gets the wordCount. - * - * An estimate of the number of words in the source document. Returned only if `status` is `available`. - * - * @return the wordCount - */ - public Long getWordCount() { - return wordCount; - } - - /** - * Gets the characterCount. - * - * The number of characters in the source document, present only if status=available. - * - * @return the characterCount - */ - public Long getCharacterCount() { - return characterCount; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java deleted file mode 100644 index 5c3f0c34855..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getDocumentStatus options. - */ -public class GetDocumentStatusOptions extends GenericModel { - - protected String documentId; - - /** - * Builder. - */ - public static class Builder { - private String documentId; - - private Builder(GetDocumentStatusOptions getDocumentStatusOptions) { - this.documentId = getDocumentStatusOptions.documentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param documentId the documentId - */ - public Builder(String documentId) { - this.documentId = documentId; - } - - /** - * Builds a GetDocumentStatusOptions. - * - * @return the getDocumentStatusOptions - */ - public GetDocumentStatusOptions build() { - return new GetDocumentStatusOptions(this); - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the GetDocumentStatusOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - } - - protected GetDocumentStatusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.documentId, - "documentId cannot be empty"); - documentId = builder.documentId; - } - - /** - * New builder. - * - * @return a GetDocumentStatusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the documentId. - * - * The document ID of the document. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java deleted file mode 100644 index 9c457cfe879..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getModel options. - */ -public class GetModelOptions extends GenericModel { - - protected String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(GetModelOptions getModelOptions) { - this.modelId = getModelOptions.modelId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param modelId the modelId - */ - public Builder(String modelId) { - this.modelId = modelId; - } - - /** - * Builds a GetModelOptions. - * - * @return the getModelOptions - */ - public GetModelOptions build() { - return new GetModelOptions(this); - } - - /** - * Set the modelId. - * - * @param modelId the modelId - * @return the GetModelOptions builder - */ - public Builder modelId(String modelId) { - this.modelId = modelId; - return this; - } - } - - protected GetModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, - "modelId cannot be empty"); - modelId = builder.modelId; - } - - /** - * New builder. - * - * @return a GetModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the modelId. - * - * Model ID of the model to get. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java deleted file mode 100644 index 51a2b42d855..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getTranslatedDocument options. - */ -public class GetTranslatedDocumentOptions extends GenericModel { - - protected String documentId; - protected String accept; - - /** - * Builder. - */ - public static class Builder { - private String documentId; - private String accept; - - private Builder(GetTranslatedDocumentOptions getTranslatedDocumentOptions) { - this.documentId = getTranslatedDocumentOptions.documentId; - this.accept = getTranslatedDocumentOptions.accept; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param documentId the documentId - */ - public Builder(String documentId) { - this.documentId = documentId; - } - - /** - * Builds a GetTranslatedDocumentOptions. - * - * @return the getTranslatedDocumentOptions - */ - public GetTranslatedDocumentOptions build() { - return new GetTranslatedDocumentOptions(this); - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the GetTranslatedDocumentOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - - /** - * Set the accept. - * - * @param accept the accept - * @return the GetTranslatedDocumentOptions builder - */ - public Builder accept(String accept) { - this.accept = accept; - return this; - } - } - - protected GetTranslatedDocumentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.documentId, - "documentId cannot be empty"); - documentId = builder.documentId; - accept = builder.accept; - } - - /** - * New builder. - * - * @return a GetTranslatedDocumentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the documentId. - * - * The document ID of the document that was submitted for translation. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } - - /** - * Gets the accept. - * - * The type of the response: application/powerpoint, application/mspowerpoint, application/x-rtf, application/json, - * application/xml, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, - * application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, - * application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, - * application/vnd.oasis.opendocument.spreadsheet, application/vnd.oasis.opendocument.presentation, - * application/vnd.oasis.opendocument.text, application/pdf, application/rtf, text/html, text/json, text/plain, - * text/richtext, text/rtf, or text/xml. A character encoding can be specified by including a `charset` parameter. For - * example, 'text/html;charset=utf-8'. - * - * @return the accept - */ - public String accept() { - return accept; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java deleted file mode 100644 index b88de80dbfd..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * IdentifiableLanguage. - */ -public class IdentifiableLanguage extends GenericModel { - - protected String language; - protected String name; - - /** - * Gets the language. - * - * The language code for an identifiable language. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the name. - * - * The name of the identifiable language. - * - * @return the name - */ - public String getName() { - return name; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java deleted file mode 100644 index 764a9c431da..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * IdentifiableLanguages. - */ -public class IdentifiableLanguages extends GenericModel { - - protected List languages; - - /** - * Gets the languages. - * - * A list of all languages that the service can identify. - * - * @return the languages - */ - public List getLanguages() { - return languages; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java deleted file mode 100644 index 5514424ee0a..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * IdentifiedLanguage. - */ -public class IdentifiedLanguage extends GenericModel { - - protected String language; - protected Double confidence; - - /** - * Gets the language. - * - * The language code for an identified language. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the confidence. - * - * The confidence score for the identified language. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java deleted file mode 100644 index aae1bf01926..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * IdentifiedLanguages. - */ -public class IdentifiedLanguages extends GenericModel { - - protected List languages; - - /** - * Gets the languages. - * - * A ranking of identified languages with confidence scores. - * - * @return the languages - */ - public List getLanguages() { - return languages; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java deleted file mode 100644 index f995fb78fd1..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The identify options. - */ -public class IdentifyOptions extends GenericModel { - - protected String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(IdentifyOptions identifyOptions) { - this.text = identifyOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param text the text - */ - public Builder(String text) { - this.text = text; - } - - /** - * Builds a IdentifyOptions. - * - * @return the identifyOptions - */ - public IdentifyOptions build() { - return new IdentifyOptions(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the IdentifyOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - protected IdentifyOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a IdentifyOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * Input text in UTF-8 format. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java deleted file mode 100644 index 4c13f4e44e7..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listDocuments options. - */ -public class ListDocumentsOptions extends GenericModel { - - /** - * Builder. - */ - public static class Builder { - - private Builder(ListDocumentsOptions listDocumentsOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListDocumentsOptions. - * - * @return the listDocumentsOptions - */ - public ListDocumentsOptions build() { - return new ListDocumentsOptions(this); - } - } - - private ListDocumentsOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListDocumentsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java deleted file mode 100644 index a445b7c4642..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listIdentifiableLanguages options. - */ -public class ListIdentifiableLanguagesOptions extends GenericModel { - - /** - * Builder. - */ - public static class Builder { - - private Builder(ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListIdentifiableLanguagesOptions. - * - * @return the listIdentifiableLanguagesOptions - */ - public ListIdentifiableLanguagesOptions build() { - return new ListIdentifiableLanguagesOptions(this); - } - } - - private ListIdentifiableLanguagesOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListIdentifiableLanguagesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java deleted file mode 100644 index de9aee0ea4a..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listModels options. - */ -public class ListModelsOptions extends GenericModel { - - protected String source; - protected String target; - protected Boolean xDefault; - - /** - * Builder. - */ - public static class Builder { - private String source; - private String target; - private Boolean xDefault; - - private Builder(ListModelsOptions listModelsOptions) { - this.source = listModelsOptions.source; - this.target = listModelsOptions.target; - this.xDefault = listModelsOptions.xDefault; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListModelsOptions. - * - * @return the listModelsOptions - */ - public ListModelsOptions build() { - return new ListModelsOptions(this); - } - - /** - * Set the source. - * - * @param source the source - * @return the ListModelsOptions builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the target. - * - * @param target the target - * @return the ListModelsOptions builder - */ - public Builder target(String target) { - this.target = target; - return this; - } - - /** - * Set the xDefault. - * - * @param xDefault the xDefault - * @return the ListModelsOptions builder - */ - public Builder xDefault(Boolean xDefault) { - this.xDefault = xDefault; - return this; - } - } - - protected ListModelsOptions(Builder builder) { - source = builder.source; - target = builder.target; - xDefault = builder.xDefault; - } - - /** - * New builder. - * - * @return a ListModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the source. - * - * Specify a language code to filter results by source language. - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the target. - * - * Specify a language code to filter results by target language. - * - * @return the target - */ - public String target() { - return target; - } - - /** - * Gets the xDefault. - * - * If the default parameter isn't specified, the service will return all models (default and non-default) for each - * language pair. To return only default models, set this to `true`. To return only non-default models, set this to - * `false`. There is exactly one default model per language pair, the IBM provided base model. - * - * @return the xDefault - */ - public Boolean xDefault() { - return xDefault; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java deleted file mode 100644 index 5b8c748b871..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.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 translateDocument options. - */ -public class TranslateDocumentOptions extends GenericModel { - - protected InputStream file; - protected String filename; - protected String fileContentType; - protected String modelId; - protected String source; - protected String target; - protected String documentId; - - /** - * Builder. - */ - public static class Builder { - private InputStream file; - private String filename; - private String fileContentType; - private String modelId; - private String source; - private String target; - private String documentId; - - private Builder(TranslateDocumentOptions translateDocumentOptions) { - this.file = translateDocumentOptions.file; - this.filename = translateDocumentOptions.filename; - this.fileContentType = translateDocumentOptions.fileContentType; - this.modelId = translateDocumentOptions.modelId; - this.source = translateDocumentOptions.source; - this.target = translateDocumentOptions.target; - this.documentId = translateDocumentOptions.documentId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param file the file - * @param filename the filename - */ - public Builder(InputStream file, String filename) { - this.file = file; - this.filename = filename; - } - - /** - * Builds a TranslateDocumentOptions. - * - * @return the translateDocumentOptions - */ - public TranslateDocumentOptions build() { - return new TranslateDocumentOptions(this); - } - - /** - * Set the file. - * - * @param file the file - * @return the TranslateDocumentOptions builder - */ - public Builder file(InputStream file) { - this.file = file; - return this; - } - - /** - * Set the filename. - * - * @param filename the filename - * @return the TranslateDocumentOptions builder - */ - public Builder filename(String filename) { - this.filename = filename; - return this; - } - - /** - * Set the fileContentType. - * - * @param fileContentType the fileContentType - * @return the TranslateDocumentOptions builder - */ - public Builder fileContentType(String fileContentType) { - this.fileContentType = fileContentType; - return this; - } - - /** - * Set the modelId. - * - * @param modelId the modelId - * @return the TranslateDocumentOptions builder - */ - public Builder modelId(String modelId) { - this.modelId = modelId; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the TranslateDocumentOptions builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the target. - * - * @param target the target - * @return the TranslateDocumentOptions builder - */ - public Builder target(String target) { - this.target = target; - return this; - } - - /** - * Set the documentId. - * - * @param documentId the documentId - * @return the TranslateDocumentOptions builder - */ - public Builder documentId(String documentId) { - this.documentId = documentId; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the TranslateDocumentOptions 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; - } - } - - protected TranslateDocumentOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file, - "file cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.filename, - "filename cannot be null"); - file = builder.file; - filename = builder.filename; - fileContentType = builder.fileContentType; - modelId = builder.modelId; - source = builder.source; - target = builder.target; - documentId = builder.documentId; - } - - /** - * New builder. - * - * @return a TranslateDocumentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the file. - * - * The contents of the source file to translate. - * - * [Supported file - * types](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats) - * - * Maximum file size: **20 MB**. - * - * @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 modelId. - * - * The model to use for translation. `model_id` or both `source` and `target` are required. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } - - /** - * Gets the source. - * - * Language code that specifies the language of the source document. - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the target. - * - * Language code that specifies the target language for translation. - * - * @return the target - */ - public String target() { - return target; - } - - /** - * Gets the documentId. - * - * To use a previously submitted document as the source for a new translation, enter the `document_id` of the - * document. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java deleted file mode 100644 index 273a4f4c9df..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.language_translator.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The translate options. - */ -public class TranslateOptions extends GenericModel { - - protected List text; - protected String modelId; - protected String source; - protected String target; - - /** - * Builder. - */ - public static class Builder { - private List text; - private String modelId; - private String source; - private String target; - - private Builder(TranslateOptions translateOptions) { - this.text = translateOptions.text; - this.modelId = translateOptions.modelId; - this.source = translateOptions.source; - this.target = translateOptions.target; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param text the text - */ - public Builder(List text) { - this.text = text; - } - - /** - * Builds a TranslateOptions. - * - * @return the translateOptions - */ - public TranslateOptions build() { - return new TranslateOptions(this); - } - - /** - * Adds an text to text. - * - * @param text the new text - * @return the TranslateOptions builder - */ - public Builder addText(String text) { - com.ibm.cloud.sdk.core.util.Validator.notNull(text, - "text cannot be null"); - if (this.text == null) { - this.text = new ArrayList(); - } - this.text.add(text); - return this; - } - - /** - * Set the text. - * Existing text will be replaced. - * - * @param text the text - * @return the TranslateOptions builder - */ - public Builder text(List text) { - this.text = text; - return this; - } - - /** - * Set the modelId. - * - * @param modelId the modelId - * @return the TranslateOptions builder - */ - public Builder modelId(String modelId) { - this.modelId = modelId; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the TranslateOptions builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the target. - * - * @param target the target - * @return the TranslateOptions builder - */ - public Builder target(String target) { - this.target = target; - return this; - } - } - - protected TranslateOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - text = builder.text; - modelId = builder.modelId; - source = builder.source; - target = builder.target; - } - - /** - * New builder. - * - * @return a TranslateOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * Input text in UTF-8 encoding. Multiple entries will result in multiple translations in the response. - * - * @return the text - */ - public List text() { - return text; - } - - /** - * Gets the modelId. - * - * A globally unique string that identifies the underlying model that is used for translation. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } - - /** - * Gets the source. - * - * Translation source language code. - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the target. - * - * Translation target language code. - * - * @return the target - */ - public String target() { - return target; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java deleted file mode 100644 index bd4d2ffa479..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Translation. - */ -public class Translation extends GenericModel { - - protected String translation; - - /** - * Gets the translation. - * - * Translation output in UTF-8. - * - * @return the translation - */ - public String getTranslation() { - return translation; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java deleted file mode 100644 index c176fd20f75..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.language_translator.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response payload for models. - */ -public class TranslationModel extends GenericModel { - - /** - * Availability of a model. - */ - public interface Status { - /** uploading. */ - String UPLOADING = "uploading"; - /** uploaded. */ - String UPLOADED = "uploaded"; - /** dispatching. */ - String DISPATCHING = "dispatching"; - /** queued. */ - String QUEUED = "queued"; - /** training. */ - String TRAINING = "training"; - /** trained. */ - String TRAINED = "trained"; - /** publishing. */ - String PUBLISHING = "publishing"; - /** available. */ - String AVAILABLE = "available"; - /** deleted. */ - String DELETED = "deleted"; - /** error. */ - String ERROR = "error"; - } - - @SerializedName("model_id") - protected String modelId; - protected String name; - protected String source; - protected String target; - @SerializedName("base_model_id") - protected String baseModelId; - protected String domain; - protected Boolean customizable; - @SerializedName("default_model") - protected Boolean defaultModel; - protected String owner; - protected String status; - - /** - * Gets the modelId. - * - * A globally unique string that identifies the underlying model that is used for translation. - * - * @return the modelId - */ - public String getModelId() { - return modelId; - } - - /** - * Gets the name. - * - * Optional name that can be specified when the model is created. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the source. - * - * Translation source language code. - * - * @return the source - */ - public String getSource() { - return source; - } - - /** - * Gets the target. - * - * Translation target language code. - * - * @return the target - */ - public String getTarget() { - return target; - } - - /** - * Gets the baseModelId. - * - * Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be - * an empty string. - * - * @return the baseModelId - */ - public String getBaseModelId() { - return baseModelId; - } - - /** - * Gets the domain. - * - * The domain of the translation model. - * - * @return the domain - */ - public String getDomain() { - return domain; - } - - /** - * Gets the customizable. - * - * Whether this model can be used as a base for customization. Customized models are not further customizable, and - * some base models are not customizable. - * - * @return the customizable - */ - public Boolean isCustomizable() { - return customizable; - } - - /** - * Gets the defaultModel. - * - * Whether or not the model is a default model. A default model is the model for a given language pair that will be - * used when that language pair is specified in the source and target parameters. - * - * @return the defaultModel - */ - public Boolean isDefaultModel() { - return defaultModel; - } - - /** - * Gets the owner. - * - * Either an empty string, indicating the model is not a custom model, or the ID of the service instance that created - * the model. - * - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * Gets the status. - * - * Availability of a model. - * - * @return the status - */ - public String getStatus() { - return status; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java deleted file mode 100644 index 269f19cfa02..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The response type for listing existing translation models. - */ -public class TranslationModels extends GenericModel { - - protected List models; - - /** - * Gets the models. - * - * An array of available models. - * - * @return the models - */ - public List getModels() { - return models; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java deleted file mode 100644 index 84f50ffdd9d..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.language_translator.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * TranslationResult. - */ -public class TranslationResult extends GenericModel { - - @SerializedName("word_count") - protected Long wordCount; - @SerializedName("character_count") - protected Long characterCount; - protected List translations; - - /** - * Gets the wordCount. - * - * An estimate of the number of words in the input text. - * - * @return the wordCount - */ - public Long getWordCount() { - return wordCount; - } - - /** - * Gets the characterCount. - * - * Number of characters in the input text. - * - * @return the characterCount - */ - public Long getCharacterCount() { - return characterCount; - } - - /** - * Gets the translations. - * - * List of translation output in UTF-8, corresponding to the input text entries. - * - * @return the translations - */ - public List getTranslations() { - return translations; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java deleted file mode 100644 index 9245dae08ec..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Language Translator v3. - */ -package com.ibm.watson.language_translator.v3; diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/util/Language.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/util/Language.java deleted file mode 100644 index 433fb5ccf7f..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/util/Language.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 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.language_translator.v3.util; - -import com.ibm.watson.language_translator.v3.LanguageTranslator; - -/** - * The languages available in {@link LanguageTranslator}. - */ - -public interface Language { - /** Afrikaans. */ - String AFRIKAANS = "af"; - - /** Arabic. */ - String ARABIC = "ar"; - - /** Azerbaijani. */ - String AZERBAIJANI = "az"; - - /** Bashkir. */ - String BASHKIR = "ba"; - - /** Belarusian. */ - String BELARUSIAN = "be"; - - /** Bulgarian. */ - String BULGARIAN = "bg"; - - /** Bengali. */ - String BENGALI = "bn"; - - /** Bosnian. */ - String BOSNIAN = "bs"; - - /** Czech. */ - String CZECH = "cs"; - - /** Chuvash. */ - String CHUVASH = "cv"; - - /** Danish. */ - String DANISH = "da"; - - /** German. */ - String GERMAN = "de"; - - /** Greek. */ - String GREEK = "el"; - - /** English. */ - String ENGLISH = "en"; - - /** Esperanto. */ - String ESPERANTO = "eo"; - - /** Spanish. */ - String SPANISH = "es"; - - /** Estonian. */ - String ESTONIAN = "et"; - - /** Basque. */ - String BASQUE = "eu"; - - /** Persian. */ - String PERSIAN = "fa"; - - /** Finnish. */ - String FINNISH = "fi"; - - /** French. */ - String FRENCH = "fr"; - - /** Gujarati. */ - String GUJARATI = "gu"; - - /** Hebrew. */ - String HEBREW = "he"; - - /** Hindi. */ - String HINDI = "hi"; - - /** Haitian. */ - String HAITIAN = "ht"; - - /** Hungarian. */ - String HUNGARIAN = "hu"; - - /** Armenian. */ - String ARMENIAN = "hy"; - - /** Indonesian. */ - String INDONESIAN = "id"; - - /** Icelandic. */ - String ICELANDIC = "is"; - - /** Italian. */ - String ITALIAN = "it"; - - /** Japanese. */ - String JAPANESE = "ja"; - - /** Georgian. */ - String GEORGIAN = "ka"; - - /** Kazakh. */ - String KAZAKH = "kk"; - - /** Central Khmer. */ - String CENTRAL_KHMER = "km"; - - /** Korean. */ - String KOREAN = "ko"; - - /** Kurdish. */ - String KURDISH = "ku"; - - /** Kirghiz. */ - String KIRGHIZ = "ky"; - - /** Lithuanian. */ - String LITHUANIAN = "lt"; - - /** Latvian. */ - String LATVIAN = "lv"; - - /** Malayalam. */ - String MALAYALAM = "ml"; - - /** Mongolian. */ - String MONGOLIAN = "mn"; - - /** Norwegian Bokmal. */ - String NORWEGIAN_BOKMAL = "nb"; - - /** Dutch. */ - String DUTCH = "nl"; - - /** Norwegian Nynorsk. */ - String NORWEGIAN_NYNORSK = "nn"; - - /** Panjabi. */ - String PANJABI = "pa"; - - /** Polish. */ - String POLISH = "pl"; - - /** Pushto. */ - String PUSHTO = "ps"; - - /** Portuguese. */ - String PORTUGUESE = "pt"; - - /** Romanian. */ - String ROMANIAN = "ro"; - - /** Russian. */ - String RUSSIAN = "ru"; - - /** Slovakian. */ - String SLOVAKIAN = "sk"; - - /** Somali. */ - String SOMALI = "so"; - - /** Albanian. */ - String ALBANIAN = "sq"; - - /** Swedish. */ - String SWEDISH = "sv"; - - /** Tamil. */ - String TAMIL = "ta"; - - /** Telugu. */ - String TELUGU = "te"; - - /** Turkish. */ - String TURKISH = "tr"; - - /** Ukrainian. */ - String UKRAINIAN = "uk"; - - /** Urdu. */ - String URDU = "ur"; - - /** Vietnamese. */ - String VIETNAMESE = "vi"; - - /** Chinese. */ - String CHINESE = "zh"; - - /** Traditional Chinese. */ - String TRADITIONAL_CHINESE = "zh-TW"; -} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorIT.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorIT.java deleted file mode 100644 index 3e4aa863d56..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorIT.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.http.Response; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.cloud.sdk.core.service.exception.TooManyRequestsException; -import com.ibm.watson.common.WatsonHttpHeaders; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.language_translator.v3.model.DeleteDocumentOptions; -import com.ibm.watson.language_translator.v3.model.DeleteModelOptions; -import com.ibm.watson.language_translator.v3.model.DocumentList; -import com.ibm.watson.language_translator.v3.model.DocumentStatus; -import com.ibm.watson.language_translator.v3.model.GetDocumentStatusOptions; -import com.ibm.watson.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.language_translator.v3.model.GetTranslatedDocumentOptions; -import com.ibm.watson.language_translator.v3.model.IdentifiableLanguage; -import com.ibm.watson.language_translator.v3.model.IdentifiedLanguage; -import com.ibm.watson.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.language_translator.v3.model.TranslateDocumentOptions; -import com.ibm.watson.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.language_translator.v3.model.TranslationModel; -import com.ibm.watson.language_translator.v3.model.TranslationResult; -import com.ibm.watson.language_translator.v3.util.Language; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Language Translator integration test. - */ -public class LanguageTranslatorIT extends WatsonServiceTest { - - private static final String ENGLISH_TO_SPANISH = "en-es"; - - private LanguageTranslator service; - - private final Map translations = ImmutableMap.of( - "The IBM Watson team is awesome", - "El equipo de IBM Watson es impresionante", - "Welcome to the cognitive era", - "Bienvenidos a la era cognitiva"); - private final List texts = ImmutableList.copyOf(translations.keySet()); - - /* - * (non-Javadoc) - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String iamApiKey = getProperty("language_translator.apikey"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", (iamApiKey == null)); - - Authenticator authenticator = new IamAuthenticator(iamApiKey); - service = new LanguageTranslator("2018-05-01", authenticator); - service.setServiceUrl(getProperty("language_translator.url")); - - // issue currently where document translation fails with learning opt-out - Map headers = new HashMap<>(); - headers.put(WatsonHttpHeaders.X_WATSON_TEST, "1"); - service.setDefaultHeaders(headers); - } - - /** - * Test README. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello").source(Language.ENGLISH).target(Language.SPANISH).build(); - Response translationResult = service.translate(translateOptions).execute(); - - System.out.println(translationResult); - } - - /** - * Test Get Identifiable languages. - */ - @Test - public void testGetIdentifiableLanguages() { - List languages = service.listIdentifiableLanguages().execute().getResult().getLanguages(); - assertNotNull(languages); - assertTrue(!languages.isEmpty()); - } - - /** - * Test Get model by id. - */ - @Test - public void testGetModel() { - GetModelOptions getOptions = new GetModelOptions.Builder(ENGLISH_TO_SPANISH).build(); - try { - final Response model = service.getModel(getOptions).execute(); - assertNotNull(model); - } catch (TooManyRequestsException e) { - // The service seems to have a very strict rate limit. Failing this way is okay. - } - } - - /** - * Test List Models. - */ - @Test - public void testListModels() { - try { - List models = service.listModels(null).execute().getResult().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - } catch (TooManyRequestsException e) { - // The service seems to have a very strict rate limit. Failing this way is okay. - } - } - - /** - * Test List Models with Options. - */ - @Test - public void testListModelsWithOptions() { - try { - ListModelsOptions options = new ListModelsOptions.Builder() - .source("en") - .target("es") - .xDefault(true) - .build(); - List models = service.listModels(options).execute().getResult().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - assertEquals(models.get(0).getSource(), options.source()); - assertEquals(models.get(0).getTarget(), options.target()); - } catch (TooManyRequestsException e) { - // The service seems to have a very strict rate limit. Failing this way is okay. - } - } - - /** - * Test Identify. - */ - @Test - public void testIdentify() { - - IdentifyOptions options = new IdentifyOptions.Builder(texts.get(0)).build(); - List identifiedLanguages = service.identify(options).execute().getResult().getLanguages(); - assertNotNull(identifiedLanguages); - assertFalse(identifiedLanguages.isEmpty()); - } - - /** - * Test translate. - */ - @Test - public void testTranslate() { - for (String text : texts) { - TranslateOptions options = new TranslateOptions.Builder() - .addText(text).modelId(ENGLISH_TO_SPANISH).build(); - testTranslationResult(text, translations.get(text), service.translate(options).execute().getResult()); - TranslateOptions options1 = new TranslateOptions.Builder() - .addText(text).source(Language.ENGLISH).target(Language.SPANISH).build(); - testTranslationResult(text, translations.get(text), service.translate(options1).execute().getResult()); - } - } - - /** - * Test translate multiple. - */ - @Test - public void testTranslateMultiple() { - TranslateOptions options = new TranslateOptions.Builder(texts) - .modelId(ENGLISH_TO_SPANISH).build(); - TranslationResult results = service.translate(options).execute().getResult(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslation()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslation()); - - TranslateOptions.Builder builder = new TranslateOptions.Builder(); - builder.source(Language.ENGLISH).target(Language.SPANISH); - for (String text : texts) { - builder.addText(text); - } - results = service.translate(builder.build()).execute().getResult(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslation()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslation()); - } - - /** - * Test delete all models. - */ - @Test - @Ignore - public void testDeleteAllModels() { - List models = service.listModels(null).execute().getResult().getModels(); - for (TranslationModel translationModel : models) { - DeleteModelOptions options = new DeleteModelOptions.Builder(translationModel.getModelId()).build(); - service.deleteModel(options).execute(); - } - } - - @Test - public void testDocumentTranslation() throws FileNotFoundException, InterruptedException { - DocumentList listResponse = service.listDocuments().execute().getResult(); - int originalDocumentCount = listResponse.getDocuments().size(); - - TranslateDocumentOptions translateOptions = new TranslateDocumentOptions.Builder() - .file(new File("src/test/resources/language_translation/document_to_translate.txt")) - .fileContentType(HttpMediaType.TEXT_PLAIN) - .filename("java-integration-test-file") - .source("en") - .target("es") - .build(); - DocumentStatus translateResponse = service.translateDocument(translateOptions).execute().getResult(); - String documentId = translateResponse.getDocumentId(); - - try { - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder() - .documentId(documentId) - .build(); - DocumentStatus getResponse = service.getDocumentStatus(getOptions).execute().getResult(); - while (!getResponse.getStatus().equals(DocumentStatus.Status.AVAILABLE)) { - Thread.sleep(3000); - getResponse = service.getDocumentStatus(getOptions).execute().getResult(); - } - - GetTranslatedDocumentOptions getTranslatedDocumentOptions = new GetTranslatedDocumentOptions.Builder() - .documentId(documentId) - .accept(HttpMediaType.TEXT_PLAIN) - .build(); - InputStream getTranslatedDocumentResponse = service.getTranslatedDocument(getTranslatedDocumentOptions).execute() - .getResult(); - assertNotNull(getTranslatedDocumentResponse); - - listResponse = service.listDocuments().execute().getResult(); - assertTrue(listResponse.getDocuments().size() > originalDocumentCount); - } finally { - DeleteDocumentOptions deleteOptions = new DeleteDocumentOptions.Builder() - .documentId(documentId) - .build(); - service.deleteDocument(deleteOptions).execute().getResult(); - } - } - - /** - * Test translation result. - * - * @param text the text - * @param result the result - * @param translationResult the translation result - */ - private void testTranslationResult(String text, String result, TranslationResult translationResult) { - assertNotNull(translationResult); - assertEquals(translationResult.getCharacterCount().intValue(), text.length()); - assertEquals(translationResult.getWordCount().intValue(), text.split(" ").length); - assertNotNull(translationResult.getTranslations()); - assertNotNull(translationResult.getTranslations().get(0).getTranslation()); - assertEquals(result, translationResult.getTranslations().get(0).getTranslation()); - } -} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java deleted file mode 100644 index 74c31d29ce0..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java +++ /dev/null @@ -1,558 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.language_translator.v3; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.service.exception.BadRequestException; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.language_translator.v3.model.CreateModelOptions; -import com.ibm.watson.language_translator.v3.model.DeleteDocumentOptions; -import com.ibm.watson.language_translator.v3.model.DocumentList; -import com.ibm.watson.language_translator.v3.model.DocumentStatus; -import com.ibm.watson.language_translator.v3.model.GetDocumentStatusOptions; -import com.ibm.watson.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.language_translator.v3.model.GetTranslatedDocumentOptions; -import com.ibm.watson.language_translator.v3.model.IdentifiableLanguage; -import com.ibm.watson.language_translator.v3.model.IdentifiedLanguage; -import com.ibm.watson.language_translator.v3.model.IdentifiedLanguages; -import com.ibm.watson.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.language_translator.v3.model.ListDocumentsOptions; -import com.ibm.watson.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.language_translator.v3.model.TranslateDocumentOptions; -import com.ibm.watson.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.language_translator.v3.model.TranslationModel; -import com.ibm.watson.language_translator.v3.model.TranslationModels; -import com.ibm.watson.language_translator.v3.model.TranslationResult; -import com.ibm.watson.language_translator.v3.util.Language; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Before; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -/** - * Language Translator v3 Unit tests. - */ -public class LanguageTranslatorTest extends WatsonServiceUnitTest { - - private static final String GET_MODELS_PATH = "/v3/models"; - private static final String IDENTIFIABLE_LANGUAGES_PATH = "/v3/identifiable_languages"; - private static final String IDENTITY_PATH = "/v3/identify"; - private static final String LANGUAGE_TRANSLATION_PATH = "/v3/translate"; - private static final String VERSION_PARAM = "?version=2018-05-01"; - private static final String RESOURCE = "src/test/resources/language_translation/"; - private static final Type TYPE_IDENTIFIED_LANGUAGES = new TypeToken>>() { - }.getType(); - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - private final String modelId = "foo-bar"; - private LanguageTranslator service; - - private final Map translations = ImmutableMap.of("The IBM Watson team is awesome", - "El equipo es increíble IBM Watson", "Welcome to the cognitive era", "Bienvenido a la era cognitiva"); - private final List texts = ImmutableList.copyOf(translations.keySet()); - - private TranslationModel model; - private TranslationModels models; - private IdentifiedLanguages identifiedLanguages; - private TranslationResult singleTranslation; - private TranslationResult multipleTranslations; - private Map identifiableLanguages; - private DocumentList documentList; - private DocumentStatus documentStatus; - private File translatedDocument; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new LanguageTranslator("2018-05-01", new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - // fixtures - String jsonString = getStringFromInputStream(new FileInputStream(RESOURCE + "identifiable_languages.json")); - identifiableLanguages = GSON.fromJson(jsonString, TYPE_IDENTIFIED_LANGUAGES); - - model = loadFixture(RESOURCE + "model.json", TranslationModel.class); - models = loadFixture(RESOURCE + "models.json", TranslationModels.class); - identifiedLanguages = loadFixture(RESOURCE + "identify_response.json", IdentifiedLanguages.class); - singleTranslation = loadFixture(RESOURCE + "single_translation.json", TranslationResult.class); - multipleTranslations = loadFixture(RESOURCE + "multiple_translations.json", TranslationResult.class); - documentList = loadFixture(RESOURCE + "list_documents_response.json", DocumentList.class); - documentStatus = loadFixture(RESOURCE + "document_status.json", DocumentStatus.class); - translatedDocument = new File(RESOURCE + "translated_document.txt"); - } - - /** - * Test create model with base model null. - */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithBaseModelNull() throws IOException { - InputStream glossary = new FileInputStream(new File(RESOURCE + "glossary.tmx")); - final CreateModelOptions options = new CreateModelOptions.Builder() - .forcedGlossary(glossary) - .build(); - service.createModel(options).execute(); - } - - /** - * Test create model with baseModelId null. - */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithBaseModelIdNull() { - service.createModel(new CreateModelOptions.Builder().build()).execute(); - } - - /** - * Test create model with glossary null. - */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithGlossaryNull() { - service.createModel(new CreateModelOptions.Builder(modelId).build()).execute(); - } - - /** - * Test delete with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testDeleteWithNull() { - service.deleteModel(null).execute(); - } - - /** - * Test Get Identifiable languages. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetIdentifiableLanguages() throws InterruptedException { - server.enqueue(jsonResponse(identifiableLanguages)); - - List languages = service.listIdentifiableLanguages().execute().getResult().getLanguages(); - RecordedRequest request = server.takeRequest(); - - assertEquals(IDENTIFIABLE_LANGUAGES_PATH + VERSION_PARAM, request.getPath()); - assertEquals(GSON.toJson(languages), GSON.toJson(identifiableLanguages.get("languages"))); - } - - /** - * Test Get Model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetModel() throws InterruptedException { - server.enqueue(jsonResponse(model)); - - GetModelOptions getOptions = new GetModelOptions.Builder(model.getModelId()).build(); - TranslationModel returnedModel = service.getModel(getOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_MODELS_PATH + "/" + model.getModelId() + VERSION_PARAM, request.getPath()); - assertEquals(model, returnedModel); - } - - /** - * Test Get Models. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testListModels() throws InterruptedException { - server.enqueue(jsonResponse(models)); - - ListModelsOptions options = new ListModelsOptions.Builder().build(); - List modelList = service.listModels(options).execute().getResult().getModels(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET_MODELS_PATH + VERSION_PARAM, request.getPath()); - assertEquals(GSON.toJson(models.getModels()), GSON.toJson(modelList)); - } - - /** - * Test get model with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testGetModelWithNull() { - final String modelId = null; - GetModelOptions getOptions = new GetModelOptions.Builder(modelId).build(); - service.getModel(getOptions).execute(); - } - - /** - * Test Identify. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testIdentify() throws InterruptedException { - server.enqueue(jsonResponse(identifiedLanguages)); - - final String text = texts.get(0); - IdentifyOptions identifyOptions = new IdentifyOptions.Builder(text).build(); - List identifiedLanguages = service.identify(identifyOptions).execute().getResult() - .getLanguages(); - RecordedRequest request = server.takeRequest(); - - assertEquals(IDENTITY_PATH + VERSION_PARAM, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(identifiedLanguages); - assertFalse(identifiedLanguages.isEmpty()); - assertEquals(identifiedLanguages.get(0).getLanguage(), Language.ENGLISH); - assertEquals(identifiedLanguages.get(0).getConfidence(), 0.877159, 0.05); - assertEquals(identifiedLanguages.get(1).getLanguage(), Language.AFRIKAANS); - assertEquals(identifiedLanguages.get(1).getConfidence(), 0.0752636, 0.05); - - } - - /** - * Test translate. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testTranslate() throws InterruptedException { - server.enqueue(jsonResponse(singleTranslation)); - - final String text = texts.get(0); - final Map requestBody = ImmutableMap.of("text", Collections.singleton(text), "model_id", modelId); - - TranslateOptions translateOptions = new TranslateOptions.Builder().addText(text).modelId(modelId).build(); - TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(LANGUAGE_TRANSLATION_PATH + VERSION_PARAM, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(GSON.toJson(requestBody), request.getBody().readUtf8()); - testTranslationResult(text, translationResult); - } - - /** - * Test translate multiple texts. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testTranslateMultiple() throws InterruptedException { - server.enqueue(jsonResponse(multipleTranslations)); - - final Map requestBody = ImmutableMap.of("text", texts, "model_id", modelId); - - TranslateOptions translateOptions = new TranslateOptions.Builder() - .text(texts) - .modelId(modelId) - .build(); - TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(LANGUAGE_TRANSLATION_PATH + VERSION_PARAM, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(GSON.toJson(requestBody), request.getBody().readUtf8()); - assertEquals(2, translationResult.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), translationResult.getTranslations().get(0).getTranslation()); - assertEquals(translations.get(texts.get(1)), translationResult.getTranslations().get(1).getTranslation()); - } - - /** - * Test Translate with an invalid model. - */ - @Test(expected = BadRequestException.class) - public void testTranslateNotSupported() { - Map response = ImmutableMap.of("error_code", 400, "error message", "error"); - server.enqueue(jsonResponse(response).setResponseCode(400)); - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("X") - .modelId("FOO-BAR-FOO") - .build(); - service.translate(translateOptions).execute(); - } - - /** - * Test translate with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testTranslateWithNull() { - TranslateOptions translateOptions = new TranslateOptions.Builder().build(); - service.translate(translateOptions).execute(); - } - - /** - * Test translation result. - * - * @param text the text - * @param translationResult the translation result - */ - private void testTranslationResult(String text, TranslationResult translationResult) { - assertNotNull(translationResult); - assertEquals(translationResult.getWordCount().intValue(), text.split(" ").length); - assertNotNull(translationResult.getTranslations()); - assertNotNull(translationResult.getTranslations().get(0).getTranslation()); - } - - /** - * Test translate options. - */ - @Test - public void testTranslateOptions() { - final String text = "Hello, Watson!"; - - TranslateOptions options1 = new TranslateOptions.Builder() - .addText(text) - .modelId(modelId) - .build(); - TranslateOptions.Builder builder = options1.newBuilder(); - TranslateOptions options2 = builder.text(texts).build(); - assertEquals(options2.text(), texts); - assertEquals(options2.modelId(), modelId); - } - - /** - * Test create model options. - */ - @Test - public void testCreateModelOptions() { - - String myParallelCorpus = "{\"field\":\"value\"}"; - InputStream parallelCorpusStream = new ByteArrayInputStream(myParallelCorpus.getBytes()); - - CreateModelOptions options1 = new CreateModelOptions.Builder(modelId) - .parallelCorpus(parallelCorpusStream) - .build(); - CreateModelOptions.Builder builder = options1.newBuilder(); - CreateModelOptions options2 = builder.name("baz").build(); - assertEquals(options2.baseModelId(), modelId); - assertEquals(options2.parallelCorpus(), parallelCorpusStream); - assertEquals(options2.name(), "baz"); - } - - @Test - public void testListDocumentsOptions() { - ListDocumentsOptions options = new ListDocumentsOptions.Builder() - .build(); - options = options.newBuilder().build(); - } - - @Test - public void testListDocuments() throws InterruptedException { - server.enqueue(jsonResponse(documentList)); - ListDocumentsOptions options = new ListDocumentsOptions.Builder().build(); - DocumentList response = service.listDocuments(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(documentList.getDocuments().get(0).getDocumentId(), response.getDocuments().get(0).getDocumentId()); - assertEquals(documentList.getDocuments().get(0).getBaseModelId(), response.getDocuments().get(0).getBaseModelId()); - assertEquals(documentList.getDocuments().get(0) - .getCharacterCount(), response.getDocuments().get(0).getCharacterCount()); - assertEquals(documentList.getDocuments().get(0).getCompleted(), response.getDocuments().get(0).getCompleted()); - assertEquals(documentList.getDocuments().get(0).getCreated(), response.getDocuments().get(0).getCreated()); - assertEquals(documentList.getDocuments().get(0).getFilename(), response.getDocuments().get(0).getFilename()); - assertEquals(documentList.getDocuments().get(0).getModelId(), response.getDocuments().get(0).getModelId()); - assertEquals(documentList.getDocuments().get(0).getSource(), response.getDocuments().get(0).getSource()); - assertEquals(documentList.getDocuments().get(0).getStatus(), response.getDocuments().get(0).getStatus()); - assertEquals(documentList.getDocuments().get(0).getTarget(), response.getDocuments().get(0).getTarget()); - assertEquals(documentList.getDocuments().get(0).getWordCount(), response.getDocuments().get(0).getWordCount()); - } - - @Test - public void testListDocumentsNoOptions() throws InterruptedException { - server.enqueue(jsonResponse(documentList)); - DocumentList response = service.listDocuments().execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(documentList.getDocuments().get(0).getDocumentId(), response.getDocuments().get(0).getDocumentId()); - assertEquals(documentList.getDocuments().get(0).getBaseModelId(), response.getDocuments().get(0).getBaseModelId()); - assertEquals(documentList.getDocuments().get(0) - .getCharacterCount(), response.getDocuments().get(0).getCharacterCount()); - assertEquals(documentList.getDocuments().get(0).getCompleted(), response.getDocuments().get(0).getCompleted()); - assertEquals(documentList.getDocuments().get(0).getCreated(), response.getDocuments().get(0).getCreated()); - assertEquals(documentList.getDocuments().get(0).getFilename(), response.getDocuments().get(0).getFilename()); - assertEquals(documentList.getDocuments().get(0).getModelId(), response.getDocuments().get(0).getModelId()); - assertEquals(documentList.getDocuments().get(0).getSource(), response.getDocuments().get(0).getSource()); - assertEquals(documentList.getDocuments().get(0).getStatus(), response.getDocuments().get(0).getStatus()); - assertEquals(documentList.getDocuments().get(0).getTarget(), response.getDocuments().get(0).getTarget()); - assertEquals(documentList.getDocuments().get(0).getWordCount(), response.getDocuments().get(0).getWordCount()); - } - - @Test - public void testTranslateDocumentOptions() throws FileNotFoundException { - File file = new File(RESOURCE + "document_to_translate.txt"); - String fileContentType = HttpMediaType.TEXT_PLAIN; - String filename = "filename"; - String modelId = "modelId"; - String source = "en"; - String target = "es"; - String documentId = "documentId"; - - TranslateDocumentOptions options = new TranslateDocumentOptions.Builder() - .file(file) - .fileContentType(fileContentType) - .filename(filename) - .modelId(modelId) - .source(source) - .target(target) - .documentId(documentId) - .build(); - options = options.newBuilder().build(); - - assertNotNull(options.file()); - assertEquals(fileContentType, options.fileContentType()); - assertEquals(filename, options.filename()); - assertEquals(modelId, options.modelId()); - assertEquals(source, options.source()); - assertEquals(target, options.target()); - assertEquals(documentId, options.documentId()); - } - - @Test - public void testTranslateDocument() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(documentStatus)); - File file = new File(RESOURCE + "document_to_translate.txt"); - TranslateDocumentOptions options = new TranslateDocumentOptions.Builder() - .file(file) - .build(); - DocumentStatus response = service.translateDocument(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(POST, request.getMethod()); - assertEquals(documentStatus.getWordCount(), response.getWordCount()); - assertEquals(documentStatus.getTarget(), response.getTarget()); - assertEquals(documentStatus.getStatus(), response.getStatus()); - assertEquals(documentStatus.getSource(), response.getSource()); - assertEquals(documentStatus.getModelId(), response.getModelId()); - assertEquals(documentStatus.getFilename(), response.getFilename()); - assertEquals(documentStatus.getCreated(), response.getCreated()); - assertEquals(documentStatus.getCompleted(), response.getCompleted()); - assertEquals(documentStatus.getCharacterCount(), response.getCharacterCount()); - assertEquals(documentStatus.getBaseModelId(), response.getBaseModelId()); - assertEquals(documentStatus.getDocumentId(), response.getDocumentId()); - } - - @Test - public void testGetDocumentStatusOptions() { - String documentId = "documentId"; - - GetDocumentStatusOptions options = new GetDocumentStatusOptions.Builder() - .documentId(documentId) - .build(); - options = options.newBuilder().build(); - - assertEquals(documentId, options.documentId()); - } - - @Test - public void testGetDocumentStatus() throws InterruptedException { - server.enqueue(jsonResponse(documentStatus)); - GetDocumentStatusOptions options = new GetDocumentStatusOptions.Builder() - .documentId("documentId") - .build(); - DocumentStatus response = service.getDocumentStatus(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertEquals(documentStatus.getWordCount(), response.getWordCount()); - assertEquals(documentStatus.getTarget(), response.getTarget()); - assertEquals(documentStatus.getStatus(), response.getStatus()); - assertEquals(documentStatus.getSource(), response.getSource()); - assertEquals(documentStatus.getModelId(), response.getModelId()); - assertEquals(documentStatus.getFilename(), response.getFilename()); - assertEquals(documentStatus.getCreated(), response.getCreated()); - assertEquals(documentStatus.getCompleted(), response.getCompleted()); - assertEquals(documentStatus.getCharacterCount(), response.getCharacterCount()); - assertEquals(documentStatus.getBaseModelId(), response.getBaseModelId()); - assertEquals(documentStatus.getDocumentId(), response.getDocumentId()); - } - - @Test - public void testDeleteDocumentOptions() { - String documentId = "documentId"; - - DeleteDocumentOptions options = new DeleteDocumentOptions.Builder() - .documentId(documentId) - .build(); - options = options.newBuilder().build(); - - assertEquals(documentId, options.documentId()); - } - - @Test - public void testDeleteDocument() throws InterruptedException { - server.enqueue(new MockResponse().setResponseCode(200)); - DeleteDocumentOptions options = new DeleteDocumentOptions.Builder() - .documentId("documentId") - .build(); - service.deleteDocument(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void testGetTranslatedDocumentOptions() { - String documentId = "documentId"; - String accept = HttpMediaType.APPLICATION_JSON; - - GetTranslatedDocumentOptions options = new GetTranslatedDocumentOptions.Builder() - .accept(accept) - .documentId(documentId) - .build(); - options = options.newBuilder().build(); - - assertEquals(documentId, options.documentId()); - assertEquals(accept, options.accept()); - } - - @Test - public void testGetTranslatedDocument() throws IOException, InterruptedException { - Buffer buffer = new Buffer().write(Files.toByteArray(translatedDocument)); - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.TEXT_PLAIN).setBody(buffer)); - - GetTranslatedDocumentOptions options = new GetTranslatedDocumentOptions.Builder() - .documentId("documentId") - .accept("") - .build(); - InputStream response = service.getTranslatedDocument(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals(GET, request.getMethod()); - assertNotNull(response); - } -} diff --git a/language-translator/src/test/resources/language_translation/document_status.json b/language-translator/src/test/resources/language_translation/document_status.json deleted file mode 100644 index 56536bcee0c..00000000000 --- a/language-translator/src/test/resources/language_translation/document_status.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "document_id": "1bdb9528-bf73-45eb-87fa-c4f519af23a0", - "filename": "en.pdf", - "model_id": "12345", - "base_model_id": "en-fr", - "source": "en", - "target": "fr", - "status": "available", - "created": "2018-08-24T08:20:30.5Z", - "completed": "2018-08-24T08:20:35.5Z", - "word_count": 12, - "character_count": 100 -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/document_to_translate.txt b/language-translator/src/test/resources/language_translation/document_to_translate.txt deleted file mode 100644 index 432334030a9..00000000000 --- a/language-translator/src/test/resources/language_translation/document_to_translate.txt +++ /dev/null @@ -1,2 +0,0 @@ -Where is the library? -How are you? \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/glossary.tmx b/language-translator/src/test/resources/language_translation/glossary.tmx deleted file mode 100644 index 427dfbda475..00000000000 --- a/language-translator/src/test/resources/language_translation/glossary.tmx +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - - admittedTerm-admn-sts - entryTerm - Colloquial use term - Informal salutation - Hello - - - admittedTerm-admn-sts - entryTerm - Termino de uso coloquial - Saludo informal - Hola - - - - \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/identifiable_languages.json b/language-translator/src/test/resources/language_translation/identifiable_languages.json deleted file mode 100644 index f5e31f4fde5..00000000000 --- a/language-translator/src/test/resources/language_translation/identifiable_languages.json +++ /dev/null @@ -1,252 +0,0 @@ -{ - "languages": [ - { - "language": "af", - "name": "Afrikaans" - }, - { - "language": "ar", - "name": "Arabic" - }, - { - "language": "az", - "name": "Azerbaijani" - }, - { - "language": "ba", - "name": "Bashkir" - }, - { - "language": "be", - "name": "Belarusian" - }, - { - "language": "bg", - "name": "Bulgarian" - }, - { - "language": "bn", - "name": "Bengali" - }, - { - "language": "bs", - "name": "Bosnian" - }, - { - "language": "cs", - "name": "Czech" - }, - { - "language": "cv", - "name": "Chuvash" - }, - { - "language": "da", - "name": "Danish" - }, - { - "language": "de", - "name": "German" - }, - { - "language": "el", - "name": "Greek" - }, - { - "language": "en", - "name": "English" - }, - { - "language": "eo", - "name": "Esperanto" - }, - { - "language": "es", - "name": "Spanish" - }, - { - "language": "et", - "name": "Estonian" - }, - { - "language": "eu", - "name": "Basque" - }, - { - "language": "fa", - "name": "Persian" - }, - { - "language": "fi", - "name": "Finnish" - }, - { - "language": "fr", - "name": "French" - }, - { - "language": "gu", - "name": "Gujarati" - }, - { - "language": "he", - "name": "Hebrew" - }, - { - "language": "hi", - "name": "Hindi" - }, - { - "language": "ht", - "name": "Haitian" - }, - { - "language": "hu", - "name": "Hungarian" - }, - { - "language": "hy", - "name": "Armenian" - }, - { - "language": "id", - "name": "Indonesian" - }, - { - "language": "is", - "name": "Icelandic" - }, - { - "language": "it", - "name": "Italian" - }, - { - "language": "ja", - "name": "Japanese" - }, - { - "language": "ka", - "name": "Georgian" - }, - { - "language": "kk", - "name": "Kazakh" - }, - { - "language": "km", - "name": "Central Khmer" - }, - { - "language": "ko", - "name": "Korean" - }, - { - "language": "ku", - "name": "Kurdish" - }, - { - "language": "ky", - "name": "Kirghiz" - }, - { - "language": "lt", - "name": "Lithuanian" - }, - { - "language": "lv", - "name": "Latvian" - }, - { - "language": "ml", - "name": "Malayalam" - }, - { - "language": "mn", - "name": "Mongolian" - }, - { - "language": "nb", - "name": "Norwegian Bokmal" - }, - { - "language": "nl", - "name": "Dutch" - }, - { - "language": "nn", - "name": "Norwegian Nynorsk" - }, - { - "language": "pa", - "name": "Panjabi" - }, - { - "language": "pl", - "name": "Polish" - }, - { - "language": "ps", - "name": "Pushto" - }, - { - "language": "pt", - "name": "Portuguese" - }, - { - "language": "ro", - "name": "Romanian" - }, - { - "language": "ru", - "name": "Russian" - }, - { - "language": "sk", - "name": "Slovakian" - }, - { - "language": "so", - "name": "Somali" - }, - { - "language": "sq", - "name": "Albanian" - }, - { - "language": "sv", - "name": "Swedish" - }, - { - "language": "ta", - "name": "Tamil" - }, - { - "language": "te", - "name": "Telugu" - }, - { - "language": "tr", - "name": "Turkish" - }, - { - "language": "uk", - "name": "Ukrainian" - }, - { - "language": "ur", - "name": "Urdu" - }, - { - "language": "vi", - "name": "Vietnamese" - }, - { - "language": "zh", - "name": "Chinese" - }, - { - "language": "zh-TW", - "name": "Traditional Chinese" - } - ] -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/identify_response.json b/language-translator/src/test/resources/language_translation/identify_response.json deleted file mode 100644 index d1544ca6490..00000000000 --- a/language-translator/src/test/resources/language_translation/identify_response.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "languages": [ - { - "language": "en", - "confidence": 0.877159 - }, - { - "language": "af", - "confidence": 0.0752636 - } - ] -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/list_documents_response.json b/language-translator/src/test/resources/language_translation/list_documents_response.json deleted file mode 100644 index d6481d014fe..00000000000 --- a/language-translator/src/test/resources/language_translation/list_documents_response.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "documents": [ - { - "document_id": "1bdb9528-bf73-45eb-87fa-c4f519af23a0", - "filename": "en.docx", - "model_id": "9ef1eda2-e4dc-460f-b51a-efeec95f239f", - "base_model_id": "en-de", - "source": "en", - "target": "de", - "status": "processing", - "created": "2018-08-24T08:20:30.5Z", - "completed": "2018-08-24T08:20:35.5Z", - "word_count": 12, - "character_count": 100 - }, - { - "document_id": "1bdb9528-bf73-45eb-87fa-c4f519af23a0", - "filename": "en.pdf", - "model_id": "9ef1eda2-e4dc-460f-b51a-efeec95f239f", - "base_model_id": "en-fr", - "source": "en", - "target": "fr", - "status": "available", - "created": "2018-08-24T08:20:30.5Z", - "completed": "2018-08-24T08:20:35.5Z" - } - ] -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/model.json b/language-translator/src/test/resources/language_translation/model.json deleted file mode 100644 index 92a200c011c..00000000000 --- a/language-translator/src/test/resources/language_translation/model.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "model_id": "ar-en", - "source": "ar", - "target": "en", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/models.json b/language-translator/src/test/resources/language_translation/models.json deleted file mode 100644 index 3cfccfabe49..00000000000 --- a/language-translator/src/test/resources/language_translation/models.json +++ /dev/null @@ -1,290 +0,0 @@ -{ - "models": [ - { - "model_id": "ar-en", - "source": "ar", - "target": "en", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "ar-en-conversational", - "source": "ar", - "target": "en", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "arz-en", - "source": "arz", - "target": "en", - "base_model_id": "", - "domain": "news", - "customizable": false, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-ar", - "source": "en", - "target": "ar", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-ar-conversational", - "source": "en", - "target": "ar", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-arz", - "source": "en", - "target": "arz", - "base_model_id": "", - "domain": "news", - "customizable": false, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-es", - "source": "en", - "target": "es", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-es-conversational", - "source": "en", - "target": "es", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-fr", - "source": "en", - "target": "fr", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-fr-conversational", - "source": "en", - "target": "fr", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-pt", - "source": "en", - "target": "pt", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "en-pt-conversational", - "source": "en", - "target": "pt", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "es-en", - "source": "es", - "target": "en", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "es-en-conversational", - "source": "es", - "target": "en", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "es-en-patent", - "source": "es", - "target": "en", - "base_model_id": "", - "domain": "patent", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "fr-en", - "source": "fr", - "target": "en", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "fr-en-conversational", - "source": "fr", - "target": "en", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "ko-en-patent", - "source": "ko", - "target": "en", - "base_model_id": "", - "domain": "patent", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "pt-en", - "source": "pt", - "target": "en", - "base_model_id": "", - "domain": "news", - "customizable": true, - "default_model": true, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "pt-en-conversational", - "source": "pt", - "target": "en", - "base_model_id": "", - "domain": "conversational", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "pt-en-patent", - "source": "pt", - "target": "en", - "base_model_id": "", - "domain": "patent", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - }, - { - "model_id": "zh-en-patent", - "source": "zh", - "target": "en", - "base_model_id": "", - "domain": "patent", - "customizable": false, - "default_model": false, - "owner": "", - "status": "available", - "name": "", - "train_log": null - } - ] -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/multiple_translations.json b/language-translator/src/test/resources/language_translation/multiple_translations.json deleted file mode 100644 index 1e4eb6f4744..00000000000 --- a/language-translator/src/test/resources/language_translation/multiple_translations.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "translations": [ - { - "translation": "El equipo es increíble IBM Watson" - }, - { - "translation": "Bienvenido a la era cognitiva" - } - ], - "word_count": 6, - "character_count": 20 -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/single_translation.json b/language-translator/src/test/resources/language_translation/single_translation.json deleted file mode 100644 index 22a4d0488a0..00000000000 --- a/language-translator/src/test/resources/language_translation/single_translation.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "translations": [ - { - "translation": "El equipo es increíble IBM Watson" - } - ], - "word_count": 6, - "character_count": 20 -} \ No newline at end of file diff --git a/language-translator/src/test/resources/language_translation/translated_document.txt b/language-translator/src/test/resources/language_translation/translated_document.txt deleted file mode 100644 index b15c31adfea..00000000000 --- a/language-translator/src/test/resources/language_translation/translated_document.txt +++ /dev/null @@ -1,2 +0,0 @@ -¿Dónde está la biblioteca? -¿Cómo estás? \ No newline at end of file diff --git a/natural-language-classifier/README.md b/natural-language-classifier/README.md deleted file mode 100644 index 961a12e4814..00000000000 --- a/natural-language-classifier/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Natural Language Classifier - -## Installation - -##### Maven - -```xml - - com.ibm.watson - natural-language-classifier - 8.3.1 - -``` - -##### Gradle - -```gradle -'com.ibm.watson:natural-language-classifier:8.3.1' -``` - -## Usage - -Use [Natural Language Classifier](https://cloud.ibm.com/docs/natural-language-classifier?topic=natural-language-classifier-natural-language-classifier) service to create a classifier instance by providing a set of representative strings and a set of one or more correct classes for each as training. Then use the trained classifier to classify your new question for best matching answers or to retrieve next actions for your application. - -```java -Authenticator authenticator = new IamAuthenticator(""); -NaturalLanguageClassifier service = new NaturalLanguageClassifier(authenticator); - -ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId("") - .text("Is it sunny?") - .build(); - -Classification classification = service.classify(classifyOptions).execute().getResult(); -System.out.println(classification); -``` - -**Note:** You will need to create and train a classifier in order to be able to classify phrases. diff --git a/natural-language-classifier/build.gradle b/natural-language-classifier/build.gradle deleted file mode 100644 index d9dc2b74f77..00000000000 --- a/natural-language-classifier/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyleTest { - ignoreFailures = false -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/natural-language-classifier/gradle.properties b/natural-language-classifier/gradle.properties deleted file mode 100644 index a46b1ad4c33..00000000000 --- a/natural-language-classifier/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:natural-language-classifier -ARTIFACT_ID=natural-language-classifier -NAME=IBM Watson Java SDK - Natural Language Classifier -DESCRIPTION=Java client library to use the IBM Natural Language Classifier API \ No newline at end of file diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java deleted file mode 100644 index 6aa2daa935a..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_classifier.v1; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.natural_language_classifier.v1.model.Classification; -import com.ibm.watson.natural_language_classifier.v1.model.ClassificationCollection; -import com.ibm.watson.natural_language_classifier.v1.model.Classifier; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifierList; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyCollectionOptions; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.natural_language_classifier.v1.model.CreateClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.DeleteClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.GetClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions; -import java.util.Map; -import java.util.Map.Entry; -import okhttp3.MultipartBody; - -/** - * IBM Watson™ Natural Language Classifier uses machine learning algorithms to return the top matching predefined - * classes for short text input. You create and train a classifier to connect predefined classes to example texts so - * that the service can apply those classes to new inputs. - * - * @version v1 - * @see Natural Language Classifier - */ -public class NaturalLanguageClassifier extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "natural_language_classifier"; - - private static final String DEFAULT_SERVICE_URL - = "https://gateway.watsonplatform.net/natural-language-classifier/api"; - - /** - * Constructs a new `NaturalLanguageClassifier` client using the DEFAULT_SERVICE_NAME. - * - */ - public NaturalLanguageClassifier() { - this(DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `NaturalLanguageClassifier` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param authenticator the Authenticator instance to be configured for this service - */ - public NaturalLanguageClassifier(Authenticator authenticator) { - this(DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `NaturalLanguageClassifier` client with the specified serviceName. - * - * @param serviceName The name of the service to configure. - */ - public NaturalLanguageClassifier(String serviceName) { - this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `NaturalLanguageClassifier` client with the specified Authenticator - * and serviceName. - * - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public NaturalLanguageClassifier(String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - this.configureService(serviceName); - } - - /** - * Classify a phrase. - * - * Returns label information for the input. The status must be `Available` before you can use the classifier to - * classify text. - * - * @param classifyOptions the {@link ClassifyOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classification} - */ - public ServiceCall classify(ClassifyOptions classifyOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classifyOptions, - "classifyOptions cannot be null"); - String[] pathSegments = { "v1/classifiers", "classify" }; - String[] pathParameters = { classifyOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classify"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", classifyOptions.text()); - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Classify multiple phrases. - * - * Returns label information for multiple phrases. The status must be `Available` before you can use the classifier to - * classify text. - * - * Note that classifying Japanese texts is a beta feature. - * - * @param classifyCollectionOptions the {@link ClassifyCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ClassificationCollection} - */ - public ServiceCall classifyCollection(ClassifyCollectionOptions classifyCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classifyCollectionOptions, - "classifyCollectionOptions cannot be null"); - String[] pathSegments = { "v1/classifiers", "classify_collection" }; - String[] pathParameters = { classifyCollectionOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classifyCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.add("collection", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - classifyCollectionOptions.collection())); - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create classifier. - * - * Sends data to create and train a classifier and returns information about the new classifier. - * - * @param createClassifierOptions the {@link CreateClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} - */ - public ServiceCall createClassifier(CreateClassifierOptions createClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createClassifierOptions, - "createClassifierOptions cannot be null"); - String[] pathSegments = { "v1/classifiers" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "createClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - okhttp3.RequestBody trainingMetadataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingMetadata(), - "application/json"); - multipartBuilder.addFormDataPart("training_metadata", "filename", trainingMetadataBody); - okhttp3.RequestBody trainingDataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingData(), - "text/csv"); - multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List classifiers. - * - * Returns an empty array if no classifiers are available. - * - * @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ClassifierList} - */ - public ServiceCall listClassifiers(ListClassifiersOptions listClassifiersOptions) { - String[] pathSegments = { "v1/classifiers" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "listClassifiers"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listClassifiersOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List classifiers. - * - * Returns an empty array if no classifiers are available. - * - * @return a {@link ServiceCall} with a response type of {@link ClassifierList} - */ - public ServiceCall listClassifiers() { - return listClassifiers(null); - } - - /** - * Get information about a classifier. - * - * Returns status and other information about a classifier. - * - * @param getClassifierOptions the {@link GetClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} - */ - public ServiceCall getClassifier(GetClassifierOptions getClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getClassifierOptions, - "getClassifierOptions cannot be null"); - String[] pathSegments = { "v1/classifiers" }; - String[] pathParameters = { getClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "getClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete classifier. - * - * @param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteClassifier(DeleteClassifierOptions deleteClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteClassifierOptions, - "deleteClassifierOptions cannot be null"); - String[] pathSegments = { "v1/classifiers" }; - String[] pathParameters = { deleteClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "deleteClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java deleted file mode 100644 index 319eb52c8fd..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.natural_language_classifier.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response from the classifier for a phrase. - */ -public class Classification extends GenericModel { - - @SerializedName("classifier_id") - protected String classifierId; - protected String url; - protected String text; - @SerializedName("top_class") - protected String topClass; - protected List classes; - - /** - * Gets the classifierId. - * - * Unique identifier for this classifier. - * - * @return the classifierId - */ - public String getClassifierId() { - return classifierId; - } - - /** - * Gets the url. - * - * Link to the classifier. - * - * @return the url - */ - public String getUrl() { - return url; - } - - /** - * Gets the text. - * - * The submitted phrase. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the topClass. - * - * The class with the highest confidence. - * - * @return the topClass - */ - public String getTopClass() { - return topClass; - } - - /** - * Gets the classes. - * - * An array of up to ten class-confidence pairs sorted in descending order of confidence. - * - * @return the classes - */ - public List getClasses() { - return classes; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java deleted file mode 100644 index dc3f704ab6c..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response from the classifier for multiple phrases. - */ -public class ClassificationCollection extends GenericModel { - - @SerializedName("classifier_id") - protected String classifierId; - protected String url; - protected List collection; - - /** - * Gets the classifierId. - * - * Unique identifier for this classifier. - * - * @return the classifierId - */ - public String getClassifierId() { - return classifierId; - } - - /** - * Gets the url. - * - * Link to the classifier. - * - * @return the url - */ - public String getUrl() { - return url; - } - - /** - * Gets the collection. - * - * An array of classifier responses for each submitted phrase. - * - * @return the collection - */ - public List getCollection() { - return collection; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java deleted file mode 100644 index 2b8be1b61a2..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_classifier.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Class and confidence. - */ -public class ClassifiedClass extends GenericModel { - - protected Double confidence; - @SerializedName("class_name") - protected String className; - - /** - * Gets the confidence. - * - * A decimal percentage that represents the confidence that Watson has in this class. Higher values represent higher - * confidences. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } - - /** - * Gets the className. - * - * Class label. - * - * @return the className - */ - public String getClassName() { - return className; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java deleted file mode 100644 index 0cbd862d698..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.natural_language_classifier.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A classifier for natural language phrases. - */ -public class Classifier extends GenericModel { - - /** - * The state of the classifier. - */ - public interface Status { - /** Non Existent. */ - String NON_EXISTENT = "Non Existent"; - /** Training. */ - String TRAINING = "Training"; - /** Failed. */ - String FAILED = "Failed"; - /** Available. */ - String AVAILABLE = "Available"; - /** Unavailable. */ - String UNAVAILABLE = "Unavailable"; - } - - protected String name; - protected String url; - protected String status; - @SerializedName("classifier_id") - protected String classifierId; - protected Date created; - @SerializedName("status_description") - protected String statusDescription; - protected String language; - - /** - * Gets the name. - * - * User-supplied name for the classifier. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the url. - * - * Link to the classifier. - * - * @return the url - */ - public String getUrl() { - return url; - } - - /** - * Gets the status. - * - * The state of the classifier. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the classifierId. - * - * Unique identifier for this classifier. - * - * @return the classifierId - */ - public String getClassifierId() { - return classifierId; - } - - /** - * Gets the created. - * - * Date and time (UTC) the classifier was created. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the statusDescription. - * - * Additional detail about the status. - * - * @return the statusDescription - */ - public String getStatusDescription() { - return statusDescription; - } - - /** - * Gets the language. - * - * The language used for the classifier. - * - * @return the language - */ - public String getLanguage() { - return language; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java deleted file mode 100644 index ae77d5ebd00..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_classifier.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * List of available classifiers. - */ -public class ClassifierList extends GenericModel { - - protected List classifiers; - - /** - * Gets the classifiers. - * - * The classifiers available to the user. Returns an empty array if no classifiers are available. - * - * @return the classifiers - */ - public List getClassifiers() { - return classifiers; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java deleted file mode 100644 index 0aa93fb2686..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The classifyCollection options. - */ -public class ClassifyCollectionOptions extends GenericModel { - - protected String classifierId; - protected List collection; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - private List collection; - - private Builder(ClassifyCollectionOptions classifyCollectionOptions) { - this.classifierId = classifyCollectionOptions.classifierId; - this.collection = classifyCollectionOptions.collection; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - * @param collection the collection - */ - public Builder(String classifierId, List collection) { - this.classifierId = classifierId; - this.collection = collection; - } - - /** - * Builds a ClassifyCollectionOptions. - * - * @return the classifyCollectionOptions - */ - public ClassifyCollectionOptions build() { - return new ClassifyCollectionOptions(this); - } - - /** - * Adds an classifyInput to collection. - * - * @param classifyInput the new classifyInput - * @return the ClassifyCollectionOptions builder - */ - public Builder addClassifyInput(ClassifyInput classifyInput) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classifyInput, - "classifyInput cannot be null"); - if (this.collection == null) { - this.collection = new ArrayList(); - } - this.collection.add(classifyInput); - return this; - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the ClassifyCollectionOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - - /** - * Set the collection. - * Existing collection will be replaced. - * - * @param collection the collection - * @return the ClassifyCollectionOptions builder - */ - public Builder collection(List collection) { - this.collection = collection; - return this; - } - } - - protected ClassifyCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collection, - "collection cannot be null"); - classifierId = builder.classifierId; - collection = builder.collection; - } - - /** - * New builder. - * - * @return a ClassifyCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * Classifier ID to use. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } - - /** - * Gets the collection. - * - * The submitted phrases. - * - * @return the collection - */ - public List collection() { - return collection; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java deleted file mode 100644 index 1895f963bce..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_classifier.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Request payload to classify. - */ -public class ClassifyInput extends GenericModel { - - protected String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(ClassifyInput classifyInput) { - this.text = classifyInput.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param text the text - */ - public Builder(String text) { - this.text = text; - } - - /** - * Builds a ClassifyInput. - * - * @return the classifyInput - */ - public ClassifyInput build() { - return new ClassifyInput(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the ClassifyInput builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - protected ClassifyInput(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a ClassifyInput builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * The submitted phrase. The maximum length is 2048 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java deleted file mode 100644 index eee4381d7c4..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The classify options. - */ -public class ClassifyOptions extends GenericModel { - - protected String classifierId; - protected String text; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - private String text; - - private Builder(ClassifyOptions classifyOptions) { - this.classifierId = classifyOptions.classifierId; - this.text = classifyOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - * @param text the text - */ - public Builder(String classifierId, String text) { - this.classifierId = classifierId; - this.text = text; - } - - /** - * Builds a ClassifyOptions. - * - * @return the classifyOptions - */ - public ClassifyOptions build() { - return new ClassifyOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the ClassifyOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the ClassifyOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - protected ClassifyOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - classifierId = builder.classifierId; - text = builder.text; - } - - /** - * New builder. - * - * @return a ClassifyOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * Classifier ID to use. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } - - /** - * Gets the text. - * - * The submitted phrase. The maximum length is 2048 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java deleted file mode 100644 index 4dcf66e5ad6..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Response from the classifier for a phrase in a collection. - */ -public class CollectionItem extends GenericModel { - - protected String text; - @SerializedName("top_class") - protected String topClass; - protected List classes; - - /** - * Gets the text. - * - * The submitted phrase. The maximum length is 2048 characters. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the topClass. - * - * The class with the highest confidence. - * - * @return the topClass - */ - public String getTopClass() { - return topClass; - } - - /** - * Gets the classes. - * - * An array of up to ten class-confidence pairs sorted in descending order of confidence. - * - * @return the classes - */ - public List getClasses() { - return classes; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java deleted file mode 100644 index f98e1e74959..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.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 createClassifier options. - */ -public class CreateClassifierOptions extends GenericModel { - - protected InputStream trainingMetadata; - protected InputStream trainingData; - - /** - * Builder. - */ - public static class Builder { - private InputStream trainingMetadata; - private InputStream trainingData; - - private Builder(CreateClassifierOptions createClassifierOptions) { - this.trainingMetadata = createClassifierOptions.trainingMetadata; - this.trainingData = createClassifierOptions.trainingData; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param trainingMetadata the trainingMetadata - * @param trainingData the trainingData - */ - public Builder(InputStream trainingMetadata, InputStream trainingData) { - this.trainingMetadata = trainingMetadata; - this.trainingData = trainingData; - } - - /** - * Builds a CreateClassifierOptions. - * - * @return the createClassifierOptions - */ - public CreateClassifierOptions build() { - return new CreateClassifierOptions(this); - } - - /** - * Set the trainingMetadata. - * - * @param trainingMetadata the trainingMetadata - * @return the CreateClassifierOptions builder - */ - public Builder trainingMetadata(InputStream trainingMetadata) { - this.trainingMetadata = trainingMetadata; - return this; - } - - /** - * Set the trainingData. - * - * @param trainingData the trainingData - * @return the CreateClassifierOptions builder - */ - public Builder trainingData(InputStream trainingData) { - this.trainingData = trainingData; - return this; - } - - /** - * Set the trainingMetadata. - * - * @param trainingMetadata the trainingMetadata - * @return the CreateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder trainingMetadata(File trainingMetadata) throws FileNotFoundException { - this.trainingMetadata = new FileInputStream(trainingMetadata); - return this; - } - - /** - * Set the trainingData. - * - * @param trainingData the trainingData - * @return the CreateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder trainingData(File trainingData) throws FileNotFoundException { - this.trainingData = new FileInputStream(trainingData); - return this; - } - } - - protected CreateClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.trainingMetadata, - "trainingMetadata cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.trainingData, - "trainingData cannot be null"); - trainingMetadata = builder.trainingMetadata; - trainingData = builder.trainingData; - } - - /** - * New builder. - * - * @return a CreateClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the trainingMetadata. - * - * Metadata in JSON format. The metadata identifies the language of the data, and an optional name to identify the - * classifier. Specify the language with the 2-letter primary language code as assigned in ISO standard 639. - * - * Supported languages are English (`en`), Arabic (`ar`), French (`fr`), German, (`de`), Italian (`it`), Japanese - * (`ja`), Korean (`ko`), Brazilian Portuguese (`pt`), and Spanish (`es`). - * - * @return the trainingMetadata - */ - public InputStream trainingMetadata() { - return trainingMetadata; - } - - /** - * Gets the trainingData. - * - * Training data in CSV format. Each text value must have at least one class. The data can include up to 3,000 classes - * and 20,000 records. For details, see [Data - * preparation](https://cloud.ibm.com/docs/natural-language-classifier?topic=natural-language-classifier-using-your-data). - * - * @return the trainingData - */ - public InputStream trainingData() { - return trainingData; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java deleted file mode 100644 index c625f291ae6..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteClassifier options. - */ -public class DeleteClassifierOptions extends GenericModel { - - protected String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(DeleteClassifierOptions deleteClassifierOptions) { - this.classifierId = deleteClassifierOptions.classifierId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this.classifierId = classifierId; - } - - /** - * Builds a DeleteClassifierOptions. - * - * @return the deleteClassifierOptions - */ - public DeleteClassifierOptions build() { - return new DeleteClassifierOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the DeleteClassifierOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - } - - protected DeleteClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - classifierId = builder.classifierId; - } - - /** - * New builder. - * - * @return a DeleteClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * Classifier ID to delete. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java deleted file mode 100644 index b84a8c3a671..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.natural_language_classifier.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getClassifier options. - */ -public class GetClassifierOptions extends GenericModel { - - protected String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(GetClassifierOptions getClassifierOptions) { - this.classifierId = getClassifierOptions.classifierId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this.classifierId = classifierId; - } - - /** - * Builds a GetClassifierOptions. - * - * @return the getClassifierOptions - */ - public GetClassifierOptions build() { - return new GetClassifierOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the GetClassifierOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - } - - protected GetClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - classifierId = builder.classifierId; - } - - /** - * New builder. - * - * @return a GetClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * Classifier ID to query. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java deleted file mode 100644 index e91b651756b..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_classifier.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listClassifiers options. - */ -public class ListClassifiersOptions extends GenericModel { - - /** - * Builder. - */ - public static class Builder { - - private Builder(ListClassifiersOptions listClassifiersOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListClassifiersOptions. - * - * @return the listClassifiersOptions - */ - public ListClassifiersOptions build() { - return new ListClassifiersOptions(this); - } - } - - private ListClassifiersOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListClassifiersOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java deleted file mode 100644 index 098c3ed49ab..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Natural Language Classifier v1. - */ -package com.ibm.watson.natural_language_classifier.v1; diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierIT.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierIT.java deleted file mode 100644 index 67821275d85..00000000000 --- a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierIT.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * (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.natural_language_classifier.v1; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.cloud.sdk.core.service.exception.NotFoundException; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.natural_language_classifier.v1.model.Classification; -import com.ibm.watson.natural_language_classifier.v1.model.ClassificationCollection; -import com.ibm.watson.natural_language_classifier.v1.model.Classifier; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifierList; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyCollectionOptions; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyInput; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.natural_language_classifier.v1.model.CreateClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.DeleteClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.GetClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.AssumptionViolatedException; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import java.io.File; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * The Class NaturalLanguageClassifierTest. - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class NaturalLanguageClassifierIT extends WatsonServiceTest { - - /** The classifier id. */ - private static String classifierId = null; - private String preCreatedClassifierId; - - /** The service. */ - private NaturalLanguageClassifier service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String apiKey = getProperty("natural_language_classifier.apikey"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); - - Authenticator authenticator = new IamAuthenticator(apiKey); - service = new NaturalLanguageClassifier(authenticator); - service.setDefaultHeaders(getDefaultHeaders()); - service.setServiceUrl(getProperty("natural_language_classifier.url")); - - preCreatedClassifierId = getProperty("natural_language_classifier.classifier_id"); - } - - /** - * Creates the classifier. - * - * @throws Exception the exception - */ - @Test - public void aCreate() throws Exception { - final File trainingData = new File("src/test/resources/natural_language_classifier/weather_data_train.csv"); - final File metadata = new File("src/test/resources/natural_language_classifier/metadata.json"); - - CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder() - .trainingMetadata(metadata) - .trainingData(trainingData) - .build(); - Classifier classifier = service.createClassifier(createOptions).execute().getResult(); - - try { - assertNotNull(classifier); - Assert.assertEquals(Classifier.Status.TRAINING, classifier.getStatus()); - assertEquals("test-classifier", classifier.getName()); - assertEquals("en", classifier.getLanguage()); - } finally { - classifierId = classifier.getClassifierId(); - } - - } - - /** - * Test get classifier. - */ - @Test - public void bGetClassifier() { - final Classifier classifier; - - try { - GetClassifierOptions getOptions = new GetClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - classifier = service.getClassifier(getOptions).execute().getResult(); - } catch (NotFoundException e) { - // #324: Classifiers may be empty, because of other tests interfering. - // The build should not fail here, because this is out of our control. - throw new AssumptionViolatedException(e.getMessage(), e); - } - assertNotNull(classifier); - assertEquals(classifierId, classifier.getClassifierId()); - assertEquals(Classifier.Status.TRAINING, classifier.getStatus()); - } - - /** - * Test list classifiers. - */ - @Test - public void cListClassifiers() { - ListClassifiersOptions listOptions = new ListClassifiersOptions.Builder() - .build(); - final ClassifierList classifiers = service.listClassifiers(listOptions).execute().getResult(); - assertNotNull(classifiers); - - // #324: Classifiers may be empty, because of other tests interfering. - // The build should not fail here, because this is out of our control. - Assume.assumeFalse(classifiers.getClassifiers().isEmpty()); - } - - /** - * Test classify. Use the pre created classifier to avoid waiting for availability - */ - @Test - public void dClassify() { - Classification classification = null; - - try { - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId(preCreatedClassifierId) - .text("is it hot outside?") - .build(); - classification = service.classify(classifyOptions).execute().getResult(); - } catch (NotFoundException e) { - // #324: Classifiers may be empty, because of other tests interfering. - // The build should not fail here, because this is out of our control. - throw new AssumptionViolatedException(e.getMessage(), e); - } - - assertNotNull(classification); - assertEquals("temperature", classification.getTopClass()); - } - - /** - * Test delete classifier. Only delete the classifier we created earlier. - */ - @Test - public void eDelete() throws InterruptedException { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - service.deleteClassifier(deleteOptions).execute(); - } - - /** - * Test classifyCollection. Use the pre created classifier to avoid waiting for availability - */ - @Test - public void fClassifyCollection() { - ClassificationCollection classificationCollection = null; - ClassifyInput input1 = new ClassifyInput.Builder() - .text("How hot will it be today?") - .build(); - ClassifyInput input2 = new ClassifyInput.Builder() - .text("Is it hot outside?") - .build(); - - try { - ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder() - .classifierId(preCreatedClassifierId) - .addClassifyInput(input1) - .addClassifyInput(input2) - .build(); - classificationCollection = service.classifyCollection(classifyOptions).execute().getResult(); - } catch (NotFoundException e) { - // #324: Classifiers may be empty, because of other tests interfering. - // The build should not fail here, because this is out of our control. - throw new AssumptionViolatedException(e.getMessage(), e); - } - - assertNotNull(classificationCollection); - assertEquals("temperature", classificationCollection.getCollection().get(0).getTopClass()); - assertEquals("temperature", classificationCollection.getCollection().get(1).getTopClass()); - } - -} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java deleted file mode 100644 index 15cd7ee842e..00000000000 --- a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * (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.natural_language_classifier.v1; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.natural_language_classifier.v1.model.Classification; -import com.ibm.watson.natural_language_classifier.v1.model.ClassificationCollection; -import com.ibm.watson.natural_language_classifier.v1.model.Classifier; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifierList; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyCollectionOptions; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyInput; -import com.ibm.watson.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.natural_language_classifier.v1.model.CreateClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.DeleteClassifierOptions; -import com.ibm.watson.natural_language_classifier.v1.model.GetClassifierOptions; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -/** - * The Class NaturalLanguageClassifierTest. - */ -public class NaturalLanguageClassifierTest extends WatsonServiceUnitTest { - private static final String TEXT = "text"; - private static final String CLASSIFIERS_PATH = "/v1/classifiers"; - private static final String CLASSIFY_PATH = "/v1/classifiers/%s/classify"; - private static final String CLASSIFY_COLLECTION_PATH = "/v1/classifiers/%s/classify_collection"; - private static final String RESOURCE = "src/test/resources/natural_language_classifier/"; - - private ClassifierList classifiers; - private Classifier classifier; - private Classification classification; - private ClassificationCollection classificationCollection; - - private String classifierId; - private NaturalLanguageClassifier service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new NaturalLanguageClassifier(new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - classifierId = "foo"; - classifiers = loadFixture(RESOURCE + "classifiers.json", ClassifierList.class); - classifier = loadFixture(RESOURCE + "classifier.json", Classifier.class); - classification = loadFixture(RESOURCE + "classification.json", Classification.class); - classificationCollection = loadFixture(RESOURCE + "classification_collection.json", - ClassificationCollection.class); - } - - /** - * Test classify. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testClassify() throws InterruptedException { - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty(TEXT, classification.getText()); - - final String path = String.format(CLASSIFY_PATH, classifierId); - - server.enqueue(jsonResponse(classification)); - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId(classifierId) - .text(classification.getText()) - .build(); - final Classification result = service.classify(classifyOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(contentJson.toString(), request.getBody().readUtf8()); - assertEquals(classification, result); - } - - /** - * Test classifying a collection. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testClassifyCollection() throws InterruptedException { - final String path = String.format(CLASSIFY_COLLECTION_PATH, classifierId); - - server.enqueue(jsonResponse(classificationCollection)); - - ClassifyInput input1 = new ClassifyInput.Builder() - .text("How hot will it be today?") - .build(); - ClassifyInput input2 = new ClassifyInput.Builder() - .text("Is it hot outside?") - .build(); - List inputCollection = Arrays.asList(input1, input2); - - ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder() - .classifierId(classifierId) - .collection(inputCollection) - .build(); - final ClassificationCollection result = service.classifyCollection(classifyOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(classificationCollection, result); - } - - /** - * Test get classifier. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetClassifier() throws InterruptedException { - server.enqueue(jsonResponse(classifier)); - GetClassifierOptions getOptions = new GetClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - final Classifier response = service.getClassifier(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(CLASSIFIERS_PATH + "/" + classifierId, request.getPath()); - assertEquals(classifier, response); - } - - /** - * Test get classifiers. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetClassifiers() throws InterruptedException { - server.enqueue(jsonResponse(classifiers)); - final ClassifierList response = service.listClassifiers().execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(CLASSIFIERS_PATH, request.getPath()); - assertEquals(classifiers, response); - } - - /** - * Test create classifier. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testCreateClassifier() throws InterruptedException, FileNotFoundException { - server.enqueue(jsonResponse(classifier)); - File metadata = new File(RESOURCE + "metadata.json"); - File trainingData = new File(RESOURCE + "weather_data_train.csv"); - CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder() - .trainingMetadata(metadata) - .trainingData(trainingData) - .build(); - final Classifier response = service.createClassifier(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(CLASSIFIERS_PATH, request.getPath()); - assertEquals(classifier, response); - } - - /** - * Test delete classifier. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteClassifier() throws InterruptedException { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - service.deleteClassifier(deleteOptions); - } - - // START NEGATIVE TESTS - /** - * Test null classifier. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullClassifier() { - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .text("test") - .build(); - service.classify(classifyOptions); - } - - /** - * Test null text. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullText() { - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId(classifierId) - .build(); - service.classify(classifyOptions); - } - - /** - * Test null delete classifier. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullDeleteClassifier() { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder() - .build(); - service.deleteClassifier(deleteOptions); - } - - /** - * Test null training data file. - */ - @Test(expected = FileNotFoundException.class) - public void testNullTrainingDataFile() throws FileNotFoundException { - server.enqueue(jsonResponse(classifier)); - File metadata = new File(RESOURCE + "metadata.json"); - File trainingData = new File(RESOURCE + "notfound.txt"); - CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder() - .trainingMetadata(metadata) - .trainingData(trainingData) - .build(); - service.createClassifier(createOptions).execute(); - } - -} diff --git a/natural-language-classifier/src/test/resources/natural_language_classifier/classification.json b/natural-language-classifier/src/test/resources/natural_language_classifier/classification.json deleted file mode 100644 index fd42da197ae..00000000000 --- a/natural-language-classifier/src/test/resources/natural_language_classifier/classification.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "classifier_id": "47C164-nlc-243", - "url": "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/47C164-nlc-243", - "text": "is it hot ?", - "top_class": "temperature", - "classes": [ - { - "class_name": "temperature", - "confidence": 0.981897175307704 - }, - { - "class_name": "conditions", - "confidence": 0.018102824692296068 - } - ] -} \ No newline at end of file diff --git a/natural-language-classifier/src/test/resources/natural_language_classifier/classification_collection.json b/natural-language-classifier/src/test/resources/natural_language_classifier/classification_collection.json deleted file mode 100644 index 9ebc67cd830..00000000000 --- a/natural-language-classifier/src/test/resources/natural_language_classifier/classification_collection.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "classifier_id" : "10D41B-nlc-1", - "url" : "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/10D41B-nlc-1", - "collection" : [ { - "text" : "How hot will it be today?", - "top_class" : "temperature", - "classes" : [ { - "class_name" : "temperature", - "confidence" : 0.9930558798985937 - }, { - "class_name" : "conditions", - "confidence" : 0.006944120101406304 - } ] - }, { - "text" : "Is it hot outside?", - "top_class" : "temperature", - "classes" : [ { - "class_name" : "temperature", - "confidence" : 1 - }, { - "class_name" : "conditions", - "confidence" : 0 - } ] - } ] -} \ No newline at end of file diff --git a/natural-language-classifier/src/test/resources/natural_language_classifier/classifier.json b/natural-language-classifier/src/test/resources/natural_language_classifier/classifier.json deleted file mode 100644 index cf6ff545823..00000000000 --- a/natural-language-classifier/src/test/resources/natural_language_classifier/classifier.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "classifier_id": "5E00F7x2-nlc-507", - "url": "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/5E00F7x2-nlc-507", - "name": "Music controls", - "language": "en", - "created": "2015-10-17T20:56:29.974Z" -} \ No newline at end of file diff --git a/natural-language-classifier/src/test/resources/natural_language_classifier/classifiers.json b/natural-language-classifier/src/test/resources/natural_language_classifier/classifiers.json deleted file mode 100644 index cf4afcf95fc..00000000000 --- a/natural-language-classifier/src/test/resources/natural_language_classifier/classifiers.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "classifiers": [ - { - "classifier_id": "47C164-nlc-243", - "url": "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/47C164-nlc-243", - "name": "weather", - "language": "en", - "created": "2015-08-24T18:42:25.324Z" - }, - { - "classifier_id": "5E00F7x2-nlc-507", - "url": "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/5E00F7x2-nlc-507", - "name": "Music controls", - "language": "en", - "created": "2015-10-17T20:56:29.974Z" - } - ] -} \ No newline at end of file diff --git a/natural-language-classifier/src/test/resources/natural_language_classifier/metadata.json b/natural-language-classifier/src/test/resources/natural_language_classifier/metadata.json deleted file mode 100644 index 28e2e1f0405..00000000000 --- a/natural-language-classifier/src/test/resources/natural_language_classifier/metadata.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "test-classifier", - "language": "en" -} \ No newline at end of file diff --git a/natural-language-classifier/src/test/resources/natural_language_classifier/weather_data_train.csv b/natural-language-classifier/src/test/resources/natural_language_classifier/weather_data_train.csv deleted file mode 100644 index 454276ab6db..00000000000 --- a/natural-language-classifier/src/test/resources/natural_language_classifier/weather_data_train.csv +++ /dev/null @@ -1 +0,0 @@ -How hot is it today?,temperature Is it hot outside?,temperature Will it be uncomfortably hot?,temperature Will it be sweltering?,temperature How cold is it today?,temperature Is it cold outside?,temperature Will it be uncomfortably cold?,temperature Will it be frigid?,temperature What is the expected high for today?,temperature What is the expected temperature?,temperature Will high temperatures be dangerous?,temperature Is it dangerously cold?,temperature When will the heat subside?,temperature Is it hot?,temperature Is it cold?,temperature How cold is it now?,temperature Will we have a cold day today?,temperature,conditions When will the cold subside?,temperature What highs are we expecting?,temperature What lows are we expecting?,temperature Is it warm?,temperature Is it chilly?,temperature What's the current temp in Celsius?,temperature,conditions What is the temperature in Fahrenheit?,temperature,conditions Is it windy?,conditions Will it rain today?,conditions What are the chances for rain?,conditions Will we get snow?,conditions Are we expecting sunny conditions?,conditions Is it overcast?,conditions Will it be cloudy?,conditions How much rain will fall today?,conditions How much snow are we expecting?,conditions Is it windy outside?,conditions How much snow do we expect?,conditions Is the forecast calling for snow today?,conditions Will we see some sun?,conditions When will the rain subside?,conditions Is it cloudy?,conditions Is it sunny now?,conditions Will it rain?,conditions Will we have much snow?,conditions Are the winds dangerous?,conditions What is the expected snowfall today?,conditions Will it be dry?,conditions Will it be breezy?,conditions Will it be humid?,conditions What is today's expected humidity?,conditions Will the blizzard hit us?,conditions Is it drizzling?,conditions \ No newline at end of file diff --git a/natural-language-understanding/README.md b/natural-language-understanding/README.md index 4c0bc8be782..eb14de22e1d 100644 --- a/natural-language-understanding/README.md +++ b/natural-language-understanding/README.md @@ -8,14 +8,14 @@ com.ibm.watson natural-language-understanding - 8.3.1 + 16.2.0 ``` ##### Gradle ```gradle -'com.ibm.watson:natural-language-understanding:8.3.1' +'com.ibm.watson:natural-language-understanding:16.2.0' ``` ## Usage diff --git a/natural-language-understanding/build.gradle b/natural-language-understanding/build.gradle deleted file mode 100644 index e63b7d64fa9..00000000000 --- a/natural-language-understanding/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/natural-language-understanding/gradle.properties b/natural-language-understanding/gradle.properties deleted file mode 100644 index 74c3c3cef85..00000000000 --- a/natural-language-understanding/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:natural-language-understanding -ARTIFACT_ID=natural-language-understanding -NAME=IBM Watson Java SDK - Natural Language Understanding -DESCRIPTION=Java client library to use the IBM Natural Language Understanding API \ No newline at end of file diff --git a/natural-language-understanding/pom.xml b/natural-language-understanding/pom.xml new file mode 100644 index 00000000000..de747e9ff55 --- /dev/null +++ b/natural-language-understanding/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + natural-language-understanding + jar + IBM Watson Java SDK - Natural Language Understanding + + + + com.ibm.cloud + sdk-core + + + ${project.groupId} + common + compile + + + ${project.groupId} + common + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java index f416cfbc306..7db48403f4d 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.85.0-75c38f8f-20240206-210220 + */ + package com.ibm.watson.natural_language_understanding.v1; import com.google.gson.JsonObject; @@ -19,125 +24,164 @@ import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; +import com.ibm.cloud.sdk.core.util.RequestUtils; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; import com.ibm.watson.common.SdkCommon; import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResults; import com.ibm.watson.natural_language_understanding.v1.model.AnalyzeOptions; +import com.ibm.watson.natural_language_understanding.v1.model.CategoriesModel; +import com.ibm.watson.natural_language_understanding.v1.model.CategoriesModelList; +import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsModel; +import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsModelList; +import com.ibm.watson.natural_language_understanding.v1.model.CreateCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.CreateClassificationsModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.DeleteCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.DeleteClassificationsModelOptions; import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelOptions; import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults; +import com.ibm.watson.natural_language_understanding.v1.model.GetCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.GetClassificationsModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ListCategoriesModelsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ListClassificationsModelsOptions; import com.ibm.watson.natural_language_understanding.v1.model.ListModelsOptions; import com.ibm.watson.natural_language_understanding.v1.model.ListModelsResults; +import com.ibm.watson.natural_language_understanding.v1.model.UpdateCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.UpdateClassificationsModelOptions; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import okhttp3.MultipartBody; /** - * Analyze various features of text content at scale. Provide text, raw HTML, or a public URL and IBM Watson Natural - * Language Understanding will give you results for the features you request. The service cleans HTML content before - * analysis by default, so the results can ignore most advertisements and other unwanted content. + * Analyze various features of text content at scale. Provide text, raw HTML, or a public URL and + * IBM Watson Natural Language Understanding will give you results for the features you request. The + * service cleans HTML content before analysis by default, so the results can ignore most + * advertisements and other unwanted content. * - * You can create [custom + *

You can create [custom * models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) - * with Watson Knowledge Studio to detect custom entities and relations in Natural Language Understanding. + * with Watson Knowledge Studio to detect custom entities and relations in Natural Language + * Understanding. * - * @version v1 - * @see Natural Language Understanding + *

API Version: 1.0 See: https://cloud.ibm.com/docs/natural-language-understanding */ public class NaturalLanguageUnderstanding extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "natural_language_understanding"; + /** Default service name used when configuring the `NaturalLanguageUnderstanding` client. */ + public static final String DEFAULT_SERVICE_NAME = "natural-language-understanding"; - private static final String DEFAULT_SERVICE_URL - = "https://gateway.watsonplatform.net/natural-language-understanding/api"; + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `NaturalLanguageUnderstanding` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The default service name + * is used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2022-04-07`. */ - public NaturalLanguageUnderstanding(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + public NaturalLanguageUnderstanding(String version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `NaturalLanguageUnderstanding` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The default service name + * and specified authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2022-04-07`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public NaturalLanguageUnderstanding(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public NaturalLanguageUnderstanding(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `NaturalLanguageUnderstanding` client with the specified serviceName. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The specified service name + * is used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2022-04-07`. + * @param serviceName the service name to be used when configuring the client instance */ - public NaturalLanguageUnderstanding(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public NaturalLanguageUnderstanding(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `NaturalLanguageUnderstanding` client with the specified Authenticator - * and serviceName. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The specified service name + * and authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2022-04-07`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public NaturalLanguageUnderstanding(String versionDate, String serviceName, Authenticator authenticator) { + public NaturalLanguageUnderstanding( + String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2022-04-07`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Analyze text. * - * Analyzes text, HTML, or a public webpage for the following features: - * - Categories - * - Concepts - * - Emotion - * - Entities - * - Keywords - * - Metadata - * - Relations - * - Semantic roles - * - Sentiment - * - Syntax (Experimental). - * - * If a language for the input text is not specified with the `language` parameter, the service [automatically detects - * the + *

Analyzes text, HTML, or a public webpage for the following features: - Categories - + * Classifications - Concepts - Emotion - Entities - Keywords - Metadata - Relations - Semantic + * roles - Sentiment - Syntax + * + *

If a language for the input text is not specified with the `language` parameter, the service + * [automatically detects the * language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages). * * @param analyzeOptions the {@link AnalyzeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AnalysisResults} + * @return a {@link ServiceCall} with a result of type {@link AnalysisResults} */ public ServiceCall analyze(AnalyzeOptions analyzeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(analyzeOptions, - "analyzeOptions cannot be null"); - String[] pathSegments = { "v1/analyze" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "analyze"); + com.ibm.cloud.sdk.core.util.Validator.notNull(analyzeOptions, "analyzeOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/analyze")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "analyze"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); - contentJson.add("features", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(analyzeOptions - .features())); + contentJson.add( + "features", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(analyzeOptions.features())); if (analyzeOptions.text() != null) { contentJson.addProperty("text", analyzeOptions.text()); } @@ -166,48 +210,46 @@ public ServiceCall analyze(AnalyzeOptions analyzeOptions) { contentJson.addProperty("limit_text_characters", analyzeOptions.limitTextCharacters()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List models. * - * Lists Watson Knowledge Studio [custom entities and relations + *

Lists Watson Knowledge Studio [custom entities and relations * models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) * that are deployed to your Natural Language Understanding service. * * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListModelsResults} + * @return a {@link ServiceCall} with a result of type {@link ListModelsResults} */ public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = { "v1/models" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "listModels"); + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "listModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listModelsOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List models. * - * Lists Watson Knowledge Studio [custom entities and relations + *

Lists Watson Knowledge Studio [custom entities and relations * models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) * that are deployed to your Natural Language Understanding service. * - * @return a {@link ServiceCall} with a response type of {@link ListModelsResults} + * @return a {@link ServiceCall} with a result of type {@link ListModelsResults} */ public ServiceCall listModels() { return listModels(null); @@ -216,29 +258,500 @@ public ServiceCall listModels() { /** * Delete model. * - * Deletes a custom model. + *

Deletes a custom model. * * @param deleteModelOptions the {@link DeleteModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteModelResults} + * @return a {@link ServiceCall} with a result of type {@link DeleteModelResults} */ public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteModelOptions, - "deleteModelOptions cannot be null"); - String[] pathSegments = { "v1/models" }; - String[] pathParameters = { deleteModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "deleteModel"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteModelOptions, "deleteModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", deleteModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "deleteModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create categories model. + * + *

(Beta) Creates a custom categories model by uploading training data and associated metadata. + * The model begins the training and deploying process and is ready to use when the `status` is + * `available`. + * + * @param createCategoriesModelOptions the {@link CreateCategoriesModelOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link CategoriesModel} + */ + public ServiceCall createCategoriesModel( + CreateCategoriesModelOptions createCategoriesModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createCategoriesModelOptions, "createCategoriesModelOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models/categories")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "createCategoriesModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart("language", createCategoriesModelOptions.language()); + okhttp3.RequestBody trainingDataBody = + RequestUtils.inputStreamBody( + createCategoriesModelOptions.trainingData(), + createCategoriesModelOptions.trainingDataContentType()); + multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); + if (createCategoriesModelOptions.name() != null) { + multipartBuilder.addFormDataPart("name", createCategoriesModelOptions.name()); + } + if (createCategoriesModelOptions.userMetadata() != null) { + multipartBuilder.addFormDataPart( + "user_metadata", String.valueOf(createCategoriesModelOptions.userMetadata())); + } + if (createCategoriesModelOptions.description() != null) { + multipartBuilder.addFormDataPart("description", createCategoriesModelOptions.description()); + } + if (createCategoriesModelOptions.modelVersion() != null) { + multipartBuilder.addFormDataPart( + "model_version", createCategoriesModelOptions.modelVersion()); + } + if (createCategoriesModelOptions.workspaceId() != null) { + multipartBuilder.addFormDataPart("workspace_id", createCategoriesModelOptions.workspaceId()); + } + if (createCategoriesModelOptions.versionDescription() != null) { + multipartBuilder.addFormDataPart( + "version_description", createCategoriesModelOptions.versionDescription()); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List categories models. + * + *

(Beta) Returns all custom categories models associated with this service instance. + * + * @param listCategoriesModelsOptions the {@link ListCategoriesModelsOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link CategoriesModelList} + */ + public ServiceCall listCategoriesModels( + ListCategoriesModelsOptions listCategoriesModelsOptions) { + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models/categories")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "listCategoriesModels"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List categories models. + * + *

(Beta) Returns all custom categories models associated with this service instance. + * + * @return a {@link ServiceCall} with a result of type {@link CategoriesModelList} + */ + public ServiceCall listCategoriesModels() { + return listCategoriesModels(null); + } + + /** + * Get categories model details. + * + *

(Beta) Returns the status of the categories model with the given model ID. + * + * @param getCategoriesModelOptions the {@link GetCategoriesModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link CategoriesModel} + */ + public ServiceCall getCategoriesModel( + GetCategoriesModelOptions getCategoriesModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getCategoriesModelOptions, "getCategoriesModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", getCategoriesModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/categories/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "getCategoriesModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update categories model. + * + *

(Beta) Overwrites the training data associated with this custom categories model and + * retrains the model. The new model replaces the current deployment. + * + * @param updateCategoriesModelOptions the {@link UpdateCategoriesModelOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link CategoriesModel} + */ + public ServiceCall updateCategoriesModel( + UpdateCategoriesModelOptions updateCategoriesModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateCategoriesModelOptions, "updateCategoriesModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", updateCategoriesModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.put( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/categories/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "updateCategoriesModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart("language", updateCategoriesModelOptions.language()); + okhttp3.RequestBody trainingDataBody = + RequestUtils.inputStreamBody( + updateCategoriesModelOptions.trainingData(), + updateCategoriesModelOptions.trainingDataContentType()); + multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); + if (updateCategoriesModelOptions.name() != null) { + multipartBuilder.addFormDataPart("name", updateCategoriesModelOptions.name()); + } + if (updateCategoriesModelOptions.userMetadata() != null) { + multipartBuilder.addFormDataPart( + "user_metadata", String.valueOf(updateCategoriesModelOptions.userMetadata())); + } + if (updateCategoriesModelOptions.description() != null) { + multipartBuilder.addFormDataPart("description", updateCategoriesModelOptions.description()); + } + if (updateCategoriesModelOptions.modelVersion() != null) { + multipartBuilder.addFormDataPart( + "model_version", updateCategoriesModelOptions.modelVersion()); + } + if (updateCategoriesModelOptions.workspaceId() != null) { + multipartBuilder.addFormDataPart("workspace_id", updateCategoriesModelOptions.workspaceId()); + } + if (updateCategoriesModelOptions.versionDescription() != null) { + multipartBuilder.addFormDataPart( + "version_description", updateCategoriesModelOptions.versionDescription()); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete categories model. + * + *

(Beta) Un-deploys the custom categories model with the given model ID and deletes all + * associated customer data, including any training data or binary artifacts. + * + * @param deleteCategoriesModelOptions the {@link DeleteCategoriesModelOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link DeleteModelResults} + */ + public ServiceCall deleteCategoriesModel( + DeleteCategoriesModelOptions deleteCategoriesModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteCategoriesModelOptions, "deleteCategoriesModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", deleteCategoriesModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/categories/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "deleteCategoriesModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create classifications model. + * + *

Creates a custom classifications model by uploading training data and associated metadata. + * The model begins the training and deploying process and is ready to use when the `status` is + * `available`. + * + * @param createClassificationsModelOptions the {@link CreateClassificationsModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ClassificationsModel} + */ + public ServiceCall createClassificationsModel( + CreateClassificationsModelOptions createClassificationsModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createClassificationsModelOptions, "createClassificationsModelOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models/classifications")); + Map sdkHeaders = + SdkCommon.getSdkHeaders( + "natural-language-understanding", "v1", "createClassificationsModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart("language", createClassificationsModelOptions.language()); + okhttp3.RequestBody trainingDataBody = + RequestUtils.inputStreamBody( + createClassificationsModelOptions.trainingData(), + createClassificationsModelOptions.trainingDataContentType()); + multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); + if (createClassificationsModelOptions.name() != null) { + multipartBuilder.addFormDataPart("name", createClassificationsModelOptions.name()); + } + if (createClassificationsModelOptions.userMetadata() != null) { + multipartBuilder.addFormDataPart( + "user_metadata", String.valueOf(createClassificationsModelOptions.userMetadata())); + } + if (createClassificationsModelOptions.description() != null) { + multipartBuilder.addFormDataPart( + "description", createClassificationsModelOptions.description()); + } + if (createClassificationsModelOptions.modelVersion() != null) { + multipartBuilder.addFormDataPart( + "model_version", createClassificationsModelOptions.modelVersion()); + } + if (createClassificationsModelOptions.workspaceId() != null) { + multipartBuilder.addFormDataPart( + "workspace_id", createClassificationsModelOptions.workspaceId()); + } + if (createClassificationsModelOptions.versionDescription() != null) { + multipartBuilder.addFormDataPart( + "version_description", createClassificationsModelOptions.versionDescription()); + } + if (createClassificationsModelOptions.trainingParameters() != null) { + multipartBuilder.addFormDataPart( + "training_parameters", createClassificationsModelOptions.trainingParameters().toString()); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List classifications models. + * + *

Returns all custom classifications models associated with this service instance. + * + * @param listClassificationsModelsOptions the {@link ListClassificationsModelsOptions} containing + * the options for the call + * @return a {@link ServiceCall} with a result of type {@link ClassificationsModelList} + */ + public ServiceCall listClassificationsModels( + ListClassificationsModelsOptions listClassificationsModelsOptions) { + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models/classifications")); + Map sdkHeaders = + SdkCommon.getSdkHeaders( + "natural-language-understanding", "v1", "listClassificationsModels"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List classifications models. + * + *

Returns all custom classifications models associated with this service instance. + * + * @return a {@link ServiceCall} with a result of type {@link ClassificationsModelList} + */ + public ServiceCall listClassificationsModels() { + return listClassificationsModels(null); + } + + /** + * Get classifications model details. + * + *

Returns the status of the classifications model with the given model ID. + * + * @param getClassificationsModelOptions the {@link GetClassificationsModelOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link ClassificationsModel} + */ + public ServiceCall getClassificationsModel( + GetClassificationsModelOptions getClassificationsModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getClassificationsModelOptions, "getClassificationsModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", getClassificationsModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/classifications/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "getClassificationsModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + /** + * Update classifications model. + * + *

Overwrites the training data associated with this custom classifications model and retrains + * the model. The new model replaces the current deployment. + * + * @param updateClassificationsModelOptions the {@link UpdateClassificationsModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ClassificationsModel} + */ + public ServiceCall updateClassificationsModel( + UpdateClassificationsModelOptions updateClassificationsModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateClassificationsModelOptions, "updateClassificationsModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", updateClassificationsModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.put( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/classifications/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders( + "natural-language-understanding", "v1", "updateClassificationsModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart("language", updateClassificationsModelOptions.language()); + okhttp3.RequestBody trainingDataBody = + RequestUtils.inputStreamBody( + updateClassificationsModelOptions.trainingData(), + updateClassificationsModelOptions.trainingDataContentType()); + multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); + if (updateClassificationsModelOptions.name() != null) { + multipartBuilder.addFormDataPart("name", updateClassificationsModelOptions.name()); + } + if (updateClassificationsModelOptions.userMetadata() != null) { + multipartBuilder.addFormDataPart( + "user_metadata", String.valueOf(updateClassificationsModelOptions.userMetadata())); + } + if (updateClassificationsModelOptions.description() != null) { + multipartBuilder.addFormDataPart( + "description", updateClassificationsModelOptions.description()); + } + if (updateClassificationsModelOptions.modelVersion() != null) { + multipartBuilder.addFormDataPart( + "model_version", updateClassificationsModelOptions.modelVersion()); + } + if (updateClassificationsModelOptions.workspaceId() != null) { + multipartBuilder.addFormDataPart( + "workspace_id", updateClassificationsModelOptions.workspaceId()); + } + if (updateClassificationsModelOptions.versionDescription() != null) { + multipartBuilder.addFormDataPart( + "version_description", updateClassificationsModelOptions.versionDescription()); + } + if (updateClassificationsModelOptions.trainingParameters() != null) { + multipartBuilder.addFormDataPart( + "training_parameters", updateClassificationsModelOptions.trainingParameters().toString()); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } + /** + * Delete classifications model. + * + *

Un-deploys the custom classifications model with the given model ID and deletes all + * associated customer data, including any training data or binary artifacts. + * + * @param deleteClassificationsModelOptions the {@link DeleteClassificationsModelOptions} + * containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DeleteModelResults} + */ + public ServiceCall deleteClassificationsModel( + DeleteClassificationsModelOptions deleteClassificationsModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteClassificationsModelOptions, "deleteClassificationsModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", deleteClassificationsModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/classifications/{model_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders( + "natural-language-understanding", "v1", "deleteClassificationsModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java index c162927fe8b..5a2f96a124b 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -12,38 +12,43 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Results of the analysis, organized by feature. - */ +/** Results of the analysis, organized by feature. */ public class AnalysisResults extends GenericModel { protected String language; + @SerializedName("analyzed_text") protected String analyzedText; + @SerializedName("retrieved_url") protected String retrievedUrl; + protected AnalysisResultsUsage usage; protected List concepts; protected List entities; protected List keywords; protected List categories; + protected List classifications; protected EmotionResult emotion; - protected AnalysisResultsMetadata metadata; + protected FeaturesResultsMetadata metadata; protected List relations; + @SerializedName("semantic_roles") protected List semanticRoles; + protected SentimentResult sentiment; protected SyntaxResult syntax; + protected AnalysisResults() {} + /** * Gets the language. * - * Language used to analyze the text. + *

Language used to analyze the text. * * @return the language */ @@ -54,7 +59,7 @@ public String getLanguage() { /** * Gets the analyzedText. * - * Text that was used in the analysis. + *

Text that was used in the analysis. * * @return the analyzedText */ @@ -65,7 +70,7 @@ public String getAnalyzedText() { /** * Gets the retrievedUrl. * - * URL of the webpage that was analyzed. + *

URL of the webpage that was analyzed. * * @return the retrievedUrl */ @@ -76,7 +81,7 @@ public String getRetrievedUrl() { /** * Gets the usage. * - * API usage information for the request. + *

API usage information for the request. * * @return the usage */ @@ -87,7 +92,7 @@ public AnalysisResultsUsage getUsage() { /** * Gets the concepts. * - * The general concepts referenced or alluded to in the analyzed text. + *

The general concepts referenced or alluded to in the analyzed text. * * @return the concepts */ @@ -98,7 +103,7 @@ public List getConcepts() { /** * Gets the entities. * - * The entities detected in the analyzed text. + *

The entities detected in the analyzed text. * * @return the entities */ @@ -109,7 +114,7 @@ public List getEntities() { /** * Gets the keywords. * - * The keywords from the analyzed text. + *

The keywords from the analyzed text. * * @return the keywords */ @@ -120,7 +125,7 @@ public List getKeywords() { /** * Gets the categories. * - * The categories that the service assigned to the analyzed text. + *

The categories that the service assigned to the analyzed text. * * @return the categories */ @@ -128,10 +133,21 @@ public List getCategories() { return categories; } + /** + * Gets the classifications. + * + *

The classifications assigned to the analyzed text. + * + * @return the classifications + */ + public List getClassifications() { + return classifications; + } + /** * Gets the emotion. * - * The anger, disgust, fear, joy, or sadness conveyed by the content. + *

The anger, disgust, fear, joy, or sadness conveyed by the content. * * @return the emotion */ @@ -142,18 +158,18 @@ public EmotionResult getEmotion() { /** * Gets the metadata. * - * Webpage metadata, such as the author and the title of the page. + *

Webpage metadata, such as the author and the title of the page. * * @return the metadata */ - public AnalysisResultsMetadata getMetadata() { + public FeaturesResultsMetadata getMetadata() { return metadata; } /** * Gets the relations. * - * The relationships between entities in the content. + *

The relationships between entities in the content. * * @return the relations */ @@ -164,7 +180,7 @@ public List getRelations() { /** * Gets the semanticRoles. * - * Sentences parsed into `subject`, `action`, and `object` form. + *

Sentences parsed into `subject`, `action`, and `object` form. * * @return the semanticRoles */ @@ -175,7 +191,7 @@ public List getSemanticRoles() { /** * Gets the sentiment. * - * The sentiment of the content. + *

The sentiment of the content. * * @return the sentiment */ @@ -186,7 +202,7 @@ public SentimentResult getSentiment() { /** * Gets the syntax. * - * Tokens and sentences returned from syntax analysis. + *

Tokens and sentences returned from syntax analysis. * * @return the syntax */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsMetadata.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsMetadata.java deleted file mode 100644 index e974d0a0e36..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsMetadata.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_understanding.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Webpage metadata, such as the author and the title of the page. - */ -public class AnalysisResultsMetadata extends GenericModel { - - protected List authors; - @SerializedName("publication_date") - protected String publicationDate; - protected String title; - protected String image; - protected List feeds; - - /** - * Gets the authors. - * - * The authors of the document. - * - * @return the authors - */ - public List getAuthors() { - return authors; - } - - /** - * Gets the publicationDate. - * - * The publication date in the format ISO 8601. - * - * @return the publicationDate - */ - public String getPublicationDate() { - return publicationDate; - } - - /** - * Gets the title. - * - * The title of the document. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the image. - * - * URL of a prominent image on the webpage. - * - * @return the image - */ - public String getImage() { - return image; - } - - /** - * Gets the feeds. - * - * RSS/ATOM feeds found on the webpage. - * - * @return the feeds - */ - public List getFeeds() { - return feeds; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java index 207518d17a6..6914af72970 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,21 +15,23 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * API usage information for the request. - */ +/** API usage information for the request. */ public class AnalysisResultsUsage extends GenericModel { protected Long features; + @SerializedName("text_characters") protected Long textCharacters; + @SerializedName("text_units") protected Long textUnits; + protected AnalysisResultsUsage() {} + /** * Gets the features. * - * Number of features used in the API call. + *

Number of features used in the API call. * * @return the features */ @@ -40,7 +42,7 @@ public Long getFeatures() { /** * Gets the textCharacters. * - * Number of text characters processed. + *

Number of text characters processed. * * @return the textCharacters */ @@ -51,7 +53,7 @@ public Long getTextCharacters() { /** * Gets the textUnits. * - * Number of 10,000-character units processed. + *

Number of 10,000-character units processed. * * @return the textUnits */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java index f348aaedb51..3aca7aa0dea 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -14,9 +14,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The analyze options. - */ +/** The analyze options. */ public class AnalyzeOptions extends GenericModel { protected Features features; @@ -30,9 +28,7 @@ public class AnalyzeOptions extends GenericModel { protected String language; protected Long limitTextCharacters; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Features features; private String text; @@ -45,6 +41,11 @@ public static class Builder { private String language; private Long limitTextCharacters; + /** + * Instantiates a new Builder from an existing AnalyzeOptions instance. + * + * @param analyzeOptions the instance to initialize the Builder with + */ private Builder(AnalyzeOptions analyzeOptions) { this.features = analyzeOptions.features; this.text = analyzeOptions.text; @@ -58,11 +59,8 @@ private Builder(AnalyzeOptions analyzeOptions) { this.limitTextCharacters = analyzeOptions.limitTextCharacters; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -76,7 +74,7 @@ public Builder(Features features) { /** * Builds a AnalyzeOptions. * - * @return the analyzeOptions + * @return the new AnalyzeOptions instance */ public AnalyzeOptions build() { return new AnalyzeOptions(this); @@ -193,9 +191,10 @@ public Builder limitTextCharacters(long limitTextCharacters) { } } + protected AnalyzeOptions() {} + protected AnalyzeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.features, - "features cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.features, "features cannot be null"); features = builder.features; text = builder.text; html = builder.html; @@ -220,7 +219,7 @@ public Builder newBuilder() { /** * Gets the features. * - * Specific features to analyze the document for. + *

Specific features to analyze the document for. * * @return the features */ @@ -231,7 +230,7 @@ public Features features() { /** * Gets the text. * - * The plain text to analyze. One of the `text`, `html`, or `url` parameters is required. + *

The plain text to analyze. One of the `text`, `html`, or `url` parameters is required. * * @return the text */ @@ -242,7 +241,7 @@ public String text() { /** * Gets the html. * - * The HTML file to analyze. One of the `text`, `html`, or `url` parameters is required. + *

The HTML file to analyze. One of the `text`, `html`, or `url` parameters is required. * * @return the html */ @@ -253,7 +252,7 @@ public String html() { /** * Gets the url. * - * The webpage to analyze. One of the `text`, `html`, or `url` parameters is required. + *

The webpage to analyze. One of the `text`, `html`, or `url` parameters is required. * * @return the url */ @@ -264,9 +263,9 @@ public String url() { /** * Gets the clean. * - * Set this to `false` to disable webpage cleaning. To learn more about webpage cleaning, see the [Analyzing - * webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages) - * documentation. + *

Set this to `false` to disable webpage cleaning. For more information about webpage + * cleaning, see [Analyzing + * webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages). * * @return the clean */ @@ -277,10 +276,11 @@ public Boolean clean() { /** * Gets the xpath. * - * An [XPath + *

An [XPath * query](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath) - * to perform on `html` or `url` input. Results of the query will be appended to the cleaned webpage text before it is - * analyzed. To analyze only the results of the XPath query, set the `clean` parameter to `false`. + * to perform on `html` or `url` input. Results of the query will be appended to the cleaned + * webpage text before it is analyzed. To analyze only the results of the XPath query, set the + * `clean` parameter to `false`. * * @return the xpath */ @@ -291,7 +291,7 @@ public String xpath() { /** * Gets the fallbackToRaw. * - * Whether to use raw HTML content if text cleaning fails. + *

Whether to use raw HTML content if text cleaning fails. * * @return the fallbackToRaw */ @@ -302,7 +302,7 @@ public Boolean fallbackToRaw() { /** * Gets the returnAnalyzedText. * - * Whether or not to return the analyzed text. + *

Whether or not to return the analyzed text. * * @return the returnAnalyzedText */ @@ -313,10 +313,10 @@ public Boolean returnAnalyzedText() { /** * Gets the language. * - * ISO 639-1 code that specifies the language of your text. This overrides automatic language detection. Language - * support differs depending on the features you include in your analysis. See [Language - * support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support) - * for more information. + *

ISO 639-1 code that specifies the language of your text. This overrides automatic language + * detection. Language support differs depending on the features you include in your analysis. For + * more information, see [Language + * support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support). * * @return the language */ @@ -327,7 +327,7 @@ public String language() { /** * Gets the limitTextCharacters. * - * Sets the maximum number of characters that are processed by the service. + *

Sets the maximum number of characters that are processed by the service. * * @return the limitTextCharacters */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java index c71e6f910b5..fe2522fe1a5 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The author of the analyzed content. - */ +/** The author of the analyzed content. */ public class Author extends GenericModel { protected String name; + protected Author() {} + /** * Gets the name. * - * Name of the author. + *

Name of the author. * * @return the name */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModel.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModel.java new file mode 100644 index 00000000000..9284db394d1 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModel.java @@ -0,0 +1,226 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** Categories model. */ +public class CategoriesModel extends GenericModel { + + /** When the status is `available`, the model is ready to use. */ + public interface Status { + /** starting. */ + String STARTING = "starting"; + /** training. */ + String TRAINING = "training"; + /** deploying. */ + String DEPLOYING = "deploying"; + /** available. */ + String AVAILABLE = "available"; + /** error. */ + String ERROR = "error"; + /** deleted. */ + String DELETED = "deleted"; + } + + protected String name; + + @SerializedName("user_metadata") + protected Map userMetadata; + + protected String language; + protected String description; + + @SerializedName("model_version") + protected String modelVersion; + + @SerializedName("workspace_id") + protected String workspaceId; + + @SerializedName("version_description") + protected String versionDescription; + + protected List features; + protected String status; + + @SerializedName("model_id") + protected String modelId; + + protected Date created; + protected List notices; + + @SerializedName("last_trained") + protected Date lastTrained; + + @SerializedName("last_deployed") + protected Date lastDeployed; + + protected CategoriesModel() {} + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map getUserMetadata() { + return userMetadata; + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String getModelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String getWorkspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String getVersionDescription() { + return versionDescription; + } + + /** + * Gets the features. + * + *

The service features that are supported by the custom model. + * + * @return the features + */ + public List getFeatures() { + return features; + } + + /** + * Gets the status. + * + *

When the status is `available`, the model is ready to use. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the modelId. + * + *

Unique model ID. + * + * @return the modelId + */ + public String getModelId() { + return modelId; + } + + /** + * Gets the created. + * + *

dateTime indicating when the model was created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the notices. + * + * @return the notices + */ + public List getNotices() { + return notices; + } + + /** + * Gets the lastTrained. + * + *

dateTime of last successful model training. + * + * @return the lastTrained + */ + public Date getLastTrained() { + return lastTrained; + } + + /** + * Gets the lastDeployed. + * + *

dateTime of last successful model deployment. + * + * @return the lastDeployed + */ + public Date getLastDeployed() { + return lastDeployed; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelList.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelList.java new file mode 100644 index 00000000000..c665303513d --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelList.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** List of categories models. */ +public class CategoriesModelList extends GenericModel { + + protected List models; + + protected CategoriesModelList() {} + + /** + * Gets the models. + * + *

The categories models. + * + * @return the models + */ + public List getModels() { + return models; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java index 2198126bbc9..1712a720993 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,42 +15,41 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Returns a five-level taxonomy of the content. The top three categories are returned. + * Returns a hierarchical taxonomy of the content. The top three categories are returned by default. * - * Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Spanish. + *

Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, + * Spanish. */ public class CategoriesOptions extends GenericModel { protected Boolean explanation; protected Long limit; - @Deprecated protected String model; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean explanation; private Long limit; - @Deprecated private String model; + /** + * Instantiates a new Builder from an existing CategoriesOptions instance. + * + * @param categoriesOptions the instance to initialize the Builder with + */ private Builder(CategoriesOptions categoriesOptions) { this.explanation = categoriesOptions.explanation; this.limit = categoriesOptions.limit; this.model = categoriesOptions.model; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a CategoriesOptions. * - * @return the categoriesOptions + * @return the new CategoriesOptions instance */ public CategoriesOptions build() { return new CategoriesOptions(this); @@ -83,8 +82,6 @@ public Builder limit(long limit) { * * @param model the model * @return the CategoriesOptions builder - * @deprecated the model parameter is no longer supported by the Natural Language Understanding service and will - * be removed in the next major release */ public Builder model(String model) { this.model = model; @@ -92,6 +89,8 @@ public Builder model(String model) { } } + protected CategoriesOptions() {} + protected CategoriesOptions(Builder builder) { explanation = builder.explanation; limit = builder.limit; @@ -110,8 +109,8 @@ public Builder newBuilder() { /** * Gets the explanation. * - * Set this to `true` to return explanations for each categorization. **This is available only for English - * categories.**. + *

Set this to `true` to return explanations for each categorization. **This is available only + * for English categories.**. * * @return the explanation */ @@ -122,7 +121,7 @@ public Boolean explanation() { /** * Gets the limit. * - * Maximum number of categories to return. + *

Maximum number of categories to return. * * @return the limit */ @@ -133,18 +132,12 @@ public Long limit() { /** * Gets the model. * - * Enter a [custom + *

(Beta) Enter a [custom * model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) - * ID to override the standard categories model. - * - * The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom - * categories models will no longer be accessible in Natural Language Understanding. The feature will be removed from - * Knowledge Studio on an earlier date. Custom categories models will no longer be accessible in Knowledge Studio on - * 17 December 2019. + * ID to override the standard categories model. **This is available only for English + * categories.**. * * @return the model - * @deprecated the model parameter is no longer supported by the Natural Language Understanding - * service and will be removed in the next major release */ public String model() { return model; diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java index cfed7a33f9c..aba897fc07a 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Relevant text that contributed to the categorization. - */ +/** Relevant text that contributed to the categorization. */ public class CategoriesRelevantText extends GenericModel { protected String text; + protected CategoriesRelevantText() {} + /** * Gets the text. * - * Text from the analyzed source that supports the categorization. + *

Text from the analyzed source that supports the categorization. * * @return the text */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java index 486fc15d168..f95533fa5b3 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,22 +14,21 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * A categorization of the analyzed text. - */ +/** A categorization of the analyzed text. */ public class CategoriesResult extends GenericModel { protected String label; protected Double score; protected CategoriesResultExplanation explanation; + protected CategoriesResult() {} + /** * Gets the label. * - * The path to the category through the 5-level taxonomy hierarchy. For the complete list of categories, see the - * [Categories - * hierarchy](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy) - * documentation. + *

The path to the category through the multi-level taxonomy hierarchy. For more information + * about the categories, see [Categories + * hierarchy](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy). * * @return the label */ @@ -40,7 +39,7 @@ public String getLabel() { /** * Gets the score. * - * Confidence score for the category classification. Higher values indicate greater confidence. + *

Confidence score for the category classification. Higher values indicate greater confidence. * * @return the score */ @@ -51,7 +50,7 @@ public Double getScore() { /** * Gets the explanation. * - * Information that helps to explain what contributed to the categories result. + *

Information that helps to explain what contributed to the categories result. * * @return the explanation */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java index d8a9b9bab5a..089fa972b46 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,24 +12,24 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information that helps to explain what contributed to the categories result. - */ +/** Information that helps to explain what contributed to the categories result. */ public class CategoriesResultExplanation extends GenericModel { @SerializedName("relevant_text") protected List relevantText; + protected CategoriesResultExplanation() {} + /** * Gets the relevantText. * - * An array of relevant text from the source that contributed to the categorization. The sorted array begins with the - * phrase that contributed most significantly to the result, followed by phrases that were less and less impactful. + *

An array of relevant text from the source that contributed to the categorization. The sorted + * array begins with the phrase that contributed most significantly to the result, followed by + * phrases that were less and less impactful. * * @return the relevantText */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModel.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModel.java new file mode 100644 index 00000000000..5e12d8df0f1 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModel.java @@ -0,0 +1,226 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** Classifications model. */ +public class ClassificationsModel extends GenericModel { + + /** When the status is `available`, the model is ready to use. */ + public interface Status { + /** starting. */ + String STARTING = "starting"; + /** training. */ + String TRAINING = "training"; + /** deploying. */ + String DEPLOYING = "deploying"; + /** available. */ + String AVAILABLE = "available"; + /** error. */ + String ERROR = "error"; + /** deleted. */ + String DELETED = "deleted"; + } + + protected String name; + + @SerializedName("user_metadata") + protected Map userMetadata; + + protected String language; + protected String description; + + @SerializedName("model_version") + protected String modelVersion; + + @SerializedName("workspace_id") + protected String workspaceId; + + @SerializedName("version_description") + protected String versionDescription; + + protected List features; + protected String status; + + @SerializedName("model_id") + protected String modelId; + + protected Date created; + protected List notices; + + @SerializedName("last_trained") + protected Date lastTrained; + + @SerializedName("last_deployed") + protected Date lastDeployed; + + protected ClassificationsModel() {} + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map getUserMetadata() { + return userMetadata; + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String getModelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String getWorkspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String getVersionDescription() { + return versionDescription; + } + + /** + * Gets the features. + * + *

The service features that are supported by the custom model. + * + * @return the features + */ + public List getFeatures() { + return features; + } + + /** + * Gets the status. + * + *

When the status is `available`, the model is ready to use. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the modelId. + * + *

Unique model ID. + * + * @return the modelId + */ + public String getModelId() { + return modelId; + } + + /** + * Gets the created. + * + *

dateTime indicating when the model was created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Gets the notices. + * + * @return the notices + */ + public List getNotices() { + return notices; + } + + /** + * Gets the lastTrained. + * + *

dateTime of last successful model training. + * + * @return the lastTrained + */ + public Date getLastTrained() { + return lastTrained; + } + + /** + * Gets the lastDeployed. + * + *

dateTime of last successful model deployment. + * + * @return the lastDeployed + */ + public Date getLastDeployed() { + return lastDeployed; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelList.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelList.java new file mode 100644 index 00000000000..3bfcec10624 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelList.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** List of classifications models. */ +public class ClassificationsModelList extends GenericModel { + + protected List models; + + protected ClassificationsModelList() {} + + /** + * Gets the models. + * + *

The classifications models. + * + * @return the models + */ + public List getModels() { + return models; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsOptions.java new file mode 100644 index 00000000000..9ad1fd416cb --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsOptions.java @@ -0,0 +1,90 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Returns text classifications for the content. */ +public class ClassificationsOptions extends GenericModel { + + protected String model; + + /** Builder. */ + public static class Builder { + private String model; + + /** + * Instantiates a new Builder from an existing ClassificationsOptions instance. + * + * @param classificationsOptions the instance to initialize the Builder with + */ + private Builder(ClassificationsOptions classificationsOptions) { + this.model = classificationsOptions.model; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ClassificationsOptions. + * + * @return the new ClassificationsOptions instance + */ + public ClassificationsOptions build() { + return new ClassificationsOptions(this); + } + + /** + * Set the model. + * + * @param model the model + * @return the ClassificationsOptions builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + protected ClassificationsOptions() {} + + protected ClassificationsOptions(Builder builder) { + model = builder.model; + } + + /** + * New builder. + * + * @return a ClassificationsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the model. + * + *

Enter a [custom + * model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) + * ID of the classifications model to be used. + * + *

You can analyze tone by using a language-specific model ID. See [Tone analytics + * (Classifications)](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-tone_analytics) + * for more information. + * + * @return the model + */ + public String model() { + return model; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsResult.java new file mode 100644 index 00000000000..c90bf21422d --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsResult.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A classification of the analyzed text. */ +public class ClassificationsResult extends GenericModel { + + @SerializedName("class_name") + protected String className; + + protected Double confidence; + + protected ClassificationsResult() {} + + /** + * Gets the className. + * + *

Classification assigned to the text. + * + * @return the className + */ + public String getClassName() { + return className; + } + + /** + * Gets the confidence. + * + *

Confidence score for the classification. Higher values indicate greater confidence. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsTrainingParameters.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsTrainingParameters.java new file mode 100644 index 00000000000..fcf13b58691 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsTrainingParameters.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2022, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Optional classifications training parameters along with model train requests. */ +public class ClassificationsTrainingParameters extends GenericModel { + + /** Model type selector to train either a single_label or a multi_label classifier. */ + public interface ModelType { + /** single_label. */ + String SINGLE_LABEL = "single_label"; + /** multi_label. */ + String MULTI_LABEL = "multi_label"; + } + + @SerializedName("model_type") + protected String modelType; + + /** Builder. */ + public static class Builder { + private String modelType; + + /** + * Instantiates a new Builder from an existing ClassificationsTrainingParameters instance. + * + * @param classificationsTrainingParameters the instance to initialize the Builder with + */ + private Builder(ClassificationsTrainingParameters classificationsTrainingParameters) { + this.modelType = classificationsTrainingParameters.modelType; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ClassificationsTrainingParameters. + * + * @return the new ClassificationsTrainingParameters instance + */ + public ClassificationsTrainingParameters build() { + return new ClassificationsTrainingParameters(this); + } + + /** + * Set the modelType. + * + * @param modelType the modelType + * @return the ClassificationsTrainingParameters builder + */ + public Builder modelType(String modelType) { + this.modelType = modelType; + return this; + } + } + + protected ClassificationsTrainingParameters() {} + + protected ClassificationsTrainingParameters(Builder builder) { + modelType = builder.modelType; + } + + /** + * New builder. + * + * @return a ClassificationsTrainingParameters builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelType. + * + *

Model type selector to train either a single_label or a multi_label classifier. + * + * @return the modelType + */ + public String modelType() { + return modelType; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java index 536fb897cb7..be8cdcb7225 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -15,35 +15,35 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Returns high-level concepts in the content. For example, a research paper about deep learning might return the - * concept, "Artificial Intelligence" although the term is not mentioned. + * Returns high-level concepts in the content. For example, a research paper about deep learning + * might return the concept, "Artificial Intelligence" although the term is not mentioned. * - * Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Spanish. + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Spanish. */ public class ConceptsOptions extends GenericModel { protected Long limit; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Long limit; + /** + * Instantiates a new Builder from an existing ConceptsOptions instance. + * + * @param conceptsOptions the instance to initialize the Builder with + */ private Builder(ConceptsOptions conceptsOptions) { this.limit = conceptsOptions.limit; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a ConceptsOptions. * - * @return the conceptsOptions + * @return the new ConceptsOptions instance */ public ConceptsOptions build() { return new ConceptsOptions(this); @@ -61,6 +61,8 @@ public Builder limit(long limit) { } } + protected ConceptsOptions() {} + protected ConceptsOptions(Builder builder) { limit = builder.limit; } @@ -77,7 +79,7 @@ public Builder newBuilder() { /** * Gets the limit. * - * Maximum number of concepts to return. + *

Maximum number of concepts to return. * * @return the limit */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java index a348848be34..9d366586b83 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -15,20 +15,21 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The general concepts referenced or alluded to in the analyzed text. - */ +/** The general concepts referenced or alluded to in the analyzed text. */ public class ConceptsResult extends GenericModel { protected String text; protected Double relevance; + @SerializedName("dbpedia_resource") protected String dbpediaResource; + protected ConceptsResult() {} + /** * Gets the text. * - * Name of the concept. + *

Name of the concept. * * @return the text */ @@ -39,7 +40,7 @@ public String getText() { /** * Gets the relevance. * - * Relevance score between 0 and 1. Higher scores indicate greater relevance. + *

Relevance score between 0 and 1. Higher scores indicate greater relevance. * * @return the relevance */ @@ -50,7 +51,7 @@ public Double getRelevance() { /** * Gets the dbpediaResource. * - * Link to the corresponding DBpedia resource. + *

Link to the corresponding DBpedia resource. * * @return the dbpediaResource */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateCategoriesModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateCategoriesModelOptions.java new file mode 100644 index 00000000000..2d5a036a598 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateCategoriesModelOptions.java @@ -0,0 +1,326 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Map; + +/** The createCategoriesModel options. */ +public class CreateCategoriesModelOptions extends GenericModel { + + protected String language; + protected InputStream trainingData; + protected String trainingDataContentType; + protected String name; + protected Map userMetadata; + protected String description; + protected String modelVersion; + protected String workspaceId; + protected String versionDescription; + + /** Builder. */ + public static class Builder { + private String language; + private InputStream trainingData; + private String trainingDataContentType; + private String name; + private Map userMetadata; + private String description; + private String modelVersion; + private String workspaceId; + private String versionDescription; + + /** + * Instantiates a new Builder from an existing CreateCategoriesModelOptions instance. + * + * @param createCategoriesModelOptions the instance to initialize the Builder with + */ + private Builder(CreateCategoriesModelOptions createCategoriesModelOptions) { + this.language = createCategoriesModelOptions.language; + this.trainingData = createCategoriesModelOptions.trainingData; + this.trainingDataContentType = createCategoriesModelOptions.trainingDataContentType; + this.name = createCategoriesModelOptions.name; + this.userMetadata = createCategoriesModelOptions.userMetadata; + this.description = createCategoriesModelOptions.description; + this.modelVersion = createCategoriesModelOptions.modelVersion; + this.workspaceId = createCategoriesModelOptions.workspaceId; + this.versionDescription = createCategoriesModelOptions.versionDescription; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param language the language + * @param trainingData the trainingData + */ + public Builder(String language, InputStream trainingData) { + this.language = language; + this.trainingData = trainingData; + } + + /** + * Builds a CreateCategoriesModelOptions. + * + * @return the new CreateCategoriesModelOptions instance + */ + public CreateCategoriesModelOptions build() { + return new CreateCategoriesModelOptions(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateCategoriesModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateCategoriesModelOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the trainingDataContentType. + * + * @param trainingDataContentType the trainingDataContentType + * @return the CreateCategoriesModelOptions builder + */ + public Builder trainingDataContentType(String trainingDataContentType) { + this.trainingDataContentType = trainingDataContentType; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateCategoriesModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the userMetadata. + * + * @param userMetadata the userMetadata + * @return the CreateCategoriesModelOptions builder + */ + public Builder userMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateCategoriesModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the modelVersion. + * + * @param modelVersion the modelVersion + * @return the CreateCategoriesModelOptions builder + */ + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateCategoriesModelOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the versionDescription. + * + * @param versionDescription the versionDescription + * @return the CreateCategoriesModelOptions builder + */ + public Builder versionDescription(String versionDescription) { + this.versionDescription = versionDescription; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateCategoriesModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + } + + protected CreateCategoriesModelOptions() {} + + protected CreateCategoriesModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + language = builder.language; + trainingData = builder.trainingData; + trainingDataContentType = builder.trainingDataContentType; + name = builder.name; + userMetadata = builder.userMetadata; + description = builder.description; + modelVersion = builder.modelVersion; + workspaceId = builder.workspaceId; + versionDescription = builder.versionDescription; + } + + /** + * New builder. + * + * @return a CreateCategoriesModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the trainingData. + * + *

Training data in JSON format. For more information, see [Categories training data + * requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the trainingDataContentType. + * + *

The content type of trainingData. Values for this parameter can be obtained from the + * HttpMediaType class. + * + * @return the trainingDataContentType + */ + public String trainingDataContentType() { + return trainingDataContentType; + } + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map userMetadata() { + return userMetadata; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String modelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String versionDescription() { + return versionDescription; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateClassificationsModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateClassificationsModelOptions.java new file mode 100644 index 00000000000..ce4e410458c --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateClassificationsModelOptions.java @@ -0,0 +1,352 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Map; + +/** The createClassificationsModel options. */ +public class CreateClassificationsModelOptions extends GenericModel { + + protected String language; + protected InputStream trainingData; + protected String trainingDataContentType; + protected String name; + protected Map userMetadata; + protected String description; + protected String modelVersion; + protected String workspaceId; + protected String versionDescription; + protected ClassificationsTrainingParameters trainingParameters; + + /** Builder. */ + public static class Builder { + private String language; + private InputStream trainingData; + private String trainingDataContentType; + private String name; + private Map userMetadata; + private String description; + private String modelVersion; + private String workspaceId; + private String versionDescription; + private ClassificationsTrainingParameters trainingParameters; + + /** + * Instantiates a new Builder from an existing CreateClassificationsModelOptions instance. + * + * @param createClassificationsModelOptions the instance to initialize the Builder with + */ + private Builder(CreateClassificationsModelOptions createClassificationsModelOptions) { + this.language = createClassificationsModelOptions.language; + this.trainingData = createClassificationsModelOptions.trainingData; + this.trainingDataContentType = createClassificationsModelOptions.trainingDataContentType; + this.name = createClassificationsModelOptions.name; + this.userMetadata = createClassificationsModelOptions.userMetadata; + this.description = createClassificationsModelOptions.description; + this.modelVersion = createClassificationsModelOptions.modelVersion; + this.workspaceId = createClassificationsModelOptions.workspaceId; + this.versionDescription = createClassificationsModelOptions.versionDescription; + this.trainingParameters = createClassificationsModelOptions.trainingParameters; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param language the language + * @param trainingData the trainingData + */ + public Builder(String language, InputStream trainingData) { + this.language = language; + this.trainingData = trainingData; + } + + /** + * Builds a CreateClassificationsModelOptions. + * + * @return the new CreateClassificationsModelOptions instance + */ + public CreateClassificationsModelOptions build() { + return new CreateClassificationsModelOptions(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateClassificationsModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateClassificationsModelOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the trainingDataContentType. + * + * @param trainingDataContentType the trainingDataContentType + * @return the CreateClassificationsModelOptions builder + */ + public Builder trainingDataContentType(String trainingDataContentType) { + this.trainingDataContentType = trainingDataContentType; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateClassificationsModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the userMetadata. + * + * @param userMetadata the userMetadata + * @return the CreateClassificationsModelOptions builder + */ + public Builder userMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateClassificationsModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the modelVersion. + * + * @param modelVersion the modelVersion + * @return the CreateClassificationsModelOptions builder + */ + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateClassificationsModelOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the versionDescription. + * + * @param versionDescription the versionDescription + * @return the CreateClassificationsModelOptions builder + */ + public Builder versionDescription(String versionDescription) { + this.versionDescription = versionDescription; + return this; + } + + /** + * Set the trainingParameters. + * + * @param trainingParameters the trainingParameters + * @return the CreateClassificationsModelOptions builder + */ + public Builder trainingParameters(ClassificationsTrainingParameters trainingParameters) { + this.trainingParameters = trainingParameters; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateClassificationsModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + } + + protected CreateClassificationsModelOptions() {} + + protected CreateClassificationsModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + language = builder.language; + trainingData = builder.trainingData; + trainingDataContentType = builder.trainingDataContentType; + name = builder.name; + userMetadata = builder.userMetadata; + description = builder.description; + modelVersion = builder.modelVersion; + workspaceId = builder.workspaceId; + versionDescription = builder.versionDescription; + trainingParameters = builder.trainingParameters; + } + + /** + * New builder. + * + * @return a CreateClassificationsModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the trainingData. + * + *

Training data in JSON format. For more information, see [Classifications training data + * requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the trainingDataContentType. + * + *

The content type of trainingData. Values for this parameter can be obtained from the + * HttpMediaType class. + * + * @return the trainingDataContentType + */ + public String trainingDataContentType() { + return trainingDataContentType; + } + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map userMetadata() { + return userMetadata; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String modelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String versionDescription() { + return versionDescription; + } + + /** + * Gets the trainingParameters. + * + *

Optional classifications training parameters along with model train requests. + * + * @return the trainingParameters + */ + public ClassificationsTrainingParameters trainingParameters() { + return trainingParameters; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateSentimentModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateSentimentModelOptions.java new file mode 100644 index 00000000000..c37ee6bd738 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CreateSentimentModelOptions.java @@ -0,0 +1,294 @@ +/* + * (C) Copyright IBM Corp. 2021, 2022. + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Map; + +/** The createSentimentModel options. */ +public class CreateSentimentModelOptions extends GenericModel { + + protected String language; + protected InputStream trainingData; + protected String name; + protected Map userMetadata; + protected String description; + protected String modelVersion; + protected String workspaceId; + protected String versionDescription; + + /** Builder. */ + public static class Builder { + private String language; + private InputStream trainingData; + private String name; + private Map userMetadata; + private String description; + private String modelVersion; + private String workspaceId; + private String versionDescription; + + private Builder(CreateSentimentModelOptions createSentimentModelOptions) { + this.language = createSentimentModelOptions.language; + this.trainingData = createSentimentModelOptions.trainingData; + this.name = createSentimentModelOptions.name; + this.userMetadata = createSentimentModelOptions.userMetadata; + this.description = createSentimentModelOptions.description; + this.modelVersion = createSentimentModelOptions.modelVersion; + this.workspaceId = createSentimentModelOptions.workspaceId; + this.versionDescription = createSentimentModelOptions.versionDescription; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param language the language + * @param trainingData the trainingData + */ + public Builder(String language, InputStream trainingData) { + this.language = language; + this.trainingData = trainingData; + } + + /** + * Builds a CreateSentimentModelOptions. + * + * @return the new CreateSentimentModelOptions instance + */ + public CreateSentimentModelOptions build() { + return new CreateSentimentModelOptions(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateSentimentModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateSentimentModelOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateSentimentModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the userMetadata. + * + * @param userMetadata the userMetadata + * @return the CreateSentimentModelOptions builder + */ + public Builder userMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateSentimentModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the modelVersion. + * + * @param modelVersion the modelVersion + * @return the CreateSentimentModelOptions builder + */ + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateSentimentModelOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the versionDescription. + * + * @param versionDescription the versionDescription + * @return the CreateSentimentModelOptions builder + */ + public Builder versionDescription(String versionDescription) { + this.versionDescription = versionDescription; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the CreateSentimentModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + } + + protected CreateSentimentModelOptions() {} + + protected CreateSentimentModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + language = builder.language; + trainingData = builder.trainingData; + name = builder.name; + userMetadata = builder.userMetadata; + description = builder.description; + modelVersion = builder.modelVersion; + workspaceId = builder.workspaceId; + versionDescription = builder.versionDescription; + } + + /** + * New builder. + * + * @return a CreateSentimentModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the trainingData. + * + *

Training data in CSV format. For more information, see [Sentiment training data + * requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map userMetadata() { + return userMetadata; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String modelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String versionDescription() { + return versionDescription; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteCategoriesModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteCategoriesModelOptions.java new file mode 100644 index 00000000000..671f3140ea2 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteCategoriesModelOptions.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteCategoriesModel options. */ +public class DeleteCategoriesModelOptions extends GenericModel { + + protected String modelId; + + /** Builder. */ + public static class Builder { + private String modelId; + + /** + * Instantiates a new Builder from an existing DeleteCategoriesModelOptions instance. + * + * @param deleteCategoriesModelOptions the instance to initialize the Builder with + */ + private Builder(DeleteCategoriesModelOptions deleteCategoriesModelOptions) { + this.modelId = deleteCategoriesModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a DeleteCategoriesModelOptions. + * + * @return the new DeleteCategoriesModelOptions instance + */ + public DeleteCategoriesModelOptions build() { + return new DeleteCategoriesModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the DeleteCategoriesModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected DeleteCategoriesModelOptions() {} + + protected DeleteCategoriesModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a DeleteCategoriesModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteClassificationsModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteClassificationsModelOptions.java new file mode 100644 index 00000000000..3181d4dd34e --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteClassificationsModelOptions.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteClassificationsModel options. */ +public class DeleteClassificationsModelOptions extends GenericModel { + + protected String modelId; + + /** Builder. */ + public static class Builder { + private String modelId; + + /** + * Instantiates a new Builder from an existing DeleteClassificationsModelOptions instance. + * + * @param deleteClassificationsModelOptions the instance to initialize the Builder with + */ + private Builder(DeleteClassificationsModelOptions deleteClassificationsModelOptions) { + this.modelId = deleteClassificationsModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a DeleteClassificationsModelOptions. + * + * @return the new DeleteClassificationsModelOptions instance + */ + public DeleteClassificationsModelOptions build() { + return new DeleteClassificationsModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the DeleteClassificationsModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected DeleteClassificationsModelOptions() {} + + protected DeleteClassificationsModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a DeleteClassificationsModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java index 88501494d3f..fb737d5264f 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -14,28 +14,26 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteModel options. - */ +/** The deleteModel options. */ public class DeleteModelOptions extends GenericModel { protected String modelId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String modelId; + /** + * Instantiates a new Builder from an existing DeleteModelOptions instance. + * + * @param deleteModelOptions the instance to initialize the Builder with + */ private Builder(DeleteModelOptions deleteModelOptions) { this.modelId = deleteModelOptions.modelId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +47,7 @@ public Builder(String modelId) { /** * Builds a DeleteModelOptions. * - * @return the deleteModelOptions + * @return the new DeleteModelOptions instance */ public DeleteModelOptions build() { return new DeleteModelOptions(this); @@ -67,9 +65,10 @@ public Builder modelId(String modelId) { } } + protected DeleteModelOptions() {} + protected DeleteModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, - "modelId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); modelId = builder.modelId; } @@ -85,7 +84,7 @@ public Builder newBuilder() { /** * Gets the modelId. * - * Model ID of the model to delete. + *

Model ID of the model to delete. * * @return the modelId */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java index c43d632523b..faaf4959157 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Delete model results. - */ +/** Delete model results. */ public class DeleteModelResults extends GenericModel { protected String deleted; + protected DeleteModelResults() {} + /** * Gets the deleted. * - * model_id of the deleted model. + *

model_id of the deleted model. * * @return the deleted */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteSentimentModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteSentimentModelOptions.java new file mode 100644 index 00000000000..70eb9fd34b8 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteSentimentModelOptions.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2021, 2022. + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteSentimentModel options. */ +public class DeleteSentimentModelOptions extends GenericModel { + + protected String modelId; + + /** Builder. */ + public static class Builder { + private String modelId; + + private Builder(DeleteSentimentModelOptions deleteSentimentModelOptions) { + this.modelId = deleteSentimentModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a DeleteSentimentModelOptions. + * + * @return the new DeleteSentimentModelOptions instance + */ + public DeleteSentimentModelOptions build() { + return new DeleteSentimentModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the DeleteSentimentModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected DeleteSentimentModelOptions() {} + + protected DeleteSentimentModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a DeleteSentimentModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java index a3c93a79220..250d583320d 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,25 +12,26 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Disambiguation information for the entity. - */ +/** Disambiguation information for the entity. */ public class DisambiguationResult extends GenericModel { protected String name; + @SerializedName("dbpedia_resource") protected String dbpediaResource; + protected List subtype; + protected DisambiguationResult() {} + /** * Gets the name. * - * Common entity name. + *

Common entity name. * * @return the name */ @@ -41,7 +42,7 @@ public String getName() { /** * Gets the dbpediaResource. * - * Link to the corresponding DBpedia resource. + *

Link to the corresponding DBpedia resource. * * @return the dbpediaResource */ @@ -52,7 +53,7 @@ public String getDbpediaResource() { /** * Gets the subtype. * - * Entity subtype information. + *

Entity subtype information. * * @return the subtype */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java index d58691830b8..ac257609564 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Emotion results for the document as a whole. - */ +/** Emotion results for the document as a whole. */ public class DocumentEmotionResults extends GenericModel { protected EmotionScores emotion; + protected DocumentEmotionResults() {} + /** * Gets the emotion. * - * Emotion results for the document as a whole. + *

Emotion results for the document as a whole. * * @return the emotion */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java index a46c0bfe359..273f8541f9a 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,18 +14,18 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * DocumentSentimentResults. - */ +/** DocumentSentimentResults. */ public class DocumentSentimentResults extends GenericModel { protected String label; protected Double score; + protected DocumentSentimentResults() {} + /** * Gets the label. * - * Indicates whether the sentiment is positive, neutral, or negative. + *

Indicates whether the sentiment is positive, neutral, or negative. * * @return the label */ @@ -36,7 +36,7 @@ public String getLabel() { /** * Gets the score. * - * Sentiment score from -1 (negative) to 1 (positive). + *

Sentiment score from -1 (negative) to 1 (positive). * * @return the score */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java index d22a099cdd4..b407d78062e 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -12,59 +12,57 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - /** - * Detects anger, disgust, fear, joy, or sadness that is conveyed in the content or by the context around target phrases - * specified in the targets parameter. You can analyze emotion for detected entities with `entities.emotion` and for - * keywords with `keywords.emotion`. + * Detects anger, disgust, fear, joy, or sadness that is conveyed in the content or by the context + * around target phrases specified in the targets parameter. You can analyze emotion for detected + * entities with `entities.emotion` and for keywords with `keywords.emotion`. * - * Supported languages: English. + *

Supported languages: English. */ public class EmotionOptions extends GenericModel { protected Boolean document; protected List targets; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean document; private List targets; + /** + * Instantiates a new Builder from an existing EmotionOptions instance. + * + * @param emotionOptions the instance to initialize the Builder with + */ private Builder(EmotionOptions emotionOptions) { this.document = emotionOptions.document; this.targets = emotionOptions.targets; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a EmotionOptions. * - * @return the emotionOptions + * @return the new EmotionOptions instance */ public EmotionOptions build() { return new EmotionOptions(this); } /** - * Adds an targets to targets. + * Adds a new element to targets. * - * @param targets the new targets + * @param targets the new element to be added * @return the EmotionOptions builder */ public Builder addTargets(String targets) { - com.ibm.cloud.sdk.core.util.Validator.notNull(targets, - "targets cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(targets, "targets cannot be null"); if (this.targets == null) { this.targets = new ArrayList(); } @@ -84,8 +82,7 @@ public Builder document(Boolean document) { } /** - * Set the targets. - * Existing targets will be replaced. + * Set the targets. Existing targets will be replaced. * * @param targets the targets * @return the EmotionOptions builder @@ -96,6 +93,8 @@ public Builder targets(List targets) { } } + protected EmotionOptions() {} + protected EmotionOptions(Builder builder) { document = builder.document; targets = builder.targets; @@ -113,7 +112,7 @@ public Builder newBuilder() { /** * Gets the document. * - * Set this to `false` to hide document-level emotion results. + *

Set this to `false` to hide document-level emotion results. * * @return the document */ @@ -124,7 +123,7 @@ public Boolean document() { /** * Gets the targets. * - * Emotion results will be returned for each target string that is found in the document. + *

Emotion results will be returned for each target string that is found in the document. * * @return the targets */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java index a1934d7d090..61801a19037 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,23 +12,25 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; /** - * The detected anger, disgust, fear, joy, or sadness that is conveyed by the content. Emotion information can be - * returned for detected entities, keywords, or user-specified target phrases found in the text. + * The detected anger, disgust, fear, joy, or sadness that is conveyed by the content. Emotion + * information can be returned for detected entities, keywords, or user-specified target phrases + * found in the text. */ public class EmotionResult extends GenericModel { protected DocumentEmotionResults document; protected List targets; + protected EmotionResult() {} + /** * Gets the document. * - * Emotion results for the document as a whole. + *

Emotion results for the document as a whole. * * @return the document */ @@ -39,7 +41,7 @@ public DocumentEmotionResults getDocument() { /** * Gets the targets. * - * Emotion results for specified targets. + *

Emotion results for specified targets. * * @return the targets */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java index 74343a3f006..69284585b16 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -14,9 +14,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * EmotionScores. - */ +/** EmotionScores. */ public class EmotionScores extends GenericModel { protected Double anger; @@ -25,10 +23,12 @@ public class EmotionScores extends GenericModel { protected Double joy; protected Double sadness; + protected EmotionScores() {} + /** * Gets the anger. * - * Anger score from 0 to 1. A higher score means that the text is more likely to convey anger. + *

Anger score from 0 to 1. A higher score means that the text is more likely to convey anger. * * @return the anger */ @@ -39,7 +39,8 @@ public Double getAnger() { /** * Gets the disgust. * - * Disgust score from 0 to 1. A higher score means that the text is more likely to convey disgust. + *

Disgust score from 0 to 1. A higher score means that the text is more likely to convey + * disgust. * * @return the disgust */ @@ -50,7 +51,7 @@ public Double getDisgust() { /** * Gets the fear. * - * Fear score from 0 to 1. A higher score means that the text is more likely to convey fear. + *

Fear score from 0 to 1. A higher score means that the text is more likely to convey fear. * * @return the fear */ @@ -61,7 +62,7 @@ public Double getFear() { /** * Gets the joy. * - * Joy score from 0 to 1. A higher score means that the text is more likely to convey joy. + *

Joy score from 0 to 1. A higher score means that the text is more likely to convey joy. * * @return the joy */ @@ -72,7 +73,8 @@ public Double getJoy() { /** * Gets the sadness. * - * Sadness score from 0 to 1. A higher score means that the text is more likely to convey sadness. + *

Sadness score from 0 to 1. A higher score means that the text is more likely to convey + * sadness. * * @return the sadness */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java index fa3d46a67a6..6e898aa5da6 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -15,11 +15,12 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Identifies people, cities, organizations, and other entities in the content. See [Entity types and - * subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-types). + * Identifies people, cities, organizations, and other entities in the content. For more + * information, see [Entity types and + * subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-type-systems). * - * Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. - * Arabic, Chinese, and Dutch are supported only through custom models. + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, + * Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models. */ public class EntitiesOptions extends GenericModel { @@ -29,9 +30,7 @@ public class EntitiesOptions extends GenericModel { protected Boolean sentiment; protected Boolean emotion; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Long limit; private Boolean mentions; @@ -39,6 +38,11 @@ public static class Builder { private Boolean sentiment; private Boolean emotion; + /** + * Instantiates a new Builder from an existing EntitiesOptions instance. + * + * @param entitiesOptions the instance to initialize the Builder with + */ private Builder(EntitiesOptions entitiesOptions) { this.limit = entitiesOptions.limit; this.mentions = entitiesOptions.mentions; @@ -47,16 +51,13 @@ private Builder(EntitiesOptions entitiesOptions) { this.emotion = entitiesOptions.emotion; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a EntitiesOptions. * - * @return the entitiesOptions + * @return the new EntitiesOptions instance */ public EntitiesOptions build() { return new EntitiesOptions(this); @@ -118,6 +119,8 @@ public Builder emotion(Boolean emotion) { } } + protected EntitiesOptions() {} + protected EntitiesOptions(Builder builder) { limit = builder.limit; mentions = builder.mentions; @@ -138,7 +141,7 @@ public Builder newBuilder() { /** * Gets the limit. * - * Maximum number of entities to return. + *

Maximum number of entities to return. * * @return the limit */ @@ -149,7 +152,7 @@ public Long limit() { /** * Gets the mentions. * - * Set this to `true` to return locations of entity mentions. + *

Set this to `true` to return locations of entity mentions. * * @return the mentions */ @@ -160,7 +163,7 @@ public Boolean mentions() { /** * Gets the model. * - * Enter a [custom + *

Enter a [custom * model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) * ID to override the standard entity detection model. * @@ -173,7 +176,7 @@ public String model() { /** * Gets the sentiment. * - * Set this to `true` to return sentiment information for detected entities. + *

Set this to `true` to return sentiment information for detected entities. * * @return the sentiment */ @@ -184,7 +187,7 @@ public Boolean sentiment() { /** * Gets the emotion. * - * Set this to `true` to analyze emotion for detected keywords. + *

Set this to `true` to analyze emotion for detected keywords. * * @return the emotion */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java index c56515209d4..ae4a66a1b96 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -12,9 +12,8 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; /** * The important people, places, geopolitical entities and other types of entities in your content. @@ -31,10 +30,12 @@ public class EntitiesResult extends GenericModel { protected FeatureSentimentResults sentiment; protected DisambiguationResult disambiguation; + protected EntitiesResult() {} + /** * Gets the type. * - * Entity type. + *

Entity type. * * @return the type */ @@ -45,7 +46,7 @@ public String getType() { /** * Gets the text. * - * The name of the entity. + *

The name of the entity. * * @return the text */ @@ -56,7 +57,7 @@ public String getText() { /** * Gets the relevance. * - * Relevance score from 0 to 1. Higher values indicate greater relevance. + *

Relevance score from 0 to 1. Higher values indicate greater relevance. * * @return the relevance */ @@ -67,9 +68,9 @@ public Double getRelevance() { /** * Gets the confidence. * - * Confidence in the entity identification from 0 to 1. Higher values indicate higher confidence. In standard entities - * requests, confidence is returned only for English text. All entities requests that use custom models return the - * confidence score. + *

Confidence in the entity identification from 0 to 1. Higher values indicate higher + * confidence. In standard entities requests, confidence is returned only for English text. All + * entities requests that use custom models return the confidence score. * * @return the confidence */ @@ -80,7 +81,7 @@ public Double getConfidence() { /** * Gets the mentions. * - * Entity mentions and locations. + *

Entity mentions and locations. * * @return the mentions */ @@ -91,7 +92,7 @@ public List getMentions() { /** * Gets the count. * - * How many times the entity was mentioned in the text. + *

How many times the entity was mentioned in the text. * * @return the count */ @@ -102,7 +103,7 @@ public Long getCount() { /** * Gets the emotion. * - * Emotion analysis results for the entity, enabled with the `emotion` option. + *

Emotion analysis results for the entity, enabled with the `emotion` option. * * @return the emotion */ @@ -113,7 +114,7 @@ public EmotionScores getEmotion() { /** * Gets the sentiment. * - * Sentiment analysis results for the entity, enabled with the `sentiment` option. + *

Sentiment analysis results for the entity, enabled with the `sentiment` option. * * @return the sentiment */ @@ -124,7 +125,7 @@ public FeatureSentimentResults getSentiment() { /** * Gets the disambiguation. * - * Disambiguation information for the entity. + *

Disambiguation information for the entity. * * @return the disambiguation */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java index 369761a1318..487ddc0e493 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,23 +12,22 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * EntityMention. - */ +/** EntityMention. */ public class EntityMention extends GenericModel { protected String text; protected List location; protected Double confidence; + protected EntityMention() {} + /** * Gets the text. * - * Entity mention text. + *

Entity mention text. * * @return the text */ @@ -39,7 +38,7 @@ public String getText() { /** * Gets the location. * - * Character offsets indicating the beginning and end of the mention in the analyzed text. + *

Character offsets indicating the beginning and end of the mention in the analyzed text. * * @return the location */ @@ -50,9 +49,9 @@ public List getLocation() { /** * Gets the confidence. * - * Confidence in the entity identification from 0 to 1. Higher values indicate higher confidence. In standard entities - * requests, confidence is returned only for English text. All entities requests that use custom models return the - * confidence score. + *

Confidence in the entity identification from 0 to 1. Higher values indicate higher + * confidence. In standard entities requests, confidence is returned only for English text. All + * entities requests that use custom models return the confidence score. * * @return the confidence */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java index d9f48c7f9fa..bba6e3e19b1 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * FeatureSentimentResults. - */ +/** FeatureSentimentResults. */ public class FeatureSentimentResults extends GenericModel { protected Double score; + protected FeatureSentimentResults() {} + /** * Gets the score. * - * Sentiment score from -1 (negative) to 1 (positive). + *

Sentiment score from -1 (negative) to 1 (positive). * * @return the score */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java index dd1b9e39d86..203f312f5d9 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -14,40 +14,47 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; -/** - * Analysis features and options. - */ +/** Analysis features and options. */ public class Features extends GenericModel { + protected ClassificationsOptions classifications; protected ConceptsOptions concepts; protected EmotionOptions emotion; protected EntitiesOptions entities; protected KeywordsOptions keywords; - protected MetadataOptions metadata; + protected Map metadata; protected RelationsOptions relations; + @SerializedName("semantic_roles") protected SemanticRolesOptions semanticRoles; + protected SentimentOptions sentiment; protected CategoriesOptions categories; protected SyntaxOptions syntax; - /** - * Builder. - */ + /** Builder. */ public static class Builder { + private ClassificationsOptions classifications; private ConceptsOptions concepts; private EmotionOptions emotion; private EntitiesOptions entities; private KeywordsOptions keywords; - private MetadataOptions metadata; + private Map metadata; private RelationsOptions relations; private SemanticRolesOptions semanticRoles; private SentimentOptions sentiment; private CategoriesOptions categories; private SyntaxOptions syntax; + /** + * Instantiates a new Builder from an existing Features instance. + * + * @param features the instance to initialize the Builder with + */ private Builder(Features features) { + this.classifications = features.classifications; this.concepts = features.concepts; this.emotion = features.emotion; this.entities = features.entities; @@ -60,21 +67,29 @@ private Builder(Features features) { this.syntax = features.syntax; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a Features. * - * @return the features + * @return the new Features instance */ public Features build() { return new Features(this); } + /** + * Set the classifications. + * + * @param classifications the classifications + * @return the Features builder + */ + public Builder classifications(ClassificationsOptions classifications) { + this.classifications = classifications; + return this; + } + /** * Set the concepts. * @@ -125,7 +140,7 @@ public Builder keywords(KeywordsOptions keywords) { * @param metadata the metadata * @return the Features builder */ - public Builder metadata(MetadataOptions metadata) { + public Builder metadata(Map metadata) { this.metadata = metadata; return this; } @@ -186,7 +201,10 @@ public Builder syntax(SyntaxOptions syntax) { } } + protected Features() {} + protected Features(Builder builder) { + classifications = builder.classifications; concepts = builder.concepts; emotion = builder.emotion; entities = builder.entities; @@ -208,13 +226,26 @@ public Builder newBuilder() { return new Builder(this); } + /** + * Gets the classifications. + * + *

Returns text classifications for the content. + * + * @return the classifications + */ + public ClassificationsOptions classifications() { + return classifications; + } + /** * Gets the concepts. * - * Returns high-level concepts in the content. For example, a research paper about deep learning might return the - * concept, "Artificial Intelligence" although the term is not mentioned. + *

Returns high-level concepts in the content. For example, a research paper about deep + * learning might return the concept, "Artificial Intelligence" although the term is not + * mentioned. * - * Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Spanish. + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, + * Spanish. * * @return the concepts */ @@ -225,11 +256,11 @@ public ConceptsOptions concepts() { /** * Gets the emotion. * - * Detects anger, disgust, fear, joy, or sadness that is conveyed in the content or by the context around target - * phrases specified in the targets parameter. You can analyze emotion for detected entities with `entities.emotion` - * and for keywords with `keywords.emotion`. + *

Detects anger, disgust, fear, joy, or sadness that is conveyed in the content or by the + * context around target phrases specified in the targets parameter. You can analyze emotion for + * detected entities with `entities.emotion` and for keywords with `keywords.emotion`. * - * Supported languages: English. + *

Supported languages: English. * * @return the emotion */ @@ -240,11 +271,12 @@ public EmotionOptions emotion() { /** * Gets the entities. * - * Identifies people, cities, organizations, and other entities in the content. See [Entity types and - * subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-types). + *

Identifies people, cities, organizations, and other entities in the content. For more + * information, see [Entity types and + * subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-type-systems). * - * Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. - * Arabic, Chinese, and Dutch are supported only through custom models. + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, + * Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models. * * @return the entities */ @@ -255,9 +287,10 @@ public EntitiesOptions entities() { /** * Gets the keywords. * - * Returns important keywords in the content. + *

Returns important keywords in the content. * - * Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, + * Russian, Spanish, Swedish. * * @return the keywords */ @@ -268,24 +301,25 @@ public KeywordsOptions keywords() { /** * Gets the metadata. * - * Returns information from the document, including author name, title, RSS/ATOM feeds, prominent page image, and - * publication date. Supports URL and HTML input types only. + *

Returns information from the document, including author name, title, RSS/ATOM feeds, + * prominent page image, and publication date. Supports URL and HTML input types only. * * @return the metadata */ - public MetadataOptions metadata() { + public Map metadata() { return metadata; } /** * Gets the relations. * - * Recognizes when two entities are related and identifies the type of relation. For example, an `awardedTo` relation - * might connect the entities "Nobel Prize" and "Albert Einstein". See [Relation + *

Recognizes when two entities are related and identifies the type of relation. For example, + * an `awardedTo` relation might connect the entities "Nobel Prize" and "Albert Einstein". For + * more information, see [Relation * types](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-relations). * - * Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, French, Italian, and - * Portuguese custom models are also supported. + *

Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, + * French, Italian, and Portuguese custom models are also supported. * * @return the relations */ @@ -296,9 +330,9 @@ public RelationsOptions relations() { /** * Gets the semanticRoles. * - * Parses sentences into subject, action, and object form. + *

Parses sentences into subject, action, and object form. * - * Supported languages: English, German, Japanese, Korean, Spanish. + *

Supported languages: English, German, Japanese, Korean, Spanish. * * @return the semanticRoles */ @@ -309,10 +343,12 @@ public SemanticRolesOptions semanticRoles() { /** * Gets the sentiment. * - * Analyzes the general sentiment of your content or the sentiment toward specific target phrases. You can analyze - * sentiment for detected entities with `entities.sentiment` and for keywords with `keywords.sentiment`. + *

Analyzes the general sentiment of your content or the sentiment toward specific target + * phrases. You can analyze sentiment for detected entities with `entities.sentiment` and for + * keywords with `keywords.sentiment`. * - * Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish. + *

Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, + * Russian, Spanish. * * @return the sentiment */ @@ -323,9 +359,11 @@ public SentimentOptions sentiment() { /** * Gets the categories. * - * Returns a five-level taxonomy of the content. The top three categories are returned. + *

Returns a hierarchical taxonomy of the content. The top three categories are returned by + * default. * - * Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Spanish. + *

Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, + * Spanish. * * @return the categories */ @@ -336,7 +374,7 @@ public CategoriesOptions categories() { /** * Gets the syntax. * - * Returns tokens and sentences from the input text. + *

Returns tokens and sentences from the input text. * * @return the syntax */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadata.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadata.java new file mode 100644 index 00000000000..511930c6877 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadata.java @@ -0,0 +1,87 @@ +/* + * (C) Copyright IBM Corp. 2019, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Webpage metadata, such as the author and the title of the page. */ +public class FeaturesResultsMetadata extends GenericModel { + + protected List authors; + + @SerializedName("publication_date") + protected String publicationDate; + + protected String title; + protected String image; + protected List feeds; + + protected FeaturesResultsMetadata() {} + + /** + * Gets the authors. + * + *

The authors of the document. + * + * @return the authors + */ + public List getAuthors() { + return authors; + } + + /** + * Gets the publicationDate. + * + *

The publication date in the format ISO 8601. + * + * @return the publicationDate + */ + public String getPublicationDate() { + return publicationDate; + } + + /** + * Gets the title. + * + *

The title of the document. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the image. + * + *

URL of a prominent image on the webpage. + * + * @return the image + */ + public String getImage() { + return image; + } + + /** + * Gets the feeds. + * + *

RSS/ATOM feeds found on the webpage. + * + * @return the feeds + */ + public List getFeeds() { + return feeds; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java index 031a21c91b0..8533f4b7eee 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * RSS or ATOM feed found on the webpage. - */ +/** RSS or ATOM feed found on the webpage. */ public class Feed extends GenericModel { protected String link; + protected Feed() {} + /** * Gets the link. * - * URL of the RSS or ATOM feed. + *

URL of the RSS or ATOM feed. * * @return the link */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetCategoriesModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetCategoriesModelOptions.java new file mode 100644 index 00000000000..6005b13ba6c --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetCategoriesModelOptions.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getCategoriesModel options. */ +public class GetCategoriesModelOptions extends GenericModel { + + protected String modelId; + + /** Builder. */ + public static class Builder { + private String modelId; + + /** + * Instantiates a new Builder from an existing GetCategoriesModelOptions instance. + * + * @param getCategoriesModelOptions the instance to initialize the Builder with + */ + private Builder(GetCategoriesModelOptions getCategoriesModelOptions) { + this.modelId = getCategoriesModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a GetCategoriesModelOptions. + * + * @return the new GetCategoriesModelOptions instance + */ + public GetCategoriesModelOptions build() { + return new GetCategoriesModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the GetCategoriesModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected GetCategoriesModelOptions() {} + + protected GetCategoriesModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a GetCategoriesModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetClassificationsModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetClassificationsModelOptions.java new file mode 100644 index 00000000000..41b793c6493 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetClassificationsModelOptions.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getClassificationsModel options. */ +public class GetClassificationsModelOptions extends GenericModel { + + protected String modelId; + + /** Builder. */ + public static class Builder { + private String modelId; + + /** + * Instantiates a new Builder from an existing GetClassificationsModelOptions instance. + * + * @param getClassificationsModelOptions the instance to initialize the Builder with + */ + private Builder(GetClassificationsModelOptions getClassificationsModelOptions) { + this.modelId = getClassificationsModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a GetClassificationsModelOptions. + * + * @return the new GetClassificationsModelOptions instance + */ + public GetClassificationsModelOptions build() { + return new GetClassificationsModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the GetClassificationsModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected GetClassificationsModelOptions() {} + + protected GetClassificationsModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a GetClassificationsModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetSentimentModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetSentimentModelOptions.java new file mode 100644 index 00000000000..3a7d7e3924e --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/GetSentimentModelOptions.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2021, 2022. + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getSentimentModel options. */ +public class GetSentimentModelOptions extends GenericModel { + + protected String modelId; + + /** Builder. */ + public static class Builder { + private String modelId; + + private Builder(GetSentimentModelOptions getSentimentModelOptions) { + this.modelId = getSentimentModelOptions.modelId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a GetSentimentModelOptions. + * + * @return the new GetSentimentModelOptions instance + */ + public GetSentimentModelOptions build() { + return new GetSentimentModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the GetSentimentModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + } + + protected GetSentimentModelOptions() {} + + protected GetSentimentModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + modelId = builder.modelId; + } + + /** + * New builder. + * + * @return a GetSentimentModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java index 25c44df7bf5..7ffccb18c05 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -17,7 +17,8 @@ /** * Returns important keywords in the content. * - * Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, + * Spanish, Swedish. */ public class KeywordsOptions extends GenericModel { @@ -25,30 +26,30 @@ public class KeywordsOptions extends GenericModel { protected Boolean sentiment; protected Boolean emotion; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Long limit; private Boolean sentiment; private Boolean emotion; + /** + * Instantiates a new Builder from an existing KeywordsOptions instance. + * + * @param keywordsOptions the instance to initialize the Builder with + */ private Builder(KeywordsOptions keywordsOptions) { this.limit = keywordsOptions.limit; this.sentiment = keywordsOptions.sentiment; this.emotion = keywordsOptions.emotion; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a KeywordsOptions. * - * @return the keywordsOptions + * @return the new KeywordsOptions instance */ public KeywordsOptions build() { return new KeywordsOptions(this); @@ -88,6 +89,8 @@ public Builder emotion(Boolean emotion) { } } + protected KeywordsOptions() {} + protected KeywordsOptions(Builder builder) { limit = builder.limit; sentiment = builder.sentiment; @@ -106,7 +109,7 @@ public Builder newBuilder() { /** * Gets the limit. * - * Maximum number of keywords to return. + *

Maximum number of keywords to return. * * @return the limit */ @@ -117,7 +120,7 @@ public Long limit() { /** * Gets the sentiment. * - * Set this to `true` to return sentiment information for detected keywords. + *

Set this to `true` to return sentiment information for detected keywords. * * @return the sentiment */ @@ -128,7 +131,7 @@ public Boolean sentiment() { /** * Gets the emotion. * - * Set this to `true` to analyze emotion for detected keywords. + *

Set this to `true` to analyze emotion for detected keywords. * * @return the emotion */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java index a3101b6853a..3dd6486a425 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -14,9 +14,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The important keywords in the content, organized by relevance. - */ +/** The important keywords in the content, organized by relevance. */ public class KeywordsResult extends GenericModel { protected Long count; @@ -25,10 +23,12 @@ public class KeywordsResult extends GenericModel { protected EmotionScores emotion; protected FeatureSentimentResults sentiment; + protected KeywordsResult() {} + /** * Gets the count. * - * Number of times the keyword appears in the analyzed text. + *

Number of times the keyword appears in the analyzed text. * * @return the count */ @@ -39,7 +39,7 @@ public Long getCount() { /** * Gets the relevance. * - * Relevance score from 0 to 1. Higher values indicate greater relevance. + *

Relevance score from 0 to 1. Higher values indicate greater relevance. * * @return the relevance */ @@ -50,7 +50,7 @@ public Double getRelevance() { /** * Gets the text. * - * The keyword text. + *

The keyword text. * * @return the text */ @@ -61,7 +61,7 @@ public String getText() { /** * Gets the emotion. * - * Emotion analysis results for the keyword, enabled with the `emotion` option. + *

Emotion analysis results for the keyword, enabled with the `emotion` option. * * @return the emotion */ @@ -72,7 +72,7 @@ public EmotionScores getEmotion() { /** * Gets the sentiment. * - * Sentiment analysis results for the keyword, enabled with the `sentiment` option. + *

Sentiment analysis results for the keyword, enabled with the `sentiment` option. * * @return the sentiment */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListCategoriesModelsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListCategoriesModelsOptions.java new file mode 100644 index 00000000000..e6d4fbeed63 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListCategoriesModelsOptions.java @@ -0,0 +1,22 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listCategoriesModels options. */ +public class ListCategoriesModelsOptions extends GenericModel { + + /** Construct a new instance of ListCategoriesModelsOptions. */ + public ListCategoriesModelsOptions() {} +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListClassificationsModelsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListClassificationsModelsOptions.java new file mode 100644 index 00000000000..d41dffdf92f --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListClassificationsModelsOptions.java @@ -0,0 +1,22 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listClassificationsModels options. */ +public class ListClassificationsModelsOptions extends GenericModel { + + /** Construct a new instance of ListClassificationsModelsOptions. */ + public ListClassificationsModelsOptions() {} +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java index 055d53e68ba..f9b3351075b 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 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 @@ -14,44 +14,9 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listModels options. - */ +/** The listModels options. */ public class ListModelsOptions extends GenericModel { - /** - * Builder. - */ - public static class Builder { - - private Builder(ListModelsOptions listModelsOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListModelsOptions. - * - * @return the listModelsOptions - */ - public ListModelsOptions build() { - return new ListModelsOptions(this); - } - } - - private ListModelsOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } + /** Construct a new instance of ListModelsOptions. */ + public ListModelsOptions() {} } diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java index 4bf1114dbb8..d563798e8a7 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,21 +12,20 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Custom models that are available for entities and relations. - */ +/** Custom models that are available for entities and relations. */ public class ListModelsResults extends GenericModel { protected List models; + protected ListModelsResults() {} + /** * Gets the models. * - * An array of available models. + *

An array of available models. * * @return the models */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListSentimentModelsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListSentimentModelsOptions.java new file mode 100644 index 00000000000..639fe224681 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListSentimentModelsOptions.java @@ -0,0 +1,18 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listSentimentModels options. */ +public class ListSentimentModelsOptions extends GenericModel {} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/MetadataOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/MetadataOptions.java deleted file mode 100644 index 4d5aba6b46c..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/MetadataOptions.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.natural_language_understanding.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Returns information from the document, including author name, title, RSS/ATOM feeds, prominent page image, and - * publication date. Supports URL and HTML input types only. - */ -public class MetadataOptions extends GenericModel { - - /** - * Builder. - */ - public static class Builder { - - private Builder(MetadataOptions metadataOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a MetadataOptions. - * - * @return the metadataOptions - */ - public MetadataOptions build() { - return new MetadataOptions(this); - } - } - - private MetadataOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a MetadataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java index 0590af6541f..b2d52519904 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -12,32 +12,56 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.Date; - import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; -/** - * Model. - */ +/** Model. */ public class Model extends GenericModel { + /** When the status is `available`, the model is ready to use. */ + public interface Status { + /** starting. */ + String STARTING = "starting"; + /** training. */ + String TRAINING = "training"; + /** deploying. */ + String DEPLOYING = "deploying"; + /** available. */ + String AVAILABLE = "available"; + /** error. */ + String ERROR = "error"; + /** deleted. */ + String DELETED = "deleted"; + } + protected String status; + @SerializedName("model_id") protected String modelId; + protected String language; protected String description; + @SerializedName("workspace_id") protected String workspaceId; + + @SerializedName("model_version") + protected String modelVersion; + protected String version; + @SerializedName("version_description") protected String versionDescription; + protected Date created; + protected Model() {} + /** * Gets the status. * - * When the status is `available`, the model is ready to use. + *

When the status is `available`, the model is ready to use. * * @return the status */ @@ -48,7 +72,7 @@ public String getStatus() { /** * Gets the modelId. * - * Unique model ID. + *

Unique model ID. * * @return the modelId */ @@ -59,7 +83,7 @@ public String getModelId() { /** * Gets the language. * - * ISO 639-1 code indicating the language of the model. + *

ISO 639-1 code that indicates the language of the model. * * @return the language */ @@ -70,7 +94,7 @@ public String getLanguage() { /** * Gets the description. * - * Model description. + *

Model description. * * @return the description */ @@ -81,7 +105,8 @@ public String getDescription() { /** * Gets the workspaceId. * - * ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. * * @return the workspaceId */ @@ -89,13 +114,26 @@ public String getWorkspaceId() { return workspaceId; } + /** + * Gets the modelVersion. + * + *

The model version, if it was manually provided in Watson Knowledge Studio. + * + * @return the modelVersion + */ + public String getModelVersion() { + return modelVersion; + } + /** * Gets the version. * - * The model version, if it was manually provided in Watson Knowledge Studio. + *

Deprecated — use `model_version`. * * @return the version + * @deprecated this method is deprecated and may be removed in a future release */ + @Deprecated public String getVersion() { return version; } @@ -103,7 +141,7 @@ public String getVersion() { /** * Gets the versionDescription. * - * The description of the version, if it was manually provided in Watson Knowledge Studio. + *

The description of the version, if it was manually provided in Watson Knowledge Studio. * * @return the versionDescription */ @@ -114,7 +152,7 @@ public String getVersionDescription() { /** * Gets the created. * - * A dateTime indicating when the model was created. + *

A dateTime indicating when the model was created. * * @return the created */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Notice.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Notice.java new file mode 100644 index 00000000000..7572da57772 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Notice.java @@ -0,0 +1,34 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A list of messages describing model training issues when model status is `error`. */ +public class Notice extends GenericModel { + + protected String message; + + protected Notice() {} + + /** + * Gets the message. + * + *

Describes deficiencies or inconsistencies in training data. + * + * @return the message + */ + public String getMessage() { + return message; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java index 6ba958ff6b7..0ec3aac25b7 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,23 +12,22 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * RelationArgument. - */ +/** RelationArgument. */ public class RelationArgument extends GenericModel { protected List entities; protected List location; protected String text; + protected RelationArgument() {} + /** * Gets the entities. * - * An array of extracted entities. + *

An array of extracted entities. * * @return the entities */ @@ -39,7 +38,7 @@ public List getEntities() { /** * Gets the location. * - * Character offsets indicating the beginning and end of the mention in the analyzed text. + *

Character offsets indicating the beginning and end of the mention in the analyzed text. * * @return the location */ @@ -50,7 +49,7 @@ public List getLocation() { /** * Gets the text. * - * Text that corresponds to the argument. + *

Text that corresponds to the argument. * * @return the text */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java index c80bf99502b..b30e086b966 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,18 +14,18 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An entity that corresponds with an argument in a relation. - */ +/** An entity that corresponds with an argument in a relation. */ public class RelationEntity extends GenericModel { protected String text; protected String type; + protected RelationEntity() {} + /** * Gets the text. * - * Text that corresponds to the entity. + *

Text that corresponds to the entity. * * @return the text */ @@ -36,7 +36,7 @@ public String getText() { /** * Gets the type. * - * Entity type. + *

Entity type. * * @return the type */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java index 5a7fc76b2b0..a951875ec62 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -15,37 +15,38 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Recognizes when two entities are related and identifies the type of relation. For example, an `awardedTo` relation - * might connect the entities "Nobel Prize" and "Albert Einstein". See [Relation + * Recognizes when two entities are related and identifies the type of relation. For example, an + * `awardedTo` relation might connect the entities "Nobel Prize" and "Albert Einstein". For more + * information, see [Relation * types](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-relations). * - * Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, French, Italian, and - * Portuguese custom models are also supported. + *

Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, + * French, Italian, and Portuguese custom models are also supported. */ public class RelationsOptions extends GenericModel { protected String model; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String model; + /** + * Instantiates a new Builder from an existing RelationsOptions instance. + * + * @param relationsOptions the instance to initialize the Builder with + */ private Builder(RelationsOptions relationsOptions) { this.model = relationsOptions.model; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a RelationsOptions. * - * @return the relationsOptions + * @return the new RelationsOptions instance */ public RelationsOptions build() { return new RelationsOptions(this); @@ -63,6 +64,8 @@ public Builder model(String model) { } } + protected RelationsOptions() {} + protected RelationsOptions(Builder builder) { model = builder.model; } @@ -79,7 +82,7 @@ public Builder newBuilder() { /** * Gets the model. * - * Enter a [custom + *

Enter a [custom * model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) * ID to override the default model. * diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java index 0cc2be95a8b..ac9d74d8c21 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -12,13 +12,10 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * The relations between entities found in the content. - */ +/** The relations between entities found in the content. */ public class RelationsResult extends GenericModel { protected Double score; @@ -26,10 +23,12 @@ public class RelationsResult extends GenericModel { protected String type; protected List arguments; + protected RelationsResult() {} + /** * Gets the score. * - * Confidence score for the relation. Higher values indicate greater confidence. + *

Confidence score for the relation. Higher values indicate greater confidence. * * @return the score */ @@ -40,7 +39,7 @@ public Double getScore() { /** * Gets the sentence. * - * The sentence that contains the relation. + *

The sentence that contains the relation. * * @return the sentence */ @@ -51,7 +50,7 @@ public String getSentence() { /** * Gets the type. * - * The type of the relation. + *

The type of the relation. * * @return the type */ @@ -62,7 +61,7 @@ public String getType() { /** * Gets the arguments. * - * Entity mentions that are involved in the relation. + *

Entity mentions that are involved in the relation. * * @return the arguments */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java index aa6ed2855a6..f100951811b 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,18 +14,18 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * SemanticRolesEntity. - */ +/** SemanticRolesEntity. */ public class SemanticRolesEntity extends GenericModel { protected String type; protected String text; + protected SemanticRolesEntity() {} + /** * Gets the type. * - * Entity type. + *

Entity type. * * @return the type */ @@ -36,7 +36,7 @@ public String getType() { /** * Gets the text. * - * The entity text. + *

The entity text. * * @return the text */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java index b450f74be1a..fc9b439e080 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,17 +14,17 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * SemanticRolesKeyword. - */ +/** SemanticRolesKeyword. */ public class SemanticRolesKeyword extends GenericModel { protected String text; + protected SemanticRolesKeyword() {} + /** * Gets the text. * - * The keyword text. + *

The keyword text. * * @return the text */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java index e0e07d67a1f..e6a5b2db9cd 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -17,7 +17,7 @@ /** * Parses sentences into subject, action, and object form. * - * Supported languages: English, German, Japanese, Korean, Spanish. + *

Supported languages: English, German, Japanese, Korean, Spanish. */ public class SemanticRolesOptions extends GenericModel { @@ -25,30 +25,30 @@ public class SemanticRolesOptions extends GenericModel { protected Boolean keywords; protected Boolean entities; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Long limit; private Boolean keywords; private Boolean entities; + /** + * Instantiates a new Builder from an existing SemanticRolesOptions instance. + * + * @param semanticRolesOptions the instance to initialize the Builder with + */ private Builder(SemanticRolesOptions semanticRolesOptions) { this.limit = semanticRolesOptions.limit; this.keywords = semanticRolesOptions.keywords; this.entities = semanticRolesOptions.entities; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a SemanticRolesOptions. * - * @return the semanticRolesOptions + * @return the new SemanticRolesOptions instance */ public SemanticRolesOptions build() { return new SemanticRolesOptions(this); @@ -88,6 +88,8 @@ public Builder entities(Boolean entities) { } } + protected SemanticRolesOptions() {} + protected SemanticRolesOptions(Builder builder) { limit = builder.limit; keywords = builder.keywords; @@ -106,7 +108,7 @@ public Builder newBuilder() { /** * Gets the limit. * - * Maximum number of semantic_roles results to return. + *

Maximum number of semantic_roles results to return. * * @return the limit */ @@ -117,7 +119,7 @@ public Long limit() { /** * Gets the keywords. * - * Set this to `true` to return keyword information for subjects and objects. + *

Set this to `true` to return keyword information for subjects and objects. * * @return the keywords */ @@ -128,7 +130,7 @@ public Boolean keywords() { /** * Gets the entities. * - * Set this to `true` to return entity information for subjects and objects. + *

Set this to `true` to return entity information for subjects and objects. * * @return the entities */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java index 7db12da8e45..d7893ac0310 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 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 @@ -14,9 +14,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The object containing the actions and the objects the actions act upon. - */ +/** The object containing the actions and the objects the actions act upon. */ public class SemanticRolesResult extends GenericModel { protected String sentence; @@ -24,10 +22,12 @@ public class SemanticRolesResult extends GenericModel { protected SemanticRolesResultAction action; protected SemanticRolesResultObject object; + protected SemanticRolesResult() {} + /** * Gets the sentence. * - * Sentence from the source that contains the subject, action, and object. + *

Sentence from the source that contains the subject, action, and object. * * @return the sentence */ @@ -38,7 +38,7 @@ public String getSentence() { /** * Gets the subject. * - * The extracted subject from the sentence. + *

The extracted subject from the sentence. * * @return the subject */ @@ -49,7 +49,7 @@ public SemanticRolesResultSubject getSubject() { /** * Gets the action. * - * The extracted action from the sentence. + *

The extracted action from the sentence. * * @return the action */ @@ -60,7 +60,7 @@ public SemanticRolesResultAction getAction() { /** * Gets the object. * - * The extracted object from the sentence. + *

The extracted object from the sentence. * * @return the object */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java index 50bf9e55b13..713e7503e35 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,19 +14,19 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The extracted action from the sentence. - */ +/** The extracted action from the sentence. */ public class SemanticRolesResultAction extends GenericModel { protected String text; protected String normalized; protected SemanticRolesVerb verb; + protected SemanticRolesResultAction() {} + /** * Gets the text. * - * Analyzed text that corresponds to the action. + *

Analyzed text that corresponds to the action. * * @return the text */ @@ -37,7 +37,7 @@ public String getText() { /** * Gets the normalized. * - * normalized version of the action. + *

normalized version of the action. * * @return the normalized */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java index a50823e4cc8..b36755c9614 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,22 +12,21 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * The extracted object from the sentence. - */ +/** The extracted object from the sentence. */ public class SemanticRolesResultObject extends GenericModel { protected String text; protected List keywords; + protected SemanticRolesResultObject() {} + /** * Gets the text. * - * Object text. + *

Object text. * * @return the text */ @@ -38,7 +37,7 @@ public String getText() { /** * Gets the keywords. * - * An array of extracted keywords. + *

An array of extracted keywords. * * @return the keywords */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java index 6ff7498d0d2..681fd2cd912 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,23 +12,22 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * The extracted subject from the sentence. - */ +/** The extracted subject from the sentence. */ public class SemanticRolesResultSubject extends GenericModel { protected String text; protected List entities; protected List keywords; + protected SemanticRolesResultSubject() {} + /** * Gets the text. * - * Text that corresponds to the subject role. + *

Text that corresponds to the subject role. * * @return the text */ @@ -39,7 +38,7 @@ public String getText() { /** * Gets the entities. * - * An array of extracted entities. + *

An array of extracted entities. * * @return the entities */ @@ -50,7 +49,7 @@ public List getEntities() { /** * Gets the keywords. * - * An array of extracted keywords. + *

An array of extracted keywords. * * @return the keywords */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java index f1484446c52..cc636811f96 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,18 +14,18 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * SemanticRolesVerb. - */ +/** SemanticRolesVerb. */ public class SemanticRolesVerb extends GenericModel { protected String text; protected String tense; + protected SemanticRolesVerb() {} + /** * Gets the text. * - * The keyword text. + *

The keyword text. * * @return the text */ @@ -36,7 +36,7 @@ public String getText() { /** * Gets the tense. * - * Verb tense. + *

Verb tense. * * @return the tense */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java index 45194538678..d80e08b277d 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,22 +12,21 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * SentenceResult. - */ +/** SentenceResult. */ public class SentenceResult extends GenericModel { protected String text; protected List location; + protected SentenceResult() {} + /** * Gets the text. * - * The sentence. + *

The sentence. * * @return the text */ @@ -38,7 +37,7 @@ public String getText() { /** * Gets the location. * - * Character offsets indicating the beginning and end of the sentence in the analyzed text. + *

Character offsets indicating the beginning and end of the sentence in the analyzed text. * * @return the location */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java index 3407a6b2408..4737f1cd3e3 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2017, 2024. * * 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 @@ -12,58 +12,58 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - /** - * Analyzes the general sentiment of your content or the sentiment toward specific target phrases. You can analyze - * sentiment for detected entities with `entities.sentiment` and for keywords with `keywords.sentiment`. + * Analyzes the general sentiment of your content or the sentiment toward specific target phrases. + * You can analyze sentiment for detected entities with `entities.sentiment` and for keywords with + * `keywords.sentiment`. * - * Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish. + *

Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, + * Russian, Spanish. */ public class SentimentOptions extends GenericModel { protected Boolean document; protected List targets; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean document; private List targets; + /** + * Instantiates a new Builder from an existing SentimentOptions instance. + * + * @param sentimentOptions the instance to initialize the Builder with + */ private Builder(SentimentOptions sentimentOptions) { this.document = sentimentOptions.document; this.targets = sentimentOptions.targets; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a SentimentOptions. * - * @return the sentimentOptions + * @return the new SentimentOptions instance */ public SentimentOptions build() { return new SentimentOptions(this); } /** - * Adds an targets to targets. + * Adds a new element to targets. * - * @param targets the new targets + * @param targets the new element to be added * @return the SentimentOptions builder */ public Builder addTargets(String targets) { - com.ibm.cloud.sdk.core.util.Validator.notNull(targets, - "targets cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(targets, "targets cannot be null"); if (this.targets == null) { this.targets = new ArrayList(); } @@ -83,8 +83,7 @@ public Builder document(Boolean document) { } /** - * Set the targets. - * Existing targets will be replaced. + * Set the targets. Existing targets will be replaced. * * @param targets the targets * @return the SentimentOptions builder @@ -95,6 +94,8 @@ public Builder targets(List targets) { } } + protected SentimentOptions() {} + protected SentimentOptions(Builder builder) { document = builder.document; targets = builder.targets; @@ -112,7 +113,7 @@ public Builder newBuilder() { /** * Gets the document. * - * Set this to `false` to hide document-level sentiment results. + *

Set this to `false` to hide document-level sentiment results. * * @return the document */ @@ -123,7 +124,7 @@ public Boolean document() { /** * Gets the targets. * - * Sentiment results will be returned for each target string that is found in the document. + *

Sentiment results will be returned for each target string that is found in the document. * * @return the targets */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java index 993ff2dac3f..5f2b473a7bc 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,22 +12,21 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * The sentiment of the content. - */ +/** The sentiment of the content. */ public class SentimentResult extends GenericModel { protected DocumentSentimentResults document; protected List targets; + protected SentimentResult() {} + /** * Gets the document. * - * The document level sentiment. + *

The document level sentiment. * * @return the document */ @@ -38,7 +37,7 @@ public DocumentSentimentResults getDocument() { /** * Gets the targets. * - * The targeted sentiment to analyze. + *

The targeted sentiment to analyze. * * @return the targets */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SummarizationOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SummarizationOptions.java new file mode 100644 index 00000000000..2cf2aa69454 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SummarizationOptions.java @@ -0,0 +1,90 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * (Experimental) Returns a summary of content. + * + *

Supported languages: English only. + * + *

Supported regions: Dallas region only. + */ +public class SummarizationOptions extends GenericModel { + + protected Long limit; + + /** Builder. */ + public static class Builder { + private Long limit; + + /** + * Instantiates a new Builder from an existing SummarizationOptions instance. + * + * @param summarizationOptions the instance to initialize the Builder with + */ + private Builder(SummarizationOptions summarizationOptions) { + this.limit = summarizationOptions.limit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a SummarizationOptions. + * + * @return the new SummarizationOptions instance + */ + public SummarizationOptions build() { + return new SummarizationOptions(this); + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the SummarizationOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + } + + protected SummarizationOptions() {} + + protected SummarizationOptions(Builder builder) { + limit = builder.limit; + } + + /** + * New builder. + * + * @return a SummarizationOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the limit. + * + *

Maximum number of summary sentences to return. + * + * @return the limit + */ + public Long limit() { + return limit; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java index 8315e3a8713..575000c34a1 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,36 +14,34 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Returns tokens and sentences from the input text. - */ +/** Returns tokens and sentences from the input text. */ public class SyntaxOptions extends GenericModel { protected SyntaxOptionsTokens tokens; protected Boolean sentences; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private SyntaxOptionsTokens tokens; private Boolean sentences; + /** + * Instantiates a new Builder from an existing SyntaxOptions instance. + * + * @param syntaxOptions the instance to initialize the Builder with + */ private Builder(SyntaxOptions syntaxOptions) { this.tokens = syntaxOptions.tokens; this.sentences = syntaxOptions.sentences; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a SyntaxOptions. * - * @return the syntaxOptions + * @return the new SyntaxOptions instance */ public SyntaxOptions build() { return new SyntaxOptions(this); @@ -72,6 +70,8 @@ public Builder sentences(Boolean sentences) { } } + protected SyntaxOptions() {} + protected SyntaxOptions(Builder builder) { tokens = builder.tokens; sentences = builder.sentences; @@ -89,7 +89,7 @@ public Builder newBuilder() { /** * Gets the tokens. * - * Tokenization options. + *

Tokenization options. * * @return the tokens */ @@ -100,7 +100,7 @@ public SyntaxOptionsTokens tokens() { /** * Gets the sentences. * - * Set this to `true` to return sentence information. + *

Set this to `true` to return sentence information. * * @return the sentences */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java index e1bcbf0ebd4..fc9e061ef39 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -15,37 +15,36 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Tokenization options. - */ +/** Tokenization options. */ public class SyntaxOptionsTokens extends GenericModel { protected Boolean lemma; + @SerializedName("part_of_speech") protected Boolean partOfSpeech; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private Boolean lemma; private Boolean partOfSpeech; + /** + * Instantiates a new Builder from an existing SyntaxOptionsTokens instance. + * + * @param syntaxOptionsTokens the instance to initialize the Builder with + */ private Builder(SyntaxOptionsTokens syntaxOptionsTokens) { this.lemma = syntaxOptionsTokens.lemma; this.partOfSpeech = syntaxOptionsTokens.partOfSpeech; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a SyntaxOptionsTokens. * - * @return the syntaxOptionsTokens + * @return the new SyntaxOptionsTokens instance */ public SyntaxOptionsTokens build() { return new SyntaxOptionsTokens(this); @@ -74,6 +73,8 @@ public Builder partOfSpeech(Boolean partOfSpeech) { } } + protected SyntaxOptionsTokens() {} + protected SyntaxOptionsTokens(Builder builder) { lemma = builder.lemma; partOfSpeech = builder.partOfSpeech; @@ -91,7 +92,7 @@ public Builder newBuilder() { /** * Gets the lemma. * - * Set this to `true` to return the lemma for each token. + *

Set this to `true` to return the lemma for each token. * * @return the lemma */ @@ -102,7 +103,7 @@ public Boolean lemma() { /** * Gets the partOfSpeech. * - * Set this to `true` to return the part of speech for each token. + *

Set this to `true` to return the part of speech for each token. * * @return the partOfSpeech */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java index 0ad07b3a91a..c82095c628c 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,18 +12,17 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Tokens and sentences returned from syntax analysis. - */ +/** Tokens and sentences returned from syntax analysis. */ public class SyntaxResult extends GenericModel { protected List tokens; protected List sentences; + protected SyntaxResult() {} + /** * Gets the tokens. * diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java index 511f72e7e65..229645afa57 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,18 +14,18 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Emotion results for a specified target. - */ +/** Emotion results for a specified target. */ public class TargetedEmotionResults extends GenericModel { protected String text; protected EmotionScores emotion; + protected TargetedEmotionResults() {} + /** * Gets the text. * - * Targeted text. + *

Targeted text. * * @return the text */ @@ -36,7 +36,7 @@ public String getText() { /** * Gets the emotion. * - * The emotion results for the target. + *

The emotion results for the target. * * @return the emotion */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java index f14b664d8c2..4b46acd47aa 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -14,18 +14,18 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * TargetedSentimentResults. - */ +/** TargetedSentimentResults. */ public class TargetedSentimentResults extends GenericModel { protected String text; protected Double score; + protected TargetedSentimentResults() {} + /** * Gets the text. * - * Targeted text. + *

Targeted text. * * @return the text */ @@ -36,7 +36,7 @@ public String getText() { /** * Gets the score. * - * Sentiment score from -1 (negative) to 1 (positive). + *

Sentiment score from -1 (negative) to 1 (positive). * * @return the score */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java index a907fa039d9..123a3df65ee 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,19 +12,16 @@ */ package com.ibm.watson.natural_language_understanding.v1.model; -import java.util.List; - import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * TokenResult. - */ +/** TokenResult. */ public class TokenResult extends GenericModel { /** - * The part of speech of the token. For descriptions of the values, see [Universal Dependencies POS - * tags](https://universaldependencies.org/u/pos/). + * The part of speech of the token. For more information about the values, see [Universal + * Dependencies POS tags](https://universaldependencies.org/u/pos/). */ public interface PartOfSpeech { /** ADJ. */ @@ -64,15 +61,19 @@ public interface PartOfSpeech { } protected String text; + @SerializedName("part_of_speech") protected String partOfSpeech; + protected List location; protected String lemma; + protected TokenResult() {} + /** * Gets the text. * - * The token as it appears in the analyzed text. + *

The token as it appears in the analyzed text. * * @return the text */ @@ -83,8 +84,8 @@ public String getText() { /** * Gets the partOfSpeech. * - * The part of speech of the token. For descriptions of the values, see [Universal Dependencies POS - * tags](https://universaldependencies.org/u/pos/). + *

The part of speech of the token. For more information about the values, see [Universal + * Dependencies POS tags](https://universaldependencies.org/u/pos/). * * @return the partOfSpeech */ @@ -95,7 +96,7 @@ public String getPartOfSpeech() { /** * Gets the location. * - * Character offsets indicating the beginning and end of the token in the analyzed text. + *

Character offsets indicating the beginning and end of the token in the analyzed text. * * @return the location */ @@ -106,7 +107,7 @@ public List getLocation() { /** * Gets the lemma. * - * The [lemma](https://wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + *

The [lemma](https://wikipedia.org/wiki/Lemma_%28morphology%29) of the token. * * @return the lemma */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateCategoriesModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateCategoriesModelOptions.java new file mode 100644 index 00000000000..1b08735c50e --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateCategoriesModelOptions.java @@ -0,0 +1,355 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Map; + +/** The updateCategoriesModel options. */ +public class UpdateCategoriesModelOptions extends GenericModel { + + protected String modelId; + protected String language; + protected InputStream trainingData; + protected String trainingDataContentType; + protected String name; + protected Map userMetadata; + protected String description; + protected String modelVersion; + protected String workspaceId; + protected String versionDescription; + + /** Builder. */ + public static class Builder { + private String modelId; + private String language; + private InputStream trainingData; + private String trainingDataContentType; + private String name; + private Map userMetadata; + private String description; + private String modelVersion; + private String workspaceId; + private String versionDescription; + + /** + * Instantiates a new Builder from an existing UpdateCategoriesModelOptions instance. + * + * @param updateCategoriesModelOptions the instance to initialize the Builder with + */ + private Builder(UpdateCategoriesModelOptions updateCategoriesModelOptions) { + this.modelId = updateCategoriesModelOptions.modelId; + this.language = updateCategoriesModelOptions.language; + this.trainingData = updateCategoriesModelOptions.trainingData; + this.trainingDataContentType = updateCategoriesModelOptions.trainingDataContentType; + this.name = updateCategoriesModelOptions.name; + this.userMetadata = updateCategoriesModelOptions.userMetadata; + this.description = updateCategoriesModelOptions.description; + this.modelVersion = updateCategoriesModelOptions.modelVersion; + this.workspaceId = updateCategoriesModelOptions.workspaceId; + this.versionDescription = updateCategoriesModelOptions.versionDescription; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + * @param language the language + * @param trainingData the trainingData + */ + public Builder(String modelId, String language, InputStream trainingData) { + this.modelId = modelId; + this.language = language; + this.trainingData = trainingData; + } + + /** + * Builds a UpdateCategoriesModelOptions. + * + * @return the new UpdateCategoriesModelOptions instance + */ + public UpdateCategoriesModelOptions build() { + return new UpdateCategoriesModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the UpdateCategoriesModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the UpdateCategoriesModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateCategoriesModelOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the trainingDataContentType. + * + * @param trainingDataContentType the trainingDataContentType + * @return the UpdateCategoriesModelOptions builder + */ + public Builder trainingDataContentType(String trainingDataContentType) { + this.trainingDataContentType = trainingDataContentType; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateCategoriesModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the userMetadata. + * + * @param userMetadata the userMetadata + * @return the UpdateCategoriesModelOptions builder + */ + public Builder userMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateCategoriesModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the modelVersion. + * + * @param modelVersion the modelVersion + * @return the UpdateCategoriesModelOptions builder + */ + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateCategoriesModelOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the versionDescription. + * + * @param versionDescription the versionDescription + * @return the UpdateCategoriesModelOptions builder + */ + public Builder versionDescription(String versionDescription) { + this.versionDescription = versionDescription; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateCategoriesModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + } + + protected UpdateCategoriesModelOptions() {} + + protected UpdateCategoriesModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + modelId = builder.modelId; + language = builder.language; + trainingData = builder.trainingData; + trainingDataContentType = builder.trainingDataContentType; + name = builder.name; + userMetadata = builder.userMetadata; + description = builder.description; + modelVersion = builder.modelVersion; + workspaceId = builder.workspaceId; + versionDescription = builder.versionDescription; + } + + /** + * New builder. + * + * @return a UpdateCategoriesModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the trainingData. + * + *

Training data in JSON format. For more information, see [Categories training data + * requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the trainingDataContentType. + * + *

The content type of trainingData. Values for this parameter can be obtained from the + * HttpMediaType class. + * + * @return the trainingDataContentType + */ + public String trainingDataContentType() { + return trainingDataContentType; + } + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map userMetadata() { + return userMetadata; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String modelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String versionDescription() { + return versionDescription; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateClassificationsModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateClassificationsModelOptions.java new file mode 100644 index 00000000000..096556bada3 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateClassificationsModelOptions.java @@ -0,0 +1,381 @@ +/* + * (C) Copyright IBM Corp. 2021, 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 + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Map; + +/** The updateClassificationsModel options. */ +public class UpdateClassificationsModelOptions extends GenericModel { + + protected String modelId; + protected String language; + protected InputStream trainingData; + protected String trainingDataContentType; + protected String name; + protected Map userMetadata; + protected String description; + protected String modelVersion; + protected String workspaceId; + protected String versionDescription; + protected ClassificationsTrainingParameters trainingParameters; + + /** Builder. */ + public static class Builder { + private String modelId; + private String language; + private InputStream trainingData; + private String trainingDataContentType; + private String name; + private Map userMetadata; + private String description; + private String modelVersion; + private String workspaceId; + private String versionDescription; + private ClassificationsTrainingParameters trainingParameters; + + /** + * Instantiates a new Builder from an existing UpdateClassificationsModelOptions instance. + * + * @param updateClassificationsModelOptions the instance to initialize the Builder with + */ + private Builder(UpdateClassificationsModelOptions updateClassificationsModelOptions) { + this.modelId = updateClassificationsModelOptions.modelId; + this.language = updateClassificationsModelOptions.language; + this.trainingData = updateClassificationsModelOptions.trainingData; + this.trainingDataContentType = updateClassificationsModelOptions.trainingDataContentType; + this.name = updateClassificationsModelOptions.name; + this.userMetadata = updateClassificationsModelOptions.userMetadata; + this.description = updateClassificationsModelOptions.description; + this.modelVersion = updateClassificationsModelOptions.modelVersion; + this.workspaceId = updateClassificationsModelOptions.workspaceId; + this.versionDescription = updateClassificationsModelOptions.versionDescription; + this.trainingParameters = updateClassificationsModelOptions.trainingParameters; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + * @param language the language + * @param trainingData the trainingData + */ + public Builder(String modelId, String language, InputStream trainingData) { + this.modelId = modelId; + this.language = language; + this.trainingData = trainingData; + } + + /** + * Builds a UpdateClassificationsModelOptions. + * + * @return the new UpdateClassificationsModelOptions instance + */ + public UpdateClassificationsModelOptions build() { + return new UpdateClassificationsModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the UpdateClassificationsModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the UpdateClassificationsModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateClassificationsModelOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the trainingDataContentType. + * + * @param trainingDataContentType the trainingDataContentType + * @return the UpdateClassificationsModelOptions builder + */ + public Builder trainingDataContentType(String trainingDataContentType) { + this.trainingDataContentType = trainingDataContentType; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateClassificationsModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the userMetadata. + * + * @param userMetadata the userMetadata + * @return the UpdateClassificationsModelOptions builder + */ + public Builder userMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateClassificationsModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the modelVersion. + * + * @param modelVersion the modelVersion + * @return the UpdateClassificationsModelOptions builder + */ + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateClassificationsModelOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the versionDescription. + * + * @param versionDescription the versionDescription + * @return the UpdateClassificationsModelOptions builder + */ + public Builder versionDescription(String versionDescription) { + this.versionDescription = versionDescription; + return this; + } + + /** + * Set the trainingParameters. + * + * @param trainingParameters the trainingParameters + * @return the UpdateClassificationsModelOptions builder + */ + public Builder trainingParameters(ClassificationsTrainingParameters trainingParameters) { + this.trainingParameters = trainingParameters; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateClassificationsModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + } + + protected UpdateClassificationsModelOptions() {} + + protected UpdateClassificationsModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + modelId = builder.modelId; + language = builder.language; + trainingData = builder.trainingData; + trainingDataContentType = builder.trainingDataContentType; + name = builder.name; + userMetadata = builder.userMetadata; + description = builder.description; + modelVersion = builder.modelVersion; + workspaceId = builder.workspaceId; + versionDescription = builder.versionDescription; + trainingParameters = builder.trainingParameters; + } + + /** + * New builder. + * + * @return a UpdateClassificationsModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the trainingData. + * + *

Training data in JSON format. For more information, see [Classifications training data + * requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the trainingDataContentType. + * + *

The content type of trainingData. Values for this parameter can be obtained from the + * HttpMediaType class. + * + * @return the trainingDataContentType + */ + public String trainingDataContentType() { + return trainingDataContentType; + } + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map userMetadata() { + return userMetadata; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String modelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String versionDescription() { + return versionDescription; + } + + /** + * Gets the trainingParameters. + * + *

Optional classifications training parameters along with model train requests. + * + * @return the trainingParameters + */ + public ClassificationsTrainingParameters trainingParameters() { + return trainingParameters; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateSentimentModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateSentimentModelOptions.java new file mode 100644 index 00000000000..9e6a4682416 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateSentimentModelOptions.java @@ -0,0 +1,323 @@ +/* + * (C) Copyright IBM Corp. 2021, 2022. + * + * 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.natural_language_understanding.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Map; + +/** The updateSentimentModel options. */ +public class UpdateSentimentModelOptions extends GenericModel { + + protected String modelId; + protected String language; + protected InputStream trainingData; + protected String name; + protected Map userMetadata; + protected String description; + protected String modelVersion; + protected String workspaceId; + protected String versionDescription; + + /** Builder. */ + public static class Builder { + private String modelId; + private String language; + private InputStream trainingData; + private String name; + private Map userMetadata; + private String description; + private String modelVersion; + private String workspaceId; + private String versionDescription; + + private Builder(UpdateSentimentModelOptions updateSentimentModelOptions) { + this.modelId = updateSentimentModelOptions.modelId; + this.language = updateSentimentModelOptions.language; + this.trainingData = updateSentimentModelOptions.trainingData; + this.name = updateSentimentModelOptions.name; + this.userMetadata = updateSentimentModelOptions.userMetadata; + this.description = updateSentimentModelOptions.description; + this.modelVersion = updateSentimentModelOptions.modelVersion; + this.workspaceId = updateSentimentModelOptions.workspaceId; + this.versionDescription = updateSentimentModelOptions.versionDescription; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param modelId the modelId + * @param language the language + * @param trainingData the trainingData + */ + public Builder(String modelId, String language, InputStream trainingData) { + this.modelId = modelId; + this.language = language; + this.trainingData = trainingData; + } + + /** + * Builds a UpdateSentimentModelOptions. + * + * @return the new UpdateSentimentModelOptions instance + */ + public UpdateSentimentModelOptions build() { + return new UpdateSentimentModelOptions(this); + } + + /** + * Set the modelId. + * + * @param modelId the modelId + * @return the UpdateSentimentModelOptions builder + */ + public Builder modelId(String modelId) { + this.modelId = modelId; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the UpdateSentimentModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateSentimentModelOptions builder + */ + public Builder trainingData(InputStream trainingData) { + this.trainingData = trainingData; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateSentimentModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the userMetadata. + * + * @param userMetadata the userMetadata + * @return the UpdateSentimentModelOptions builder + */ + public Builder userMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateSentimentModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the modelVersion. + * + * @param modelVersion the modelVersion + * @return the UpdateSentimentModelOptions builder + */ + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateSentimentModelOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the versionDescription. + * + * @param versionDescription the versionDescription + * @return the UpdateSentimentModelOptions builder + */ + public Builder versionDescription(String versionDescription) { + this.versionDescription = versionDescription; + return this; + } + + /** + * Set the trainingData. + * + * @param trainingData the trainingData + * @return the UpdateSentimentModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder trainingData(File trainingData) throws FileNotFoundException { + this.trainingData = new FileInputStream(trainingData); + return this; + } + } + + protected UpdateSentimentModelOptions() {} + + protected UpdateSentimentModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.trainingData, "trainingData cannot be null"); + modelId = builder.modelId; + language = builder.language; + trainingData = builder.trainingData; + name = builder.name; + userMetadata = builder.userMetadata; + description = builder.description; + modelVersion = builder.modelVersion; + workspaceId = builder.workspaceId; + versionDescription = builder.versionDescription; + } + + /** + * New builder. + * + * @return a UpdateSentimentModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the modelId. + * + *

ID of the model. + * + * @return the modelId + */ + public String modelId() { + return modelId; + } + + /** + * Gets the language. + * + *

The 2-letter language code of this model. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the trainingData. + * + *

Training data in CSV format. For more information, see [Sentiment training data + * requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements). + * + * @return the trainingData + */ + public InputStream trainingData() { + return trainingData; + } + + /** + * Gets the name. + * + *

An optional name for the model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the userMetadata. + * + *

An optional map of metadata key-value pairs to store with this model. + * + * @return the userMetadata + */ + public Map userMetadata() { + return userMetadata; + } + + /** + * Gets the description. + * + *

An optional description of the model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the modelVersion. + * + *

An optional version string. + * + * @return the modelVersion + */ + public String modelVersion() { + return modelVersion; + } + + /** + * Gets the workspaceId. + * + *

ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language + * Understanding. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the versionDescription. + * + *

The description of the version. + * + * @return the versionDescription + */ + public String versionDescription() { + return versionDescription; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java index 355236ae4cf..7afb2ae5b5c 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -10,7 +10,5 @@ * 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. */ -/** - * Natural Language Understanding v1. - */ +/** Natural Language Understanding v1. */ package com.ibm.watson.natural_language_understanding.v1; diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java index 96c23e89ceb..401c2f94fa8 100644 --- a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,74 +12,66 @@ */ package com.ibm.watson.natural_language_understanding.v1; +import static junit.framework.TestCase.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.common.RetryRunner; import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResults; -import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResultsMetadata; -import com.ibm.watson.natural_language_understanding.v1.model.AnalyzeOptions; -import com.ibm.watson.natural_language_understanding.v1.model.Author; -import com.ibm.watson.natural_language_understanding.v1.model.CategoriesOptions; -import com.ibm.watson.natural_language_understanding.v1.model.CategoriesResult; -import com.ibm.watson.natural_language_understanding.v1.model.ConceptsOptions; -import com.ibm.watson.natural_language_understanding.v1.model.ConceptsResult; -import com.ibm.watson.natural_language_understanding.v1.model.EmotionOptions; -import com.ibm.watson.natural_language_understanding.v1.model.EmotionScores; -import com.ibm.watson.natural_language_understanding.v1.model.EntitiesOptions; -import com.ibm.watson.natural_language_understanding.v1.model.EntitiesResult; -import com.ibm.watson.natural_language_understanding.v1.model.Features; -import com.ibm.watson.natural_language_understanding.v1.model.KeywordsOptions; -import com.ibm.watson.natural_language_understanding.v1.model.KeywordsResult; -import com.ibm.watson.natural_language_understanding.v1.model.MetadataOptions; -import com.ibm.watson.natural_language_understanding.v1.model.RelationsOptions; -import com.ibm.watson.natural_language_understanding.v1.model.SemanticRolesOptions; -import com.ibm.watson.natural_language_understanding.v1.model.SemanticRolesResult; -import com.ibm.watson.natural_language_understanding.v1.model.SentimentOptions; -import com.ibm.watson.natural_language_understanding.v1.model.TargetedSentimentResults; -import org.junit.Assume; +import com.ibm.watson.natural_language_understanding.v1.model.*; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.FileInputStream; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; -import java.io.FileInputStream; -import java.util.Arrays; -import java.util.List; - -import static junit.framework.TestCase.assertNull; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Natural Language Understanding integration tests. - */ +/** Natural Language Understanding integration tests. */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @RunWith(RetryRunner.class) public class NaturalLanguageUnderstandingIT extends WatsonServiceTest { private NaturalLanguageUnderstanding service; - private String text = "In 2009, Elliot Turner launched AlchemyAPI to process the written word," - + " with all of its quirks and nuances, and got immediate traction."; + private String text = + "In 2009, Elliot Turner launched AlchemyAPI to process the written word," + + " with all of its quirks and nuances, and got immediate traction."; + /** + * Sets up the tests. + * + * @throws Exception the exception + */ /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - String apiKey = getProperty("natural_language_understanding.apikey"); + String apiKey = System.getenv("NATURAL_LANGUAGE_UNDERSTANDING_APIKEY"); + String serviceUrl = System.getenv("NATURAL_LANGUAGE_UNDERSTANDING_URL"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); + if (apiKey == null) { + apiKey = getProperty("natural_language_understanding.apikey"); + serviceUrl = getProperty("natural_language_understanding.url"); + } + + assertNotNull( + "NATURAL_LANGUAGE_UNDERSTANDING_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey); Authenticator authenticator = new IamAuthenticator(apiKey); service = new NaturalLanguageUnderstanding("2019-07-12", authenticator); service.setDefaultHeaders(getDefaultHeaders()); - service.setServiceUrl(getProperty("natural_language_understanding.url")); + service.setServiceUrl(serviceUrl); } /** @@ -92,9 +84,7 @@ public void analyzeHtmlIsSuccessful() throws Exception { String testHtmlFileName = "src/test/resources/natural_language_understanding/testArticle.html"; String html = getStringFromInputStream(new FileInputStream(testHtmlFileName)); - ConceptsOptions concepts = new ConceptsOptions.Builder() - .limit(5) - .build(); + ConceptsOptions concepts = new ConceptsOptions.Builder().limit(5).build(); Features features = new Features.Builder().concepts(concepts).build(); AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).build(); @@ -111,14 +101,9 @@ public void analyzeHtmlIsSuccessful() throws Exception { */ @Test public void analyzeTextIsSuccessful() throws Exception { - ConceptsOptions concepts = new ConceptsOptions.Builder() - .limit(5) - .build(); + ConceptsOptions concepts = new ConceptsOptions.Builder().limit(5).build(); Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .text(text) - .features(features) - .build(); + AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -134,15 +119,10 @@ public void analyzeTextIsSuccessful() throws Exception { public void analyzeUrlIsSuccessful() throws Exception { String url = "http://www.politico.com/story/2016/07/dnc-2016-obama-prepared-remarks-226345"; - ConceptsOptions concepts = new ConceptsOptions.Builder() - .limit(5) - .build(); + ConceptsOptions concepts = new ConceptsOptions.Builder().limit(5).build(); Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .url(url) - .features(features) - .returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().url(url).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -157,25 +137,21 @@ public void analyzeUrlIsSuccessful() throws Exception { */ @Test public void analyzeTextForConceptsIsSuccessful() throws Exception { - String text = "In remote corners of the world, citizens are demanding respect" - + " for the dignity of all people no matter their gender, or race, or religion, or disability," - + " or sexual orientation, and those who deny others dignity are subject to public reproach." - + " An explosion of social media has given ordinary people more ways to express themselves," - + " and has raised people's expectations for those of us in power. Indeed, our international" - + " order has been so successful that we take it as a given that great powers no longer" - + " fight world wars; that the end of the Cold War lifted the shadow of nuclear Armageddon;" - + " that the battlefields of Europe have been replaced by peaceful union; that China and India" - + " remain on a path of remarkable growth."; - - ConceptsOptions concepts = new ConceptsOptions.Builder() - .limit(5) - .build(); + String text = + "In remote corners of the world, citizens are demanding respect" + + " for the dignity of all people no matter their gender, or race, or religion, or disability," + + " or sexual orientation, and those who deny others dignity are subject to public reproach." + + " An explosion of social media has given ordinary people more ways to express themselves," + + " and has raised people's expectations for those of us in power. Indeed, our international" + + " order has been so successful that we take it as a given that great powers no longer" + + " fight world wars; that the end of the Cold War lifted the shadow of nuclear Armageddon;" + + " that the battlefields of Europe have been replaced by peaceful union; that China and India" + + " remain on a path of remarkable growth."; + + ConceptsOptions concepts = new ConceptsOptions.Builder().limit(5).build(); Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .text(text) - .features(features) - .returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -199,11 +175,10 @@ public void analyzeHtmlForConceptsIsSuccessful() throws Exception { String testHtmlFileName = "src/test/resources/natural_language_understanding/testArticle.html"; String html = getStringFromInputStream(new FileInputStream(testHtmlFileName)); - ConceptsOptions concepts = new ConceptsOptions.Builder() - .build(); + ConceptsOptions concepts = new ConceptsOptions.Builder().build(); Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().html(html).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -224,15 +199,18 @@ public void analyzeHtmlForConceptsIsSuccessful() throws Exception { */ @Test public void analyzeTextForEmotionsWithoutTargetsIsSuccessful() throws Exception { - String text = "But I believe this thinking is wrong. I believe the road of true democracy remains the better path." - + " I believe that in the 21st century, economies can only grow to a certain point until they need to open up" - + " -- because entrepreneurs need to access information in order to invent; young people need a global" - + " education in order to thrive; independent media needs to check the abuses of power."; + String text = + "But I believe this thinking is wrong. I believe the road of true democracy remains the better path." + + " I believe that in the 21st century, economies can only grow to a certain point until they" + + " need to open up" + + " -- because entrepreneurs need to access information in order to invent; young people need" + + " a global" + + " education in order to thrive; independent media needs to check the abuses of power."; EmotionOptions emotion = new EmotionOptions.Builder().build(); Features features = new Features.Builder().emotion(emotion).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -259,23 +237,16 @@ public void analyzeTextForEmotionsWithoutTargetsIsSuccessful() throws Exception */ @Test public void analyzeTextForEntitiesIsSuccessful() throws Exception { - String text = "In 2009, Elliot Turner launched AlchemyAPI to process the written word, with all of its quirks " - + "and nuances, and got immediate traction."; + String text = + "In 2009, Elliot Turner launched AlchemyAPI to process the written word, with all of its quirks " + + "and nuances, and got immediate traction."; - EntitiesOptions entities = new EntitiesOptions.Builder() - .limit(2) - .sentiment(true) - .build(); + EntitiesOptions entities = new EntitiesOptions.Builder().limit(2).sentiment(true).build(); - Features features = new Features.Builder() - .entities(entities) - .build(); + Features features = new Features.Builder().entities(entities).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .text(text) - .features(features) - .returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -300,15 +271,10 @@ public void analyzeTextForEntitiesIsSuccessful() throws Exception { */ @Test public void analyzeTextForKeywordsIsSuccessful() throws Exception { - KeywordsOptions keywords = new KeywordsOptions.Builder() - .sentiment(true) - .build(); + KeywordsOptions keywords = new KeywordsOptions.Builder().sentiment(true).build(); Features features = new Features.Builder().keywords(keywords).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .text(text) - .features(features) - .returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -335,21 +301,16 @@ public void analyzeHtmlForMetadataIsSuccessful() throws Exception { String fileTitle = "This 5,000-year-old recipe for beer actually sounds pretty tasty"; String fileDate = "2016-05-23T20:13:00"; String fileAuthor = "Annalee Newitz"; - Features features = new Features.Builder() - .metadata(new MetadataOptions.Builder().build()) - .build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .html(html) - .features(features) - .returnAnalyzedText(true) - .build(); + Features features = new Features.Builder().metadata(new HashMap()).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().html(html).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); assertNotNull(results); assertEquals(results.getLanguage(), "en"); assertNotNull(results.getMetadata()); - AnalysisResultsMetadata result = results.getMetadata(); + FeaturesResultsMetadata result = results.getMetadata(); assertNotNull(result.getTitle()); assertEquals(result.getTitle(), fileTitle); assertNotNull(result.getPublicationDate()); @@ -367,9 +328,10 @@ public void analyzeHtmlForMetadataIsSuccessful() throws Exception { */ @Test public void analyzeTextForRelationsIsSuccessful() throws Exception { - Features features = new Features.Builder().relations(new RelationsOptions.Builder().build()).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); + Features features = + new Features.Builder().relations(new RelationsOptions.Builder().build()).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -386,15 +348,12 @@ public void analyzeTextForRelationsIsSuccessful() throws Exception { */ @Test public void analyzeTextForSemanticRolesIsSuccessful() throws Exception { - SemanticRolesOptions options = new SemanticRolesOptions.Builder() - .limit(7) - .keywords(true) - .entities(true) - .build(); + SemanticRolesOptions options = + new SemanticRolesOptions.Builder().limit(7).keywords(true).entities(true).build(); Features features = new Features.Builder().semanticRoles(options).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -423,13 +382,14 @@ public void analyzeTextForSemanticRolesIsSuccessful() throws Exception { */ @Test public void analyzeTextForSentimentWithTargetsIsSuccessful() throws Exception { - SentimentOptions options = new SentimentOptions.Builder() - .document(true) - .targets(Arrays.asList("Elliot Turner", "traction")) - .build(); + SentimentOptions options = + new SentimentOptions.Builder() + .document(true) + .targets(Arrays.asList("Elliot Turner", "traction")) + .build(); Features features = new Features.Builder().sentiment(options).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -453,12 +413,10 @@ public void analyzeTextForSentimentWithTargetsIsSuccessful() throws Exception { */ @Test public void analyzeTextForSentimentWithoutTargetsIsSuccessful() throws Exception { - SentimentOptions options = new SentimentOptions.Builder() - .document(true) - .build(); + SentimentOptions options = new SentimentOptions.Builder().document(true).build(); Features features = new Features.Builder().sentiment(options).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -478,9 +436,10 @@ public void analyzeTextForSentimentWithoutTargetsIsSuccessful() throws Exception */ @Test public void analyzeTextForCategoriesIsSuccessful() throws Exception { - Features features = new Features.Builder().categories(new CategoriesOptions.Builder().build()).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); + Features features = + new Features.Builder().categories(new CategoriesOptions.Builder().build()).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -503,7 +462,8 @@ public void analyzeTextForCategoriesIsSuccessful() throws Exception { public void analyzeHtmlForDisambiguationIsSuccessful() throws Exception { EntitiesOptions entities = new EntitiesOptions.Builder().sentiment(true).limit(1).build(); Features features = new Features.Builder().entities(entities).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().url("www.cnn.com").features(features).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().url("www.cnn.com").features(features).build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -514,7 +474,8 @@ public void analyzeHtmlForDisambiguationIsSuccessful() throws Exception { for (EntitiesResult result : results.getEntities()) { assertNotNull(result.getDisambiguation()); assertEquals(result.getDisambiguation().getName(), "CNN"); - assertEquals(result.getDisambiguation().getDbpediaResource(), "http://dbpedia.org/resource/CNN"); + assertEquals( + result.getDisambiguation().getDbpediaResource(), "http://dbpedia.org/resource/CNN"); assertNotNull(result.getDisambiguation().getSubtype()); assertTrue(result.getDisambiguation().getSubtype().size() > 0); } @@ -527,15 +488,23 @@ public void analyzeHtmlForDisambiguationIsSuccessful() throws Exception { */ @Test public void analyzeTextWithCharacterLimitIsSuccessful() throws Exception { - String text = "But I believe this thinking is wrong. I believe the road of true democracy remains the better path." - + " I believe that in the 21st century, economies can only grow to a certain point until they need to open up" - + " -- because entrepreneurs need to access information in order to invent; young people need a global" - + " education in order to thrive; independent media needs to check the abuses of power."; + String text = + "But I believe this thinking is wrong. I believe the road of true democracy remains the better path." + + " I believe that in the 21st century, economies can only grow to a certain " + + "point until they need to open up" + + " -- because entrepreneurs need to access information in order to invent; young people need a global" + + " education in order to thrive; independent media needs to check the abuses of power."; Long characterLimit = 10L; - Features features = new Features.Builder().categories(new CategoriesOptions.Builder().build()).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .limitTextCharacters(characterLimit).build(); + Features features = + new Features.Builder().categories(new CategoriesOptions.Builder().build()).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder() + .text(text) + .features(features) + .returnAnalyzedText(true) + .limitTextCharacters(characterLimit) + .build(); AnalysisResults results = service.analyze(parameters).execute().getResult(); @@ -543,4 +512,616 @@ public void analyzeTextWithCharacterLimitIsSuccessful() throws Exception { assertNotNull(results.getAnalyzedText()); assertTrue(results.getAnalyzedText().length() == characterLimit); } + + /** + * Test createCategoriesModel service call + * + * @throws Exception the exception + */ + @Test + public void testCreateCategoriesModel() throws Exception { + // Construct an instance of the CreateCategoriesModelOptions model + CreateCategoriesModelOptions createCategoriesModelOptionsModel = + new CreateCategoriesModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase\",\n" + + " \"key phrase 2\"\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\",\n" + + " \"level2\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase 3\",\n" + + " \"key phrase 4\"\n" + + " ]\n" + + " }\n" + + " ]")) + .trainingDataContentType("application/json") + .name("testString") + .description("testString") + .modelVersion("testString") + .versionDescription("testString") + .build(); + CategoriesModel response = + service.createCategoriesModel(createCategoriesModelOptionsModel).execute().getResult(); + assertEquals(response.getName(), "testString"); + assertEquals(response.getLanguage(), "en"); + assertEquals(response.getDescription(), "testString"); + assertEquals(response.getModelVersion(), "testString"); + assertEquals(response.getVersionDescription(), "testString"); + + DeleteCategoriesModelOptions deleteCategoriesModelOptions = + new DeleteCategoriesModelOptions.Builder().modelId(response.getModelId()).build(); + DeleteModelResults deleteModelResults = + service.deleteCategoriesModel(deleteCategoriesModelOptions).execute().getResult(); + } + /** + * Test listCategoriesModels service call + * + * @throws Exception the exception + */ + @Test + public void testListCategoriesModels() throws Exception { + CategoriesModelList response = service.listCategoriesModels().execute().getResult(); + assertNotNull(response.getModels()); + + for (CategoriesModel categoriesModel : response.getModels()) { + if (categoriesModel.getName().startsWith("testString")) { + DeleteCategoriesModelOptions deleteCategoriesModelOptions = + new DeleteCategoriesModelOptions.Builder() + .modelId(categoriesModel.getModelId()) + .build(); + DeleteModelResults deleteModelResults = + service.deleteCategoriesModel(deleteCategoriesModelOptions).execute().getResult(); + } + } + } + + /** + * Test updateCategoriesModel service call + * + * @throws Exception the exception + */ + @Test + public void testUpdateCategoriesModel() throws Exception { + String modelId = ""; + try { + // Construct an instance of the CreateCategoriesModelOptions model + CreateCategoriesModelOptions createCategoriesModelOptionsModel = + new CreateCategoriesModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase\",\n" + + " \"key phrase 2\"\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\",\n" + + " \"level2\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase 3\",\n" + + " \"key phrase 4\"\n" + + " ]\n" + + " }\n" + + " ]")) + .trainingDataContentType("application/json") + .name("testString") + .description("testString") + .modelVersion("testString") + .versionDescription("testString") + .build(); + CategoriesModel response = + service.createCategoriesModel(createCategoriesModelOptionsModel).execute().getResult(); + assertEquals(response.getName(), "testString"); + assertEquals(response.getLanguage(), "en"); + assertEquals(response.getDescription(), "testString"); + assertEquals(response.getModelVersion(), "testString"); + assertEquals(response.getVersionDescription(), "testString"); + + modelId = response.getModelId(); + // Construct an instance of the UpdateCategoriesModelOptions model + UpdateCategoriesModelOptions updateCategoriesModelOptionsModel = + new UpdateCategoriesModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase\",\n" + + " \"key phrase 2\"\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\",\n" + + " \"level2\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase 3\",\n" + + " \"key phrase 4\"\n" + + " ]\n" + + " }\n" + + " ]")) + .trainingDataContentType("application/json") + .name("newName") + .description("newDescription") + .modelVersion("testString") + .versionDescription("testString") + .modelId(modelId) + .build(); + CategoriesModel response2 = + service.updateCategoriesModel(updateCategoriesModelOptionsModel).execute().getResult(); + + assertEquals(response2.getName(), "newName"); + assertEquals(response2.getLanguage(), "en"); + assertEquals(response2.getDescription(), "newDescription"); + assertEquals(response2.getModelVersion(), "testString"); + assertEquals(response2.getVersionDescription(), "testString"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (modelId != "") { + DeleteCategoriesModelOptions deleteCategoriesModelOptions = + new DeleteCategoriesModelOptions.Builder().modelId(modelId).build(); + DeleteModelResults deleteModelResults = + service.deleteCategoriesModel(deleteCategoriesModelOptions).execute().getResult(); + } + } + } + /** + * Test getCategoriesModel service call + * + * @throws Exception the exception + */ + @Test + public void testGetCategoriesModel() throws Exception { + String modelId = ""; + try { + // Construct an instance of the CreateCategoriesModelOptions model + CreateCategoriesModelOptions createCategoriesModelOptionsModel = + new CreateCategoriesModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase\",\n" + + " \"key phrase 2\"\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"labels\": [\n" + + " \"level1\",\n" + + " \"level2\"\n" + + " ],\n" + + " \"key_phrases\": [\n" + + " \"key phrase 3\",\n" + + " \"key phrase 4\"\n" + + " ]\n" + + " }\n" + + " ]")) + .trainingDataContentType("application/json") + .name("testString") + .description("testString") + .modelVersion("testString") + .versionDescription("testString") + .build(); + CategoriesModel response = + service.createCategoriesModel(createCategoriesModelOptionsModel).execute().getResult(); + assertEquals(response.getName(), "testString"); + assertEquals(response.getLanguage(), "en"); + assertEquals(response.getDescription(), "testString"); + assertEquals(response.getModelVersion(), "testString"); + assertEquals(response.getVersionDescription(), "testString"); + + modelId = response.getModelId(); + + GetCategoriesModelOptions getCategoriesModelOptions = + new GetCategoriesModelOptions.Builder().modelId(response.getModelId()).build(); + CategoriesModel response2 = + service.getCategoriesModel(getCategoriesModelOptions).execute().getResult(); + + assertEquals(response2.getName(), "testString"); + assertEquals(response2.getLanguage(), "en"); + assertEquals(response2.getDescription(), "testString"); + assertEquals(response2.getModelVersion(), "testString"); + assertEquals(response2.getVersionDescription(), "testString"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (modelId != "") { + DeleteCategoriesModelOptions deleteCategoriesModelOptions = + new DeleteCategoriesModelOptions.Builder().modelId(modelId).build(); + DeleteModelResults deleteModelResults = + service.deleteCategoriesModel(deleteCategoriesModelOptions).execute().getResult(); + } + } + } + /** + * Test createClassification service call + * + * @throws Exception the exception + */ + @Test + public void testCreateClassificationModel() throws Exception { + // Construct an instance of the CreateClassificationsModelOptions model + ClassificationsTrainingParameters trainingParameters = + new ClassificationsTrainingParameters.Builder().modelType("multi_label").build(); + CreateClassificationsModelOptions createClassificationsModelOptionsModel = + new CreateClassificationsModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"text\": \"How hot is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it hot outside?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be uncomfortably hot?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be sweltering?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How cold is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will we get snow?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Are we expecting sunny conditions?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it overcast?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be cloudy?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How much rain will fall today?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " }\n" + + "]")) + .trainingDataContentType("application/json") + .name("testString") + .description("testString") + .modelVersion("testString") + .versionDescription("testString") + .trainingParameters(trainingParameters) + .build(); + ClassificationsModel response = + service + .createClassificationsModel(createClassificationsModelOptionsModel) + .execute() + .getResult(); + assertEquals(response.getName(), "testString"); + assertEquals(response.getLanguage(), "en"); + assertEquals(response.getDescription(), "testString"); + assertEquals(response.getModelVersion(), "testString"); + assertEquals(response.getVersionDescription(), "testString"); + + DeleteClassificationsModelOptions deleteClassificationsModelOptions = + new DeleteClassificationsModelOptions.Builder().modelId(response.getModelId()).build(); + DeleteModelResults deleteModelResults = + service.deleteClassificationsModel(deleteClassificationsModelOptions).execute().getResult(); + } + /** + * Test listClassificationModels service call + * + * @throws Exception the exception + */ + @Test + public void testListClassificationModels() throws Exception { + ClassificationsModelList response = service.listClassificationsModels().execute().getResult(); + assertNotNull(response.getModels()); + + for (ClassificationsModel classificationsModel : response.getModels()) { + if (classificationsModel.getName().startsWith("testString")) { + DeleteClassificationsModelOptions deleteClassificationsModelOptions = + new DeleteClassificationsModelOptions.Builder() + .modelId(classificationsModel.getModelId()) + .build(); + DeleteModelResults deleteModelResults = + service + .deleteClassificationsModel(deleteClassificationsModelOptions) + .execute() + .getResult(); + } + } + } + /** + * Test updateClassificationModel service call + * + * @throws Exception the exception + */ + @Test + public void testUpdateClassificationModel() throws Exception { + String modelId = ""; + try { + // Construct an instance of the CreateClassificationsModelOptions model + CreateClassificationsModelOptions createClassificationsModelOptionsModel = + new CreateClassificationsModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"text\": \"How hot is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it hot outside?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be uncomfortably hot?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be sweltering?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How cold is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will we get snow?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Are we expecting sunny conditions?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it overcast?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be cloudy?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How much rain will fall today?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " }\n" + + "]")) + .trainingDataContentType("application/json") + .name("testString") + .description("testString") + .modelVersion("testString") + .versionDescription("testString") + .build(); + ClassificationsModel response = + service + .createClassificationsModel(createClassificationsModelOptionsModel) + .execute() + .getResult(); + assertEquals(response.getName(), "testString"); + assertEquals(response.getLanguage(), "en"); + assertEquals(response.getDescription(), "testString"); + assertEquals(response.getModelVersion(), "testString"); + assertEquals(response.getVersionDescription(), "testString"); + + modelId = response.getModelId(); + // Construct an instance of the UpdateCategoriesModelOptions model + UpdateClassificationsModelOptions updateClassificationsModelOptions = + new UpdateClassificationsModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"text\": \"How hot is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it hot outside?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be uncomfortably hot?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be sweltering?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How cold is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will we get snow?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Are we expecting sunny conditions?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it overcast?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be cloudy?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How much rain will fall today?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " }\n" + + "]")) + .trainingDataContentType("application/json") + .name("newName") + .description("newDescription") + .modelVersion("testString") + .versionDescription("testString") + .modelId(modelId) + .build(); + ClassificationsModel response2 = + service + .updateClassificationsModel(updateClassificationsModelOptions) + .execute() + .getResult(); + + assertEquals(response2.getName(), "newName"); + assertEquals(response2.getLanguage(), "en"); + assertEquals(response2.getDescription(), "newDescription"); + assertEquals(response2.getModelVersion(), "testString"); + assertEquals(response2.getVersionDescription(), "testString"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (modelId != "") { + DeleteClassificationsModelOptions deleteClassificationsModelOptions = + new DeleteClassificationsModelOptions.Builder().modelId(modelId).build(); + DeleteModelResults deleteModelResults = + service + .deleteClassificationsModel(deleteClassificationsModelOptions) + .execute() + .getResult(); + } + } + } + /** + * Test getClassificationModel service call + * + * @throws Exception the exception + */ + @Test + public void testGetClassificationModel() throws Exception { + String modelId = ""; + try { + // Construct an instance of the CreateClassificationsModelOptions model + CreateClassificationsModelOptions createClassificationsModelOptionsModel = + new CreateClassificationsModelOptions.Builder() + .language("en") + .trainingData( + TestUtilities.createMockStream( + "[\n" + + " {\n" + + " \"text\": \"How hot is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it hot outside?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be uncomfortably hot?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be sweltering?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How cold is it today?\",\n" + + " \"labels\": [\"temperature\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will we get snow?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Are we expecting sunny conditions?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Is it overcast?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"Will it be cloudy?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " },\n" + + " {\n" + + " \"text\": \"How much rain will fall today?\",\n" + + " \"labels\": [\"conditions\"]\n" + + " }\n" + + "]")) + .trainingDataContentType("application/json") + .name("testString") + .description("testString") + .modelVersion("testString") + .versionDescription("testString") + .build(); + ClassificationsModel response = + service + .createClassificationsModel(createClassificationsModelOptionsModel) + .execute() + .getResult(); + assertEquals(response.getName(), "testString"); + assertEquals(response.getLanguage(), "en"); + assertEquals(response.getDescription(), "testString"); + assertEquals(response.getModelVersion(), "testString"); + assertEquals(response.getVersionDescription(), "testString"); + + modelId = response.getModelId(); + + GetClassificationsModelOptions getClassificationsModelOptions = + new GetClassificationsModelOptions.Builder().modelId(response.getModelId()).build(); + ClassificationsModel response2 = + service.getClassificationsModel(getClassificationsModelOptions).execute().getResult(); + + assertEquals(response2.getName(), "testString"); + assertEquals(response2.getLanguage(), "en"); + assertEquals(response2.getDescription(), "testString"); + assertEquals(response2.getModelVersion(), "testString"); + assertEquals(response2.getVersionDescription(), "testString"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (modelId != "") { + DeleteClassificationsModelOptions deleteClassificationsModelOptions = + new DeleteClassificationsModelOptions.Builder().modelId(modelId).build(); + DeleteModelResults deleteModelResults = + service + .deleteClassificationsModel(deleteClassificationsModelOptions) + .execute() + .getResult(); + } + } + } } diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java index d752f121e06..36e1f0ace91 100644 --- a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -12,288 +12,959 @@ */ package com.ibm.watson.natural_language_understanding.v1; +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResults; import com.ibm.watson.natural_language_understanding.v1.model.AnalyzeOptions; +import com.ibm.watson.natural_language_understanding.v1.model.CategoriesModel; +import com.ibm.watson.natural_language_understanding.v1.model.CategoriesModelList; import com.ibm.watson.natural_language_understanding.v1.model.CategoriesOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsModel; +import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsModelList; +import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsTrainingParameters; import com.ibm.watson.natural_language_understanding.v1.model.ConceptsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.CreateCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.CreateClassificationsModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.DeleteCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.DeleteClassificationsModelOptions; import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults; import com.ibm.watson.natural_language_understanding.v1.model.EmotionOptions; import com.ibm.watson.natural_language_understanding.v1.model.EntitiesOptions; import com.ibm.watson.natural_language_understanding.v1.model.Features; +import com.ibm.watson.natural_language_understanding.v1.model.GetCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.GetClassificationsModelOptions; import com.ibm.watson.natural_language_understanding.v1.model.KeywordsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ListCategoriesModelsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ListClassificationsModelsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ListModelsOptions; import com.ibm.watson.natural_language_understanding.v1.model.ListModelsResults; -import com.ibm.watson.natural_language_understanding.v1.model.MetadataOptions; import com.ibm.watson.natural_language_understanding.v1.model.RelationsOptions; import com.ibm.watson.natural_language_understanding.v1.model.SemanticRolesOptions; import com.ibm.watson.natural_language_understanding.v1.model.SentimentOptions; +import com.ibm.watson.natural_language_understanding.v1.model.SyntaxOptions; +import com.ibm.watson.natural_language_understanding.v1.model.SyntaxOptionsTokens; +import com.ibm.watson.natural_language_understanding.v1.model.UpdateCategoriesModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.UpdateClassificationsModelOptions; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the NaturalLanguageUnderstanding service. */ +public class NaturalLanguageUnderstandingTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected NaturalLanguageUnderstanding naturalLanguageUnderstandingService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // Set mock values for global params + String version = "testString"; + new NaturalLanguageUnderstanding(version, serviceName, null); + } -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; + // Test the getter for the version global parameter + @Test + public void testGetVersion() throws Throwable { + assertEquals(naturalLanguageUnderstandingService.getVersion(), "testString"); + } + + // Test the analyze operation with a valid options model parameter + @Test + public void testAnalyzeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"language\": \"language\", \"analyzed_text\": \"analyzedText\", \"retrieved_url\": \"retrievedUrl\", \"usage\": {\"features\": 8, \"text_characters\": 14, \"text_units\": 9}, \"concepts\": [{\"text\": \"text\", \"relevance\": 9, \"dbpedia_resource\": \"dbpediaResource\"}], \"entities\": [{\"type\": \"type\", \"text\": \"text\", \"relevance\": 9, \"confidence\": 10, \"mentions\": [{\"text\": \"text\", \"location\": [8], \"confidence\": 10}], \"count\": 5, \"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}, \"sentiment\": {\"score\": 5}, \"disambiguation\": {\"name\": \"name\", \"dbpedia_resource\": \"dbpediaResource\", \"subtype\": [\"subtype\"]}}], \"keywords\": [{\"count\": 5, \"relevance\": 9, \"text\": \"text\", \"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}, \"sentiment\": {\"score\": 5}}], \"categories\": [{\"label\": \"label\", \"score\": 5, \"explanation\": {\"relevant_text\": [{\"text\": \"text\"}]}}], \"classifications\": [{\"class_name\": \"className\", \"confidence\": 10}], \"emotion\": {\"document\": {\"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}}, \"targets\": [{\"text\": \"text\", \"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}}]}, \"metadata\": {\"authors\": [{\"name\": \"name\"}], \"publication_date\": \"publicationDate\", \"title\": \"title\", \"image\": \"image\", \"feeds\": [{\"link\": \"link\"}]}, \"relations\": [{\"score\": 5, \"sentence\": \"sentence\", \"type\": \"type\", \"arguments\": [{\"entities\": [{\"text\": \"text\", \"type\": \"type\"}], \"location\": [8], \"text\": \"text\"}]}], \"semantic_roles\": [{\"sentence\": \"sentence\", \"subject\": {\"text\": \"text\", \"entities\": [{\"type\": \"type\", \"text\": \"text\"}], \"keywords\": [{\"text\": \"text\"}]}, \"action\": {\"text\": \"text\", \"normalized\": \"normalized\", \"verb\": {\"text\": \"text\", \"tense\": \"tense\"}}, \"object\": {\"text\": \"text\", \"keywords\": [{\"text\": \"text\"}]}}], \"sentiment\": {\"document\": {\"label\": \"label\", \"score\": 5}, \"targets\": [{\"text\": \"text\", \"score\": 5}]}, \"syntax\": {\"tokens\": [{\"text\": \"text\", \"part_of_speech\": \"ADJ\", \"location\": [8], \"lemma\": \"lemma\"}], \"sentences\": [{\"text\": \"text\", \"location\": [8]}]}}"; + String analyzePath = "/v1/analyze"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ClassificationsOptions model + ClassificationsOptions classificationsOptionsModel = + new ClassificationsOptions.Builder().model("testString").build(); + + // Construct an instance of the ConceptsOptions model + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("8")).build(); + + // Construct an instance of the EmotionOptions model + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the EntitiesOptions model + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("50")) + .mentions(false) + .model("testString") + .sentiment(false) + .emotion(false) + .build(); + + // Construct an instance of the KeywordsOptions model + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("50")) + .sentiment(false) + .emotion(false) + .build(); + + // Construct an instance of the RelationsOptions model + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + + // Construct an instance of the SemanticRolesOptions model + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("50")) + .keywords(false) + .entities(false) + .build(); + + // Construct an instance of the SentimentOptions model + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CategoriesOptions model + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(false) + .limit(Long.valueOf("3")) + .model("testString") + .build(); + + // Construct an instance of the SyntaxOptionsTokens model + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + + // Construct an instance of the SyntaxOptions model + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + + // Construct an instance of the Features model + Features featuresModel = + new Features.Builder() + .classifications(classificationsOptionsModel) + .concepts(conceptsOptionsModel) + .emotion(emotionOptionsModel) + .entities(entitiesOptionsModel) + .keywords(keywordsOptionsModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .relations(relationsOptionsModel) + .semanticRoles(semanticRolesOptionsModel) + .sentiment(sentimentOptionsModel) + .categories(categoriesOptionsModel) + .syntax(syntaxOptionsModel) + .build(); + + // Construct an instance of the AnalyzeOptions model + AnalyzeOptions analyzeOptionsModel = + new AnalyzeOptions.Builder() + .features(featuresModel) + .text("testString") + .html("testString") + .url("testString") + .clean(true) + .xpath("testString") + .fallbackToRaw(true) + .returnAnalyzedText(false) + .language("testString") + .limitTextCharacters(Long.valueOf("26")) + .build(); + + // Invoke analyze() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService.analyze(analyzeOptionsModel).execute(); + assertNotNull(response); + AnalysisResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, analyzePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; + // Test the analyze operation with and without retries enabled + @Test + public void testAnalyzeWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testAnalyzeWOptions(); -/** - * The Class NaturalLanguageunderstandingTest. - */ -public class NaturalLanguageUnderstandingTest extends WatsonServiceUnitTest { - private static final String MODELS_PATH = "/v1/models?version=2019-07-12"; - private static final String DELETE_PATH = "/v1/models/foo?version=2019-07-12"; - private static final String ANALYZE_PATH = "/v1/analyze?version=2019-07-12"; - private static final String RESOURCE = "src/test/resources/natural_language_understanding/"; - - private static final String TEXT = "text"; - private static final Long LOCATION = 0L; - private static final Double CONFIDENCE = 0.5; - - private ListModelsResults models; - private AnalysisResults analyzeResults; - private String modelId; - private NaturalLanguageUnderstanding service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new NaturalLanguageUnderstanding("2019-07-12", new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - modelId = "foo"; - models = loadFixture(RESOURCE + "models.json", ListModelsResults.class); - analyzeResults = loadFixture(RESOURCE + "analyze.json", AnalysisResults.class); - } - - // --- MODELS --- - - /** - * Test some of the model constructors. pump up the code coverage numbers - * - * @throws InterruptedException the interrupted exception - */ + naturalLanguageUnderstandingService.disableRetries(); + testAnalyzeWOptions(); + } + + // Test the analyze operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.analyze(null).execute(); + } + + // Test the listModels operation with a valid options model parameter + @Test + public void testListModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"models\": [{\"status\": \"starting\", \"model_id\": \"modelId\", \"language\": \"language\", \"description\": \"description\", \"workspace_id\": \"workspaceId\", \"model_version\": \"modelVersion\", \"version\": \"version\", \"version_description\": \"versionDescription\", \"created\": \"2019-01-01T12:00:00.000Z\"}]}"; + String listModelsPath = "/v1/models"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListModelsOptions model + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + + // Invoke listModels() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService.listModels(listModelsOptionsModel).execute(); + assertNotNull(response); + ListModelsResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listModels operation with and without retries enabled + @Test + public void testListModelsWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testListModelsWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testListModelsWOptions(); + } + + // Test the deleteModel operation with a valid options model parameter + @Test + public void testDeleteModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"deleted\": \"deleted\"}"; + String deleteModelPath = "/v1/models/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteModelOptions model + DeleteModelOptions deleteModelOptionsModel = + new DeleteModelOptions.Builder().modelId("testString").build(); + + // Invoke deleteModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService.deleteModel(deleteModelOptionsModel).execute(); + assertNotNull(response); + DeleteModelResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteModel operation with and without retries enabled + @Test + public void testDeleteModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testDeleteModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testDeleteModelWOptions(); + } + + // Test the deleteModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.deleteModel(null).execute(); + } + + // Test the createCategoriesModel operation with a valid options model parameter @Test - public void testModelOptions() throws InterruptedException { - Features features = new Features.Builder().concepts(null).categories(null).emotion(null).entities(null).keywords( - null).metadata(null).relations(null).semanticRoles(null).sentiment(null).build(); - - // AnalyzeOptions - AnalyzeOptions analyzeOptions = new AnalyzeOptions.Builder().text("text").html("html").url("url") - .features(features).clean(true).xpath("xpath").fallbackToRaw(false).returnAnalyzedText(true) - .language("language").build(); - assertEquals(analyzeOptions.text(), "text"); - assertEquals(analyzeOptions.html(), "html"); - assertEquals(analyzeOptions.url(), "url"); - assertEquals(analyzeOptions.features(), features); - assertEquals(analyzeOptions.clean(), true); - assertEquals(analyzeOptions.xpath(), "xpath"); - assertEquals(analyzeOptions.fallbackToRaw(), false); - assertEquals(analyzeOptions.returnAnalyzedText(), true); - assertEquals(analyzeOptions.language(), "language"); - analyzeOptions.newBuilder(); - - // CategoriesOptions - CategoriesOptions categoriesOptions = new CategoriesOptions.Builder().build(); - assertNotNull(categoriesOptions); - - // EmotionOptions - List emotionOptionsTargets = new ArrayList<>(Arrays.asList("target1", "target2")); - EmotionOptions emotionOptions = new EmotionOptions.Builder() - .document(true) - .targets(emotionOptionsTargets) - .addTargets("target3").build(); - emotionOptionsTargets.add("target3"); - assertEquals(emotionOptions.document(), true); - assertEquals(emotionOptions.targets(), emotionOptionsTargets); - emotionOptions.newBuilder(); - - // EntitiesOptions - EntitiesOptions entitiesOptions = new EntitiesOptions.Builder().emotion(true).limit(10).model("model").sentiment( - false).mentions(false).build(); - assertEquals(entitiesOptions.emotion(), true); - assertEquals(entitiesOptions.limit(), 10, 0); - assertEquals(entitiesOptions.model(), "model"); - assertEquals(entitiesOptions.sentiment(), false); - assertEquals(entitiesOptions.mentions(), false); - entitiesOptions.newBuilder(); - - // Features - assertEquals(features.categories(), null); - assertEquals(features.concepts(), null); - assertEquals(features.emotion(), null); - assertEquals(features.entities(), null); - assertEquals(features.keywords(), null); - assertEquals(features.metadata(), null); - assertEquals(features.relations(), null); - assertEquals(features.semanticRoles(), null); - assertEquals(features.sentiment(), null); - features.newBuilder(); - - // KeywordsOptions - KeywordsOptions keywordsOptions = new KeywordsOptions.Builder().emotion(true).limit(10).sentiment(false).build(); - assertEquals(keywordsOptions.emotion(), true); - assertEquals(keywordsOptions.limit(), 10, 0); - assertEquals(keywordsOptions.sentiment(), false); - keywordsOptions.newBuilder(); - - // MetadataOptions - MetadataOptions metadataOptions = new MetadataOptions.Builder().build(); - assertNotNull(metadataOptions); - - // RelationsOptions - RelationsOptions relationsOptions = new RelationsOptions.Builder().model("model").build(); - assertEquals(relationsOptions.model(), "model"); - relationsOptions.newBuilder(); - - // SemanticRolesOptions - SemanticRolesOptions semanticRolesOptions = new SemanticRolesOptions.Builder().entities(true).keywords(false).limit( - 10).build(); - assertEquals(semanticRolesOptions.entities(), true); - assertEquals(semanticRolesOptions.keywords(), false); - assertEquals(semanticRolesOptions.limit(), 10, 0); - semanticRolesOptions.newBuilder(); - - // SentimentOptions - List optionsTargets = new ArrayList<>(Arrays.asList("target1", "target2")); - SentimentOptions sentimentOptions = new SentimentOptions.Builder() - .document(true) - .targets(optionsTargets) - .addTargets("target3") - .build(); - optionsTargets.add("target3"); - assertEquals(sentimentOptions.document(), true); - assertEquals(sentimentOptions.targets(), optionsTargets); - sentimentOptions.newBuilder(); - } - - // --- METHODS --- - - /** - * Test analyze. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException - */ + public void testCreateCategoriesModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}"; + String createCategoriesModelPath = "/v1/models/categories"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateCategoriesModelOptions model + CreateCategoriesModelOptions createCategoriesModelOptionsModel = + new CreateCategoriesModelOptions.Builder() + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .build(); + + // Invoke createCategoriesModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .createCategoriesModel(createCategoriesModelOptionsModel) + .execute(); + assertNotNull(response); + CategoriesModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCategoriesModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createCategoriesModel operation with and without retries enabled @Test - public void testAnalyze() throws InterruptedException, FileNotFoundException { - String testHtmlFileName = RESOURCE + "testArticle.html"; - String html = getStringFromInputStream(new FileInputStream(testHtmlFileName)); - - ConceptsOptions concepts = new ConceptsOptions.Builder() - .limit(5) - .build(); - assertEquals(concepts.limit(), 5, 0); - concepts.newBuilder(); - - Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).build(); - - server.enqueue(jsonResponse(analyzeResults)); - final AnalysisResults response = service.analyze(parameters).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ANALYZE_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(analyzeResults, response); - assertNotNull(analyzeResults.getAnalyzedText()); - assertNotNull(analyzeResults.getSentiment()); - assertNotNull(analyzeResults.getLanguage()); - assertNotNull(analyzeResults.getEntities()); - assertNotNull(analyzeResults.getEmotion()); - assertNotNull(analyzeResults.getConcepts()); - assertNotNull(analyzeResults.getCategories()); - assertEquals(analyzeResults.getCategories().get(0).getExplanation().getRelevantText().get(0).getText(), - response.getCategories().get(0).getExplanation().getRelevantText().get(0).getText()); - assertNotNull(analyzeResults.getKeywords()); - assertNotNull(analyzeResults.getMetadata()); - assertNotNull(analyzeResults.getSemanticRoles()); - assertNotNull(analyzeResults.getRetrievedUrl()); - assertNotNull(analyzeResults.getRelations()); - assertNotNull(analyzeResults.getSyntax()); - assertNotNull(analyzeResults.getUsage()); - assertEquals(CONFIDENCE, analyzeResults.getEntities().get(0).getConfidence()); - assertEquals(TEXT, analyzeResults.getEntities().get(0).getMentions().get(0).getText()); - assertEquals(LOCATION, analyzeResults.getEntities().get(0).getMentions().get(0).getLocation().get(0)); - assertEquals(CONFIDENCE, analyzeResults.getEntities().get(0).getMentions().get(0).getConfidence()); - } - - /** - * Test analyze with null parameters. Test different constructor - * - * @throws InterruptedException the interrupted exception - */ + public void testCreateCategoriesModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testCreateCategoriesModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testCreateCategoriesModelWOptions(); + } + + // Test the createCategoriesModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCategoriesModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.createCategoriesModel(null).execute(); + } + + // Test the listCategoriesModels operation with a valid options model parameter @Test - public void testAnalyzeNullParams() throws InterruptedException { - server.enqueue(jsonResponse(analyzeResults)); - Features features = new Features.Builder().concepts(null).categories(null).emotion(null) - .entities(null).keywords(null).metadata(null).relations(null).semanticRoles(null).sentiment(null).build(); - AnalyzeOptions.Builder builder = new AnalyzeOptions.Builder().features(features); - final AnalysisResults response = service.analyze(builder.build()).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ANALYZE_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(analyzeResults, response); - } - - /** - * Test get models. - * - * @throws InterruptedException the interrupted exception - */ + public void testListCategoriesModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"models\": [{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}]}"; + String listCategoriesModelsPath = "/v1/models/categories"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListCategoriesModelsOptions model + ListCategoriesModelsOptions listCategoriesModelsOptionsModel = + new ListCategoriesModelsOptions(); + + // Invoke listCategoriesModels() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .listCategoriesModels(listCategoriesModelsOptionsModel) + .execute(); + assertNotNull(response); + CategoriesModelList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCategoriesModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listCategoriesModels operation with and without retries enabled @Test - public void testListModels() throws InterruptedException { - server.enqueue(jsonResponse(models)); - final ListModelsResults response = service.listModels().execute().getResult(); - final RecordedRequest request = server.takeRequest(); + public void testListCategoriesModelsWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testListCategoriesModelsWOptions(); - assertEquals(MODELS_PATH, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(models, response); + naturalLanguageUnderstandingService.disableRetries(); + testListCategoriesModelsWOptions(); } - /** - * Test delete model. - * - * @throws InterruptedException the interrupted exception - */ + // Test the getCategoriesModel operation with a valid options model parameter @Test - public void testDeleteModel() throws InterruptedException { - server.enqueue(jsonResponse(null)); - DeleteModelOptions deleteOptions = new DeleteModelOptions.Builder(modelId).build(); - service.deleteModel(deleteOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + public void testGetCategoriesModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}"; + String getCategoriesModelPath = "/v1/models/categories/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCategoriesModelOptions model + GetCategoriesModelOptions getCategoriesModelOptionsModel = + new GetCategoriesModelOptions.Builder().modelId("testString").build(); + + // Invoke getCategoriesModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .getCategoriesModel(getCategoriesModelOptionsModel) + .execute(); + assertNotNull(response); + CategoriesModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCategoriesModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } - assertEquals(DELETE_PATH, request.getPath()); - assertEquals("DELETE", request.getMethod()); + // Test the getCategoriesModel operation with and without retries enabled + @Test + public void testGetCategoriesModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testGetCategoriesModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testGetCategoriesModelWOptions(); } - // START NEGATIVE TESTS - /** - * Test delete model with a null model ID. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullModelId() { - service.deleteModel(null).execute(); + // Test the getCategoriesModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCategoriesModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.getCategoriesModel(null).execute(); } - /** - * Test constructor with null version. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullVersion() { - @SuppressWarnings("unused") - NaturalLanguageUnderstanding service2 = new NaturalLanguageUnderstanding(null, new NoAuthAuthenticator()); + // Test the updateCategoriesModel operation with a valid options model parameter + @Test + public void testUpdateCategoriesModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}"; + String updateCategoriesModelPath = "/v1/models/categories/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateCategoriesModelOptions model + UpdateCategoriesModelOptions updateCategoriesModelOptionsModel = + new UpdateCategoriesModelOptions.Builder() + .modelId("testString") + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .build(); + + // Invoke updateCategoriesModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .updateCategoriesModel(updateCategoriesModelOptionsModel) + .execute(); + assertNotNull(response); + CategoriesModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCategoriesModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateCategoriesModel operation with and without retries enabled + @Test + public void testUpdateCategoriesModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testUpdateCategoriesModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testUpdateCategoriesModelWOptions(); } + // Test the updateCategoriesModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCategoriesModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.updateCategoriesModel(null).execute(); + } + + // Test the deleteCategoriesModel operation with a valid options model parameter + @Test + public void testDeleteCategoriesModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"deleted\": \"deleted\"}"; + String deleteCategoriesModelPath = "/v1/models/categories/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteCategoriesModelOptions model + DeleteCategoriesModelOptions deleteCategoriesModelOptionsModel = + new DeleteCategoriesModelOptions.Builder().modelId("testString").build(); + + // Invoke deleteCategoriesModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .deleteCategoriesModel(deleteCategoriesModelOptionsModel) + .execute(); + assertNotNull(response); + DeleteModelResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCategoriesModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteCategoriesModel operation with and without retries enabled + @Test + public void testDeleteCategoriesModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testDeleteCategoriesModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testDeleteCategoriesModelWOptions(); + } + + // Test the deleteCategoriesModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCategoriesModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.deleteCategoriesModel(null).execute(); + } + + // Test the createClassificationsModel operation with a valid options model parameter + @Test + public void testCreateClassificationsModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}"; + String createClassificationsModelPath = "/v1/models/classifications"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the ClassificationsTrainingParameters model + ClassificationsTrainingParameters classificationsTrainingParametersModel = + new ClassificationsTrainingParameters.Builder().modelType("single_label").build(); + + // Construct an instance of the CreateClassificationsModelOptions model + CreateClassificationsModelOptions createClassificationsModelOptionsModel = + new CreateClassificationsModelOptions.Builder() + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .trainingParameters(classificationsTrainingParametersModel) + .build(); + + // Invoke createClassificationsModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .createClassificationsModel(createClassificationsModelOptionsModel) + .execute(); + assertNotNull(response); + ClassificationsModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createClassificationsModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the createClassificationsModel operation with and without retries enabled + @Test + public void testCreateClassificationsModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testCreateClassificationsModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testCreateClassificationsModelWOptions(); + } + + // Test the createClassificationsModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateClassificationsModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.createClassificationsModel(null).execute(); + } + + // Test the listClassificationsModels operation with a valid options model parameter + @Test + public void testListClassificationsModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"models\": [{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}]}"; + String listClassificationsModelsPath = "/v1/models/classifications"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListClassificationsModelsOptions model + ListClassificationsModelsOptions listClassificationsModelsOptionsModel = + new ListClassificationsModelsOptions(); + + // Invoke listClassificationsModels() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .listClassificationsModels(listClassificationsModelsOptionsModel) + .execute(); + assertNotNull(response); + ClassificationsModelList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listClassificationsModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the listClassificationsModels operation with and without retries enabled + @Test + public void testListClassificationsModelsWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testListClassificationsModelsWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testListClassificationsModelsWOptions(); + } + + // Test the getClassificationsModel operation with a valid options model parameter + @Test + public void testGetClassificationsModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}"; + String getClassificationsModelPath = "/v1/models/classifications/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetClassificationsModelOptions model + GetClassificationsModelOptions getClassificationsModelOptionsModel = + new GetClassificationsModelOptions.Builder().modelId("testString").build(); + + // Invoke getClassificationsModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .getClassificationsModel(getClassificationsModelOptionsModel) + .execute(); + assertNotNull(response); + ClassificationsModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getClassificationsModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the getClassificationsModel operation with and without retries enabled + @Test + public void testGetClassificationsModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testGetClassificationsModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testGetClassificationsModelWOptions(); + } + + // Test the getClassificationsModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetClassificationsModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.getClassificationsModel(null).execute(); + } + + // Test the updateClassificationsModel operation with a valid options model parameter + @Test + public void testUpdateClassificationsModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"user_metadata\": {\"anyKey\": \"anyValue\"}, \"language\": \"language\", \"description\": \"description\", \"model_version\": \"modelVersion\", \"workspace_id\": \"workspaceId\", \"version_description\": \"versionDescription\", \"features\": [\"features\"], \"status\": \"starting\", \"model_id\": \"modelId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"notices\": [{\"message\": \"message\"}], \"last_trained\": \"2019-01-01T12:00:00.000Z\", \"last_deployed\": \"2019-01-01T12:00:00.000Z\"}"; + String updateClassificationsModelPath = "/v1/models/classifications/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ClassificationsTrainingParameters model + ClassificationsTrainingParameters classificationsTrainingParametersModel = + new ClassificationsTrainingParameters.Builder().modelType("single_label").build(); + + // Construct an instance of the UpdateClassificationsModelOptions model + UpdateClassificationsModelOptions updateClassificationsModelOptionsModel = + new UpdateClassificationsModelOptions.Builder() + .modelId("testString") + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .trainingParameters(classificationsTrainingParametersModel) + .build(); + + // Invoke updateClassificationsModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .updateClassificationsModel(updateClassificationsModelOptionsModel) + .execute(); + assertNotNull(response); + ClassificationsModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateClassificationsModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the updateClassificationsModel operation with and without retries enabled + @Test + public void testUpdateClassificationsModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testUpdateClassificationsModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testUpdateClassificationsModelWOptions(); + } + + // Test the updateClassificationsModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateClassificationsModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.updateClassificationsModel(null).execute(); + } + + // Test the deleteClassificationsModel operation with a valid options model parameter + @Test + public void testDeleteClassificationsModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"deleted\": \"deleted\"}"; + String deleteClassificationsModelPath = "/v1/models/classifications/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteClassificationsModelOptions model + DeleteClassificationsModelOptions deleteClassificationsModelOptionsModel = + new DeleteClassificationsModelOptions.Builder().modelId("testString").build(); + + // Invoke deleteClassificationsModel() with a valid options model and verify the result + Response response = + naturalLanguageUnderstandingService + .deleteClassificationsModel(deleteClassificationsModelOptionsModel) + .execute(); + assertNotNull(response); + DeleteModelResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteClassificationsModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("version"), "testString"); + } + + // Test the deleteClassificationsModel operation with and without retries enabled + @Test + public void testDeleteClassificationsModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testDeleteClassificationsModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testDeleteClassificationsModelWOptions(); + } + + // Test the deleteClassificationsModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteClassificationsModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + naturalLanguageUnderstandingService.deleteClassificationsModel(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + naturalLanguageUnderstandingService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + naturalLanguageUnderstandingService = + new NaturalLanguageUnderstanding(version, serviceName, authenticator); + String url = server.url("/").toString(); + naturalLanguageUnderstandingService.setServiceUrl(url); + } } diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsTest.java new file mode 100644 index 00000000000..ece4305b442 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalysisResults model. */ +public class AnalysisResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalysisResults() throws Throwable { + AnalysisResults analysisResultsModel = new AnalysisResults(); + assertNull(analysisResultsModel.getLanguage()); + assertNull(analysisResultsModel.getAnalyzedText()); + assertNull(analysisResultsModel.getRetrievedUrl()); + assertNull(analysisResultsModel.getUsage()); + assertNull(analysisResultsModel.getConcepts()); + assertNull(analysisResultsModel.getEntities()); + assertNull(analysisResultsModel.getKeywords()); + assertNull(analysisResultsModel.getCategories()); + assertNull(analysisResultsModel.getClassifications()); + assertNull(analysisResultsModel.getEmotion()); + assertNull(analysisResultsModel.getMetadata()); + assertNull(analysisResultsModel.getRelations()); + assertNull(analysisResultsModel.getSemanticRoles()); + assertNull(analysisResultsModel.getSentiment()); + assertNull(analysisResultsModel.getSyntax()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsageTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsageTest.java new file mode 100644 index 00000000000..0e34bea13da --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsageTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalysisResultsUsage model. */ +public class AnalysisResultsUsageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalysisResultsUsage() throws Throwable { + AnalysisResultsUsage analysisResultsUsageModel = new AnalysisResultsUsage(); + assertNull(analysisResultsUsageModel.getFeatures()); + assertNull(analysisResultsUsageModel.getTextCharacters()); + assertNull(analysisResultsUsageModel.getTextUnits()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptionsTest.java new file mode 100644 index 00000000000..3708c87292f --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptionsTest.java @@ -0,0 +1,171 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzeOptions model. */ +public class AnalyzeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzeOptions() throws Throwable { + ClassificationsOptions classificationsOptionsModel = + new ClassificationsOptions.Builder().model("testString").build(); + assertEquals(classificationsOptionsModel.model(), "testString"); + + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("8")).build(); + assertEquals(conceptsOptionsModel.limit(), Long.valueOf("8")); + + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + assertEquals(emotionOptionsModel.document(), Boolean.valueOf(true)); + assertEquals(emotionOptionsModel.targets(), java.util.Arrays.asList("testString")); + + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("50")) + .mentions(false) + .model("testString") + .sentiment(false) + .emotion(false) + .build(); + assertEquals(entitiesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(entitiesOptionsModel.mentions(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModel.model(), "testString"); + assertEquals(entitiesOptionsModel.sentiment(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModel.emotion(), Boolean.valueOf(false)); + + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("50")) + .sentiment(false) + .emotion(false) + .build(); + assertEquals(keywordsOptionsModel.limit(), Long.valueOf("50")); + assertEquals(keywordsOptionsModel.sentiment(), Boolean.valueOf(false)); + assertEquals(keywordsOptionsModel.emotion(), Boolean.valueOf(false)); + + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + assertEquals(relationsOptionsModel.model(), "testString"); + + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("50")) + .keywords(false) + .entities(false) + .build(); + assertEquals(semanticRolesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(semanticRolesOptionsModel.keywords(), Boolean.valueOf(false)); + assertEquals(semanticRolesOptionsModel.entities(), Boolean.valueOf(false)); + + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + assertEquals(sentimentOptionsModel.document(), Boolean.valueOf(true)); + assertEquals(sentimentOptionsModel.targets(), java.util.Arrays.asList("testString")); + + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(false) + .limit(Long.valueOf("3")) + .model("testString") + .build(); + assertEquals(categoriesOptionsModel.explanation(), Boolean.valueOf(false)); + assertEquals(categoriesOptionsModel.limit(), Long.valueOf("3")); + assertEquals(categoriesOptionsModel.model(), "testString"); + + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + assertEquals(syntaxOptionsModel.tokens(), syntaxOptionsTokensModel); + assertEquals(syntaxOptionsModel.sentences(), Boolean.valueOf(true)); + + Features featuresModel = + new Features.Builder() + .classifications(classificationsOptionsModel) + .concepts(conceptsOptionsModel) + .emotion(emotionOptionsModel) + .entities(entitiesOptionsModel) + .keywords(keywordsOptionsModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .relations(relationsOptionsModel) + .semanticRoles(semanticRolesOptionsModel) + .sentiment(sentimentOptionsModel) + .categories(categoriesOptionsModel) + .syntax(syntaxOptionsModel) + .build(); + assertEquals(featuresModel.classifications(), classificationsOptionsModel); + assertEquals(featuresModel.concepts(), conceptsOptionsModel); + assertEquals(featuresModel.emotion(), emotionOptionsModel); + assertEquals(featuresModel.entities(), entitiesOptionsModel); + assertEquals(featuresModel.keywords(), keywordsOptionsModel); + assertEquals( + featuresModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(featuresModel.relations(), relationsOptionsModel); + assertEquals(featuresModel.semanticRoles(), semanticRolesOptionsModel); + assertEquals(featuresModel.sentiment(), sentimentOptionsModel); + assertEquals(featuresModel.categories(), categoriesOptionsModel); + assertEquals(featuresModel.syntax(), syntaxOptionsModel); + + AnalyzeOptions analyzeOptionsModel = + new AnalyzeOptions.Builder() + .features(featuresModel) + .text("testString") + .html("testString") + .url("testString") + .clean(true) + .xpath("testString") + .fallbackToRaw(true) + .returnAnalyzedText(false) + .language("testString") + .limitTextCharacters(Long.valueOf("26")) + .build(); + assertEquals(analyzeOptionsModel.features(), featuresModel); + assertEquals(analyzeOptionsModel.text(), "testString"); + assertEquals(analyzeOptionsModel.html(), "testString"); + assertEquals(analyzeOptionsModel.url(), "testString"); + assertEquals(analyzeOptionsModel.clean(), Boolean.valueOf(true)); + assertEquals(analyzeOptionsModel.xpath(), "testString"); + assertEquals(analyzeOptionsModel.fallbackToRaw(), Boolean.valueOf(true)); + assertEquals(analyzeOptionsModel.returnAnalyzedText(), Boolean.valueOf(false)); + assertEquals(analyzeOptionsModel.language(), "testString"); + assertEquals(analyzeOptionsModel.limitTextCharacters(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeOptionsError() throws Throwable { + new AnalyzeOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AuthorTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AuthorTest.java new file mode 100644 index 00000000000..b0668933976 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AuthorTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Author model. */ +public class AuthorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAuthor() throws Throwable { + Author authorModel = new Author(); + assertNull(authorModel.getName()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelListTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelListTest.java new file mode 100644 index 00000000000..27ebfae8339 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesModelList model. */ +public class CategoriesModelListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesModelList() throws Throwable { + CategoriesModelList categoriesModelListModel = new CategoriesModelList(); + assertNull(categoriesModelListModel.getModels()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelTest.java new file mode 100644 index 00000000000..3bc4798f87c --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesModel model. */ +public class CategoriesModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesModel() throws Throwable { + CategoriesModel categoriesModelModel = new CategoriesModel(); + assertNull(categoriesModelModel.getName()); + assertNull(categoriesModelModel.getUserMetadata()); + assertNull(categoriesModelModel.getLanguage()); + assertNull(categoriesModelModel.getDescription()); + assertNull(categoriesModelModel.getModelVersion()); + assertNull(categoriesModelModel.getWorkspaceId()); + assertNull(categoriesModelModel.getVersionDescription()); + assertNull(categoriesModelModel.getFeatures()); + assertNull(categoriesModelModel.getStatus()); + assertNull(categoriesModelModel.getModelId()); + assertNull(categoriesModelModel.getCreated()); + assertNull(categoriesModelModel.getNotices()); + assertNull(categoriesModelModel.getLastTrained()); + assertNull(categoriesModelModel.getLastDeployed()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptionsTest.java new file mode 100644 index 00000000000..72ce2d3fe87 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesOptions model. */ +public class CategoriesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesOptions() throws Throwable { + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(false) + .limit(Long.valueOf("3")) + .model("testString") + .build(); + assertEquals(categoriesOptionsModel.explanation(), Boolean.valueOf(false)); + assertEquals(categoriesOptionsModel.limit(), Long.valueOf("3")); + assertEquals(categoriesOptionsModel.model(), "testString"); + + String json = TestUtilities.serialize(categoriesOptionsModel); + + CategoriesOptions categoriesOptionsModelNew = + TestUtilities.deserialize(json, CategoriesOptions.class); + assertTrue(categoriesOptionsModelNew instanceof CategoriesOptions); + assertEquals(categoriesOptionsModelNew.explanation(), Boolean.valueOf(false)); + assertEquals(categoriesOptionsModelNew.limit(), Long.valueOf("3")); + assertEquals(categoriesOptionsModelNew.model(), "testString"); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantTextTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantTextTest.java new file mode 100644 index 00000000000..3e542b1d268 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantTextTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesRelevantText model. */ +public class CategoriesRelevantTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesRelevantText() throws Throwable { + CategoriesRelevantText categoriesRelevantTextModel = new CategoriesRelevantText(); + assertNull(categoriesRelevantTextModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanationTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanationTest.java new file mode 100644 index 00000000000..d55a62512dc --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesResultExplanation model. */ +public class CategoriesResultExplanationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesResultExplanation() throws Throwable { + CategoriesResultExplanation categoriesResultExplanationModel = + new CategoriesResultExplanation(); + assertNull(categoriesResultExplanationModel.getRelevantText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultTest.java new file mode 100644 index 00000000000..d350d6266cc --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesResult model. */ +public class CategoriesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesResult() throws Throwable { + CategoriesResult categoriesResultModel = new CategoriesResult(); + assertNull(categoriesResultModel.getLabel()); + assertNull(categoriesResultModel.getScore()); + assertNull(categoriesResultModel.getExplanation()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelListTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelListTest.java new file mode 100644 index 00000000000..156fff73d9f --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassificationsModelList model. */ +public class ClassificationsModelListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassificationsModelList() throws Throwable { + ClassificationsModelList classificationsModelListModel = new ClassificationsModelList(); + assertNull(classificationsModelListModel.getModels()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelTest.java new file mode 100644 index 00000000000..16e3bf8e058 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsModelTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassificationsModel model. */ +public class ClassificationsModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassificationsModel() throws Throwable { + ClassificationsModel classificationsModelModel = new ClassificationsModel(); + assertNull(classificationsModelModel.getName()); + assertNull(classificationsModelModel.getUserMetadata()); + assertNull(classificationsModelModel.getLanguage()); + assertNull(classificationsModelModel.getDescription()); + assertNull(classificationsModelModel.getModelVersion()); + assertNull(classificationsModelModel.getWorkspaceId()); + assertNull(classificationsModelModel.getVersionDescription()); + assertNull(classificationsModelModel.getFeatures()); + assertNull(classificationsModelModel.getStatus()); + assertNull(classificationsModelModel.getModelId()); + assertNull(classificationsModelModel.getCreated()); + assertNull(classificationsModelModel.getNotices()); + assertNull(classificationsModelModel.getLastTrained()); + assertNull(classificationsModelModel.getLastDeployed()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsOptionsTest.java new file mode 100644 index 00000000000..9a9b1017d33 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsOptionsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassificationsOptions model. */ +public class ClassificationsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassificationsOptions() throws Throwable { + ClassificationsOptions classificationsOptionsModel = + new ClassificationsOptions.Builder().model("testString").build(); + assertEquals(classificationsOptionsModel.model(), "testString"); + + String json = TestUtilities.serialize(classificationsOptionsModel); + + ClassificationsOptions classificationsOptionsModelNew = + TestUtilities.deserialize(json, ClassificationsOptions.class); + assertTrue(classificationsOptionsModelNew instanceof ClassificationsOptions); + assertEquals(classificationsOptionsModelNew.model(), "testString"); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsResultTest.java new file mode 100644 index 00000000000..f2996af1daa --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassificationsResult model. */ +public class ClassificationsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassificationsResult() throws Throwable { + ClassificationsResult classificationsResultModel = new ClassificationsResult(); + assertNull(classificationsResultModel.getClassName()); + assertNull(classificationsResultModel.getConfidence()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsTrainingParametersTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsTrainingParametersTest.java new file mode 100644 index 00000000000..1d0b7531c8f --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ClassificationsTrainingParametersTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2022. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassificationsTrainingParameters model. */ +public class ClassificationsTrainingParametersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassificationsTrainingParameters() throws Throwable { + ClassificationsTrainingParameters classificationsTrainingParametersModel = + new ClassificationsTrainingParameters.Builder().modelType("single_label").build(); + assertEquals(classificationsTrainingParametersModel.modelType(), "single_label"); + + String json = TestUtilities.serialize(classificationsTrainingParametersModel); + + ClassificationsTrainingParameters classificationsTrainingParametersModelNew = + TestUtilities.deserialize(json, ClassificationsTrainingParameters.class); + assertTrue( + classificationsTrainingParametersModelNew instanceof ClassificationsTrainingParameters); + assertEquals(classificationsTrainingParametersModelNew.modelType(), "single_label"); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptionsTest.java new file mode 100644 index 00000000000..732758a8b12 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptionsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ConceptsOptions model. */ +public class ConceptsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConceptsOptions() throws Throwable { + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("8")).build(); + assertEquals(conceptsOptionsModel.limit(), Long.valueOf("8")); + + String json = TestUtilities.serialize(conceptsOptionsModel); + + ConceptsOptions conceptsOptionsModelNew = + TestUtilities.deserialize(json, ConceptsOptions.class); + assertTrue(conceptsOptionsModelNew instanceof ConceptsOptions); + assertEquals(conceptsOptionsModelNew.limit(), Long.valueOf("8")); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResultTest.java new file mode 100644 index 00000000000..41c21212f97 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ConceptsResult model. */ +public class ConceptsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConceptsResult() throws Throwable { + ConceptsResult conceptsResultModel = new ConceptsResult(); + assertNull(conceptsResultModel.getText()); + assertNull(conceptsResultModel.getRelevance()); + assertNull(conceptsResultModel.getDbpediaResource()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateCategoriesModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateCategoriesModelOptionsTest.java new file mode 100644 index 00000000000..0910ef2c5bd --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateCategoriesModelOptionsTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCategoriesModelOptions model. */ +public class CreateCategoriesModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCategoriesModelOptions() throws Throwable { + CreateCategoriesModelOptions createCategoriesModelOptionsModel = + new CreateCategoriesModelOptions.Builder() + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .build(); + assertEquals(createCategoriesModelOptionsModel.language(), "testString"); + assertEquals( + IOUtils.toString(createCategoriesModelOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createCategoriesModelOptionsModel.trainingDataContentType(), "json"); + assertEquals(createCategoriesModelOptionsModel.name(), "testString"); + assertEquals( + createCategoriesModelOptionsModel.userMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createCategoriesModelOptionsModel.description(), "testString"); + assertEquals(createCategoriesModelOptionsModel.modelVersion(), "testString"); + assertEquals(createCategoriesModelOptionsModel.workspaceId(), "testString"); + assertEquals(createCategoriesModelOptionsModel.versionDescription(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCategoriesModelOptionsError() throws Throwable { + new CreateCategoriesModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateClassificationsModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateClassificationsModelOptionsTest.java new file mode 100644 index 00000000000..ea1a0e8da16 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateClassificationsModelOptionsTest.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateClassificationsModelOptions model. */ +public class CreateClassificationsModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateClassificationsModelOptions() throws Throwable { + ClassificationsTrainingParameters classificationsTrainingParametersModel = + new ClassificationsTrainingParameters.Builder().modelType("single_label").build(); + assertEquals(classificationsTrainingParametersModel.modelType(), "single_label"); + + CreateClassificationsModelOptions createClassificationsModelOptionsModel = + new CreateClassificationsModelOptions.Builder() + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .trainingParameters(classificationsTrainingParametersModel) + .build(); + assertEquals(createClassificationsModelOptionsModel.language(), "testString"); + assertEquals( + IOUtils.toString(createClassificationsModelOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createClassificationsModelOptionsModel.trainingDataContentType(), "json"); + assertEquals(createClassificationsModelOptionsModel.name(), "testString"); + assertEquals( + createClassificationsModelOptionsModel.userMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(createClassificationsModelOptionsModel.description(), "testString"); + assertEquals(createClassificationsModelOptionsModel.modelVersion(), "testString"); + assertEquals(createClassificationsModelOptionsModel.workspaceId(), "testString"); + assertEquals(createClassificationsModelOptionsModel.versionDescription(), "testString"); + assertEquals( + createClassificationsModelOptionsModel.trainingParameters(), + classificationsTrainingParametersModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateClassificationsModelOptionsError() throws Throwable { + new CreateClassificationsModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateSentimentModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateSentimentModelOptionsTest.java new file mode 100644 index 00000000000..02023ebccb2 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CreateSentimentModelOptionsTest.java @@ -0,0 +1,72 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateSentimentModelOptions model. */ +public class CreateSentimentModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateSentimentModelOptions() throws Throwable { + CreateSentimentModelOptions createSentimentModelOptionsModel = + new CreateSentimentModelOptions.Builder() + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .name("testString") + .userMetadata( + new java.util.HashMap() { + { + put("foo", TestUtilities.createMockMap()); + } + }) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .build(); + assertEquals(createSentimentModelOptionsModel.language(), "testString"); + assertEquals( + IOUtils.toString(createSentimentModelOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createSentimentModelOptionsModel.name(), "testString"); + assertEquals( + createSentimentModelOptionsModel.userMetadata(), + new java.util.HashMap() { + { + put("foo", TestUtilities.createMockMap()); + } + }); + assertEquals(createSentimentModelOptionsModel.description(), "testString"); + assertEquals(createSentimentModelOptionsModel.modelVersion(), "testString"); + assertEquals(createSentimentModelOptionsModel.workspaceId(), "testString"); + assertEquals(createSentimentModelOptionsModel.versionDescription(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSentimentModelOptionsError() throws Throwable { + new CreateSentimentModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteCategoriesModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteCategoriesModelOptionsTest.java new file mode 100644 index 00000000000..050b8ea0fca --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteCategoriesModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCategoriesModelOptions model. */ +public class DeleteCategoriesModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCategoriesModelOptions() throws Throwable { + DeleteCategoriesModelOptions deleteCategoriesModelOptionsModel = + new DeleteCategoriesModelOptions.Builder().modelId("testString").build(); + assertEquals(deleteCategoriesModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCategoriesModelOptionsError() throws Throwable { + new DeleteCategoriesModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteClassificationsModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteClassificationsModelOptionsTest.java new file mode 100644 index 00000000000..fcd1aac630d --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteClassificationsModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteClassificationsModelOptions model. */ +public class DeleteClassificationsModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteClassificationsModelOptions() throws Throwable { + DeleteClassificationsModelOptions deleteClassificationsModelOptionsModel = + new DeleteClassificationsModelOptions.Builder().modelId("testString").build(); + assertEquals(deleteClassificationsModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteClassificationsModelOptionsError() throws Throwable { + new DeleteClassificationsModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptionsTest.java new file mode 100644 index 00000000000..df4e3794e78 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteModelOptions model. */ +public class DeleteModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteModelOptions() throws Throwable { + DeleteModelOptions deleteModelOptionsModel = + new DeleteModelOptions.Builder().modelId("testString").build(); + assertEquals(deleteModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteModelOptionsError() throws Throwable { + new DeleteModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResultsTest.java new file mode 100644 index 00000000000..3e3d435e03a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteModelResults model. */ +public class DeleteModelResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteModelResults() throws Throwable { + DeleteModelResults deleteModelResultsModel = new DeleteModelResults(); + assertNull(deleteModelResultsModel.getDeleted()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteSentimentModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteSentimentModelOptionsTest.java new file mode 100644 index 00000000000..48297f44c0e --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteSentimentModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteSentimentModelOptions model. */ +public class DeleteSentimentModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteSentimentModelOptions() throws Throwable { + DeleteSentimentModelOptions deleteSentimentModelOptionsModel = + new DeleteSentimentModelOptions.Builder().modelId("testString").build(); + assertEquals(deleteSentimentModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSentimentModelOptionsError() throws Throwable { + new DeleteSentimentModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResultTest.java new file mode 100644 index 00000000000..a8a47294c27 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DisambiguationResult model. */ +public class DisambiguationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDisambiguationResult() throws Throwable { + DisambiguationResult disambiguationResultModel = new DisambiguationResult(); + assertNull(disambiguationResultModel.getName()); + assertNull(disambiguationResultModel.getDbpediaResource()); + assertNull(disambiguationResultModel.getSubtype()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResultsTest.java new file mode 100644 index 00000000000..32f8462b706 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentEmotionResults model. */ +public class DocumentEmotionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentEmotionResults() throws Throwable { + DocumentEmotionResults documentEmotionResultsModel = new DocumentEmotionResults(); + assertNull(documentEmotionResultsModel.getEmotion()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResultsTest.java new file mode 100644 index 00000000000..1d8b54b398a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentSentimentResults model. */ +public class DocumentSentimentResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentSentimentResults() throws Throwable { + DocumentSentimentResults documentSentimentResultsModel = new DocumentSentimentResults(); + assertNull(documentSentimentResultsModel.getLabel()); + assertNull(documentSentimentResultsModel.getScore()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptionsTest.java new file mode 100644 index 00000000000..399bb10fc39 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EmotionOptions model. */ +public class EmotionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEmotionOptions() throws Throwable { + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + assertEquals(emotionOptionsModel.document(), Boolean.valueOf(true)); + assertEquals(emotionOptionsModel.targets(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(emotionOptionsModel); + + EmotionOptions emotionOptionsModelNew = TestUtilities.deserialize(json, EmotionOptions.class); + assertTrue(emotionOptionsModelNew instanceof EmotionOptions); + assertEquals(emotionOptionsModelNew.document(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResultTest.java new file mode 100644 index 00000000000..4dc0db2a8ed --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EmotionResult model. */ +public class EmotionResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEmotionResult() throws Throwable { + EmotionResult emotionResultModel = new EmotionResult(); + assertNull(emotionResultModel.getDocument()); + assertNull(emotionResultModel.getTargets()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScoresTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScoresTest.java new file mode 100644 index 00000000000..f1180be6a4a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScoresTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EmotionScores model. */ +public class EmotionScoresTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEmotionScores() throws Throwable { + EmotionScores emotionScoresModel = new EmotionScores(); + assertNull(emotionScoresModel.getAnger()); + assertNull(emotionScoresModel.getDisgust()); + assertNull(emotionScoresModel.getFear()); + assertNull(emotionScoresModel.getJoy()); + assertNull(emotionScoresModel.getSadness()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptionsTest.java new file mode 100644 index 00000000000..ed85bce9f71 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntitiesOptions model. */ +public class EntitiesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntitiesOptions() throws Throwable { + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("50")) + .mentions(false) + .model("testString") + .sentiment(false) + .emotion(false) + .build(); + assertEquals(entitiesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(entitiesOptionsModel.mentions(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModel.model(), "testString"); + assertEquals(entitiesOptionsModel.sentiment(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModel.emotion(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(entitiesOptionsModel); + + EntitiesOptions entitiesOptionsModelNew = + TestUtilities.deserialize(json, EntitiesOptions.class); + assertTrue(entitiesOptionsModelNew instanceof EntitiesOptions); + assertEquals(entitiesOptionsModelNew.limit(), Long.valueOf("50")); + assertEquals(entitiesOptionsModelNew.mentions(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModelNew.model(), "testString"); + assertEquals(entitiesOptionsModelNew.sentiment(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModelNew.emotion(), Boolean.valueOf(false)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResultTest.java new file mode 100644 index 00000000000..d053d5287eb --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResultTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntitiesResult model. */ +public class EntitiesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntitiesResult() throws Throwable { + EntitiesResult entitiesResultModel = new EntitiesResult(); + assertNull(entitiesResultModel.getType()); + assertNull(entitiesResultModel.getText()); + assertNull(entitiesResultModel.getRelevance()); + assertNull(entitiesResultModel.getConfidence()); + assertNull(entitiesResultModel.getMentions()); + assertNull(entitiesResultModel.getCount()); + assertNull(entitiesResultModel.getEmotion()); + assertNull(entitiesResultModel.getSentiment()); + assertNull(entitiesResultModel.getDisambiguation()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMentionTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMentionTest.java new file mode 100644 index 00000000000..9ad823e5198 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMentionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityMention model. */ +public class EntityMentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityMention() throws Throwable { + EntityMention entityMentionModel = new EntityMention(); + assertNull(entityMentionModel.getText()); + assertNull(entityMentionModel.getLocation()); + assertNull(entityMentionModel.getConfidence()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResultsTest.java new file mode 100644 index 00000000000..bf1747f6a6a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeatureSentimentResults model. */ +public class FeatureSentimentResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeatureSentimentResults() throws Throwable { + FeatureSentimentResults featureSentimentResultsModel = new FeatureSentimentResults(); + assertNull(featureSentimentResultsModel.getScore()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadataTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadataTest.java new file mode 100644 index 00000000000..79ba1f9d0a8 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadataTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeaturesResultsMetadata model. */ +public class FeaturesResultsMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeaturesResultsMetadata() throws Throwable { + FeaturesResultsMetadata featuresResultsMetadataModel = new FeaturesResultsMetadata(); + assertNull(featuresResultsMetadataModel.getAuthors()); + assertNull(featuresResultsMetadataModel.getPublicationDate()); + assertNull(featuresResultsMetadataModel.getTitle()); + assertNull(featuresResultsMetadataModel.getImage()); + assertNull(featuresResultsMetadataModel.getFeeds()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesTest.java new file mode 100644 index 00000000000..5b94606e018 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesTest.java @@ -0,0 +1,161 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Features model. */ +public class FeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeatures() throws Throwable { + ClassificationsOptions classificationsOptionsModel = + new ClassificationsOptions.Builder().model("testString").build(); + assertEquals(classificationsOptionsModel.model(), "testString"); + + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("8")).build(); + assertEquals(conceptsOptionsModel.limit(), Long.valueOf("8")); + + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + assertEquals(emotionOptionsModel.document(), Boolean.valueOf(true)); + assertEquals(emotionOptionsModel.targets(), java.util.Arrays.asList("testString")); + + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("50")) + .mentions(false) + .model("testString") + .sentiment(false) + .emotion(false) + .build(); + assertEquals(entitiesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(entitiesOptionsModel.mentions(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModel.model(), "testString"); + assertEquals(entitiesOptionsModel.sentiment(), Boolean.valueOf(false)); + assertEquals(entitiesOptionsModel.emotion(), Boolean.valueOf(false)); + + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("50")) + .sentiment(false) + .emotion(false) + .build(); + assertEquals(keywordsOptionsModel.limit(), Long.valueOf("50")); + assertEquals(keywordsOptionsModel.sentiment(), Boolean.valueOf(false)); + assertEquals(keywordsOptionsModel.emotion(), Boolean.valueOf(false)); + + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + assertEquals(relationsOptionsModel.model(), "testString"); + + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("50")) + .keywords(false) + .entities(false) + .build(); + assertEquals(semanticRolesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(semanticRolesOptionsModel.keywords(), Boolean.valueOf(false)); + assertEquals(semanticRolesOptionsModel.entities(), Boolean.valueOf(false)); + + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + assertEquals(sentimentOptionsModel.document(), Boolean.valueOf(true)); + assertEquals(sentimentOptionsModel.targets(), java.util.Arrays.asList("testString")); + + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(false) + .limit(Long.valueOf("3")) + .model("testString") + .build(); + assertEquals(categoriesOptionsModel.explanation(), Boolean.valueOf(false)); + assertEquals(categoriesOptionsModel.limit(), Long.valueOf("3")); + assertEquals(categoriesOptionsModel.model(), "testString"); + + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + assertEquals(syntaxOptionsModel.tokens(), syntaxOptionsTokensModel); + assertEquals(syntaxOptionsModel.sentences(), Boolean.valueOf(true)); + + Features featuresModel = + new Features.Builder() + .classifications(classificationsOptionsModel) + .concepts(conceptsOptionsModel) + .emotion(emotionOptionsModel) + .entities(entitiesOptionsModel) + .keywords(keywordsOptionsModel) + .metadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .relations(relationsOptionsModel) + .semanticRoles(semanticRolesOptionsModel) + .sentiment(sentimentOptionsModel) + .categories(categoriesOptionsModel) + .syntax(syntaxOptionsModel) + .build(); + assertEquals(featuresModel.classifications(), classificationsOptionsModel); + assertEquals(featuresModel.concepts(), conceptsOptionsModel); + assertEquals(featuresModel.emotion(), emotionOptionsModel); + assertEquals(featuresModel.entities(), entitiesOptionsModel); + assertEquals(featuresModel.keywords(), keywordsOptionsModel); + assertEquals( + featuresModel.metadata(), java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(featuresModel.relations(), relationsOptionsModel); + assertEquals(featuresModel.semanticRoles(), semanticRolesOptionsModel); + assertEquals(featuresModel.sentiment(), sentimentOptionsModel); + assertEquals(featuresModel.categories(), categoriesOptionsModel); + assertEquals(featuresModel.syntax(), syntaxOptionsModel); + + String json = TestUtilities.serialize(featuresModel); + + Features featuresModelNew = TestUtilities.deserialize(json, Features.class); + assertTrue(featuresModelNew instanceof Features); + assertEquals( + featuresModelNew.classifications().toString(), classificationsOptionsModel.toString()); + assertEquals(featuresModelNew.concepts().toString(), conceptsOptionsModel.toString()); + assertEquals(featuresModelNew.emotion().toString(), emotionOptionsModel.toString()); + assertEquals(featuresModelNew.entities().toString(), entitiesOptionsModel.toString()); + assertEquals(featuresModelNew.keywords().toString(), keywordsOptionsModel.toString()); + assertEquals( + featuresModelNew.metadata().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals(featuresModelNew.relations().toString(), relationsOptionsModel.toString()); + assertEquals(featuresModelNew.semanticRoles().toString(), semanticRolesOptionsModel.toString()); + assertEquals(featuresModelNew.sentiment().toString(), sentimentOptionsModel.toString()); + assertEquals(featuresModelNew.categories().toString(), categoriesOptionsModel.toString()); + assertEquals(featuresModelNew.syntax().toString(), syntaxOptionsModel.toString()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeedTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeedTest.java new file mode 100644 index 00000000000..ea02d2ae9fb --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeedTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Feed model. */ +public class FeedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeed() throws Throwable { + Feed feedModel = new Feed(); + assertNull(feedModel.getLink()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetCategoriesModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetCategoriesModelOptionsTest.java new file mode 100644 index 00000000000..b3cd9329aca --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetCategoriesModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCategoriesModelOptions model. */ +public class GetCategoriesModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCategoriesModelOptions() throws Throwable { + GetCategoriesModelOptions getCategoriesModelOptionsModel = + new GetCategoriesModelOptions.Builder().modelId("testString").build(); + assertEquals(getCategoriesModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCategoriesModelOptionsError() throws Throwable { + new GetCategoriesModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetClassificationsModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetClassificationsModelOptionsTest.java new file mode 100644 index 00000000000..37113d300ab --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetClassificationsModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetClassificationsModelOptions model. */ +public class GetClassificationsModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetClassificationsModelOptions() throws Throwable { + GetClassificationsModelOptions getClassificationsModelOptionsModel = + new GetClassificationsModelOptions.Builder().modelId("testString").build(); + assertEquals(getClassificationsModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetClassificationsModelOptionsError() throws Throwable { + new GetClassificationsModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetSentimentModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetSentimentModelOptionsTest.java new file mode 100644 index 00000000000..ee5e4866c29 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/GetSentimentModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetSentimentModelOptions model. */ +public class GetSentimentModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetSentimentModelOptions() throws Throwable { + GetSentimentModelOptions getSentimentModelOptionsModel = + new GetSentimentModelOptions.Builder().modelId("testString").build(); + assertEquals(getSentimentModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSentimentModelOptionsError() throws Throwable { + new GetSentimentModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptionsTest.java new file mode 100644 index 00000000000..34e8403a9ba --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeywordsOptions model. */ +public class KeywordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeywordsOptions() throws Throwable { + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("50")) + .sentiment(false) + .emotion(false) + .build(); + assertEquals(keywordsOptionsModel.limit(), Long.valueOf("50")); + assertEquals(keywordsOptionsModel.sentiment(), Boolean.valueOf(false)); + assertEquals(keywordsOptionsModel.emotion(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(keywordsOptionsModel); + + KeywordsOptions keywordsOptionsModelNew = + TestUtilities.deserialize(json, KeywordsOptions.class); + assertTrue(keywordsOptionsModelNew instanceof KeywordsOptions); + assertEquals(keywordsOptionsModelNew.limit(), Long.valueOf("50")); + assertEquals(keywordsOptionsModelNew.sentiment(), Boolean.valueOf(false)); + assertEquals(keywordsOptionsModelNew.emotion(), Boolean.valueOf(false)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResultTest.java new file mode 100644 index 00000000000..3899b45b881 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeywordsResult model. */ +public class KeywordsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeywordsResult() throws Throwable { + KeywordsResult keywordsResultModel = new KeywordsResult(); + assertNull(keywordsResultModel.getCount()); + assertNull(keywordsResultModel.getRelevance()); + assertNull(keywordsResultModel.getText()); + assertNull(keywordsResultModel.getEmotion()); + assertNull(keywordsResultModel.getSentiment()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListCategoriesModelsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListCategoriesModelsOptionsTest.java new file mode 100644 index 00000000000..2479fed3c9a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListCategoriesModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCategoriesModelsOptions model. */ +public class ListCategoriesModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCategoriesModelsOptions() throws Throwable { + ListCategoriesModelsOptions listCategoriesModelsOptionsModel = + new ListCategoriesModelsOptions(); + assertNotNull(listCategoriesModelsOptionsModel); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListClassificationsModelsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListClassificationsModelsOptionsTest.java new file mode 100644 index 00000000000..cc803a55106 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListClassificationsModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListClassificationsModelsOptions model. */ +public class ListClassificationsModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListClassificationsModelsOptions() throws Throwable { + ListClassificationsModelsOptions listClassificationsModelsOptionsModel = + new ListClassificationsModelsOptions(); + assertNotNull(listClassificationsModelsOptionsModel); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptionsTest.java new file mode 100644 index 00000000000..0707152c1bb --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsOptions model. */ +public class ListModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsOptions() throws Throwable { + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + assertNotNull(listModelsOptionsModel); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResultsTest.java new file mode 100644 index 00000000000..48ccae4ed6b --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsResults model. */ +public class ListModelsResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsResults() throws Throwable { + ListModelsResults listModelsResultsModel = new ListModelsResults(); + assertNull(listModelsResultsModel.getModels()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListSentimentModelsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListSentimentModelsOptionsTest.java new file mode 100644 index 00000000000..e8337354387 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListSentimentModelsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListSentimentModelsOptions model. */ +public class ListSentimentModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListSentimentModelsOptions() throws Throwable { + ListSentimentModelsOptions listSentimentModelsOptionsModel = new ListSentimentModelsOptions(); + assertNotNull(listSentimentModelsOptionsModel); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ModelTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ModelTest.java new file mode 100644 index 00000000000..11056cba484 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ModelTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Model model. */ +public class ModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testModel() throws Throwable { + Model modelModel = new Model(); + assertNull(modelModel.getStatus()); + assertNull(modelModel.getModelId()); + assertNull(modelModel.getLanguage()); + assertNull(modelModel.getDescription()); + assertNull(modelModel.getWorkspaceId()); + assertNull(modelModel.getModelVersion()); + assertNull(modelModel.getVersion()); + assertNull(modelModel.getVersionDescription()); + assertNull(modelModel.getCreated()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/NoticeTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/NoticeTest.java new file mode 100644 index 00000000000..42d06bbbe30 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/NoticeTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Notice model. */ +public class NoticeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNotice() throws Throwable { + Notice noticeModel = new Notice(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgumentTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgumentTest.java new file mode 100644 index 00000000000..82bb46bfc7f --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgumentTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationArgument model. */ +public class RelationArgumentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationArgument() throws Throwable { + RelationArgument relationArgumentModel = new RelationArgument(); + assertNull(relationArgumentModel.getEntities()); + assertNull(relationArgumentModel.getLocation()); + assertNull(relationArgumentModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntityTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntityTest.java new file mode 100644 index 00000000000..0c18a71f2b1 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntityTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationEntity model. */ +public class RelationEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationEntity() throws Throwable { + RelationEntity relationEntityModel = new RelationEntity(); + assertNull(relationEntityModel.getText()); + assertNull(relationEntityModel.getType()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptionsTest.java new file mode 100644 index 00000000000..7c85ef01f17 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptionsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationsOptions model. */ +public class RelationsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationsOptions() throws Throwable { + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + assertEquals(relationsOptionsModel.model(), "testString"); + + String json = TestUtilities.serialize(relationsOptionsModel); + + RelationsOptions relationsOptionsModelNew = + TestUtilities.deserialize(json, RelationsOptions.class); + assertTrue(relationsOptionsModelNew instanceof RelationsOptions); + assertEquals(relationsOptionsModelNew.model(), "testString"); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResultTest.java new file mode 100644 index 00000000000..a0143a69ac2 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationsResult model. */ +public class RelationsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationsResult() throws Throwable { + RelationsResult relationsResultModel = new RelationsResult(); + assertNull(relationsResultModel.getScore()); + assertNull(relationsResultModel.getSentence()); + assertNull(relationsResultModel.getType()); + assertNull(relationsResultModel.getArguments()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntityTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntityTest.java new file mode 100644 index 00000000000..27406bafbef --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntityTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesEntity model. */ +public class SemanticRolesEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesEntity() throws Throwable { + SemanticRolesEntity semanticRolesEntityModel = new SemanticRolesEntity(); + assertNull(semanticRolesEntityModel.getType()); + assertNull(semanticRolesEntityModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeywordTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeywordTest.java new file mode 100644 index 00000000000..c39e95bfaad --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeywordTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesKeyword model. */ +public class SemanticRolesKeywordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesKeyword() throws Throwable { + SemanticRolesKeyword semanticRolesKeywordModel = new SemanticRolesKeyword(); + assertNull(semanticRolesKeywordModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptionsTest.java new file mode 100644 index 00000000000..50ca3d388dd --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesOptions model. */ +public class SemanticRolesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesOptions() throws Throwable { + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("50")) + .keywords(false) + .entities(false) + .build(); + assertEquals(semanticRolesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(semanticRolesOptionsModel.keywords(), Boolean.valueOf(false)); + assertEquals(semanticRolesOptionsModel.entities(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(semanticRolesOptionsModel); + + SemanticRolesOptions semanticRolesOptionsModelNew = + TestUtilities.deserialize(json, SemanticRolesOptions.class); + assertTrue(semanticRolesOptionsModelNew instanceof SemanticRolesOptions); + assertEquals(semanticRolesOptionsModelNew.limit(), Long.valueOf("50")); + assertEquals(semanticRolesOptionsModelNew.keywords(), Boolean.valueOf(false)); + assertEquals(semanticRolesOptionsModelNew.entities(), Boolean.valueOf(false)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultActionTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultActionTest.java new file mode 100644 index 00000000000..7251c800c75 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultActionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResultAction model. */ +public class SemanticRolesResultActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResultAction() throws Throwable { + SemanticRolesResultAction semanticRolesResultActionModel = new SemanticRolesResultAction(); + assertNull(semanticRolesResultActionModel.getText()); + assertNull(semanticRolesResultActionModel.getNormalized()); + assertNull(semanticRolesResultActionModel.getVerb()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObjectTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObjectTest.java new file mode 100644 index 00000000000..2672ffa9ce7 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObjectTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResultObject model. */ +public class SemanticRolesResultObjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResultObject() throws Throwable { + SemanticRolesResultObject semanticRolesResultObjectModel = new SemanticRolesResultObject(); + assertNull(semanticRolesResultObjectModel.getText()); + assertNull(semanticRolesResultObjectModel.getKeywords()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubjectTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubjectTest.java new file mode 100644 index 00000000000..591935ca64b --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubjectTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResultSubject model. */ +public class SemanticRolesResultSubjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResultSubject() throws Throwable { + SemanticRolesResultSubject semanticRolesResultSubjectModel = new SemanticRolesResultSubject(); + assertNull(semanticRolesResultSubjectModel.getText()); + assertNull(semanticRolesResultSubjectModel.getEntities()); + assertNull(semanticRolesResultSubjectModel.getKeywords()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultTest.java new file mode 100644 index 00000000000..0457a495199 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResult model. */ +public class SemanticRolesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResult() throws Throwable { + SemanticRolesResult semanticRolesResultModel = new SemanticRolesResult(); + assertNull(semanticRolesResultModel.getSentence()); + assertNull(semanticRolesResultModel.getSubject()); + assertNull(semanticRolesResultModel.getAction()); + assertNull(semanticRolesResultModel.getObject()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerbTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerbTest.java new file mode 100644 index 00000000000..07ba0ab35ff --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerbTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesVerb model. */ +public class SemanticRolesVerbTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesVerb() throws Throwable { + SemanticRolesVerb semanticRolesVerbModel = new SemanticRolesVerb(); + assertNull(semanticRolesVerbModel.getText()); + assertNull(semanticRolesVerbModel.getTense()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResultTest.java new file mode 100644 index 00000000000..41021f841ad --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentenceResult model. */ +public class SentenceResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentenceResult() throws Throwable { + SentenceResult sentenceResultModel = new SentenceResult(); + assertNull(sentenceResultModel.getText()); + assertNull(sentenceResultModel.getLocation()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptionsTest.java new file mode 100644 index 00000000000..c10a29cb134 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentimentOptions model. */ +public class SentimentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentimentOptions() throws Throwable { + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(java.util.Arrays.asList("testString")) + .build(); + assertEquals(sentimentOptionsModel.document(), Boolean.valueOf(true)); + assertEquals(sentimentOptionsModel.targets(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(sentimentOptionsModel); + + SentimentOptions sentimentOptionsModelNew = + TestUtilities.deserialize(json, SentimentOptions.class); + assertTrue(sentimentOptionsModelNew instanceof SentimentOptions); + assertEquals(sentimentOptionsModelNew.document(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResultTest.java new file mode 100644 index 00000000000..7ef8e8a53db --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentimentResult model. */ +public class SentimentResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentimentResult() throws Throwable { + SentimentResult sentimentResultModel = new SentimentResult(); + assertNull(sentimentResultModel.getDocument()); + assertNull(sentimentResultModel.getTargets()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SummarizationOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SummarizationOptionsTest.java new file mode 100644 index 00000000000..615832ccb5e --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SummarizationOptionsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SummarizationOptions model. */ +public class SummarizationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSummarizationOptions() throws Throwable { + SummarizationOptions summarizationOptionsModel = + new SummarizationOptions.Builder().limit(Long.valueOf("3")).build(); + assertEquals(summarizationOptionsModel.limit(), Long.valueOf("3")); + + String json = TestUtilities.serialize(summarizationOptionsModel); + + SummarizationOptions summarizationOptionsModelNew = + TestUtilities.deserialize(json, SummarizationOptions.class); + assertTrue(summarizationOptionsModelNew instanceof SummarizationOptions); + assertEquals(summarizationOptionsModelNew.limit(), Long.valueOf("3")); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTest.java new file mode 100644 index 00000000000..000c74b8f97 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SyntaxOptions model. */ +public class SyntaxOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSyntaxOptions() throws Throwable { + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + assertEquals(syntaxOptionsModel.tokens(), syntaxOptionsTokensModel); + assertEquals(syntaxOptionsModel.sentences(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(syntaxOptionsModel); + + SyntaxOptions syntaxOptionsModelNew = TestUtilities.deserialize(json, SyntaxOptions.class); + assertTrue(syntaxOptionsModelNew instanceof SyntaxOptions); + assertEquals(syntaxOptionsModelNew.tokens().toString(), syntaxOptionsTokensModel.toString()); + assertEquals(syntaxOptionsModelNew.sentences(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokensTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokensTest.java new file mode 100644 index 00000000000..ac2d0a9e488 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokensTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SyntaxOptionsTokens model. */ +public class SyntaxOptionsTokensTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSyntaxOptionsTokens() throws Throwable { + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(syntaxOptionsTokensModel); + + SyntaxOptionsTokens syntaxOptionsTokensModelNew = + TestUtilities.deserialize(json, SyntaxOptionsTokens.class); + assertTrue(syntaxOptionsTokensModelNew instanceof SyntaxOptionsTokens); + assertEquals(syntaxOptionsTokensModelNew.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModelNew.partOfSpeech(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResultTest.java new file mode 100644 index 00000000000..b859e19ee9b --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SyntaxResult model. */ +public class SyntaxResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSyntaxResult() throws Throwable { + SyntaxResult syntaxResultModel = new SyntaxResult(); + assertNull(syntaxResultModel.getTokens()); + assertNull(syntaxResultModel.getSentences()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResultsTest.java new file mode 100644 index 00000000000..41218d2ccab --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TargetedEmotionResults model. */ +public class TargetedEmotionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTargetedEmotionResults() throws Throwable { + TargetedEmotionResults targetedEmotionResultsModel = new TargetedEmotionResults(); + assertNull(targetedEmotionResultsModel.getText()); + assertNull(targetedEmotionResultsModel.getEmotion()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResultsTest.java new file mode 100644 index 00000000000..25da4f0be85 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TargetedSentimentResults model. */ +public class TargetedSentimentResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTargetedSentimentResults() throws Throwable { + TargetedSentimentResults targetedSentimentResultsModel = new TargetedSentimentResults(); + assertNull(targetedSentimentResultsModel.getText()); + assertNull(targetedSentimentResultsModel.getScore()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResultTest.java new file mode 100644 index 00000000000..00386b9f3a1 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TokenResult model. */ +public class TokenResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTokenResult() throws Throwable { + TokenResult tokenResultModel = new TokenResult(); + assertNull(tokenResultModel.getText()); + assertNull(tokenResultModel.getPartOfSpeech()); + assertNull(tokenResultModel.getLocation()); + assertNull(tokenResultModel.getLemma()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateCategoriesModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateCategoriesModelOptionsTest.java new file mode 100644 index 00000000000..c1dd0e884d4 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateCategoriesModelOptionsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCategoriesModelOptions model. */ +public class UpdateCategoriesModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCategoriesModelOptions() throws Throwable { + UpdateCategoriesModelOptions updateCategoriesModelOptionsModel = + new UpdateCategoriesModelOptions.Builder() + .modelId("testString") + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .build(); + assertEquals(updateCategoriesModelOptionsModel.modelId(), "testString"); + assertEquals(updateCategoriesModelOptionsModel.language(), "testString"); + assertEquals( + IOUtils.toString(updateCategoriesModelOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateCategoriesModelOptionsModel.trainingDataContentType(), "json"); + assertEquals(updateCategoriesModelOptionsModel.name(), "testString"); + assertEquals( + updateCategoriesModelOptionsModel.userMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateCategoriesModelOptionsModel.description(), "testString"); + assertEquals(updateCategoriesModelOptionsModel.modelVersion(), "testString"); + assertEquals(updateCategoriesModelOptionsModel.workspaceId(), "testString"); + assertEquals(updateCategoriesModelOptionsModel.versionDescription(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCategoriesModelOptionsError() throws Throwable { + new UpdateCategoriesModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateClassificationsModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateClassificationsModelOptionsTest.java new file mode 100644 index 00000000000..2e07c65cf46 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateClassificationsModelOptionsTest.java @@ -0,0 +1,75 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateClassificationsModelOptions model. */ +public class UpdateClassificationsModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateClassificationsModelOptions() throws Throwable { + ClassificationsTrainingParameters classificationsTrainingParametersModel = + new ClassificationsTrainingParameters.Builder().modelType("single_label").build(); + assertEquals(classificationsTrainingParametersModel.modelType(), "single_label"); + + UpdateClassificationsModelOptions updateClassificationsModelOptionsModel = + new UpdateClassificationsModelOptions.Builder() + .modelId("testString") + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .trainingDataContentType("json") + .name("testString") + .userMetadata(java.util.Collections.singletonMap("anyKey", "anyValue")) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .trainingParameters(classificationsTrainingParametersModel) + .build(); + assertEquals(updateClassificationsModelOptionsModel.modelId(), "testString"); + assertEquals(updateClassificationsModelOptionsModel.language(), "testString"); + assertEquals( + IOUtils.toString(updateClassificationsModelOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateClassificationsModelOptionsModel.trainingDataContentType(), "json"); + assertEquals(updateClassificationsModelOptionsModel.name(), "testString"); + assertEquals( + updateClassificationsModelOptionsModel.userMetadata(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(updateClassificationsModelOptionsModel.description(), "testString"); + assertEquals(updateClassificationsModelOptionsModel.modelVersion(), "testString"); + assertEquals(updateClassificationsModelOptionsModel.workspaceId(), "testString"); + assertEquals(updateClassificationsModelOptionsModel.versionDescription(), "testString"); + assertEquals( + updateClassificationsModelOptionsModel.trainingParameters(), + classificationsTrainingParametersModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateClassificationsModelOptionsError() throws Throwable { + new UpdateClassificationsModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateSentimentModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateSentimentModelOptionsTest.java new file mode 100644 index 00000000000..8b921491864 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/UpdateSentimentModelOptionsTest.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateSentimentModelOptions model. */ +public class UpdateSentimentModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateSentimentModelOptions() throws Throwable { + UpdateSentimentModelOptions updateSentimentModelOptionsModel = + new UpdateSentimentModelOptions.Builder() + .modelId("testString") + .language("testString") + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .name("testString") + .userMetadata( + new java.util.HashMap() { + { + put("foo", TestUtilities.createMockMap()); + } + }) + .description("testString") + .modelVersion("testString") + .workspaceId("testString") + .versionDescription("testString") + .build(); + assertEquals(updateSentimentModelOptionsModel.modelId(), "testString"); + assertEquals(updateSentimentModelOptionsModel.language(), "testString"); + assertEquals( + IOUtils.toString(updateSentimentModelOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateSentimentModelOptionsModel.name(), "testString"); + assertEquals( + updateSentimentModelOptionsModel.userMetadata(), + new java.util.HashMap() { + { + put("foo", TestUtilities.createMockMap()); + } + }); + assertEquals(updateSentimentModelOptionsModel.description(), "testString"); + assertEquals(updateSentimentModelOptionsModel.modelVersion(), "testString"); + assertEquals(updateSentimentModelOptionsModel.workspaceId(), "testString"); + assertEquals(updateSentimentModelOptionsModel.versionDescription(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSentimentModelOptionsError() throws Throwable { + new UpdateSentimentModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/testng.xml b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/testng.xml new file mode 100644 index 00000000000..445780c6495 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/utils/TestUtilities.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..dfd35f5307c --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.natural_language_understanding.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} diff --git a/package-lock.json b/package-lock.json index 2218cc8f9f8..6083d66d424 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3,31 +3,170 @@ "lockfileVersion": 1, "dependencies": { "@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", + "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==", "requires": { - "@babel/highlight": "^7.8.3" + "@babel/highlight": "^7.12.13" } }, + "@babel/helper-validator-identifier": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz", + "integrity": "sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==" + }, "@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.0.tgz", + "integrity": "sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg==", "requires": { + "@babel/helper-validator-identifier": "^7.14.0", "chalk": "^2.0.0", - "esutils": "^2.0.2", "js-tokens": "^4.0.0" } }, + "@nodelib/fs.scandir": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", + "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", + "requires": { + "@nodelib/fs.stat": "2.0.4", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", + "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==" + }, + "@nodelib/fs.walk": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", + "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", + "requires": { + "@nodelib/fs.scandir": "2.1.4", + "fastq": "^1.6.0" + } + }, + "@octokit/auth-token": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.5.tgz", + "integrity": "sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA==", + "requires": { + "@octokit/types": "^6.0.3" + } + }, + "@octokit/core": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.4.0.tgz", + "integrity": "sha512-6/vlKPP8NF17cgYXqucdshWqmMZGXkuvtcrWCgU5NOI0Pl2GjlmZyWgBMrU8zJ3v2MJlM6++CiB45VKYmhiWWg==", + "requires": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.4.12", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/endpoint": { + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.11.tgz", + "integrity": "sha512-fUIPpx+pZyoLW4GCs3yMnlj2LfoXTWDUVPTC4V3MUEKZm48W+XYpeWSZCv+vYF1ZABUm2CqnDVf1sFtIYrj7KQ==", + "requires": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/graphql": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.6.2.tgz", + "integrity": "sha512-WmsIR1OzOr/3IqfG9JIczI8gMJUMzzyx5j0XXQ4YihHtKlQc+u35VpVoOXhlKAlaBntvry1WpAzPl/a+s3n89Q==", + "requires": { + "@octokit/request": "^5.3.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/openapi-types": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-7.2.3.tgz", + "integrity": "sha512-V1ycxkR19jqbIl3evf2RQiMRBvTNRi+Iy9h20G5OP5dPfEF6GJ1DPlUeiZRxo2HJxRr+UA4i0H1nn4btBDPFrw==" + }, + "@octokit/plugin-paginate-rest": { + "version": "2.13.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.13.3.tgz", + "integrity": "sha512-46lptzM9lTeSmIBt/sVP/FLSTPGx6DCzAdSX3PfeJ3mTf4h9sGC26WpaQzMEq/Z44cOcmx8VsOhO+uEgE3cjYg==", + "requires": { + "@octokit/types": "^6.11.0" + } + }, + "@octokit/plugin-request-log": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz", + "integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==" + }, + "@octokit/plugin-rest-endpoint-methods": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.3.1.tgz", + "integrity": "sha512-3B2iguGmkh6bQQaVOtCsS0gixrz8Lg0v4JuXPqBcFqLKuJtxAUf3K88RxMEf/naDOI73spD+goJ/o7Ie7Cvdjg==", + "requires": { + "@octokit/types": "^6.16.2", + "deprecation": "^2.3.1" + } + }, + "@octokit/request": { + "version": "5.4.15", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.15.tgz", + "integrity": "sha512-6UnZfZzLwNhdLRreOtTkT9n57ZwulCve8q3IT/Z477vThu6snfdkBuhxnChpOKNGxcQ71ow561Qoa6uqLdPtag==", + "requires": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.0.0", + "@octokit/types": "^6.7.1", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.1", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/request-error": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.5.tgz", + "integrity": "sha512-T/2wcCFyM7SkXzNoyVNWjyVlUwBvW3igM3Btr/eKYiPmucXTtkxt2RBsf6gn3LTzaLSLTQtNmvg+dGsOxQrjZg==", + "requires": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "@octokit/rest": { + "version": "18.5.6", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.5.6.tgz", + "integrity": "sha512-8HdG6ZjQdZytU6tCt8BQ2XLC7EJ5m4RrbyU/EARSkAM1/HP3ceOzMG/9atEfe17EDMer3IVdHWLedz2wDi73YQ==", + "requires": { + "@octokit/core": "^3.2.3", + "@octokit/plugin-paginate-rest": "^2.6.2", + "@octokit/plugin-request-log": "^1.0.2", + "@octokit/plugin-rest-endpoint-methods": "5.3.1" + } + }, + "@octokit/types": { + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.16.2.tgz", + "integrity": "sha512-wWPSynU4oLy3i4KGyk+J1BLwRKyoeW2TwRHgwbDz17WtVFzSK2GOErGliruIx8c+MaYtHSYTx36DSmLNoNbtgA==", + "requires": { + "@octokit/openapi-types": "^7.2.3" + } + }, "@semantic-release/changelog": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-5.0.0.tgz", - "integrity": "sha512-A1uKqWtQG4WX9Vh4QI5b2ddhqx1qAJFlbow8szSNiXn+TaJg15LSUA9NVqyu0VxQFy3hKUJYwbBHGRXCxCy2fg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-5.0.1.tgz", + "integrity": "sha512-unvqHo5jk4dvAf2nZ3aw4imrlwQ2I50eVVvq9D47Qc3R+keNqepx1vDYwkjF8guFXnOYaYcR28yrZWno1hFbiw==", "requires": { "@semantic-release/error": "^2.1.0", "aggregate-error": "^3.0.0", - "fs-extra": "^8.0.0", + "fs-extra": "^9.0.0", "lodash": "^4.17.4" } }, @@ -64,10 +203,63 @@ "p-reduce": "^2.0.0" } }, + "@semantic-release/github": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/@semantic-release/github/-/github-7.2.3.tgz", + "integrity": "sha512-lWjIVDLal+EQBzy697ayUNN8MoBpp+jYIyW2luOdqn5XBH4d9bQGfTnjuLyzARZBHejqh932HVjiH/j4+R7VHw==", + "requires": { + "@octokit/rest": "^18.0.0", + "@semantic-release/error": "^2.2.0", + "aggregate-error": "^3.0.0", + "bottleneck": "^2.18.1", + "debug": "^4.0.0", + "dir-glob": "^3.0.0", + "fs-extra": "^10.0.0", + "globby": "^11.0.0", + "http-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", + "issue-parser": "^6.0.0", + "lodash": "^4.17.4", + "mime": "^2.4.3", + "p-filter": "^2.0.0", + "p-retry": "^4.0.0", + "url-join": "^4.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + } + } + }, + "@tootallnate/once": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" + }, + "@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" + }, + "agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "requires": { + "debug": "4" + } + }, "aggregate-error": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", - "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", "requires": { "clean-stack": "^2.0.0", "indent-string": "^4.0.0" @@ -81,6 +273,26 @@ "color-convert": "^1.9.0" } }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==" + }, + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" + }, + "before-after-hook": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz", + "integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw==" + }, + "bottleneck": { + "version": "2.19.5", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" + }, "braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", @@ -118,9 +330,9 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "cross-spawn": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", - "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -128,13 +340,18 @@ } }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, + "deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -164,15 +381,10 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" - }, "execa": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-4.0.0.tgz", - "integrity": "sha512-JbDUxwV3BoT5ZVXQrSVbAiaXhXUkIwvbhPIwZ0N13kX+5yCzOhUNdocxB/UQRuYOHRYYwAxKYwJYc0T4D12pDA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", + "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==", "requires": { "cross-spawn": "^7.0.0", "get-stream": "^5.0.0", @@ -185,6 +397,27 @@ "strip-final-newline": "^2.0.0" } }, + "fast-glob": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz", + "integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==", + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" + } + }, + "fastq": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.11.0.tgz", + "integrity": "sha512-7Eczs8gIPDrVzT+EksYBcupqMyxSHXXrHOLRRxU2/DicV8789MRBRR8+Hc2uWzUupOs4YS4JzBmBxjjCVBxD/g==", + "requires": { + "reusify": "^1.0.4" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -194,38 +427,84 @@ } }, "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", "requires": { + "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" } }, "get-stream": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", - "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", "requires": { "pump": "^3.0.0" } }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "globby": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.3.tgz", + "integrity": "sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg==", + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" + } + }, "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==" + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", + "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==" }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, + "http-proxy-agent": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", + "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "requires": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" + } + }, + "https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "requires": { + "agent-base": "6", + "debug": "4" + } + }, "human-signals": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==" }, + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" + }, "indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", @@ -236,11 +515,29 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, "is-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", @@ -251,22 +548,35 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "issue-parser": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/issue-parser/-/issue-parser-6.0.0.tgz", + "integrity": "sha512-zKa/Dxq2lGsBIXQ7CUZWTHfvxPC2ej0KfO7fIPqLlHB9J2hJ7rGhZ5rilhuufylr4RXYPzJUeFjKxz305OsNlA==", + "requires": { + "lodash.capitalize": "^4.2.1", + "lodash.escaperegexp": "^4.1.2", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.uniqby": "^4.7.0" + } + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" }, "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "requires": { - "graceful-fs": "^4.1.6" + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" } }, "lines-and-columns": { @@ -275,24 +585,59 @@ "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=" }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash.capitalize": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/lodash.capitalize/-/lodash.capitalize-4.2.1.tgz", + "integrity": "sha1-+CbJtOKoUR2E46yinbBeGk87cqk=" + }, + "lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, + "lodash.uniqby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz", + "integrity": "sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI=" }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" + }, "micromatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", - "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", "requires": { "braces": "^3.0.1", - "picomatch": "^2.0.5" + "picomatch": "^2.2.3" } }, + "mime": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==" + }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -303,6 +648,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, "npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -320,26 +670,48 @@ } }, "onetime": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", - "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "requires": { "mimic-fn": "^2.1.0" } }, + "p-filter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-filter/-/p-filter-2.1.0.tgz", + "integrity": "sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==", + "requires": { + "p-map": "^2.0.0" + } + }, + "p-map": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", + "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==" + }, "p-reduce": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-2.1.0.tgz", "integrity": "sha512-2USApvnsutq8uoxZBGbbWM0JIYLiEMJ9RlaN7fAzVNb9OZN0SHjjTTfIcb667XynS5Y1VhwDJVDa72TnPzAYWw==" }, + "p-retry": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.5.0.tgz", + "integrity": "sha512-5Hwh4aVQSu6BEP+w2zKlVXtFAaYQe1qWuVADSgoeVlLjwe/Q/AMSoRR4MDeaAfu8llT+YNbEijWu/YF3m6avkg==", + "requires": { + "@types/retry": "^0.12.0", + "retry": "^0.12.0" + } + }, "parse-json": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", - "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", "requires": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1", + "json-parse-even-better-errors": "^2.3.0", "lines-and-columns": "^1.1.6" } }, @@ -354,9 +726,9 @@ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==" }, "picomatch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==" + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" }, "pump": { "version": "3.0.0", @@ -367,6 +739,29 @@ "once": "^1.3.1" } }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" + }, + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" + }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" + }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "requires": { + "queue-microtask": "^1.2.2" + } + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -381,9 +776,14 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" }, "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==" }, "strip-final-newline": { "version": "2.0.0", @@ -406,10 +806,20 @@ "is-number": "^7.0.0" } }, + "universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + }, + "url-join": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", + "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==" }, "which": { "version": "2.0.2", diff --git a/personality-insights/README.md b/personality-insights/README.md deleted file mode 100755 index 5546ef2d12a..00000000000 --- a/personality-insights/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Personality Insights - -## Installation - -##### Maven - -```xml - - com.ibm.watson - personality-insights - 8.3.1 - -``` - -##### Gradle - -```gradle -'com.ibm.watson:personality-insights:8.3.1' -``` - -## Usage - -Use linguistic analytics to infer personality and social characteristics, including Big Five, Needs, and Values, from text. -Example: Analyze text and get a personality profile using the [Personality Insights][personality_insights] service. - -```java -Authenticator authenticator = new IamAuthenticator(""); -PersonalityInsights service = new PersonalityInsights("2017-10-13", authenticator); - -// Demo content from Moby Dick by Hermann Melville (Chapter 1) -String text = "Call me Ishmael. Some years ago-never mind how long precisely-having " - + "little or no money in my purse, and nothing particular to interest me on shore, " - + "I thought I would sail about a little and see the watery part of the world. " - + "It is a way I have of driving off the spleen and regulating the circulation. " - + "Whenever I find myself growing grim about the mouth; whenever it is a damp, " - + "drizzly November in my soul; whenever I find myself involuntarily pausing before " - + "coffin warehouses, and bringing up the rear of every funeral I meet; and especially " - + "whenever my hypos get such an upper hand of me, that it requires a strong moral " - + "principle to prevent me from deliberately stepping into the street, and methodically " - + "knocking people's hats off-then, I account it high time to get to sea as soon as I can. " - + "This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself " - + "upon his sword; I quietly take to the ship. There is nothing surprising in this. " - + "If they but knew it, almost all men in their degree, some time or other, cherish " - + "very nearly the same feelings towards the ocean with me. There now is your insular " - + "city of the Manhattoes, belted round by wharves as Indian isles by coral reefs-commerce surrounds " - + "it with her surf. Right and left, the streets take you waterward."; - -ProfileOptions options = new ProfileOptions.Builder() - .text(text) - .build(); - -Profile profile = service.profile(options).execute().getResult(); -System.out.println(profile); -``` - -[personality_insights]: https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-about diff --git a/personality-insights/build.gradle b/personality-insights/build.gradle deleted file mode 100644 index e63b7d64fa9..00000000000 --- a/personality-insights/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/personality-insights/gradle.properties b/personality-insights/gradle.properties deleted file mode 100644 index baac056aa30..00000000000 --- a/personality-insights/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:personality-insights -ARTIFACT_ID=personality-insights -NAME=IBM Watson Java SDK - Personality Insights -DESCRIPTION=Java client library to use the IBM Personality Insights API \ No newline at end of file diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java deleted file mode 100644 index 34da594a294..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3; - -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.personality_insights.v3.model.Profile; -import com.ibm.watson.personality_insights.v3.model.ProfileOptions; -import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; - -/** - * The IBM Watson™ Personality Insights service enables applications to derive insights from social media, - * enterprise data, or other digital communications. The service uses linguistic analytics to infer individuals' - * intrinsic personality characteristics, including Big Five, Needs, and Values, from digital communications such as - * email, text messages, tweets, and forum posts. - * - * The service can automatically infer, from potentially noisy social media, portraits of individuals that reflect their - * personality characteristics. The service can infer consumption preferences based on the results of its analysis and, - * for JSON content that is timestamped, can report temporal behavior. - * * For information about the meaning of the models that the service uses to describe personality characteristics, see - * [Personality models](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-models#models). - * * For information about the meaning of the consumption preferences, see [Consumption - * preferences](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-preferences#preferences). - * - * **Note:** Request logging is disabled for the Personality Insights service. Regardless of whether you set the - * `X-Watson-Learning-Opt-Out` request header, the service does not log or retain data from requests and responses. - * - * @version v3 - * @see Personality Insights - */ -public class PersonalityInsights extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "personality_insights"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/personality-insights/api"; - - private String versionDate; - - /** - * Constructs a new `PersonalityInsights` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public PersonalityInsights(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `PersonalityInsights` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public PersonalityInsights(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `PersonalityInsights` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public PersonalityInsights(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `PersonalityInsights` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public PersonalityInsights(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Get profile. - * - * Generates a personality profile for the author of the input text. The service accepts a maximum of 20 MB of input - * content, but it requires much less text to produce an accurate profile. The service can analyze text in Arabic, - * English, Japanese, Korean, or Spanish. It can return its results in a variety of languages. - * - * **See also:** - * * [Requesting a profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#input) - * * [Providing sufficient - * input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient) - * - * ### Content types - * - * You can provide input content as plain text (`text/plain`), HTML (`text/html`), or JSON (`application/json`) by - * specifying the **Content-Type** parameter. The default is `text/plain`. - * * Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8. - * * Per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII - * character set). - * - * When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the character - * encoding of the input text; for example, `Content-Type: text/plain;charset=utf-8`. - * - * **See also:** [Specifying request and response - * formats](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#formats) - * - * ### Accept types - * - * You must request a response as JSON (`application/json`) or comma-separated values (`text/csv`) by specifying the - * **Accept** parameter. CSV output includes a fixed number of columns. Set the **csv_headers** parameter to `true` to - * request optional column headers for CSV output. - * - * **See also:** - * * [Understanding a JSON - * profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-output#output) - * * [Understanding a CSV - * profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-outputCSV#outputCSV). - * - * @param profileOptions the {@link ProfileOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Profile} - */ - public ServiceCall profile(ProfileOptions profileOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(profileOptions, - "profileOptions cannot be null"); - String[] pathSegments = { "v3/profile" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profile"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (profileOptions.contentType() != null) { - builder.header("Content-Type", profileOptions.contentType()); - } - if (profileOptions.contentLanguage() != null) { - builder.header("Content-Language", profileOptions.contentLanguage()); - } - if (profileOptions.acceptLanguage() != null) { - builder.header("Accept-Language", profileOptions.acceptLanguage()); - } - if (profileOptions.rawScores() != null) { - builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); - } - if (profileOptions.csvHeaders() != null) { - builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders())); - } - if (profileOptions.consumptionPreferences() != null) { - builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); - } - builder.bodyContent(profileOptions.contentType(), profileOptions.content(), - null, profileOptions.body()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get profile as csv. - * - * Generates a personality profile for the author of the input text. The service accepts a maximum of 20 MB of input - * content, but it requires much less text to produce an accurate profile. The service can analyze text in Arabic, - * English, Japanese, Korean, or Spanish. It can return its results in a variety of languages. - * - * **See also:** - * * [Requesting a profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#input) - * * [Providing sufficient - * input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient) - * - * ### Content types - * - * You can provide input content as plain text (`text/plain`), HTML (`text/html`), or JSON (`application/json`) by - * specifying the **Content-Type** parameter. The default is `text/plain`. - * * Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8. - * * Per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII - * character set). - * - * When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the character - * encoding of the input text; for example, `Content-Type: text/plain;charset=utf-8`. - * - * **See also:** [Specifying request and response - * formats](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#formats) - * - * ### Accept types - * - * You must request a response as JSON (`application/json`) or comma-separated values (`text/csv`) by specifying the - * **Accept** parameter. CSV output includes a fixed number of columns. Set the **csv_headers** parameter to `true` to - * request optional column headers for CSV output. - * - * **See also:** - * * [Understanding a JSON - * profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-output#output) - * * [Understanding a CSV - * profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-outputCSV#outputCSV). - * - * @param profileOptions the {@link ProfileOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link String} - */ - public ServiceCall profileAsCsv(ProfileOptions profileOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(profileOptions, - "profileOptions cannot be null"); - String[] pathSegments = { "v3/profile" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profileAsCsv"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "text/csv"); - if (profileOptions.contentType() != null) { - builder.header("Content-Type", profileOptions.contentType()); - } - if (profileOptions.contentLanguage() != null) { - builder.header("Content-Language", profileOptions.contentLanguage()); - } - if (profileOptions.acceptLanguage() != null) { - builder.header("Accept-Language", profileOptions.acceptLanguage()); - } - if (profileOptions.rawScores() != null) { - builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); - } - if (profileOptions.csvHeaders() != null) { - builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders())); - } - if (profileOptions.consumptionPreferences() != null) { - builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); - } - builder.bodyContent(profileOptions.contentType(), profileOptions.content(), - null, profileOptions.body()); - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java deleted file mode 100644 index 31e2293504a..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The temporal behavior for the input content. - */ -public class Behavior extends GenericModel { - - @SerializedName("trait_id") - protected String traitId; - protected String name; - protected String category; - protected Double percentage; - - /** - * Gets the traitId. - * - * The unique, non-localized identifier of the characteristic to which the results pertain. IDs have the form - * `behavior_{value}`. - * - * @return the traitId - */ - public String getTraitId() { - return traitId; - } - - /** - * Gets the name. - * - * The user-visible, localized name of the characteristic. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the category. - * - * The category of the characteristic: `behavior` for temporal data. - * - * @return the category - */ - public String getCategory() { - return category; - } - - /** - * Gets the percentage. - * - * For JSON content that is timestamped, the percentage of timestamped input data that occurred during that day of the - * week or hour of the day. The range is 0 to 1. - * - * @return the percentage - */ - public Double getPercentage() { - return percentage; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java deleted file mode 100644 index 5bd7108cbec..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A consumption preference that the service inferred from the input content. - */ -public class ConsumptionPreferences extends GenericModel { - - @SerializedName("consumption_preference_id") - protected String consumptionPreferenceId; - protected String name; - protected Double score; - - /** - * Gets the consumptionPreferenceId. - * - * The unique, non-localized identifier of the consumption preference to which the results pertain. IDs have the form - * `consumption_preferences_{preference}`. - * - * @return the consumptionPreferenceId - */ - public String getConsumptionPreferenceId() { - return consumptionPreferenceId; - } - - /** - * Gets the name. - * - * The user-visible, localized name of the consumption preference. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the score. - * - * The score for the consumption preference: - * * `0.0`: Unlikely - * * `0.5`: Neutral - * * `1.0`: Likely - * - * The scores for some preferences are binary and do not allow a neutral value. The score is an indication of - * preference based on the results inferred from the input text, not a normalized percentile. - * - * @return the score - */ - public Double getScore() { - return score; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java deleted file mode 100644 index fe04987f31c..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.personality_insights.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The consumption preferences that the service inferred from the input content. - */ -public class ConsumptionPreferencesCategory extends GenericModel { - - @SerializedName("consumption_preference_category_id") - protected String consumptionPreferenceCategoryId; - protected String name; - @SerializedName("consumption_preferences") - protected List consumptionPreferences; - - /** - * Gets the consumptionPreferenceCategoryId. - * - * The unique, non-localized identifier of the consumption preferences category to which the results pertain. IDs have - * the form `consumption_preferences_{category}`. - * - * @return the consumptionPreferenceCategoryId - */ - public String getConsumptionPreferenceCategoryId() { - return consumptionPreferenceCategoryId; - } - - /** - * Gets the name. - * - * The user-visible name of the consumption preferences category. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the consumptionPreferences. - * - * Detailed results inferred from the input text for the individual preferences of the category. - * - * @return the consumptionPreferences - */ - public List getConsumptionPreferences() { - return consumptionPreferences; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java deleted file mode 100644 index 859fffb7adf..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The full input content that the service is to analyze. - */ -public class Content extends GenericModel { - - protected List contentItems; - - /** - * Builder. - */ - public static class Builder { - private List contentItems; - - private Builder(Content content) { - this.contentItems = content.contentItems; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param contentItems the contentItems - */ - public Builder(List contentItems) { - this.contentItems = contentItems; - } - - /** - * Builds a Content. - * - * @return the content - */ - public Content build() { - return new Content(this); - } - - /** - * Adds an contentItem to contentItems. - * - * @param contentItem the new contentItem - * @return the Content builder - */ - public Builder addContentItem(ContentItem contentItem) { - com.ibm.cloud.sdk.core.util.Validator.notNull(contentItem, - "contentItem cannot be null"); - if (this.contentItems == null) { - this.contentItems = new ArrayList(); - } - this.contentItems.add(contentItem); - return this; - } - - /** - * Set the contentItems. - * Existing contentItems will be replaced. - * - * @param contentItems the contentItems - * @return the Content builder - */ - public Builder contentItems(List contentItems) { - this.contentItems = contentItems; - return this; - } - } - - protected Content(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.contentItems, - "contentItems cannot be null"); - contentItems = builder.contentItems; - } - - /** - * New builder. - * - * @return a Content builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the contentItems. - * - * An array of `ContentItem` objects that provides the text that is to be analyzed. - * - * @return the contentItems - */ - public List contentItems() { - return contentItems; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java deleted file mode 100644 index 17e7b55093c..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An input content item that the service is to analyze. - */ -public class ContentItem extends GenericModel { - - /** - * The MIME type of the content. The default is plain text. The tags are stripped from HTML content before it is - * analyzed; plain text is processed as submitted. - */ - public interface Contenttype { - /** text/plain. */ - String TEXT_PLAIN = "text/plain"; - /** text/html. */ - String TEXT_HTML = "text/html"; - } - - /** - * The language identifier (two-letter ISO 639-1 identifier) for the language of the content item. The default is `en` - * (English). Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. A - * language specified with the **Content-Type** parameter overrides the value of this parameter; any content items - * that specify a different language are ignored. Omit the **Content-Type** parameter to base the language on the most - * prevalent specification among the content items; again, content items that specify a different language are - * ignored. You can specify any combination of languages for the input and response content. - */ - public interface Language { - /** ar. */ - String AR = "ar"; - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - } - - protected String content; - protected String id; - protected Long created; - protected Long updated; - protected String contenttype; - protected String language; - protected String parentid; - protected Boolean reply; - protected Boolean forward; - - /** - * Builder. - */ - public static class Builder { - private String content; - private String id; - private Long created; - private Long updated; - private String contenttype; - private String language; - private String parentid; - private Boolean reply; - private Boolean forward; - - private Builder(ContentItem contentItem) { - this.content = contentItem.content; - this.id = contentItem.id; - this.created = contentItem.created; - this.updated = contentItem.updated; - this.contenttype = contentItem.contenttype; - this.language = contentItem.language; - this.parentid = contentItem.parentid; - this.reply = contentItem.reply; - this.forward = contentItem.forward; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param content the content - */ - public Builder(String content) { - this.content = content; - } - - /** - * Builds a ContentItem. - * - * @return the contentItem - */ - public ContentItem build() { - return new ContentItem(this); - } - - /** - * Set the content. - * - * @param content the content - * @return the ContentItem builder - */ - public Builder content(String content) { - this.content = content; - return this; - } - - /** - * Set the id. - * - * @param id the id - * @return the ContentItem builder - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * Set the created. - * - * @param created the created - * @return the ContentItem builder - */ - public Builder created(long created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the ContentItem builder - */ - public Builder updated(long updated) { - this.updated = updated; - return this; - } - - /** - * Set the contenttype. - * - * @param contenttype the contenttype - * @return the ContentItem builder - */ - public Builder contenttype(String contenttype) { - this.contenttype = contenttype; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the ContentItem builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the parentid. - * - * @param parentid the parentid - * @return the ContentItem builder - */ - public Builder parentid(String parentid) { - this.parentid = parentid; - return this; - } - - /** - * Set the reply. - * - * @param reply the reply - * @return the ContentItem builder - */ - public Builder reply(Boolean reply) { - this.reply = reply; - return this; - } - - /** - * Set the forward. - * - * @param forward the forward - * @return the ContentItem builder - */ - public Builder forward(Boolean forward) { - this.forward = forward; - return this; - } - } - - protected ContentItem(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.content, - "content cannot be null"); - content = builder.content; - id = builder.id; - created = builder.created; - updated = builder.updated; - contenttype = builder.contenttype; - language = builder.language; - parentid = builder.parentid; - reply = builder.reply; - forward = builder.forward; - } - - /** - * New builder. - * - * @return a ContentItem builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the content. - * - * The content that is to be analyzed. The service supports up to 20 MB of content for all `ContentItem` objects - * combined. - * - * @return the content - */ - public String content() { - return content; - } - - /** - * Gets the id. - * - * A unique identifier for this content item. - * - * @return the id - */ - public String id() { - return id; - } - - /** - * Gets the created. - * - * A timestamp that identifies when this content was created. Specify a value in milliseconds since the UNIX Epoch - * (January 1, 1970, at 0:00 UTC). Required only for results that include temporal behavior data. - * - * @return the created - */ - public Long created() { - return created; - } - - /** - * Gets the updated. - * - * A timestamp that identifies when this content was last updated. Specify a value in milliseconds since the UNIX - * Epoch (January 1, 1970, at 0:00 UTC). Required only for results that include temporal behavior data. - * - * @return the updated - */ - public Long updated() { - return updated; - } - - /** - * Gets the contenttype. - * - * The MIME type of the content. The default is plain text. The tags are stripped from HTML content before it is - * analyzed; plain text is processed as submitted. - * - * @return the contenttype - */ - public String contenttype() { - return contenttype; - } - - /** - * Gets the language. - * - * The language identifier (two-letter ISO 639-1 identifier) for the language of the content item. The default is `en` - * (English). Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. A - * language specified with the **Content-Type** parameter overrides the value of this parameter; any content items - * that specify a different language are ignored. Omit the **Content-Type** parameter to base the language on the most - * prevalent specification among the content items; again, content items that specify a different language are - * ignored. You can specify any combination of languages for the input and response content. - * - * @return the language - */ - public String language() { - return language; - } - - /** - * Gets the parentid. - * - * The unique ID of the parent content item for this item. Used to identify hierarchical relationships between - * posts/replies, messages/replies, and so on. - * - * @return the parentid - */ - public String parentid() { - return parentid; - } - - /** - * Gets the reply. - * - * Indicates whether this content item is a reply to another content item. - * - * @return the reply - */ - public Boolean reply() { - return reply; - } - - /** - * Gets the forward. - * - * Indicates whether this content item is a forwarded/copied version of another content item. - * - * @return the forward - */ - public Boolean forward() { - return forward; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java deleted file mode 100644 index 0a45943515a..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The personality profile that the service generated for the input content. - */ -public class Profile extends GenericModel { - - /** - * The language model that was used to process the input. - */ - public interface ProcessedLanguage { - /** ar. */ - String AR = "ar"; - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - } - - @SerializedName("processed_language") - protected String processedLanguage; - @SerializedName("word_count") - protected Long wordCount; - @SerializedName("word_count_message") - protected String wordCountMessage; - protected List personality; - protected List needs; - protected List values; - protected List behavior; - @SerializedName("consumption_preferences") - protected List consumptionPreferences; - protected List warnings; - - /** - * Gets the processedLanguage. - * - * The language model that was used to process the input. - * - * @return the processedLanguage - */ - public String getProcessedLanguage() { - return processedLanguage; - } - - /** - * Gets the wordCount. - * - * The number of words from the input that were used to produce the profile. - * - * @return the wordCount - */ - public Long getWordCount() { - return wordCount; - } - - /** - * Gets the wordCountMessage. - * - * When guidance is appropriate, a string that provides a message that indicates the number of words found and where - * that value falls in the range of required or suggested number of words. - * - * @return the wordCountMessage - */ - public String getWordCountMessage() { - return wordCountMessage; - } - - /** - * Gets the personality. - * - * A recursive array of `Trait` objects that provides detailed results for the Big Five personality characteristics - * (dimensions and facets) inferred from the input text. - * - * @return the personality - */ - public List getPersonality() { - return personality; - } - - /** - * Gets the needs. - * - * Detailed results for the Needs characteristics inferred from the input text. - * - * @return the needs - */ - public List getNeeds() { - return needs; - } - - /** - * Gets the values. - * - * Detailed results for the Values characteristics inferred from the input text. - * - * @return the values - */ - public List getValues() { - return values; - } - - /** - * Gets the behavior. - * - * For JSON content that is timestamped, detailed results about the social behavior disclosed by the input in terms of - * temporal characteristics. The results include information about the distribution of the content over the days of - * the week and the hours of the day. - * - * @return the behavior - */ - public List getBehavior() { - return behavior; - } - - /** - * Gets the consumptionPreferences. - * - * If the **consumption_preferences** parameter is `true`, detailed results for each category of consumption - * preferences. Each element of the array provides information inferred from the input text for the individual - * preferences of that category. - * - * @return the consumptionPreferences - */ - public List getConsumptionPreferences() { - return consumptionPreferences; - } - - /** - * Gets the warnings. - * - * An array of warning messages that are associated with the input text for the request. The array is empty if the - * input generated no warnings. - * - * @return the warnings - */ - public List getWarnings() { - return warnings; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java deleted file mode 100644 index 9ac4cc1fdc5..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The profile options. - */ -public class ProfileOptions extends GenericModel { - - /** - * The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants - * are treated as their parent language; for example, `en-US` is interpreted as `en`. - * - * The effect of the **Content-Language** parameter depends on the **Content-Type** parameter. When **Content-Type** - * is `text/plain` or `text/html`, **Content-Language** is the only way to specify the language. When **Content-Type** - * is `application/json`, **Content-Language** overrides a language specified with the `language` parameter of a - * `ContentItem` object, and content items that specify a different language are ignored; omit this parameter to base - * the language on the specification of the content items. You can specify any combination of languages for - * **Content-Language** and **Accept-Language**. - */ - public interface ContentLanguage { - /** ar. */ - String AR = "ar"; - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - } - - /** - * The desired language of the response. For two-character arguments, regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. You can specify any combination of languages for the input - * and response content. - */ - public interface AcceptLanguage { - /** ar. */ - String AR = "ar"; - /** de. */ - String DE = "de"; - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** fr. */ - String FR = "fr"; - /** it. */ - String IT = "it"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - /** pt-br. */ - String PT_BR = "pt-br"; - /** zh-cn. */ - String ZH_CN = "zh-cn"; - /** zh-tw. */ - String ZH_TW = "zh-tw"; - } - - protected Content content; - protected String body; - protected String contentType; - protected String contentLanguage; - protected String acceptLanguage; - protected Boolean rawScores; - protected Boolean csvHeaders; - protected Boolean consumptionPreferences; - - /** - * Builder. - */ - public static class Builder { - private Content content; - private String body; - private String contentType; - private String contentLanguage; - private String acceptLanguage; - private Boolean rawScores; - private Boolean csvHeaders; - private Boolean consumptionPreferences; - - private Builder(ProfileOptions profileOptions) { - this.content = profileOptions.content; - this.body = profileOptions.body; - this.contentType = profileOptions.contentType; - this.contentLanguage = profileOptions.contentLanguage; - this.acceptLanguage = profileOptions.acceptLanguage; - this.rawScores = profileOptions.rawScores; - this.csvHeaders = profileOptions.csvHeaders; - this.consumptionPreferences = profileOptions.consumptionPreferences; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ProfileOptions. - * - * @return the profileOptions - */ - public ProfileOptions build() { - return new ProfileOptions(this); - } - - /** - * Set the contentLanguage. - * - * @param contentLanguage the contentLanguage - * @return the ProfileOptions builder - */ - public Builder contentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Set the acceptLanguage. - * - * @param acceptLanguage the acceptLanguage - * @return the ProfileOptions builder - */ - public Builder acceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** - * Set the rawScores. - * - * @param rawScores the rawScores - * @return the ProfileOptions builder - */ - public Builder rawScores(Boolean rawScores) { - this.rawScores = rawScores; - return this; - } - - /** - * Set the csvHeaders. - * - * @param csvHeaders the csvHeaders - * @return the ProfileOptions builder - */ - public Builder csvHeaders(Boolean csvHeaders) { - this.csvHeaders = csvHeaders; - return this; - } - - /** - * Set the consumptionPreferences. - * - * @param consumptionPreferences the consumptionPreferences - * @return the ProfileOptions builder - */ - public Builder consumptionPreferences(Boolean consumptionPreferences) { - this.consumptionPreferences = consumptionPreferences; - return this; - } - - /** - * Set the content. - * - * @param content the content - * @return the ProfileOptions builder - */ - public Builder content(Content content) { - this.content = content; - this.contentType = "application/json"; - return this; - } - - /** - * Set the html. - * - * @param html the html - * @return the ProfileOptions builder - */ - public Builder html(String html) { - this.body = html; - this.contentType = "text/html"; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the ProfileOptions builder - */ - public Builder text(String text) { - this.body = text; - this.contentType = "text/plain"; - return this; - } - } - - protected ProfileOptions(Builder builder) { - content = builder.content; - body = builder.body; - contentType = builder.contentType; - contentLanguage = builder.contentLanguage; - acceptLanguage = builder.acceptLanguage; - rawScores = builder.rawScores; - csvHeaders = builder.csvHeaders; - consumptionPreferences = builder.consumptionPreferences; - } - - /** - * New builder. - * - * @return a ProfileOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the content. - * - * A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see - * [Providing sufficient - * input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient). For JSON - * input, provide an object of type `Content`. - * - * @return the content - */ - public Content content() { - return content; - } - - /** - * Gets the body. - * - * A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see - * [Providing sufficient - * input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient). For JSON - * input, provide an object of type `Content`. - * - * @return the body - */ - public String body() { - return body; - } - - /** - * Gets the contentType. - * - * The type of the input. For more information, see **Content types** in the method description. - * - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * Gets the contentLanguage. - * - * The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants - * are treated as their parent language; for example, `en-US` is interpreted as `en`. - * - * The effect of the **Content-Language** parameter depends on the **Content-Type** parameter. When **Content-Type** - * is `text/plain` or `text/html`, **Content-Language** is the only way to specify the language. When **Content-Type** - * is `application/json`, **Content-Language** overrides a language specified with the `language` parameter of a - * `ContentItem` object, and content items that specify a different language are ignored; omit this parameter to base - * the language on the specification of the content items. You can specify any combination of languages for - * **Content-Language** and **Accept-Language**. - * - * @return the contentLanguage - */ - public String contentLanguage() { - return contentLanguage; - } - - /** - * Gets the acceptLanguage. - * - * The desired language of the response. For two-character arguments, regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. You can specify any combination of languages for the input - * and response content. - * - * @return the acceptLanguage - */ - public String acceptLanguage() { - return acceptLanguage; - } - - /** - * Gets the rawScores. - * - * Indicates whether a raw score in addition to a normalized percentile is returned for each characteristic; raw - * scores are not compared with a sample population. By default, only normalized percentiles are returned. - * - * @return the rawScores - */ - public Boolean rawScores() { - return rawScores; - } - - /** - * Gets the csvHeaders. - * - * Indicates whether column labels are returned with a CSV response. By default, no column labels are returned. - * Applies only when the response type is CSV (`text/csv`). - * - * @return the csvHeaders - */ - public Boolean csvHeaders() { - return csvHeaders; - } - - /** - * Gets the consumptionPreferences. - * - * Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are - * returned. - * - * @return the consumptionPreferences - */ - public Boolean consumptionPreferences() { - return consumptionPreferences; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java deleted file mode 100644 index ccd743a0eb4..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.personality_insights.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The characteristics that the service inferred from the input content. - */ -public class Trait extends GenericModel { - - /** - * The category of the characteristic: `personality` for Big Five personality characteristics, `needs` for Needs, and - * `values` for Values. - */ - public interface Category { - /** personality. */ - String PERSONALITY = "personality"; - /** needs. */ - String NEEDS = "needs"; - /** values. */ - String VALUES = "values"; - } - - @SerializedName("trait_id") - protected String traitId; - protected String name; - protected String category; - protected Double percentile; - @SerializedName("raw_score") - protected Double rawScore; - protected Boolean significant; - protected List children; - - /** - * Gets the traitId. - * - * The unique, non-localized identifier of the characteristic to which the results pertain. IDs have the form - * * `big5_{characteristic}` for Big Five personality dimensions - * * `facet_{characteristic}` for Big Five personality facets - * * `need_{characteristic}` for Needs - * *`value_{characteristic}` for Values. - * - * @return the traitId - */ - public String getTraitId() { - return traitId; - } - - /** - * Gets the name. - * - * The user-visible, localized name of the characteristic. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the category. - * - * The category of the characteristic: `personality` for Big Five personality characteristics, `needs` for Needs, and - * `values` for Values. - * - * @return the category - */ - public String getCategory() { - return category; - } - - /** - * Gets the percentile. - * - * The normalized percentile score for the characteristic. The range is 0 to 1. For example, if the percentage for - * Openness is 0.60, the author scored in the 60th percentile; the author is more open than 59 percent of the - * population and less open than 39 percent of the population. - * - * @return the percentile - */ - public Double getPercentile() { - return percentile; - } - - /** - * Gets the rawScore. - * - * The raw score for the characteristic. The range is 0 to 1. A higher score generally indicates a greater likelihood - * that the author has that characteristic, but raw scores must be considered in aggregate: The range of values in - * practice might be much smaller than 0 to 1, so an individual score must be considered in the context of the overall - * scores and their range. - * - * The raw score is computed based on the input and the service model; it is not normalized or compared with a sample - * population. The raw score enables comparison of the results against a different sampling population and with a - * custom normalization approach. - * - * @return the rawScore - */ - public Double getRawScore() { - return rawScore; - } - - /** - * Gets the significant. - * - * **`2017-10-13`**: Indicates whether the characteristic is meaningful for the input language. The field is always - * `true` for all characteristics of English, Spanish, and Japanese input. The field is `false` for the subset of - * characteristics of Arabic and Korean input for which the service's models are unable to generate meaningful - * results. **`2016-10-19`**: Not returned. - * - * @return the significant - */ - public Boolean isSignificant() { - return significant; - } - - /** - * Gets the children. - * - * For `personality` (Big Five) dimensions, more detailed results for the facets of each dimension as inferred from - * the input text. - * - * @return the children - */ - public List getChildren() { - return children; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java deleted file mode 100644 index 73248e1e30c..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.personality_insights.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A warning message that is associated with the input content. - */ -public class Warning extends GenericModel { - - /** - * The identifier of the warning message. - */ - public interface WarningId { - /** WORD_COUNT_MESSAGE. */ - String WORD_COUNT_MESSAGE = "WORD_COUNT_MESSAGE"; - /** JSON_AS_TEXT. */ - String JSON_AS_TEXT = "JSON_AS_TEXT"; - /** CONTENT_TRUNCATED. */ - String CONTENT_TRUNCATED = "CONTENT_TRUNCATED"; - /** PARTIAL_TEXT_USED. */ - String PARTIAL_TEXT_USED = "PARTIAL_TEXT_USED"; - } - - @SerializedName("warning_id") - protected String warningId; - protected String message; - - /** - * Gets the warningId. - * - * The identifier of the warning message. - * - * @return the warningId - */ - public String getWarningId() { - return warningId; - } - - /** - * Gets the message. - * - * The message associated with the `warning_id`: - * * `WORD_COUNT_MESSAGE`: "There were {number} words in the input. We need a minimum of 600, preferably 1,200 or - * more, to compute statistically significant estimates." - * * `JSON_AS_TEXT`: "Request input was processed as text/plain as indicated, however detected a JSON input. Did you - * mean application/json?" - * * `CONTENT_TRUNCATED`: "For maximum accuracy while also optimizing processing time, only the first 250KB of input - * text (excluding markup) was analyzed. Accuracy levels off at approximately 3,000 words so this did not affect the - * accuracy of the profile." - * * `PARTIAL_TEXT_USED`, "The text provided to compute the profile was trimmed for performance reasons. This action - * does not affect the accuracy of the output, as not all of the input text was required." Applies only when Arabic - * input text exceeds a threshold at which additional words do not contribute to the accuracy of the profile. - * - * @return the message - */ - public String getMessage() { - return message; - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java deleted file mode 100644 index 1a4984513b7..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Personality Insights v3. - */ -package com.ibm.watson.personality_insights.v3; diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsIT.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsIT.java deleted file mode 100644 index 44c186ca2c4..00000000000 --- a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsIT.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 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.personality_insights.v3; - -import com.google.common.io.CharStreams; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.personality_insights.v3.model.ConsumptionPreferences; -import com.ibm.watson.personality_insights.v3.model.Content; -import com.ibm.watson.personality_insights.v3.model.ContentItem; -import com.ibm.watson.personality_insights.v3.model.Profile; -import com.ibm.watson.personality_insights.v3.model.ProfileOptions; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Collections; -import java.util.Date; -import java.util.UUID; - -/** - * Personality Insights Integration Tests. - * @version v3 - */ -public class PersonalityInsightsIT extends WatsonServiceTest { - - private static final String RESOURCE = "src/test/resources/personality_insights/"; - - private PersonalityInsights service; - private static final String VERSION = "2017-10-13"; - - /* - * (non-Javadoc) - * @see com.ibm.watson.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String apiKey = getProperty("personality_insights.apikey"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); - - Authenticator authenticator = new IamAuthenticator(apiKey); - service = new PersonalityInsights(VERSION, authenticator); - service.setServiceUrl(getProperty("personality_insights.url")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test example in Readme. - */ - @Test - public void testReadme() { - // PersonalityInsights service = new PersonalityInsights("2017-10-13"); - // service.setUsernameAndPassword("", ""); - - // Demo content from Moby Dick by Hermann Melville (Chapter 1) - String text = "Call me Ishmael. Some years ago-never mind how long precisely-having " - + "little or no money in my purse, and nothing particular to interest me on shore, " - + "I thought I would sail about a little and see the watery part of the world. " - + "It is a way I have of driving off the spleen and regulating the circulation. " - + "Whenever I find myself growing grim about the mouth; whenever it is a damp, " - + "drizzly November in my soul; whenever I find myself involuntarily pausing before " - + "coffin warehouses, and bringing up the rear of every funeral I meet; and especially " - + "whenever my hypos get such an upper hand of me, that it requires a strong moral " - + "principle to prevent me from deliberately stepping into the street, and methodically " - + "knocking people's hats off-then, I account it high time to get to sea as soon as I can. " - + "This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself " - + "upon his sword; I quietly take to the ship. There is nothing surprising in this. " - + "If they but knew it, almost all men in their degree, some time or other, cherish " - + "very nearly the same feelings towards the ocean with me. There now is your insular " - + "city of the Manhattoes, belted round by wharves as Indian isles by coral reefs-commerce surrounds " - + "it with her surf. Right and left, the streets take you waterward."; - - ProfileOptions options = new ProfileOptions.Builder().text(text).build(); - Profile profile = service.profile(options).execute().getResult(); - System.out.println(profile); - } - - /** - * Gets the profile with text. - * - * @throws Exception the exception - */ - @Test - public void getProfileWithText() throws Exception { - File file = new File(RESOURCE + "en.txt"); - String englishText = getStringFromInputStream(new FileInputStream(file)); - - ProfileOptions options = new ProfileOptions.Builder().text(englishText).build(); - Profile profile = service.profile(options).execute().getResult(); - - Assert.assertNotNull(profile); - Assert.assertNotNull(profile.getProcessedLanguage()); - Assert.assertNotNull(profile.getValues()); - Assert.assertNotNull(profile.getNeeds()); - Assert.assertNotNull(profile.getPersonality()); - } - - /** - * Gets the profile with text as a CSV string without headers. - * - * @throws Exception the exception - */ - @Test - public void getProfileWithTextAsCSVNoHeaders() throws Exception { - File file = new File(RESOURCE + "en.txt"); - String englishText = getStringFromInputStream(new FileInputStream(file)); - - ProfileOptions options = new ProfileOptions.Builder().text(englishText).build(); - InputStream result = service.profileAsCsv(options).execute().getResult(); - String profileString = CharStreams.toString(new InputStreamReader(result, "UTF-8")); - - Assert.assertNotNull(profileString); - Assert.assertTrue(profileString.split("\n").length == 1); - } - - /** - * Gets the profile with text as a CSV string with headers. - * - * @throws Exception the exception - */ - @Test - public void getProfileWithTextAsCSVWithHeaders() throws Exception { - File file = new File(RESOURCE + "en.txt"); - String englishText = getStringFromInputStream(new FileInputStream(file)); - - ProfileOptions options = new ProfileOptions.Builder().text(englishText).csvHeaders(true).build(); - InputStream result = service.profileAsCsv(options).execute().getResult(); - String profileString = CharStreams.toString(new InputStreamReader(result, "UTF-8")); - - Assert.assertNotNull(profileString); - Assert.assertTrue(profileString.split("\n").length == 2); - } - - /** - * Assert profile. - * - * @param profile the profile - */ - private void assertProfile(Profile profile) { - Assert.assertNotNull(profile); - Assert.assertNotNull(profile.getProcessedLanguage()); - Assert.assertNotNull(profile.getConsumptionPreferences()); - Assert.assertNotNull(profile.getValues()); - Assert.assertNotNull(profile.getNeeds()); - Assert.assertNotNull(profile.getPersonality()); - Assert.assertNotNull(profile.getPersonality().get(0).getRawScore()); - Assert.assertNotNull(profile.getWarnings()); - Assert.assertTrue(profile.getWordCount() > 0); - } - - /** - * Gets the profile from a single content item. - * - * @throws Exception the exception - */ - @Test - public void getProfileWithASingleContentItem() throws Exception { - File file = new File(RESOURCE + "en.txt"); - String englishText = getStringFromInputStream(new FileInputStream(file)); - - Long now = new Date().getTime(); - ContentItem cItem = new ContentItem.Builder(englishText) - .language(ContentItem.Language.EN) - .contenttype("text/plain") - .created(now) - .updated(now) - .id(UUID.randomUUID().toString()) - .forward(false) - .reply(false) - .parentid(null) - .build(); - Content content = new Content.Builder(Collections.singletonList(cItem)).build(); - ProfileOptions options = new ProfileOptions.Builder() - .content(content) - .consumptionPreferences(true) - .acceptLanguage(ProfileOptions.AcceptLanguage.EN) - .rawScores(true) - .build(); - Profile profile = service.profile(options).execute().getResult(); - - assertProfile(profile); - - Assert.assertTrue(profile.getValues().size() > 0); - Assert.assertNotNull(profile.getValues().get(0).getCategory()); - Assert.assertNotNull(profile.getValues().get(0).getName()); - Assert.assertNotNull(profile.getValues().get(0).getTraitId()); - Assert.assertNotNull(profile.getValues().get(0).getPercentile()); - Assert.assertNotNull(profile.getValues().get(0).getRawScore()); - - Assert.assertNotNull(profile.getBehavior()); - Assert.assertTrue(profile.getBehavior().size() > 0); - Assert.assertNotNull(profile.getBehavior().get(0).getCategory()); - Assert.assertNotNull(profile.getBehavior().get(0).getName()); - Assert.assertNotNull(profile.getBehavior().get(0).getTraitId()); - Assert.assertNotNull(profile.getBehavior().get(0).getPercentage()); - - Assert.assertTrue(profile.getConsumptionPreferences().size() > 0); - Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getName()); - Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getConsumptionPreferenceCategoryId()); - Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getConsumptionPreferences()); - Assert.assertTrue(profile.getConsumptionPreferences().get(0).getConsumptionPreferences().size() > 0); - ConsumptionPreferences preference = profile.getConsumptionPreferences().get(0).getConsumptionPreferences().get(0); - Assert.assertNotNull(preference.getConsumptionPreferenceId()); - Assert.assertNotNull(preference.getName()); - Assert.assertNotNull(preference.getScore()); - } - - /** - * Gets the profile from a single content item in Spanish. - * - * @throws Exception the exception - */ - @Test - public void getProfileWithASingleSpanishContentItem() throws Exception { - File file = new File(RESOURCE + "es.txt"); - String englishText = getStringFromInputStream(new FileInputStream(file)); - - ContentItem cItem = new ContentItem.Builder(englishText) - .language(ContentItem.Language.ES) - .build(); - Content content = new Content.Builder() - .contentItems(Collections.singletonList(cItem)) - .build(); - ProfileOptions options = new ProfileOptions.Builder() - .content(content) - .consumptionPreferences(true) - .rawScores(true) - .build(); - Profile profile = service.profile(options).execute().getResult(); - - assertProfile(profile); - } - - /** - * Gets the profile from a list of content items. - * - * @throws Exception the exception - */ - @Test - public void getProfileWithContentItems() throws Exception { - final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class); - ProfileOptions options = new ProfileOptions.Builder() - .content(content) - .consumptionPreferences(true) - .rawScores(true) - .build(); - - Profile profile = service.profile(options).execute().getResult(); - assertProfile(profile); - } -} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java deleted file mode 100644 index 9c0fade4c62..00000000000 --- a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 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.personality_insights.v3; - -import com.ibm.cloud.sdk.core.http.HttpHeaders; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.personality_insights.v3.model.Content; -import com.ibm.watson.personality_insights.v3.model.ContentItem; -import com.ibm.watson.personality_insights.v3.model.Profile; -import com.ibm.watson.personality_insights.v3.model.ProfileOptions; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.FileNotFoundException; -import java.util.Date; -import java.util.UUID; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -/** - * PersonalityInsights Unit Test v3. - * - */ -public class PersonalityInsightsTest extends WatsonServiceUnitTest { - - private static final String RESOURCE = "src/test/resources/personality_insights/"; - private static final String PROFILE_PATH = "/v3/profile"; - private static final String VERSION_DATE_2016_10_19 = "2017-10-13"; - private String text; - private PersonalityInsights service; - private Profile profile; - private ContentItem contentItem; - - /** - * Instantiates a new personality insights test. - * - * @throws FileNotFoundException the file not found exception - */ - public PersonalityInsightsTest() throws FileNotFoundException { - profile = loadFixture(RESOURCE + "profile.json", Profile.class); - text = "foo-bar-text"; - contentItem = new ContentItem.Builder().content(text).build(); - } - - /* - * (non-Javadoc) - * @see com.ibm.watson.watson.developer_cloud.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new PersonalityInsights(VERSION_DATE_2016_10_19, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new PersonalityInsights(null, new NoAuthAuthenticator()); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new PersonalityInsights("", new NoAuthAuthenticator()); - } - - /** - * Test get profile with content. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetProfileWithContent() throws InterruptedException { - final Content content = new Content.Builder() - .addContentItem(contentItem) - .build(); - final ProfileOptions options = new ProfileOptions.Builder().content(content).build(); - - server.enqueue(jsonResponse(profile)); - final Profile profile = service.profile(options).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2017-10-13", request.getPath()); - assertEquals("POST", request.getMethod()); - assertNotNull(profile); - assertEquals(this.profile, profile); - } - - /** - * Test load a content from a file. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testLoadAContentFromAFile() throws InterruptedException, FileNotFoundException { - final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class); - assertNotNull(content); - } - - /** - * Test content builders. - */ - @Test - public void testContentBuilders() { - final String content1 = "Wow, I liked @TheRock before , now I really SEE how special he is. " - + "The daughter story was IT for me. So great! #MasterClass"; - final String content2 = "Wow aren't you loving @TheRock and his candor? #Masterclass"; - Long now = new Date().getTime(); - final ContentItem cItem1 = new ContentItem.Builder(content1) - .language(ContentItem.Language.EN) - .contenttype("text/plain") - .created(now) - .updated(now) - .id(UUID.randomUUID().toString()) - .forward(false) - .reply(false) - .parentid(null) - .build(); - ContentItem cItem2 = cItem1.newBuilder() - .content(content2) - .id(UUID.randomUUID().toString()) - .build(); - assertEquals(cItem2.contenttype(), "text/plain"); - assertEquals(cItem2.created(), now); - assertEquals(cItem2.updated(), now); - assertNotEquals(cItem1.id(), cItem2.id()); - final Content content = new Content.Builder() - .addContentItem(cItem1) - .addContentItem(cItem2) - .build(); - assertEquals(content.contentItems().size(), 2); - final Content newContent = content.newBuilder().build(); - assertEquals(newContent.contentItems().size(), 2); - } - - /** - * Test get profile with English text. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetProfileWithEnglishText() throws InterruptedException { - final ProfileOptions options = new ProfileOptions.Builder() - .text(text) - .contentLanguage(ProfileOptions.ContentLanguage.EN) - .build(); - - server.enqueue(jsonResponse(profile)); - final Profile profile = service.profile(options).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2017-10-13", request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals("en", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); - assertEquals(HttpMediaType.TEXT_PLAIN, request.getHeader(HttpHeaders.CONTENT_TYPE)); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(profile); - assertEquals(this.profile, profile); - } - - /** - * Test get profile with spanish text. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetProfileWithSpanishText() throws InterruptedException { - final ProfileOptions options = new ProfileOptions.Builder() - .text(text) - .contentLanguage(ProfileOptions.ContentLanguage.ES) - .consumptionPreferences(true) - .rawScores(true) - .build(); - - server.enqueue(jsonResponse(profile)); - final Profile profile = service.profile(options).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2017-10-13&raw_scores=true&consumption_preferences=true", request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals("es", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); - assertEquals(HttpMediaType.TEXT_PLAIN, request.getHeader(HttpHeaders.CONTENT_TYPE)); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(profile); - assertEquals(profile, this.profile); - } - - /** - * Test profile options builders. - */ - @Test - public void testProfileBuilders() { - final ProfileOptions options = new ProfileOptions.Builder() - .html(text) - .contentLanguage(ProfileOptions.ContentLanguage.ES) - .acceptLanguage(ProfileOptions.AcceptLanguage.EN) - .build(); - final ProfileOptions newOptions = options.newBuilder().build(); - assertEquals(newOptions.body(), text); - assertEquals(newOptions.contentLanguage(), ProfileOptions.ContentLanguage.ES); - assertEquals(newOptions.acceptLanguage(), ProfileOptions.AcceptLanguage.EN); - } -} diff --git a/personality-insights/src/test/resources/personality_insights/contentItems.json b/personality-insights/src/test/resources/personality_insights/contentItems.json deleted file mode 100644 index 5516619e5ce..00000000000 --- a/personality-insights/src/test/resources/personality_insights/contentItems.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "contentItems": [ - { - "content": "Wow, I liked @TheRock before , now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - }, - { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en", - "sourceid": "Twitter API", - "userid": "@Oprah" - } - ] -} diff --git a/personality-insights/src/test/resources/personality_insights/en.txt b/personality-insights/src/test/resources/personality_insights/en.txt deleted file mode 100644 index 8b72b8ffa07..00000000000 --- a/personality-insights/src/test/resources/personality_insights/en.txt +++ /dev/null @@ -1,53 +0,0 @@ -Vice President Johnson, Mr. Speaker, Mr. Chief Justice, President Eisenhower, Vice President Nixon, President Truman, Reverend Clergy, fellow citizens: We observe today not a victory of party but a celebration of freedom--symbolizing an end as well as a beginning--signifying renewal as well as change. For I have sworn before you and Almighty God the same solemn oath our forbears prescribed nearly a century and three-quarters ago. - -The world is very different now. For man holds in his mortal hands the power to abolish all forms of human poverty and all forms of human life. And yet the same revolutionary beliefs for which our forebears fought are still at issue around the globe--the belief that the rights of man come not from the generosity of the state but from the hand of God. - -We dare not forget today that we are the heirs of that first revolution. Let the word go forth from this time and place, to friend and foe alike, that the torch has been passed to a new generation of Americans--born in this century, tempered by war, disciplined by a hard and bitter peace, proud of our ancient heritage--and unwilling to witness or permit the slow undoing of those human rights to which this nation has always been committed, and to which we are committed today at home and around the world. - -Let every nation know, whether it wishes us well or ill, that we shall pay any price, bear any burden, meet any hardship, support any friend, oppose any foe to assure the survival and the success of liberty. - -This much we pledge--and more. - -To those old allies whose cultural and spiritual origins we share, we pledge the loyalty of faithful friends. United there is little we cannot do in a host of cooperative ventures. Divided there is little we can do--for we dare not meet a powerful challenge at odds and split asunder. - -To those new states whom we welcome to the ranks of the free, we pledge our word that one form of colonial control shall not have passed away merely to be replaced by a far more iron tyranny. We shall not always expect to find them supporting our view. But we shall always hope to find them strongly supporting their own freedom--and to remember that, in the past, those who foolishly sought power by riding the back of the tiger ended up inside. - -To those people in the huts and villages of half the globe struggling to break the bonds of mass misery, we pledge our best efforts to help them help themselves, for whatever period is required--not because the communists may be doing it, not because we seek their votes, but because it is right. If a free society cannot help the many who are poor, it cannot save the few who are rich. - -To our sister republics south of our border, we offer a special pledge--to convert our good words into good deeds--in a new alliance for progress--to assist free men and free governments in casting off the chains of poverty. But this peaceful revolution of hope cannot become the prey of hostile powers. Let all our neighbors know that we shall join with them to oppose aggression or subversion anywhere in the Americas. And let every other power know that this Hemisphere intends to remain the master of its own house. - -To that world assembly of sovereign states, the United Nations, our last best hope in an age where the instruments of war have far outpaced the instruments of peace, we renew our pledge of support--to prevent it from becoming merely a forum for invective--to strengthen its shield of the new and the weak--and to enlarge the area in which its writ may run. - -Finally, to those nations who would make themselves our adversary, we offer not a pledge but a request: that both sides begin anew the quest for peace, before the dark powers of destruction unleashed by science engulf all humanity in planned or accidental self-destruction. - -We dare not tempt them with weakness. For only when our arms are sufficient beyond doubt can we be certain beyond doubt that they will never be employed. - -But neither can two great and powerful groups of nations take comfort from our present course--both sides overburdened by the cost of modern weapons, both rightly alarmed by the steady spread of the deadly atom, yet both racing to alter that uncertain balance of terror that stays the hand of mankind's final war. - -So let us begin anew--remembering on both sides that civility is not a sign of weakness, and sincerity is always subject to proof. Let us never negotiate out of fear. But let us never fear to negotiate. - -Let both sides explore what problems unite us instead of belaboring those problems which divide us. - -Let both sides, for the first time, formulate serious and precise proposals for the inspection and control of arms--and bring the absolute power to destroy other nations under the absolute control of all nations. - -Let both sides seek to invoke the wonders of science instead of its terrors. Together let us explore the stars, conquer the deserts, eradicate disease, tap the ocean depths and encourage the arts and commerce. - -Let both sides unite to heed in all corners of the earth the command of Isaiah--to "undo the heavy burdens . . . (and) let the oppressed go free." - -And if a beachhead of cooperation may push back the jungle of suspicion, let both sides join in creating a new endeavor, not a new balance of power, but a new world of law, where the strong are just and the weak secure and the peace preserved. - -All this will not be finished in the first one hundred days. Nor will it be finished in the first one thousand days, nor in the life of this Administration, nor even perhaps in our lifetime on this planet. But let us begin. - -In your hands, my fellow citizens, more than mine, will rest the final success or failure of our course. Since this country was founded, each generation of Americans has been summoned to give testimony to its national loyalty. The graves of young Americans who answered the call to service surround the globe. - -Now the trumpet summons us again--not as a call to bear arms, though arms we need--not as a call to battle, though embattled we are-- but a call to bear the burden of a long twilight struggle, year in and year out, "rejoicing in hope, patient in tribulation"--a struggle against the common enemies of man: tyranny, poverty, disease and war itself. - -Can we forge against these enemies a grand and global alliance, North and South, East and West, that can assure a more fruitful life for all mankind? Will you join in that historic effort? - -In the long history of the world, only a few generations have been granted the role of defending freedom in its hour of maximum danger. I do not shrink from this responsibility--I welcome it. I do not believe that any of us would exchange places with any other people or any other generation. The energy, the faith, the devotion which we bring to this endeavor will light our country and all who serve it--and the glow from that fire can truly light the world. - -And so, my fellow Americans: ask not what your country can do for you--ask what you can do for your country. - -My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man. - -Finally, whether you are citizens of America or citizens of the world, ask of us here the same high standards of strength and sacrifice which we ask of you. With a good conscience our only sure reward, with history the final judge of our deeds, let us go forth to lead the land we love, asking His blessing and His help, but knowing that here on earth God's work must truly be our own. diff --git a/personality-insights/src/test/resources/personality_insights/es.txt b/personality-insights/src/test/resources/personality_insights/es.txt deleted file mode 100644 index a1c388451d8..00000000000 --- a/personality-insights/src/test/resources/personality_insights/es.txt +++ /dev/null @@ -1,23 +0,0 @@ -En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que vivía un hidalgo de los de lanza en astillero, adarga antigua, rocín flaco y galgo corredor. Una olla de algo más vaca que carnero, salpicón las más noches, duelos y quebrantos los sábados, lantejas los viernes, algún palomino de añadidura los domingos, consumían las tres partes de su hacienda. El resto della concluían sayo de velarte, calzas de velludo para las fiestas, con sus pantuflos de lo mesmo, y los días de entresemana se honraba con su vellorí de lo más fino. Tenía en su casa una ama que pasaba de los cuarenta, y una sobrina que no llegaba a los veinte, y un mozo de campo y plaza, que así ensillaba el rocín como tomaba la podadera. Frisaba la edad de nuestro hidalgo con los cincuenta años; era de complexión recia, seco de carnes, enjuto de rostro, gran madrugador y amigo de la caza. Quieren decir que tenía el sobrenombre de Quijada, o Quesada, que en esto hay alguna diferencia en los autores que deste caso escriben; aunque, por conjeturas verosímiles, se deja entender que se llamaba Quejana. Pero esto importa poco a nuestro cuento; basta que en la narración dél no se salga un punto de la verdad. - -Es, pues, de saber que este sobredicho hidalgo, los ratos que estaba ocioso, que eran los más del año, se daba a leer libros de caballerías, con tanta afición y gusto, que olvidó casi de todo punto el ejercicio de la caza, y aun la administración de su hacienda. Y llegó a tanto su curiosidad y desatino en esto, que vendió muchas hanegas de tierra de sembradura para comprar libros de caballerías en que leer, y así, llevó a su casa todos cuantos pudo haber dellos; y de todos, ningunos le parecían tan bien como los que compuso el famoso Feliciano de Silva, porque la claridad de su prosa y aquellas entricadas razones suyas le parecían de perlas, y más cuando llegaba a leer aquellos requiebros y cartas de desafíos, donde en muchas partes hallaba escrito: La razón de la sinrazón que a mi razón se hace, de tal manera mi razón enflaquece, que con razón me quejo de la vuestra fermosura. Y también cuando leía: ...los altos cielos que de vuestra divinidad divinamente con las estrellas os fortifican, y os hacen merecedora del merecimiento que merece la vuestra grandeza. - -Con estas razones perdía el pobre caballero el juicio, y desvelábase por entenderlas y desentrañarles el sentido, que no se lo sacara ni las entendiera el mesmo Aristóteles, si resucitara para sólo ello. No estaba muy bien con las heridas que don Belianís daba y recebía, porque se imaginaba que, por grandes maestros que le hubiesen curado, no dejaría de tener el rostro y todo el cuerpo lleno de cicatrices y señales. Pero, con todo, alababa en su autor aquel acabar su libro con la promesa de aquella inacabable aventura, y muchas veces le vino deseo de tomar la pluma y dalle fin al pie de la letra, como allí se promete; y sin duda alguna lo hiciera, y aun saliera con ello, si otros mayores y continuos pensamientos no se lo estorbaran. Tuvo muchas veces competencia con el cura de su lugar —que era hombre docto, graduado en Sigüenza—, sobre cuál había sido mejor caballero: Palmerín de Ingalaterra o Amadís de Gaula; mas maese Nicolás, barbero del mesmo pueblo, decía que ninguno llegaba al Caballero del Febo, y que si alguno se le podía comparar, era don Galaor, hermano de Amadís de Gaula, porque tenía muy acomodada condición para todo; que no era caballero melindroso, ni tan llorón como su hermano, y que en lo de la valentía no le iba en zaga. - -En resolución, él se enfrascó tanto en su letura, que se le pasaban las noches leyendo de claro en claro, y los días de turbio en turbio; y así, del poco dormir y del mucho leer, se le secó el celebro, de manera que vino a perder el juicio. Llenósele la fantasía de todo aquello que leía en los libros, así de encantamentos como de pendencias, batallas, desafíos, heridas, requiebros, amores, tormentas y disparates imposibles; y asentósele de tal modo en la imaginación que era verdad toda aquella máquina de aquellas sonadas soñadas invenciones que leía, que para él no había otra historia más cierta en el mundo. Decía él que el Cid Ruy Díaz había sido muy buen caballero, pero que no tenía que ver con el Caballero de la Ardiente Espada, que de sólo un revés había partido por medio dos fieros y descomunales gigantes. Mejor estaba con Bernardo del Carpio, porque en Roncesvalles había muerto a Roldán el encantado, valiéndose de la industria de Hércules, cuando ahogó a Anteo, el hijo de la Tierra, entre los brazos. Decía mucho bien del gigante Morgante, porque, con ser de aquella generación gigantea, que todos son soberbios y descomedidos, él solo era afable y bien criado. Pero, sobre todos, estaba bien con Reinaldos de Montalbán, y más cuando le veía salir de su castillo y robar cuantos topaba, y cuando en allende robó aquel ídolo de Mahoma que era todo de oro, según dice su historia. Diera él, por dar una mano de coces al traidor de Galalón, al ama que tenía, y aun a su sobrina de añadidura. - -En efeto, rematado ya su juicio, vino a dar en el más estraño pensamiento que jamás dio loco en el mundo; y fue que le pareció convenible y necesario, así para el aumento de su honra como para el servicio de su república, hacerse caballero andante, y irse por todo el mundo con sus armas y caballo a buscar las aventuras y a ejercitarse en todo aquello que él había leído que los caballeros andantes se ejercitaban, deshaciendo todo género de agravio, y poniéndose en ocasiones y peligros donde, acabándolos, cobrase eterno nombre y fama. Imaginábase el pobre ya coronado por el valor de su brazo, por lo menos, del imperio de Trapisonda; y así, con estos tan agradables pensamientos, llevado del estraño gusto que en ellos sentía, se dio priesa a poner en efeto lo que deseaba. - -Y lo primero que hizo fue limpiar unas armas que habían sido de sus bisabuelos, que, tomadas de orín y llenas de moho, luengos siglos había que estaban puestas y olvidadas en un rincón. Limpiólas y aderezólas lo mejor que pudo, pero vio que tenían una gran falta, y era que no tenían celada de encaje, sino morrión simple; mas a esto suplió su industria, porque de cartones hizo un modo de media celada, que, encajada con el morrión, hacían una apariencia de celada entera. Es verdad que para probar si era fuerte y podía estar al riesgo de una cuchillada, sacó su espada y le dio dos golpes, y con el primero y en un punto deshizo lo que había hecho en una semana; y no dejó de parecerle mal la facilidad con que la había hecho pedazos, y, por asegurarse deste peligro, la tornó a hacer de nuevo, poniéndole unas barras de hierro por de dentro, de tal manera que él quedó satisfecho de su fortaleza; y, sin querer hacer nueva experiencia della, la diputó y tuvo por celada finísima de encaje. - -Fue luego a ver su rocín, y, aunque tenía más cuartos que un real y más tachas que el caballo de Gonela, que tantum pellis et ossa fuit, le pareció que ni el Bucéfalo de Alejandro ni Babieca el del Cid con él se igualaban. Cuatro días se le pasaron en imaginar qué nombre le pondría; porque, según se decía él a sí mesmo, no era razón que caballo de caballero tan famoso, y tan bueno él por sí, estuviese sin nombre conocido; y ansí, procuraba acomodársele de manera que declarase quién había sido, antes que fuese de caballero andante, y lo que era entonces; pues estaba muy puesto en razón que, mudando su señor estado, mudase él también el nombre, y le cobrase famoso y de estruendo, como convenía a la nueva orden y al nuevo ejercicio que ya profesaba. Y así, después de muchos nombres que formó, borró y quitó, añadió, deshizo y tornó a hacer en su memoria e imaginación, al fin le vino a llamar Rocinante: nombre, a su parecer, alto, sonoro y significativo de lo que había sido cuando fue rocín, antes de lo que ahora era, que era antes y primero de todos los rocines del mundo. - -Puesto nombre, y tan a su gusto, a su caballo, quiso ponérsele a sí mismo, y en este pensamiento duró otros ocho días, y al cabo se vino a llamar don Quijote; de donde —como queda dicho— tomaron ocasión los autores desta tan verdadera historia que, sin duda, se debía de llamar Quijada, y no Quesada, como otros quisieron decir. Pero, acordándose que el valeroso Amadís no sólo se había contentado con llamarse Amadís a secas, sino que añadió el nombre de su reino y patria, por Hepila famosa, y se llamó Amadís de Gaula, así quiso, como buen caballero, añadir al suyo el nombre de la suya y llamarse don Quijote de la Mancha, con que, a su parecer, declaraba muy al vivo su linaje y patria, y la honraba con tomar el sobrenombre della. - -Limpias, pues, sus armas, hecho del morrión celada, puesto nombre a su rocín y confirmándose a sí mismo, se dio a entender que no le faltaba otra cosa sino buscar una dama de quien enamorarse; porque el caballero andante sin amores era árbol sin hojas y sin fruto y cuerpo sin alma. Decíase él a sí: - -— Si yo, por malos de mis pecados, o por mi buena suerte, me encuentro por ahí con algún gigante, como de ordinario les acontece a los caballeros andantes, y le derribo de un encuentro, o le parto por mitad del cuerpo, o, finalmente, le venzo y le rindo, ¿no será bien tener a quien enviarle presentado y que entre y se hinque de rodillas ante mi dulce señora, y diga con voz humilde y rendido: ''Yo, señora, soy el gigante Caraculiambro, señor de la ínsula Malindrania, a quien venció en singular batalla el jamás como se debe alabado caballero don Quijote de la Mancha, el cual me mandó que me presentase ante vuestra merced, para que la vuestra grandeza disponga de mí a su talante''? - -¡Oh, cómo se holgó nuestro buen caballero cuando hubo hecho este discurso, y más cuando halló a quien dar nombre de su dama! Y fue, a lo que se cree, que en un lugar cerca del suyo había una moza labradora de muy buen parecer, de quien él un tiempo anduvo enamorado, aunque, según se entiende, ella jamás lo supo, ni le dio cata dello. Llamábase Aldonza Lorenzo, y a ésta le pareció ser bien darle título de señora de sus pensamientos; y, buscándole nombre que no desdijese mucho del suyo, y que tirase y se encaminase al de princesa y gran señora, vino a llamarla Dulcinea del Toboso, porque era natural del Toboso; nombre, a su parecer, músico y peregrino y significativo, como todos los demás que a él y a sus cosas había puesto. - - diff --git a/personality-insights/src/test/resources/personality_insights/profile.json b/personality-insights/src/test/resources/personality_insights/profile.json deleted file mode 100644 index e7a07a853a1..00000000000 --- a/personality-insights/src/test/resources/personality_insights/profile.json +++ /dev/null @@ -1 +0,0 @@ -{"tree":{"id":"r","name":"root","children":[{"id":"personality","name":"Big 5 ","children":[{"id":"Conscientiousness_parent","name":"Conscientiousness","category":"personality","percentage":0.33196099249408345,"children":[{"id":"Openness","name":"Openness","category":"personality","percentage":0.3943175774676941,"children":[{"id":"Adventurousness","name":"Adventurousness","category":"personality","percentage":0.31016692670057167},{"id":"Artistic interests","name":"Artistic interests","category":"personality","percentage":0.41615621459225915},{"id":"Emotionality","name":"Emotionality","category":"personality","percentage":0.6706714934238305},{"id":"Imagination","name":"Imagination","category":"personality","percentage":0.45036152391563694},{"id":"Intellect","name":"Intellect","category":"personality","percentage":0.39999961312246946},{"id":"Liberalism","name":"Authority-challenging","category":"personality","percentage":0.42958961724312744}]},{"id":"Conscientiousness","name":"Conscientiousness","category":"personality","percentage":0.33196099249408345,"children":[{"id":"Achievement striving","name":"Achievement striving","category":"personality","percentage":0.2781740634421541},{"id":"Cautiousness","name":"Cautiousness","category":"personality","percentage":0.3647256147520063},{"id":"Dutifulness","name":"Dutifulness","category":"personality","percentage":0.30250197735019363},{"id":"Orderliness","name":"Orderliness","category":"personality","percentage":0.578630034993974},{"id":"Self-discipline","name":"Self-discipline","category":"personality","percentage":0.24123239247545317},{"id":"Self-efficacy","name":"Self-efficacy","category":"personality","percentage":0.4829314931866885}]},{"id":"Extraversion","name":"Extraversion","category":"personality","percentage":0.584351049273549,"children":[{"id":"Activity level","name":"Activity level","category":"personality","percentage":0.19257712361664267},{"id":"Assertiveness","name":"Assertiveness","category":"personality","percentage":0.5745155179088401},{"id":"Cheerfulness","name":"Cheerfulness","category":"personality","percentage":0.6126869017060572},{"id":"Excitement-seeking","name":"Excitement-seeking","category":"personality","percentage":0.627022957297767},{"id":"Friendliness","name":"Outgoing","category":"personality","percentage":0.4649023682376607},{"id":"Gregariousness","name":"Gregariousness","category":"personality","percentage":0.4140581200019064}]},{"id":"Agreeableness","name":"Agreeableness","category":"personality","percentage":0.5181453025000275,"children":[{"id":"Altruism","name":"Altruism","category":"personality","percentage":0.42191038915039697},{"id":"Cooperation","name":"Cooperation","category":"personality","percentage":0.37188211366494556},{"id":"Modesty","name":"Modesty","category":"personality","percentage":0.26261973716060216},{"id":"Morality","name":"Uncompromising","category":"personality","percentage":0.4046808781439222},{"id":"Sympathy","name":"Sympathy","category":"personality","percentage":0.485698211561829},{"id":"Trust","name":"Trust","category":"personality","percentage":0.3585475603606466}]},{"id":"Neuroticism","name":"Emotional range","category":"personality","percentage":0.6618472083481735,"children":[{"id":"Anger","name":"Fiery","category":"personality","percentage":0.6933563383056146},{"id":"Anxiety","name":"Prone to worry","category":"personality","percentage":0.6304062609962424},{"id":"Depression","name":"Melancholy","category":"personality","percentage":0.5521049691464847},{"id":"Immoderation","name":"Immoderation","category":"personality","percentage":0.6542057156341358},{"id":"Self-consciousness","name":"Self-consciousness","category":"personality","percentage":0.6057272200567346},{"id":"Vulnerability","name":"Susceptible to stress","category":"personality","percentage":0.6382304941375857}]}]}]},{"id":"needs","name":"Needs","children":[{"id":"Self-expression_parent","name":"Self-expression","category":"needs","percentage":0.3361111216480506,"children":[{"id":"Challenge","name":"Challenge","category":"needs","percentage":0.5585352942755961},{"id":"Closeness","name":"Closeness","category":"needs","percentage":0.6366885720227188},{"id":"Curiosity","name":"Curiosity","category":"needs","percentage":0.617138558527205},{"id":"Excitement","name":"Excitement","category":"needs","percentage":0.6379315213607226},{"id":"Harmony","name":"Harmony","category":"needs","percentage":0.6452290677514632},{"id":"Ideal","name":"Ideal","category":"needs","percentage":0.5438595598193225},{"id":"Liberty","name":"Liberty","category":"needs","percentage":0.6193503585456331},{"id":"Love","name":"Love","category":"needs","percentage":0.6284877987753178},{"id":"Practicality","name":"Practicality","category":"needs","percentage":0.6467869651877424},{"id":"Self-expression","name":"Self-expression","category":"needs","percentage":0.3361111216480506},{"id":"Stability","name":"Stability","category":"needs","percentage":0.6210489516434756},{"id":"Structure","name":"Structure","category":"needs","percentage":0.5403827678045097}]}]},{"id":"values","name":"Values","children":[{"id":"Conservation_parent","name":"Conservation","category":"values","percentage":0.15998391103263213,"children":[{"id":"Conservation","name":"Conservation","category":"values","percentage":0.15998391103263213},{"id":"Openness to change","name":"Openness to change","category":"values","percentage":0.8326435682814212},{"id":"Hedonism","name":"Hedonism","category":"values","percentage":0.5769070464816999},{"id":"Self-enhancement","name":"Self-enhancement","category":"values","percentage":0.42593626737806134},{"id":"Self-transcendence","name":"Self-transcendence","category":"values","percentage":0.6926862164239139}]}]},{"id":"sbh","name":"Social Behavior","category":"sbr","children":[{"id":"sbh_dom","name":"Tue. Evening","category":"sbr","children":[{"id":"Tuesday_parent","name":"Tue.","category":"behavior","percentage":0.1811909949164851,"children":[{"id":"Sunday","name":"Sunday","category":"behavior","percentage":0.11619462599854757},{"id":"Monday","name":"Monday","category":"behavior","percentage":0.1365286855482934},{"id":"Tuesday","name":"Tuesday","category":"behavior","percentage":0.1811909949164851},{"id":"Wednesday","name":"Wednesday","category":"behavior","percentage":0.13035584604212055},{"id":"Thursday","name":"Thursday","category":"behavior","percentage":0.14742193173565724},{"id":"Friday","name":"Friday","category":"behavior","percentage":0.1419753086419753},{"id":"Saturday","name":"Saturday","category":"behavior","percentage":0.14633260711692084}]},{"id":"8:00 pm_parent","name":"Evening (PST)","category":"behavior","percentage":0.09041394335511982,"children":[{"id":"0:00 am","name":"0:00 am","category":"behavior","percentage":0.007262164124909223},{"id":"1:00 am","name":"1:00 am","category":"behavior","percentage":0.0},{"id":"2:00 am","name":"2:00 am","category":"behavior","percentage":0.0},{"id":"3:00 am","name":"3:00 am","category":"behavior","percentage":3.6310820624546115E-4},{"id":"4:00 am","name":"4:00 am","category":"behavior","percentage":7.262164124909223E-4},{"id":"5:00 am","name":"5:00 am","category":"behavior","percentage":0.0014524328249818446},{"id":"6:00 am","name":"6:00 am","category":"behavior","percentage":0.0014524328249818446},{"id":"7:00 am","name":"7:00 am","category":"behavior","percentage":0.010167029774872912},{"id":"8:00 am","name":"8:00 am","category":"behavior","percentage":0.014887436456063908},{"id":"9:00 am","name":"9:00 am","category":"behavior","percentage":0.025417574437182282},{"id":"10:00 am","name":"10:00 am","category":"behavior","percentage":0.06172839506172839},{"id":"11:00 am","name":"11:00 am","category":"behavior","percentage":0.06790123456790123},{"id":"12:00 pm","name":"12:00 pm","category":"behavior","percentage":0.07153231663035585},{"id":"1:00 pm","name":"1:00 pm","category":"behavior","percentage":0.07262164124909223},{"id":"2:00 pm","name":"2:00 pm","category":"behavior","percentage":0.06427015250544663},{"id":"3:00 pm","name":"3:00 pm","category":"behavior","percentage":0.07915758896151052},{"id":"4:00 pm","name":"4:00 pm","category":"behavior","percentage":0.08097312999273784},{"id":"5:00 pm","name":"5:00 pm","category":"behavior","percentage":0.06899055918663761},{"id":"6:00 pm","name":"6:00 pm","category":"behavior","percentage":0.06790123456790123},{"id":"7:00 pm","name":"7:00 pm","category":"behavior","percentage":0.08496732026143791},{"id":"8:00 pm","name":"8:00 pm","category":"behavior","percentage":0.09041394335511982},{"id":"9:00 pm","name":"9:00 pm","category":"behavior","percentage":0.07044299201161947},{"id":"10:00 pm","name":"10:00 pm","category":"behavior","percentage":0.04103122730573711},{"id":"11:00 pm","name":"11:00 pm","category":"behavior","percentage":0.016339869281045753}]}]}]}]},"id":"1183041","source":"twitter","tweet_count":2754} \ No newline at end of file diff --git a/personality-insights/src/test/resources/personality_insights/v3-contentItems.json b/personality-insights/src/test/resources/personality_insights/v3-contentItems.json deleted file mode 100644 index 54bc5688a38..00000000000 --- a/personality-insights/src/test/resources/personality_insights/v3-contentItems.json +++ /dev/null @@ -1,5949 +0,0 @@ -{ - "contentItems": [{ - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }, { - "content": "The Pastor and Imam represent the possibility of PEACE in the world. If they can do it. We can. Peace to All\ud83d\ude4f\ud83c\udffe #Belief", - "contenttype": "text/plain", - "created": 1445302749000, - "id": "656273415280705536", - "language": "en" - }, { - "content": "We felt privileged to film the Hajj and explore the beauty of Islam.\n#99namesforGod #Belief", - "contenttype": "text/plain", - "created": 1445301110000, - "id": "656266540967424000", - "language": "en" - }, { - "content": "Do you all believe in \"soul mates\"?\n#Belief", - "contenttype": "text/plain", - "created": 1445300138000, - "id": "656262462426238976", - "language": "en" - }, { - "content": ".@RevEdBacon thank you so much for hosting tonight's #Belief at All Saints Church.", - "contenttype": "text/plain", - "created": 1445299749000, - "id": "656260832628756480", - "language": "en" - }, { - "content": "This is one of the best love stories I've ever seen. #belief Ian and Larissa showing us the depths of love.#Belief", - "contenttype": "text/plain", - "created": 1445299614000, - "id": "656260263604310016", - "language": "en" - }, { - "content": "Hey Everyone .. Tweeting from a bar in Atlanta with @SheriSalata OWN not in my hotel. Anything for #Belief", - "contenttype": "text/plain", - "created": 1445299326000, - "id": "656259057758654464", - "language": "en" - }, { - "content": "RT @joshuadubois: When you see Ian & Larissa tonight on #BELIEF, you'll know what Christian love is all about. 8pmET, @OWNTV. Tune in! http\u2026", - "contenttype": "text/plain", - "created": 1445295716000, - "id": "656243916224638976", - "language": "en" - }, { - "content": "RT @KimHaleDance: I Believe LAUGHTER. IS. CONTAGIOUS. What do you believe? See you tonight! 8\/7c.\u2764\ufe0f #Belief #Beliefin3words https:\/\/t.co\/x\u2026", - "contenttype": "text/plain", - "created": 1445295702000, - "id": "656243854610337793", - "language": "en" - }, { - "content": "RT @OWNTV: See the world through someone else\u2019s soul. The epic journey of #Belief continues tonight at 8\/7c.\nhttps:\/\/t.co\/UKKMHZuC0g", - "contenttype": "text/plain", - "created": 1445295668000, - "id": "656243714507931648", - "language": "en" - }, { - "content": "RT @OWNTV: Mendel Hurwitz's inquisitive nature grounded him in his faith. See where it's taken him now: https:\/\/t.co\/2iWmNOxK9r https:\/\/t.c\u2026", - "contenttype": "text/plain", - "created": 1445295661000, - "id": "656243684720050176", - "language": "en" - }, { - "content": "Thank you for opening up the heart space and letting #Belief in. Tonight it keeps getting better. See you at 8\/7c\nhttps:\/\/t.co\/E65vkTray9", - "contenttype": "text/plain", - "created": 1445279425000, - "id": "656175584943341568", - "language": "en" - }, { - "content": "I believe in the @weightwatchers program so much I decided to invest, join the Board, and partner in #wwfamily evolution.", - "contenttype": "text/plain", - "created": 1445275802000, - "id": "656160388526899200", - "language": "en" - }, { - "content": "RT @AVAETC: Debut episode of #BELIEF has now aired on both coasts. Trended for 4 hours. Brava, @Oprah + team. 6 beautiful nights to come. B\u2026", - "contenttype": "text/plain", - "created": 1445229489000, - "id": "655966138279432192", - "language": "en" - }, { - "content": "RT @3LWTV: 6 more epic nights of #Belief to come! See you tomorrow 8pET\/7pCT for the next installment! @OWNTV @Oprah", - "contenttype": "text/plain", - "created": 1445227342000, - "id": "655957135688241152", - "language": "en" - }, { - "content": "RT @ledisi: I love how Ancestry and Tradition is honored throughout every story in #Belief @OWNTV @OWN Thank you @Oprah this is so importa\u2026", - "contenttype": "text/plain", - "created": 1445225935000, - "id": "655951232981295104", - "language": "en" - }, { - "content": "RT @UN: Showing #Belief at the UN \"is a bigger dream than I had\" - @Oprah https:\/\/t.co\/VC4OqD8yub #Belief #GlobalGoals https:\/\/t.co\/LZyGuC7\u2026", - "contenttype": "text/plain", - "created": 1445225228000, - "id": "655948267868426240", - "language": "en" - }, { - "content": "RT @UzoAduba: To seek, to question, to learn, to teach, to pass it on; some of the breathtaking themes running like water throughout #Belie\u2026", - "contenttype": "text/plain", - "created": 1445225008000, - "id": "655947345197076480", - "language": "en" - }, { - "content": "RT @iamtikasumpter: #Belief had me in awe. Faith in the divine is the constant that links us together. It's all beautiful and righteous. Gi\u2026", - "contenttype": "text/plain", - "created": 1445224852000, - "id": "655946689249828864", - "language": "en" - }, { - "content": "West Coast... Here we go. #Belief", - "contenttype": "text/plain", - "created": 1445224140000, - "id": "655943701840048128", - "language": "en" - }, { - "content": "Big surprise at icanady watch party. Epic night. #Belief. So much more to come. https:\/\/t.co\/kBDtFwGyQs", - "contenttype": "text/plain", - "created": 1445220694000, - "id": "655929249669378048", - "language": "en" - }, { - "content": "I loved the Mendel story so much because it represents right of passasge. \" bye bye to childhood\".#Belief", - "contenttype": "text/plain", - "created": 1445215032000, - "id": "655905500056391682", - "language": "en" - }, { - "content": "RT @squee_machine: This is a visual feast! Completely gorgeous and I am transfixed. The colors, the composition, cinematography, vibe. #Bel\u2026", - "contenttype": "text/plain", - "created": 1445214538000, - "id": "655903432079904768", - "language": "en" - }, { - "content": "RT @JamesTyphany: Looking at @ #Belief I really needed this in my life thanks @OWNTV", - "contenttype": "text/plain", - "created": 1445214534000, - "id": "655903413385891840", - "language": "en" - }, { - "content": "Just surprised a \"watch party\" @icanady 's house. #Belief http:\/\/t.co\/Di0I3OooCh", - "contenttype": "text/plain", - "created": 1445214502000, - "id": "655903277796732931", - "language": "en" - }, { - "content": "RT @MsLaWandaa: I love moments of sitting among elders and learning. I can feel this moment was special for @ReshThakkar #Belief", - "contenttype": "text/plain", - "created": 1445214498000, - "id": "655903264374812672", - "language": "en" - }, { - "content": "RT @xonecole: \"Do you have to have religion or is being a good person...is that enough?\" #Belief", - "contenttype": "text/plain", - "created": 1445214339000, - "id": "655902594171203584", - "language": "en" - }, { - "content": "RT @ChivonJohn: Very inspired by the stories on #belief https:\/\/t.co\/uMRCCfCWcY", - "contenttype": "text/plain", - "created": 1445214327000, - "id": "655902545903140864", - "language": "en" - }, { - "content": "RT @KiranSArora: powerful personal story that many of us can connect to. searching for what's missing, spiritual liberation. @ReshThakkar #\u2026", - "contenttype": "text/plain", - "created": 1445214128000, - "id": "655901708506103812", - "language": "en" - }, { - "content": "RT @createdbyerica: \"I'm willing to go as far as I have to go to get that feeling in my heart of being connected to the Divine.\" - Reshma @\u2026", - "contenttype": "text/plain", - "created": 1445213967000, - "id": "655901033952993280", - "language": "en" - }, { - "content": "RT @UrbnHealthNP: I am enjoying this so much. #Belief", - "contenttype": "text/plain", - "created": 1445213904000, - "id": "655900772467474435", - "language": "en" - }, { - "content": "RT @DrMABrown: Your relationship with #belief can be completely different than how others experience it", - "contenttype": "text/plain", - "created": 1445213901000, - "id": "655900756604620800", - "language": "en" - }, { - "content": "RT @ckerfin: On another river on the other side of the world... transition between stories, drawing connections to different beliefs #Belie\u2026", - "contenttype": "text/plain", - "created": 1445213721000, - "id": "655900002644987905", - "language": "en" - }, { - "content": "RT @nikfarrior: So profound. We are all born into #Belief @Oprah @OWN @OWNTV", - "contenttype": "text/plain", - "created": 1445213706000, - "id": "655899942242775040", - "language": "en" - }, { - "content": "RT @fgaboys: @Oprah the start of #Belief is riveting and edifying. It makes you want more and inspires you too see what's coming up next. \u2026", - "contenttype": "text/plain", - "created": 1445213699000, - "id": "655899910563217408", - "language": "en" - }, { - "content": "RT @MalikaGhosh: Here we GO- let's lose ourselves #belief NOW @Oprah JOY http:\/\/t.co\/vYSNLd3LvC", - "contenttype": "text/plain", - "created": 1445212831000, - "id": "655896269542420480", - "language": "en" - }, { - "content": "RT @MastinKipp: .@Oprah and team are about to bring the Light with #Belief.", - "contenttype": "text/plain", - "created": 1445212747000, - "id": "655895916675600384", - "language": "en" - }, { - "content": "RT @GrowingOWN: 7 minutes, y'all! #BELIEF", - "contenttype": "text/plain", - "created": 1445212465000, - "id": "655894734968217600", - "language": "en" - }, { - "content": "RT @LPToussaint: BELIEF defines experience.Choose wisely #Belief Tonight on OWN", - "contenttype": "text/plain", - "created": 1445211845000, - "id": "655892134524878848", - "language": "en" - }, { - "content": "RT @TheBeBeWinans: Congratulations to my dear friend @Oprah on the launch of your series #BELIEF #Tonight on @OWNTV. Your friendship inspir\u2026", - "contenttype": "text/plain", - "created": 1445211835000, - "id": "655892094905532416", - "language": "en" - }, { - "content": "RT @UzoAduba: Thirty minutes to @Oprah #Belief. Pretty sure it's about to be our favorite thing.", - "contenttype": "text/plain", - "created": 1445211833000, - "id": "655892084314890240", - "language": "en" - }, { - "content": "RT @DeandresVoice: Moments away from the start of @SuperSoulSunday and the first night of the epic #Belief series on @OWNTV - are you ready\u2026", - "contenttype": "text/plain", - "created": 1445209201000, - "id": "655881046102142978", - "language": "en" - }, { - "content": "RT @jennaldewan: I CANT WAIT FOR THIS TONIGHT!!!!!! Got my popcorn, got my tissues I am readyyyyyy! #Belief https:\/\/t.co\/WluTdeEqal", - "contenttype": "text/plain", - "created": 1445209181000, - "id": "655880959535939584", - "language": "en" - }, { - "content": "RT @indiaarie: U heard about @Oprah passion project? It's called #Belief - I've see some & Its special! Tonight - 7c\/8e - 7 nights!! Whose\u2026", - "contenttype": "text/plain", - "created": 1445208945000, - "id": "655879970732949504", - "language": "en" - }, { - "content": "Wow, I liked @TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass", - "contenttype": "text/plain", - "created": 1447639154000, - "id": "666073008692314113", - "language": "en" - }, { - "content": ".@TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass", - "contenttype": "text/plain", - "created": 1447638226000, - "id": "666069114889179136", - "language": "en" - }, { - "content": ".@TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass", - "contenttype": "text/plain", - "created": 1447638067000, - "id": "666068446325665792", - "language": "en" - }, { - "content": "Wow aren't you loving @TheRock and his candor? #Masterclass", - "contenttype": "text/plain", - "created": 1447637459000, - "id": "666065895932973057", - "language": "en" - }, { - "content": "RT @patt_t: @TheRock @Oprah @RichOnOWN @OWNTV this interview makes me like you as a fellow human even more for being so real.", - "contenttype": "text/plain", - "created": 1447637030000, - "id": "666064097562247168", - "language": "en" - }, { - "content": "\"Be You\".. That's the best advice ever @TheRock #MastersClass", - "contenttype": "text/plain", - "created": 1447636205000, - "id": "666060637181644800", - "language": "en" - }, { - "content": "Supersoulers let's lift our spirits pray and hold Paris in the Light\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1447602477000, - "id": "665919171062927360", - "language": "en" - }, { - "content": "RT @DeepakChopra: What I learned in week 1: Become What You Believe 21-Day Meditation Experience - https:\/\/t.co\/kqaMaMqEUp #GoogleAlerts", - "contenttype": "text/plain", - "created": 1447098990000, - "id": "663807393063538688", - "language": "en" - }, { - "content": "Watching Bryan Stevenson on #SuperSoulSunday! \"You are not the worst mistake you ever made\".\nAren't we glad about that.", - "contenttype": "text/plain", - "created": 1446998643000, - "id": "663386507856736257", - "language": "en" - }, { - "content": ".@CherylStrayed BRAVE ENOUGH my new favorite thing! Gonna buy a copy for all my girls. #Perfectgift https:\/\/t.co\/gz1tnv8t8K", - "contenttype": "text/plain", - "created": 1446915955000, - "id": "663039689360695296", - "language": "en" - }, { - "content": "Stevie Wonder singing \"Happy Birthday to you!\" to my dear mariashriver. A phenomenal woman and\u2026 https:\/\/t.co\/Ygm5eDIs4f", - "contenttype": "text/plain", - "created": 1446881193000, - "id": "662893888080879616", - "language": "en" - }, { - "content": "It\u2019s my faaaaavorite time of the Year! For the first time you can shop the list on @amazon! https:\/\/t.co\/a6GMvVrhjN https:\/\/t.co\/sJlQMROq5U", - "contenttype": "text/plain", - "created": 1446744186000, - "id": "662319239844380672", - "language": "en" - }, { - "content": "Incredible story \"the spirit of the Lord is on you\" thanks for sharing @smokey_robinson #Masterclass", - "contenttype": "text/plain", - "created": 1446428929000, - "id": "660996956861280256", - "language": "en" - }, { - "content": "Wasnt that incredible story about @smokey_robinson 's dad leaving his family at 12. #MasterClass", - "contenttype": "text/plain", - "created": 1446426630000, - "id": "660987310889041920", - "language": "en" - }, { - "content": "Gayle, Charlie, Nora @CBSThisMorning Congratulations! #1000thshow", - "contenttype": "text/plain", - "created": 1446220097000, - "id": "660121050978611205", - "language": "en" - }, { - "content": "I believe your home should rise up to meet you. @TheEllenShow you nailed it with HOME. Tweethearts, grab a copy! https:\/\/t.co\/iFMnpRAsno", - "contenttype": "text/plain", - "created": 1446074433000, - "id": "659510090748182528", - "language": "en" - }, { - "content": "Can I get a Witness?!\u270b\ud83c\udffe https:\/\/t.co\/tZ1QyAeSdE", - "contenttype": "text/plain", - "created": 1445821114000, - "id": "658447593865945089", - "language": "en" - }, { - "content": ".@TheEllenShow you're a treasure.\nYour truth set a lot of people free.\n#Masterclass", - "contenttype": "text/plain", - "created": 1445821003000, - "id": "658447130026188800", - "language": "en" - }, { - "content": "Hope you all are enjoying @TheEllenShow on #MasterClass.", - "contenttype": "text/plain", - "created": 1445820161000, - "id": "658443598313181188", - "language": "en" - }, { - "content": ".@GloriaSteinem, shero to women everywhere, on how far we\u2019ve come and how far we need to go. #SuperSoulSunday 7p\/6c.\nhttps:\/\/t.co\/3e7oxXW02J", - "contenttype": "text/plain", - "created": 1445811545000, - "id": "658407457438363648", - "language": "en" - }, { - "content": "RT @TheEllenShow: I told a story from my @OWNTV's #MasterClass on my show. Normally I\u2019d save it all for Sunday, but @Oprah made me. https:\/\u2026", - "contenttype": "text/plain", - "created": 1445804181000, - "id": "658376572521459712", - "language": "en" - }, { - "content": ".@TheEllenShow is a master teacher of living her truth & living authentically as herself. #MasterClass tonight 8\/7c.\nhttps:\/\/t.co\/iLT2KgRsSw", - "contenttype": "text/plain", - "created": 1445804072000, - "id": "658376116575449088", - "language": "en" - }, { - "content": ".@SheriSalata , @jonnysinc @part2pictures . Tears of joy and gratitude to you and our entire #BeliefTeam We DID IT!! My heart is full.\ud83d\ude4f\ud83c\udffe\ud83d\ude4f\ud83c\udffe", - "contenttype": "text/plain", - "created": 1445734755000, - "id": "658085377140363264", - "language": "en" - }, { - "content": "Donna and Bob saw the tape of their story just days before she passed. They appreciated it. #RIPDonna", - "contenttype": "text/plain", - "created": 1445734097000, - "id": "658082618819280896", - "language": "en" - }, { - "content": "RT @rempower: .@Oprah this series allowed me to slide into people's lives around the world and see the same in them ... we all have a belie\u2026", - "contenttype": "text/plain", - "created": 1445732769000, - "id": "658077046858383360", - "language": "en" - }, { - "content": "All the stories moved me, My favorite line \" I must pass the stories on to my grandson otherwise our people will loose their way. #Belief", - "contenttype": "text/plain", - "created": 1445732579000, - "id": "658076253618991104", - "language": "en" - }, { - "content": ".@part2pictures some of your best imagery yet. Filming Alex on the rock.#Belief", - "contenttype": "text/plain", - "created": 1445731782000, - "id": "658072908237934592", - "language": "en" - }, { - "content": "I just love Alex and his daring #Belief to live fully the present Moment.", - "contenttype": "text/plain", - "created": 1445731561000, - "id": "658071980982206464", - "language": "en" - }, { - "content": "RT @GrowingOWN: Let's do this! #Belief finale tweet tweet party. Thank you @Oprah! \ud83d\ude4f", - "contenttype": "text/plain", - "created": 1445731248000, - "id": "658070668785770496", - "language": "en" - }, { - "content": "RT @lizkinnell: The epic finale of #Belief on @OWNTV is about to start. 8\/et Are you ready? What do you Believe?", - "contenttype": "text/plain", - "created": 1445731081000, - "id": "658069968534171648", - "language": "en" - }, { - "content": "Thank you all for another beautiful night of Belief. Belief runs all day tomorrow for bingers and final episode!", - "contenttype": "text/plain", - "created": 1445648630000, - "id": "657724143115202560", - "language": "en" - }, { - "content": "RT @OWNingLight: #Belief is the ultimate travel map to mass acceptance. \ud83d\ude4f\ud83c\udffb\u2764\ufe0f\ud83c\udf0d @Oprah", - "contenttype": "text/plain", - "created": 1445647285000, - "id": "657718501147197442", - "language": "en" - }, { - "content": "\" I can feel my heart opening and faith coming back in\".. What's better than that? #Belief", - "contenttype": "text/plain", - "created": 1445646903000, - "id": "657716901951369218", - "language": "en" - }, { - "content": "Hey Belief team mates can yo believe how quickly the week has passed? #Belief", - "contenttype": "text/plain", - "created": 1445645633000, - "id": "657711572492533760", - "language": "en" - }, { - "content": "Ran into @5SOS backstage. Fun times with @TheEllenShow today! https:\/\/t.co\/2PP3W3RzXc", - "contenttype": "text/plain", - "created": 1445618531000, - "id": "657597898394173440", - "language": "en" - }, { - "content": "Thanks All for another great night of #BELIEF", - "contenttype": "text/plain", - "created": 1445572548000, - "id": "657405031822430208", - "language": "en" - }, { - "content": "RT @3LWTV: #BecomeWhatYouBelieve New meditation w\/ @Oprah @DeepakChopra begins 11\/2 Register https:\/\/t.co\/x0R9HWTAX0 #Belief https:\/\/t.co\/\u2026", - "contenttype": "text/plain", - "created": 1445571500000, - "id": "657400636745510912", - "language": "en" - }, { - "content": "Ok west coast let's do it! #belief", - "contenttype": "text/plain", - "created": 1445569367000, - "id": "657391689439404033", - "language": "en" - }, { - "content": "Thank u kind gentleman who told me I had kale in my teeth. Was eating kale chips with Quincy Jones. Went straight to @LairdLife party.", - "contenttype": "text/plain", - "created": 1445569296000, - "id": "657391393883619328", - "language": "en" - }, { - "content": "Hello west coast twitterati.. See you at 8 for #Belief", - "contenttype": "text/plain", - "created": 1445566144000, - "id": "657378171872874496", - "language": "en" - }, { - "content": "Thank you all for another beautiful night.#Belief", - "contenttype": "text/plain", - "created": 1445475948000, - "id": "656999861254918145", - "language": "en" - }, { - "content": "RT @PRanganathan: \"Transformation is the rule of the game. The universe is not standing still.\" - Marcelo @OWNTV @Oprah #Belief", - "contenttype": "text/plain", - "created": 1445475602000, - "id": "656998409933451264", - "language": "en" - }, { - "content": "\"The Universe is not standing still.. The whole Universe is expanding\" I love the dance between science and spirituality! #Belief", - "contenttype": "text/plain", - "created": 1445475580000, - "id": "656998320133398528", - "language": "en" - }, { - "content": "\"Without our prayers and our songs we won't be here\" Apache leader.#Belief", - "contenttype": "text/plain", - "created": 1445473768000, - "id": "656990717504393216", - "language": "en" - }, { - "content": "Notice her mother crying. She knows its last tine she will ever see her daughter.#Belief", - "contenttype": "text/plain", - "created": 1445473150000, - "id": "656988127433637888", - "language": "en" - }, { - "content": "This final trial is unbelievable. Every hair gets pulled from her head one at a time. Now that is Something!!#Belief", - "contenttype": "text/plain", - "created": 1445473063000, - "id": "656987763644891136", - "language": "en" - }, { - "content": "\"What my faith gives me no one can match\"#Belief", - "contenttype": "text/plain", - "created": 1445472961000, - "id": "656987336266223616", - "language": "en" - }, { - "content": "It's a devotion to faith beyond anything Ive seen. Fascinating.Jain nuns. #Belief", - "contenttype": "text/plain", - "created": 1445472531000, - "id": "656985529951522816", - "language": "en" - }, { - "content": "I'd never heard of Jain monks and nuns before doing this series. #Belief", - "contenttype": "text/plain", - "created": 1445472393000, - "id": "656984953037586433", - "language": "en" - }, { - "content": "Good evening Team #Belief the Tweet is on!", - "contenttype": "text/plain", - "created": 1445472098000, - "id": "656983714883239937", - "language": "en" - }, { - "content": "Thanks everyone for another Epic #Belief night!", - "contenttype": "text/plain", - "created": 1445302792000, - "id": "656273592485810176", - "language": "en" - }] -} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000000..ec0c3bcbbee --- /dev/null +++ b/pom.xml @@ -0,0 +1,514 @@ + + 4.0.0 + + ibm-watson-parent + + IBM Watson Java SDK + + Java client library to use the IBM Watson APIs + + https://github.com/watson-developer-cloud/java-sdk + + com.ibm.watson + 99-SNAPSHOT + pom + + + UTF-8 + + 9.20.0 + + + java-sdk + + 7.4.0 + 4.9.0 + 3.0.0-M3 + 0.8.5 + 3.0.0-M1 + 0.7.0 + 1.6 + 3.1.0 + 3.2.2 + 3.2.0 + 3.1.1 + 3.8.1 + 3.7.1 + 3.1.0 + 3.0.0 + 3.0.0-M4 + 1.4 + 2.0.5 + 3.2.4 + 1.7.25 + 1.2.3 + + + + + /common + + + /assistant + /discovery + /natural-language-understanding + /speech-to-text + /text-to-speech + + /ibm-watson + + + + + + + + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + IBM Cloud + + + + + scm:git:git@github.com:watson-developer-cloud/java-sdk.git + scm:git:git@github.com:watson-developer-cloud/java-sdk.git + https://github.com/watson-developer-cloud/java-sdk + + + + + Github + https://github.com/watson-developer-cloud/java-sdk/issues + + + + + Travis-CI + https://travis-ci.org/watson-developer-cloud/java-sdk + + + + + + + + + com.ibm.cloud + sdk-core + ${sdk-core-version} + + + + + + common + ${project.groupId} + ${project.version} + + + + common + ${project.groupId} + ${project.version} + test-jar + tests + test + + + + + org.testng + testng + ${testng-version} + test + + + com.squareup.okhttp3 + okhttp + ${okhttp3-version} + + + com.launchdarkly + okhttp-eventsource + 4.1.1 + + + com.squareup.okhttp3 + mockwebserver + ${okhttp3-version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock-version} + test + + + org.powermock + powermock-module-testng + ${powermock-version} + test + + + + org.slf4j + slf4j-jdk14 + ${slf4j-version} + + + ch.qos.logback + logback-classic + ${logback-version} + test + + + + + + ch.qos.logback + logback-classic + test + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin-version} + + + org.sonatype.central + central-publishing-maven-plugin + ${central-publishing-plugin-version} + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin-version} + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin-version} + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin-version} + + true + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin-version} + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin-version} + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin-version} + + + verify-style + test + + check + + + + + true + checkstyle.xml + true + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-plugin-version} + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + + + ${project.build.directory} + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven-failsafe-plugin-version} + + + + integration-test + verify + + + + + ${skipITs} + + + + org.codehaus.mojo + buildnumber-maven-plugin + ${maven-buildnumber-plugin-version} + + + validate + + create + + + + + true + 8 + {0,date,yyyyMMdd-HHmmss} + true + true + false + false + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin-version} + + + + ${maven.build.timestamp} + + + + Implementation + + ${project.name} + IBM Corporation + ${project.version} + ${buildNumber} + ${scmBranch} + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade-plugin-version} + + + package + + shade + + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-javadoc-plugin + + true + public + ${project.name}, version ${project.version} +

IBM Corporation
+ + + + aggregate + + aggregate + + package + + + + + org.jacoco + jacoco-maven-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire-version} + + ${skip.unit.tests} + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin-version} + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${maven-reports-plugin-version} + + + + + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + + + + + + central + + + + + + + + org.sonatype.central + central-publishing-maven-plugin + true + + central + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + --batch + --yes + --no-tty + --pinentry-mode + loopback + + + + + + + + ${env.GPG_KEYNAME} + ${env.GPG_PASSPHRASE} + + + + diff --git a/secrets.tar.enc b/secrets.tar.enc deleted file mode 100644 index 0798d50947b..00000000000 Binary files a/secrets.tar.enc and /dev/null differ diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 232bb21c48e..00000000000 --- a/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'ibm-watson' -include ':assistant', ':compare-comply', ':discovery', ':language-translator', ':natural-language-classifier', - ':natural-language-understanding', ':personality-insights', ':speech-to-text', ':text-to-speech', - ':tone-analyzer', ':visual-recognition', ':ibm-watson', ':common' diff --git a/speech-to-text/README.md b/speech-to-text/README.md index 2d362c13546..eb473006d10 100755 --- a/speech-to-text/README.md +++ b/speech-to-text/README.md @@ -8,14 +8,14 @@ com.ibm.watson speech-to-text - 8.3.1 + 16.2.0 ``` ##### Gradle ```gradle -'com.ibm.watson:speech-to-text:8.3.1' +'com.ibm.watson:speech-to-text:16.2.0' ``` ## Usage @@ -39,7 +39,7 @@ System.out.println(transcript); #### WebSocket support -Speech to Text supports WebSocket, the url is: `wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize` +Speech to Text supports WebSocket, the url is: `wss://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognize` ```java Authenticator authenticator = new IamAuthenticator(""); @@ -50,7 +50,6 @@ InputStream audio = new FileInputStream("src/test/resources/sample1.wav"); RecognizeOptions options = new RecognizeOptions.Builder() .audio(audio) .contentType(HttpMediaType.AUDIO_WAV) - .interimResults(true) .build(); service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { diff --git a/speech-to-text/build.gradle b/speech-to-text/build.gradle deleted file mode 100644 index d9dc2b74f77..00000000000 --- a/speech-to-text/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyleTest { - ignoreFailures = false -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/speech-to-text/gradle.properties b/speech-to-text/gradle.properties deleted file mode 100644 index 9395cf76a74..00000000000 --- a/speech-to-text/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:speech-to-text -ARTIFACT_ID=speech-to-text -NAME=IBM Watson Java SDK - Speech to Text -DESCRIPTION=Java client library to use the IBM Speech to Text API \ No newline at end of file diff --git a/speech-to-text/pom.xml b/speech-to-text/pom.xml new file mode 100644 index 00000000000..5980c9a00d9 --- /dev/null +++ b/speech-to-text/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + speech-to-text + jar + IBM Watson Java SDK - Speech to Text + + + + com.ibm.cloud + sdk-core + + + ${project.groupId} + common + compile + + + ${project.groupId} + common + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java index 5c86d407061..9c8538ef78a 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2026. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116 + */ + package com.ibm.watson.speech_to_text.v1; import com.google.gson.JsonObject; @@ -46,6 +51,7 @@ import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteUserDataOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteWordOptions; +import com.ibm.watson.speech_to_text.v1.model.DetectLanguageOptions; import com.ibm.watson.speech_to_text.v1.model.GetAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.GetAudioOptions; import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; @@ -55,6 +61,7 @@ import com.ibm.watson.speech_to_text.v1.model.GetWordOptions; import com.ibm.watson.speech_to_text.v1.model.Grammar; import com.ibm.watson.speech_to_text.v1.model.Grammars; +import com.ibm.watson.speech_to_text.v1.model.LanguageDetectionResults; import com.ibm.watson.speech_to_text.v1.model.LanguageModel; import com.ibm.watson.speech_to_text.v1.model.LanguageModels; import com.ibm.watson.speech_to_text.v1.model.ListAcousticModelsOptions; @@ -67,6 +74,7 @@ import com.ibm.watson.speech_to_text.v1.model.RecognitionJob; import com.ibm.watson.speech_to_text.v1.model.RecognitionJobs; import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; +import com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions; import com.ibm.watson.speech_to_text.v1.model.RegisterCallbackOptions; import com.ibm.watson.speech_to_text.v1.model.RegisterStatus; import com.ibm.watson.speech_to_text.v1.model.ResetAcousticModelOptions; @@ -84,76 +92,95 @@ import com.ibm.watson.speech_to_text.v1.model.Words; import com.ibm.watson.speech_to_text.v1.websocket.RecognizeCallback; import com.ibm.watson.speech_to_text.v1.websocket.SpeechToTextWebSocketListener; - +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; - import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.WebSocket; /** - * The IBM® Speech to Text service provides APIs that use IBM's speech-recognition capabilities to produce - * transcripts of spoken audio. The service can transcribe speech from various languages and audio formats. In addition - * to basic transcription, the service can produce detailed information about many different aspects of the audio. For - * most languages, the service supports two sampling rates, broadband and narrowband. It returns all JSON response + * The IBM Watson&trade; Speech to Text service provides APIs that use IBM's speech-recognition + * capabilities to produce transcripts of spoken audio. The service can transcribe speech from + * various languages and audio formats. In addition to basic transcription, the service can produce + * detailed information about many different aspects of the audio. It returns all JSON response * content in the UTF-8 character set. * - * For speech recognition, the service supports synchronous and asynchronous HTTP Representational State Transfer (REST) - * interfaces. It also supports a WebSocket interface that provides a full-duplex, low-latency communication channel: - * Clients send requests and audio to the service and receive results over a single connection asynchronously. + *

The service supports two types of models: previous-generation models that include the terms + * `Broadband` and `Narrowband` in their names, and next-generation models that include the terms + * `Multimedia` and `Telephony` in their names. Broadband and multimedia models have minimum + * sampling rates of 16 kHz. Narrowband and telephony models have minimum sampling rates of 8 kHz. + * The next-generation models offer high throughput and greater transcription accuracy. + * + *

Effective **31 July 2023**, all previous-generation models will be removed from the service + * and the documentation. Most previous-generation models were deprecated on 15 March 2022. You must + * migrate to the equivalent large speech model or next-generation model by 31 July 2023. For more + * information, see [Migrating to large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate).{: + * deprecated} + * + *

For speech recognition, the service supports synchronous and asynchronous HTTP + * Representational State Transfer (REST) interfaces. It also supports a WebSocket interface that + * provides a full-duplex, low-latency communication channel: Clients send requests and audio to the + * service and receive results over a single connection asynchronously. * - * The service also offers two customization interfaces. Use language model customization to expand the vocabulary of a - * base model with domain-specific terminology. Use acoustic model customization to adapt a base model for the acoustic - * characteristics of your audio. For language model customization, the service also supports grammars. A grammar is a - * formal language specification that lets you restrict the phrases that the service can recognize. + *

The service also offers two customization interfaces. Use language model customization to + * expand the vocabulary of a base model with domain-specific terminology. Use acoustic model + * customization to adapt a base model for the acoustic characteristics of your audio. For language + * model customization, the service also supports grammars. A grammar is a formal language + * specification that lets you restrict the phrases that the service can recognize. * - * Language model customization is generally available for production use with most supported languages. Acoustic model - * customization is beta functionality that is available for all supported languages. + *

Language model customization and grammars are available for most previous- and next-generation + * models. Acoustic model customization is available for all previous-generation models. * - * @version v1 - * @see Speech to Text + *

API Version: 1.0.0 See: https://cloud.ibm.com/docs/speech-to-text */ public class SpeechToText extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "speech_to_text"; + /** Default service name used when configuring the `SpeechToText` client. */ + public static final String DEFAULT_SERVICE_NAME = "speech_to_text"; - private static final String DEFAULT_SERVICE_URL = "https://stream.watsonplatform.net/speech-to-text/api"; + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.speech-to-text.watson.cloud.ibm.com"; /** - * Constructs a new `SpeechToText` client using the DEFAULT_SERVICE_NAME. - * + * Constructs an instance of the `SpeechToText` client. The default service name is used to + * configure the client instance. */ public SpeechToText() { - this(DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + this( + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `SpeechToText` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. + * Constructs an instance of the `SpeechToText` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param authenticator the Authenticator instance to be configured for this service + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public SpeechToText(Authenticator authenticator) { this(DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `SpeechToText` client with the specified serviceName. + * Constructs an instance of the `SpeechToText` client. The specified service name is used to + * configure the client instance. * - * @param serviceName The name of the service to configure. + * @param serviceName the service name to be used when configuring the client instance */ public SpeechToText(String serviceName) { this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `SpeechToText` client with the specified Authenticator - * and serviceName. + * Constructs an instance of the `SpeechToText` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public SpeechToText(String serviceName, Authenticator authenticator) { super(serviceName, authenticator); @@ -161,43 +188,97 @@ public SpeechToText(String serviceName, Authenticator authenticator) { this.configureService(serviceName); } + /** + * Sends audio and returns transcription results for recognition requests over a WebSocket + * connection. Requests and responses are enabled over a single TCP connection that abstracts much + * of the complexity of the request to offer efficient implementation, low latency, high + * throughput, and an asynchronous response. + * + *

The service imposes a data size limit of 100 MB per utterance (per recognition request). You + * can send multiple utterances over a single WebSocket connection. The service automatically + * detects the endianness of the incoming audio and, for audio that includes multiple channels, + * downmixes the audio to one-channel mono during transcoding. (For the audio/l16 format, you can + * specify the endianness.) + * + * @param recognizeOptions the recognize options + * @param callback the {@link RecognizeCallback} instance where results will be sent + * @return the {@link WebSocket} + */ + public WebSocket recognizeUsingWebSocket( + RecognizeWithWebsocketsOptions recognizeOptions, RecognizeCallback callback) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + recognizeOptions, "recognizeOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(recognizeOptions.audio(), "audio cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(callback, "callback cannot be null"); + + HttpUrl.Builder urlBuilder = HttpUrl.parse(getServiceUrl() + "/v1/recognize").newBuilder(); + + if (recognizeOptions.model() != null) { + urlBuilder.addQueryParameter("model", recognizeOptions.model()); + } + if (recognizeOptions.languageCustomizationId() != null) { + urlBuilder.addQueryParameter( + "language_customization_id", recognizeOptions.languageCustomizationId()); + } + if (recognizeOptions.acousticCustomizationId() != null) { + urlBuilder.addQueryParameter( + "acoustic_customization_id", recognizeOptions.acousticCustomizationId()); + } + if (recognizeOptions.baseModelVersion() != null) { + urlBuilder.addQueryParameter("base_model_version", recognizeOptions.baseModelVersion()); + } + + String url = urlBuilder.toString().replace("https://", "wss://"); + Request.Builder builder = new Request.Builder().url(url); + + setAuthentication(builder); + setDefaultHeaders(builder); + + OkHttpClient client = configureHttpClient(); + return client.newWebSocket( + builder.build(), new SpeechToTextWebSocketListener(recognizeOptions, callback)); + } + /** * List models. * - * Lists all language models that are available for use with the service. The information includes the name of the - * model and its minimum sampling rate in Hertz, among other things. + *

Lists all language models that are available for use with the service. The information + * includes the name of the model and its minimum sampling rate in Hertz, among other things. The + * ordering of the list of models can change from call to call; do not rely on an alphabetized or + * static list of models. * - * **See also:** [Languages and models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + *

**See also:** [Listing all + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-list#models-list-all). * * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechModels} + * @return a {@link ServiceCall} with a result of type {@link SpeechModels} */ public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = { "v1/models" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listModelsOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List models. * - * Lists all language models that are available for use with the service. The information includes the name of the - * model and its minimum sampling rate in Hertz, among other things. + *

Lists all language models that are available for use with the service. The information + * includes the name of the model and its minimum sampling rate in Hertz, among other things. The + * ordering of the list of models can change from call to call; do not rely on an alphabetized or + * static list of models. * - * **See also:** [Languages and models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + *

**See also:** [Listing all + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-list#models-list-all). * - * @return a {@link ServiceCall} with a response type of {@link SpeechModels} + * @return a {@link ServiceCall} with a result of type {@link SpeechModels} */ public ServiceCall listModels() { return listModels(null); @@ -206,117 +287,154 @@ public ServiceCall listModels() { /** * Get a model. * - * Gets information for a single specified language model that is available for use with the service. The information - * includes the name of the model and its minimum sampling rate in Hertz, among other things. + *

Gets information for a single specified language model that is available for use with the + * service. The information includes the name of the model and its minimum sampling rate in Hertz, + * among other things. * - * **See also:** [Languages and models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + *

**See also:** [Listing a specific + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-list#models-list-specific). * * @param getModelOptions the {@link GetModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechModel} + * @return a {@link ServiceCall} with a result of type {@link SpeechModel} */ public ServiceCall getModel(GetModelOptions getModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getModelOptions, - "getModelOptions cannot be null"); - String[] pathSegments = { "v1/models" }; - String[] pathParameters = { getModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getModelOptions, "getModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", getModelOptions.modelId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/{model_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Recognize audio. * - * Sends audio and returns transcription results for a recognition request. You can pass a maximum of 100 MB and a - * minimum of 100 bytes of audio with a request. The service automatically detects the endianness of the incoming - * audio and, for audio that includes multiple channels, downmixes the audio to one-channel mono during transcoding. - * The method returns only final results; to enable interim results, use the WebSocket API. (With the `curl` command, - * use the `--data-binary` option to upload the file for the request.) + *

Sends audio and returns transcription results for a recognition request. You can pass a + * maximum of 100 MB and a minimum of 100 bytes of audio with a request. The service automatically + * detects the endianness of the incoming audio and, for audio that includes multiple channels, + * downmixes the audio to one-channel mono during transcoding. The method returns only final + * results; to enable interim results, use the WebSocket API. (With the `curl` command, use the + * `--data-binary` option to upload the file for the request.) * - * **See also:** [Making a basic HTTP + *

**See also:** [Making a basic HTTP * request](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-http#HTTP-basic). * - * ### Streaming mode + *

### Streaming mode * - * For requests to transcribe live audio as it becomes available, you must set the `Transfer-Encoding` header to - * `chunked` to use streaming mode. In streaming mode, the service closes the connection (status code 408) if it does - * not receive at least 15 seconds of audio (including silence) in any 30-second period. The service also closes the - * connection (status code 400) if it detects no speech for `inactivity_timeout` seconds of streaming audio; use the + *

For requests to transcribe live audio as it becomes available, you must set the + * `Transfer-Encoding` header to `chunked` to use streaming mode. In streaming mode, the service + * closes the connection (status code 408) if it does not receive at least 15 seconds of audio + * (including silence) in any 30-second period. The service also closes the connection (status + * code 400) if it detects no speech for `inactivity_timeout` seconds of streaming audio; use the * `inactivity_timeout` parameter to change the default of 30 seconds. * - * **See also:** - * * [Audio transmission](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#transmission) + *

**See also:** * [Audio + * transmission](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#transmission) * * [Timeouts](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#timeouts) * - * ### Audio formats (content types) - * - * The service accepts audio in the following formats (MIME types). - * * For formats that are labeled **Required**, you must use the `Content-Type` header with the request to specify the - * format of the audio. - * * For all other formats, you can omit the `Content-Type` header or specify `application/octet-stream` with the - * header to have the service automatically detect the format of the audio. (With the `curl` command, you can specify - * either `"Content-Type:"` or `"Content-Type: application/octet-stream"`.) - * - * Where indicated, the format that you specify must include the sampling rate and can optionally include the number - * of channels and the endianness of the audio. - * * `audio/alaw` (**Required.** Specify the sampling rate (`rate`) of the audio.) - * * `audio/basic` (**Required.** Use only with narrowband models.) - * * `audio/flac` - * * `audio/g729` (Use only with narrowband models.) - * * `audio/l16` (**Required.** Specify the sampling rate (`rate`) and optionally the number of channels (`channels`) - * and endianness (`endianness`) of the audio.) - * * `audio/mp3` - * * `audio/mpeg` - * * `audio/mulaw` (**Required.** Specify the sampling rate (`rate`) of the audio.) - * * `audio/ogg` (The service automatically detects the codec of the input audio.) - * * `audio/ogg;codecs=opus` - * * `audio/ogg;codecs=vorbis` - * * `audio/wav` (Provide audio with a maximum of nine channels.) - * * `audio/webm` (The service automatically detects the codec of the input audio.) - * * `audio/webm;codecs=opus` - * * `audio/webm;codecs=vorbis` - * - * The sampling rate of the audio must match the sampling rate of the model for the recognition request: for broadband - * models, at least 16 kHz; for narrowband models, at least 8 kHz. If the sampling rate of the audio is higher than - * the minimum required rate, the service down-samples the audio to the appropriate rate. If the sampling rate of the - * audio is lower than the minimum required rate, the request fails. - * - * **See also:** [Audio - * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats#audio-formats). - * - * ### Multipart speech recognition - * - * **Note:** The Watson SDKs do not support multipart speech recognition. - * - * The HTTP `POST` method of the service also supports multipart speech recognition. With multipart requests, you pass - * all audio data as multipart form data. You specify some parameters as request headers and query parameters, but you - * pass JSON metadata as form data to control most aspects of the transcription. You can use multipart recognition to - * pass multiple audio files with a single request. - * - * Use the multipart approach with browsers for which JavaScript is disabled or when the parameters used with the - * request are greater than the 8 KB limit imposed by most HTTP servers and proxies. You can encounter this limit, for - * example, if you want to spot a very large number of keywords. - * - * **See also:** [Making a multipart HTTP + *

### Audio formats (content types) + * + *

The service accepts audio in the following formats (MIME types). * For formats that are + * labeled **Required**, you must use the `Content-Type` header with the request to specify the + * format of the audio. * For all other formats, you can omit the `Content-Type` header or specify + * `application/octet-stream` with the header to have the service automatically detect the format + * of the audio. (With the `curl` command, you can specify either `"Content-Type:"` or + * `"Content-Type: application/octet-stream"`.) + * + *

Where indicated, the format that you specify must include the sampling rate and can + * optionally include the number of channels and the endianness of the audio. * `audio/alaw` + * (**Required.** Specify the sampling rate (`rate`) of the audio.) * `audio/basic` (**Required.** + * Use only with narrowband models.) * `audio/flac` * `audio/g729` (Use only with narrowband + * models.) * `audio/l16` (**Required.** Specify the sampling rate (`rate`) and optionally the + * number of channels (`channels`) and endianness (`endianness`) of the audio.) * `audio/mp3` * + * `audio/mpeg` * `audio/mulaw` (**Required.** Specify the sampling rate (`rate`) of the audio.) * + * `audio/ogg` (The service automatically detects the codec of the input audio.) * + * `audio/ogg;codecs=opus` * `audio/ogg;codecs=vorbis` * `audio/wav` (Provide audio with a maximum + * of nine channels.) * `audio/webm` (The service automatically detects the codec of the input + * audio.) * `audio/webm;codecs=opus` * `audio/webm;codecs=vorbis` + * + *

The sampling rate of the audio must match the sampling rate of the model for the recognition + * request: for broadband models, at least 16 kHz; for narrowband models, at least 8 kHz. If the + * sampling rate of the audio is higher than the minimum required rate, the service down-samples + * the audio to the appropriate rate. If the sampling rate of the audio is lower than the minimum + * required rate, the request fails. + * + *

**See also:** [Supported audio + * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats). + * + *

### Large speech models and Next-generation models + * + *

The service supports large speech models and next-generation `Multimedia` (16 kHz) and + * `Telephony` (8 kHz) models for many languages. Large speech models and next-generation models + * have higher throughput than the service's previous generation of `Broadband` and `Narrowband` + * models. When you use large speech models and next-generation models, the service can return + * transcriptions more quickly and also provide noticeably better transcription accuracy. + * + *

You specify a large speech model or next-generation model by using the `model` query + * parameter, as you do a previous-generation model. Only the next-generation models support the + * `low_latency` parameter, and all large speech models and next-generation models support the + * `character_insertion_bias` parameter. These parameters are not available with + * previous-generation models. + * + *

Large speech models and next-generation models do not support all of the speech recognition + * parameters that are available for use with previous-generation models. Next-generation models + * do not support the following parameters: * `acoustic_customization_id` * `keywords` and + * `keywords_threshold` * `processing_metrics` and `processing_metrics_interval` * + * `word_alternatives_threshold` + * + *

**Important:** Effective **31 July 2023**, all previous-generation models will be removed + * from the service and the documentation. Most previous-generation models were deprecated on 15 + * March 2022. You must migrate to the equivalent large speech model or next-generation model by + * 31 July 2023. For more information, see [Migrating to large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). + * + *

**See also:** * [Large speech languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages) + * * [Supported features for large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages#models-lsm-supported-features) + * * [Next-generation languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng) * [Supported + * features for next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-features) + * + *

### Multipart speech recognition + * + *

**Note:** The asynchronous HTTP interface, WebSocket interface, and Watson SDKs do not + * support multipart speech recognition. + * + *

The HTTP `POST` method of the service also supports multipart speech recognition. With + * multipart requests, you pass all audio data as multipart form data. You specify some parameters + * as request headers and query parameters, but you pass JSON metadata as form data to control + * most aspects of the transcription. You can use multipart recognition to pass multiple audio + * files with a single request. + * + *

Use the multipart approach with browsers for which JavaScript is disabled or when the + * parameters used with the request are greater than the 8 KB limit imposed by most HTTP servers + * and proxies. You can encounter this limit, for example, if you want to spot a very large number + * of keywords. + * + *

**See also:** [Making a multipart HTTP * request](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-http#HTTP-multi). * * @param recognizeOptions the {@link RecognizeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechRecognitionResults} + * @return a {@link ServiceCall} with a result of type {@link SpeechRecognitionResults} */ public ServiceCall recognize(RecognizeOptions recognizeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(recognizeOptions, - "recognizeOptions cannot be null"); - String[] pathSegments = { "v1/recognize" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + recognizeOptions, "recognizeOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/recognize")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "recognize"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -326,16 +444,24 @@ public ServiceCall recognize(RecognizeOptions recogniz builder.header("Content-Type", recognizeOptions.contentType()); } if (recognizeOptions.model() != null) { - builder.query("model", recognizeOptions.model()); + builder.query("model", String.valueOf(recognizeOptions.model())); + } + if (recognizeOptions.speechBeginEvent() != null) { + builder.query("speech_begin_event", String.valueOf(recognizeOptions.speechBeginEvent())); + } + if (recognizeOptions.enrichments() != null) { + builder.query("enrichments", String.valueOf(recognizeOptions.enrichments())); } if (recognizeOptions.languageCustomizationId() != null) { - builder.query("language_customization_id", recognizeOptions.languageCustomizationId()); + builder.query( + "language_customization_id", String.valueOf(recognizeOptions.languageCustomizationId())); } if (recognizeOptions.acousticCustomizationId() != null) { - builder.query("acoustic_customization_id", recognizeOptions.acousticCustomizationId()); + builder.query( + "acoustic_customization_id", String.valueOf(recognizeOptions.acousticCustomizationId())); } if (recognizeOptions.baseModelVersion() != null) { - builder.query("base_model_version", recognizeOptions.baseModelVersion()); + builder.query("base_model_version", String.valueOf(recognizeOptions.baseModelVersion())); } if (recognizeOptions.customizationWeight() != null) { builder.query("customization_weight", String.valueOf(recognizeOptions.customizationWeight())); @@ -353,7 +479,9 @@ public ServiceCall recognize(RecognizeOptions recogniz builder.query("max_alternatives", String.valueOf(recognizeOptions.maxAlternatives())); } if (recognizeOptions.wordAlternativesThreshold() != null) { - builder.query("word_alternatives_threshold", String.valueOf(recognizeOptions.wordAlternativesThreshold())); + builder.query( + "word_alternatives_threshold", + String.valueOf(recognizeOptions.wordAlternativesThreshold())); } if (recognizeOptions.wordConfidence() != null) { builder.query("word_confidence", String.valueOf(recognizeOptions.wordConfidence())); @@ -367,14 +495,15 @@ public ServiceCall recognize(RecognizeOptions recogniz if (recognizeOptions.smartFormatting() != null) { builder.query("smart_formatting", String.valueOf(recognizeOptions.smartFormatting())); } + if (recognizeOptions.smartFormattingVersion() != null) { + builder.query( + "smart_formatting_version", String.valueOf(recognizeOptions.smartFormattingVersion())); + } if (recognizeOptions.speakerLabels() != null) { builder.query("speaker_labels", String.valueOf(recognizeOptions.speakerLabels())); } - if (recognizeOptions.customizationId() != null) { - builder.query("customization_id", recognizeOptions.customizationId()); - } if (recognizeOptions.grammarName() != null) { - builder.query("grammar_name", recognizeOptions.grammarName()); + builder.query("grammar_name", String.valueOf(recognizeOptions.grammarName())); } if (recognizeOptions.redaction() != null) { builder.query("redaction", String.valueOf(recognizeOptions.redaction())); @@ -383,143 +512,128 @@ public ServiceCall recognize(RecognizeOptions recogniz builder.query("audio_metrics", String.valueOf(recognizeOptions.audioMetrics())); } if (recognizeOptions.endOfPhraseSilenceTime() != null) { - builder.query("end_of_phrase_silence_time", String.valueOf(recognizeOptions.endOfPhraseSilenceTime())); + builder.query( + "end_of_phrase_silence_time", String.valueOf(recognizeOptions.endOfPhraseSilenceTime())); } if (recognizeOptions.splitTranscriptAtPhraseEnd() != null) { - builder.query("split_transcript_at_phrase_end", String.valueOf(recognizeOptions.splitTranscriptAtPhraseEnd())); - } - builder.bodyContent(recognizeOptions.contentType(), null, - null, recognizeOptions.audio()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query( + "split_transcript_at_phrase_end", + String.valueOf(recognizeOptions.splitTranscriptAtPhraseEnd())); + } + if (recognizeOptions.speechDetectorSensitivity() != null) { + builder.query( + "speech_detector_sensitivity", + String.valueOf(recognizeOptions.speechDetectorSensitivity())); + } + if (recognizeOptions.sadModule() != null) { + builder.query("sad_module", String.valueOf(recognizeOptions.sadModule())); + } + if (recognizeOptions.backgroundAudioSuppression() != null) { + builder.query( + "background_audio_suppression", + String.valueOf(recognizeOptions.backgroundAudioSuppression())); + } + if (recognizeOptions.lowLatency() != null) { + builder.query("low_latency", String.valueOf(recognizeOptions.lowLatency())); + } + if (recognizeOptions.characterInsertionBias() != null) { + builder.query( + "character_insertion_bias", String.valueOf(recognizeOptions.characterInsertionBias())); + } + builder.bodyContent(recognizeOptions.contentType(), null, null, recognizeOptions.audio()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } - /** - * Sends audio and returns transcription results for recognition requests over a WebSocket connection. Requests and - * responses are enabled over a single TCP connection that abstracts much of the complexity of the request to offer - * efficient implementation, low latency, high throughput, and an asynchronous response. By default, only final - * results are returned for any request; to enable interim results, set the interimResults parameter to true. - * - * The service imposes a data size limit of 100 MB per utterance (per recognition request). You can send multiple - * utterances over a single WebSocket connection. The service automatically detects the endianness of the incoming - * audio and, for audio that includes multiple channels, downmixes the audio to one-channel mono during transcoding. - * (For the audio/l16 format, you can specify the endianness.) - * - * @param recognizeOptions the recognize options - * @param callback the {@link RecognizeCallback} instance where results will be sent - * @return the {@link WebSocket} - */ - public WebSocket recognizeUsingWebSocket(RecognizeOptions recognizeOptions, RecognizeCallback callback) { - com.ibm.cloud.sdk.core.util.Validator.notNull(recognizeOptions, "recognizeOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(recognizeOptions.audio(), "audio cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(callback, "callback cannot be null"); - - HttpUrl.Builder urlBuilder = HttpUrl.parse(getServiceUrl() + "/v1/recognize").newBuilder(); - - if (recognizeOptions.model() != null) { - urlBuilder.addQueryParameter("model", recognizeOptions.model()); - } - if (recognizeOptions.customizationId() != null) { - urlBuilder.addQueryParameter("customization_id", recognizeOptions.customizationId()); - } - if (recognizeOptions.languageCustomizationId() != null) { - urlBuilder.addQueryParameter("language_customization_id", recognizeOptions.languageCustomizationId()); - } - if (recognizeOptions.acousticCustomizationId() != null) { - urlBuilder.addQueryParameter("acoustic_customization_id", recognizeOptions.acousticCustomizationId()); - } - if (recognizeOptions.baseModelVersion() != null) { - urlBuilder.addQueryParameter("base_model_version", recognizeOptions.baseModelVersion()); - } - - String url = urlBuilder.toString().replace("https://", "wss://"); - Request.Builder builder = new Request.Builder().url(url); - - setAuthentication(builder); - setDefaultHeaders(builder); - - OkHttpClient client = configureHttpClient(); - return client.newWebSocket(builder.build(), new SpeechToTextWebSocketListener(recognizeOptions, callback)); - } - /** * Register a callback. * - * Registers a callback URL with the service for use with subsequent asynchronous recognition requests. The service - * attempts to register, or white-list, the callback URL if it is not already registered by sending a `GET` request to - * the callback URL. The service passes a random alphanumeric challenge string via the `challenge_string` parameter of - * the request. The request includes an `Accept` header that specifies `text/plain` as the required response type. - * - * To be registered successfully, the callback URL must respond to the `GET` request from the service. The response - * must send status code 200 and must include the challenge string in its body. Set the `Content-Type` response header - * to `text/plain`. Upon receiving this response, the service responds to the original registration request with - * response code 201. - * - * The service sends only a single `GET` request to the callback URL. If the service does not receive a reply with a - * response code of 200 and a body that echoes the challenge string sent by the service within five seconds, it does - * not white-list the URL; it instead sends status code 400 in response to the **Register a callback** request. If the - * requested callback URL is already white-listed, the service responds to the initial registration request with - * response code 200. - * - * If you specify a user secret with the request, the service uses it as a key to calculate an HMAC-SHA1 signature of - * the challenge string in its response to the `POST` request. It sends this signature in the `X-Callback-Signature` - * header of its `GET` request to the URL during registration. It also uses the secret to calculate a signature over - * the payload of every callback notification that uses the URL. The signature provides authentication and data + *

Registers a callback URL with the service for use with subsequent asynchronous recognition + * requests. The service attempts to register, or allowlist, the callback URL if it is not already + * registered by sending a `GET` request to the callback URL. The service passes a random + * alphanumeric challenge string via the `challenge_string` parameter of the request. The request + * includes an `Accept` header that specifies `text/plain` as the required response type. + * + *

To be registered successfully, the callback URL must respond to the `GET` request from the + * service. The response must send status code 200 and must include the challenge string in its + * body. Set the `Content-Type` response header to `text/plain`. Upon receiving this response, the + * service responds to the original registration request with response code 201. + * + *

The service sends only a single `GET` request to the callback URL. If the service does not + * receive a reply with a response code of 200 and a body that echoes the challenge string sent by + * the service within five seconds, it does not allowlist the URL; it instead sends status code + * 400 in response to the request to register a callback. If the requested callback URL is already + * allowlisted, the service responds to the initial registration request with response code 200. + * + *

If you specify a user secret with the request, the service uses it as a key to calculate an + * HMAC-SHA1 signature of the challenge string in its response to the `POST` request. It sends + * this signature in the `X-Callback-Signature` header of its `GET` request to the URL during + * registration. It also uses the secret to calculate a signature over the payload of every + * callback notification that uses the URL. The signature provides authentication and data * integrity for HTTP communications. * - * After you successfully register a callback URL, you can use it with an indefinite number of recognition requests. - * You can register a maximum of 20 callback URLS in a one-hour span of time. + *

After you successfully register a callback URL, you can use it with an indefinite number of + * recognition requests. You can register a maximum of 20 callback URLS in a one-hour span of + * time. * - * **See also:** [Registering a callback + *

**See also:** [Registering a callback * URL](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#register). * - * @param registerCallbackOptions the {@link RegisterCallbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RegisterStatus} + * @param registerCallbackOptions the {@link RegisterCallbackOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link RegisterStatus} */ - public ServiceCall registerCallback(RegisterCallbackOptions registerCallbackOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(registerCallbackOptions, - "registerCallbackOptions cannot be null"); - String[] pathSegments = { "v1/register_callback" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "registerCallback"); + public ServiceCall registerCallback( + RegisterCallbackOptions registerCallbackOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + registerCallbackOptions, "registerCallbackOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/register_callback")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "registerCallback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("callback_url", registerCallbackOptions.callbackUrl()); + builder.query("callback_url", String.valueOf(registerCallbackOptions.callbackUrl())); if (registerCallbackOptions.userSecret() != null) { - builder.query("user_secret", registerCallbackOptions.userSecret()); + builder.query("user_secret", String.valueOf(registerCallbackOptions.userSecret())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Unregister a callback. * - * Unregisters a callback URL that was previously white-listed with a **Register a callback** request for use with the - * asynchronous interface. Once unregistered, the URL can no longer be used with asynchronous recognition requests. + *

Unregisters a callback URL that was previously allowlisted with a [Register a + * callback](#registercallback) request for use with the asynchronous interface. Once + * unregistered, the URL can no longer be used with asynchronous recognition requests. * - * **See also:** [Unregistering a callback + *

**See also:** [Unregistering a callback * URL](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#unregister). * - * @param unregisterCallbackOptions the {@link UnregisterCallbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param unregisterCallbackOptions the {@link UnregisterCallbackOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result */ public ServiceCall unregisterCallback(UnregisterCallbackOptions unregisterCallbackOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(unregisterCallbackOptions, - "unregisterCallbackOptions cannot be null"); - String[] pathSegments = { "v1/unregister_callback" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "unregisterCallback"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + unregisterCallbackOptions, "unregisterCallbackOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/unregister_callback")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "unregisterCallback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("callback_url", unregisterCallbackOptions.callbackUrl()); + builder.query("callback_url", String.valueOf(unregisterCallbackOptions.callbackUrl())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -527,93 +641,123 @@ public ServiceCall unregisterCallback(UnregisterCallbackOptions unregister /** * Create a job. * - * Creates a job for a new asynchronous recognition request. The job is owned by the instance of the service whose - * credentials are used to create it. How you learn the status and results of a job depends on the parameters you - * include with the job creation request: - * * By callback notification: Include the `callback_url` parameter to specify a URL to which the service is to send - * callback notifications when the status of the job changes. Optionally, you can also include the `events` and - * `user_token` parameters to subscribe to specific events and to specify a string that is to be included with each - * notification for the job. - * * By polling the service: Omit the `callback_url`, `events`, and `user_token` parameters. You must then use the - * **Check jobs** or **Check a job** methods to check the status of the job, using the latter to retrieve the results - * when the job is complete. - * - * The two approaches are not mutually exclusive. You can poll the service for job status or obtain results from the - * service manually even if you include a callback URL. In both cases, you can include the `results_ttl` parameter to - * specify how long the results are to remain available after the job is complete. Using the HTTPS **Check a job** - * method to retrieve results is more secure than receiving them via callback notification over HTTP because it - * provides confidentiality in addition to authentication and data integrity. - * - * The method supports the same basic parameters as other HTTP and WebSocket recognition requests. It also supports - * the following parameters specific to the asynchronous interface: - * * `callback_url` - * * `events` - * * `user_token` - * * `results_ttl` - * - * You can pass a maximum of 1 GB and a minimum of 100 bytes of audio with a request. The service automatically - * detects the endianness of the incoming audio and, for audio that includes multiple channels, downmixes the audio to - * one-channel mono during transcoding. The method returns only final results; to enable interim results, use the - * WebSocket API. (With the `curl` command, use the `--data-binary` option to upload the file for the request.) - * - * **See also:** [Creating a job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#create). - * - * ### Streaming mode - * - * For requests to transcribe live audio as it becomes available, you must set the `Transfer-Encoding` header to - * `chunked` to use streaming mode. In streaming mode, the service closes the connection (status code 408) if it does - * not receive at least 15 seconds of audio (including silence) in any 30-second period. The service also closes the - * connection (status code 400) if it detects no speech for `inactivity_timeout` seconds of streaming audio; use the + *

Creates a job for a new asynchronous recognition request. The job is owned by the instance + * of the service whose credentials are used to create it. How you learn the status and results of + * a job depends on the parameters you include with the job creation request: * By callback + * notification: Include the `callback_url` parameter to specify a URL to which the service is to + * send callback notifications when the status of the job changes. Optionally, you can also + * include the `events` and `user_token` parameters to subscribe to specific events and to specify + * a string that is to be included with each notification for the job. * By polling the service: + * Omit the `callback_url`, `events`, and `user_token` parameters. You must then use the [Check + * jobs](#checkjobs) or [Check a job](#checkjob) methods to check the status of the job, using the + * latter to retrieve the results when the job is complete. + * + *

The two approaches are not mutually exclusive. You can poll the service for job status or + * obtain results from the service manually even if you include a callback URL. In both cases, you + * can include the `results_ttl` parameter to specify how long the results are to remain available + * after the job is complete. Using the HTTPS [Check a job](#checkjob) method to retrieve results + * is more secure than receiving them via callback notification over HTTP because it provides + * confidentiality in addition to authentication and data integrity. + * + *

The method supports the same basic parameters as other HTTP and WebSocket recognition + * requests. It also supports the following parameters specific to the asynchronous interface: * + * `callback_url` * `events` * `user_token` * `results_ttl` + * + *

You can pass a maximum of 1 GB and a minimum of 100 bytes of audio with a request. The + * service automatically detects the endianness of the incoming audio and, for audio that includes + * multiple channels, downmixes the audio to one-channel mono during transcoding. The method + * returns only final results; to enable interim results, use the WebSocket API. (With the `curl` + * command, use the `--data-binary` option to upload the file for the request.) + * + *

**See also:** [Creating a + * job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#create). + * + *

### Streaming mode + * + *

For requests to transcribe live audio as it becomes available, you must set the + * `Transfer-Encoding` header to `chunked` to use streaming mode. In streaming mode, the service + * closes the connection (status code 408) if it does not receive at least 15 seconds of audio + * (including silence) in any 30-second period. The service also closes the connection (status + * code 400) if it detects no speech for `inactivity_timeout` seconds of streaming audio; use the * `inactivity_timeout` parameter to change the default of 30 seconds. * - * **See also:** - * * [Audio transmission](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#transmission) + *

**See also:** * [Audio + * transmission](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#transmission) * * [Timeouts](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#timeouts) * - * ### Audio formats (content types) - * - * The service accepts audio in the following formats (MIME types). - * * For formats that are labeled **Required**, you must use the `Content-Type` header with the request to specify the - * format of the audio. - * * For all other formats, you can omit the `Content-Type` header or specify `application/octet-stream` with the - * header to have the service automatically detect the format of the audio. (With the `curl` command, you can specify - * either `"Content-Type:"` or `"Content-Type: application/octet-stream"`.) - * - * Where indicated, the format that you specify must include the sampling rate and can optionally include the number - * of channels and the endianness of the audio. - * * `audio/alaw` (**Required.** Specify the sampling rate (`rate`) of the audio.) - * * `audio/basic` (**Required.** Use only with narrowband models.) - * * `audio/flac` - * * `audio/g729` (Use only with narrowband models.) - * * `audio/l16` (**Required.** Specify the sampling rate (`rate`) and optionally the number of channels (`channels`) - * and endianness (`endianness`) of the audio.) - * * `audio/mp3` - * * `audio/mpeg` - * * `audio/mulaw` (**Required.** Specify the sampling rate (`rate`) of the audio.) - * * `audio/ogg` (The service automatically detects the codec of the input audio.) - * * `audio/ogg;codecs=opus` - * * `audio/ogg;codecs=vorbis` - * * `audio/wav` (Provide audio with a maximum of nine channels.) - * * `audio/webm` (The service automatically detects the codec of the input audio.) - * * `audio/webm;codecs=opus` - * * `audio/webm;codecs=vorbis` - * - * The sampling rate of the audio must match the sampling rate of the model for the recognition request: for broadband - * models, at least 16 kHz; for narrowband models, at least 8 kHz. If the sampling rate of the audio is higher than - * the minimum required rate, the service down-samples the audio to the appropriate rate. If the sampling rate of the - * audio is lower than the minimum required rate, the request fails. - * - * **See also:** [Audio - * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats#audio-formats). + *

### Audio formats (content types) + * + *

The service accepts audio in the following formats (MIME types). * For formats that are + * labeled **Required**, you must use the `Content-Type` header with the request to specify the + * format of the audio. * For all other formats, you can omit the `Content-Type` header or specify + * `application/octet-stream` with the header to have the service automatically detect the format + * of the audio. (With the `curl` command, you can specify either `"Content-Type:"` or + * `"Content-Type: application/octet-stream"`.) + * + *

Where indicated, the format that you specify must include the sampling rate and can + * optionally include the number of channels and the endianness of the audio. * `audio/alaw` + * (**Required.** Specify the sampling rate (`rate`) of the audio.) * `audio/basic` (**Required.** + * Use only with narrowband models.) * `audio/flac` * `audio/g729` (Use only with narrowband + * models.) * `audio/l16` (**Required.** Specify the sampling rate (`rate`) and optionally the + * number of channels (`channels`) and endianness (`endianness`) of the audio.) * `audio/mp3` * + * `audio/mpeg` * `audio/mulaw` (**Required.** Specify the sampling rate (`rate`) of the audio.) * + * `audio/ogg` (The service automatically detects the codec of the input audio.) * + * `audio/ogg;codecs=opus` * `audio/ogg;codecs=vorbis` * `audio/wav` (Provide audio with a maximum + * of nine channels.) * `audio/webm` (The service automatically detects the codec of the input + * audio.) * `audio/webm;codecs=opus` * `audio/webm;codecs=vorbis` + * + *

The sampling rate of the audio must match the sampling rate of the model for the recognition + * request: for broadband models, at least 16 kHz; for narrowband models, at least 8 kHz. If the + * sampling rate of the audio is higher than the minimum required rate, the service down-samples + * the audio to the appropriate rate. If the sampling rate of the audio is lower than the minimum + * required rate, the request fails. + * + *

**See also:** [Supported audio + * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats). + * + *

### Large speech models and Next-generation models + * + *

The service supports large speech models and next-generation `Multimedia` (16 kHz) and + * `Telephony` (8 kHz) models for many languages. Large speech models and next-generation models + * have higher throughput than the service's previous generation of `Broadband` and `Narrowband` + * models. When you use large speech models and next-generation models, the service can return + * transcriptions more quickly and also provide noticeably better transcription accuracy. + * + *

You specify a large speech model or next-generation model by using the `model` query + * parameter, as you do a previous-generation model. Only the next-generation models support the + * `low_latency` parameter, and all large speech models and next-generation models support the + * `character_insertion_bias` parameter. These parameters are not available with + * previous-generation models. + * + *

Large speech models and next-generation models do not support all of the speech recognition + * parameters that are available for use with previous-generation models. Next-generation models + * do not support the following parameters: * `acoustic_customization_id` * `keywords` and + * `keywords_threshold` * `processing_metrics` and `processing_metrics_interval` * + * `word_alternatives_threshold` + * + *

**Important:** Effective **31 July 2023**, all previous-generation models will be removed + * from the service and the documentation. Most previous-generation models were deprecated on 15 + * March 2022. You must migrate to the equivalent large speech model or next-generation model by + * 31 July 2023. For more information, see [Migrating to large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). + * + *

**See also:** * [Large speech languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages) + * * [Supported features for large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages#models-lsm-supported-features) + * * [Next-generation languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng) * [Supported + * features for next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-features). * * @param createJobOptions the {@link CreateJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJob} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJob} */ public ServiceCall createJob(CreateJobOptions createJobOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createJobOptions, - "createJobOptions cannot be null"); - String[] pathSegments = { "v1/recognitions" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + createJobOptions, "createJobOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/recognitions")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createJob"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -623,28 +767,36 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) builder.header("Content-Type", createJobOptions.contentType()); } if (createJobOptions.model() != null) { - builder.query("model", createJobOptions.model()); + builder.query("model", String.valueOf(createJobOptions.model())); } if (createJobOptions.callbackUrl() != null) { - builder.query("callback_url", createJobOptions.callbackUrl()); + builder.query("callback_url", String.valueOf(createJobOptions.callbackUrl())); } if (createJobOptions.events() != null) { - builder.query("events", createJobOptions.events()); + builder.query("events", String.valueOf(createJobOptions.events())); } if (createJobOptions.userToken() != null) { - builder.query("user_token", createJobOptions.userToken()); + builder.query("user_token", String.valueOf(createJobOptions.userToken())); } if (createJobOptions.resultsTtl() != null) { builder.query("results_ttl", String.valueOf(createJobOptions.resultsTtl())); } + if (createJobOptions.speechBeginEvent() != null) { + builder.query("speech_begin_event", String.valueOf(createJobOptions.speechBeginEvent())); + } + if (createJobOptions.enrichments() != null) { + builder.query("enrichments", String.valueOf(createJobOptions.enrichments())); + } if (createJobOptions.languageCustomizationId() != null) { - builder.query("language_customization_id", createJobOptions.languageCustomizationId()); + builder.query( + "language_customization_id", String.valueOf(createJobOptions.languageCustomizationId())); } if (createJobOptions.acousticCustomizationId() != null) { - builder.query("acoustic_customization_id", createJobOptions.acousticCustomizationId()); + builder.query( + "acoustic_customization_id", String.valueOf(createJobOptions.acousticCustomizationId())); } if (createJobOptions.baseModelVersion() != null) { - builder.query("base_model_version", createJobOptions.baseModelVersion()); + builder.query("base_model_version", String.valueOf(createJobOptions.baseModelVersion())); } if (createJobOptions.customizationWeight() != null) { builder.query("customization_weight", String.valueOf(createJobOptions.customizationWeight())); @@ -662,7 +814,9 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) builder.query("max_alternatives", String.valueOf(createJobOptions.maxAlternatives())); } if (createJobOptions.wordAlternativesThreshold() != null) { - builder.query("word_alternatives_threshold", String.valueOf(createJobOptions.wordAlternativesThreshold())); + builder.query( + "word_alternatives_threshold", + String.valueOf(createJobOptions.wordAlternativesThreshold())); } if (createJobOptions.wordConfidence() != null) { builder.query("word_confidence", String.valueOf(createJobOptions.wordConfidence())); @@ -676,14 +830,15 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) if (createJobOptions.smartFormatting() != null) { builder.query("smart_formatting", String.valueOf(createJobOptions.smartFormatting())); } + if (createJobOptions.smartFormattingVersion() != null) { + builder.query( + "smart_formatting_version", String.valueOf(createJobOptions.smartFormattingVersion())); + } if (createJobOptions.speakerLabels() != null) { builder.query("speaker_labels", String.valueOf(createJobOptions.speakerLabels())); } - if (createJobOptions.customizationId() != null) { - builder.query("customization_id", createJobOptions.customizationId()); - } if (createJobOptions.grammarName() != null) { - builder.query("grammar_name", createJobOptions.grammarName()); + builder.query("grammar_name", String.valueOf(createJobOptions.grammarName())); } if (createJobOptions.redaction() != null) { builder.query("redaction", String.valueOf(createJobOptions.redaction())); @@ -692,72 +847,95 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) builder.query("processing_metrics", String.valueOf(createJobOptions.processingMetrics())); } if (createJobOptions.processingMetricsInterval() != null) { - builder.query("processing_metrics_interval", String.valueOf(createJobOptions.processingMetricsInterval())); + builder.query( + "processing_metrics_interval", + String.valueOf(createJobOptions.processingMetricsInterval())); } if (createJobOptions.audioMetrics() != null) { builder.query("audio_metrics", String.valueOf(createJobOptions.audioMetrics())); } if (createJobOptions.endOfPhraseSilenceTime() != null) { - builder.query("end_of_phrase_silence_time", String.valueOf(createJobOptions.endOfPhraseSilenceTime())); + builder.query( + "end_of_phrase_silence_time", String.valueOf(createJobOptions.endOfPhraseSilenceTime())); } if (createJobOptions.splitTranscriptAtPhraseEnd() != null) { - builder.query("split_transcript_at_phrase_end", String.valueOf(createJobOptions.splitTranscriptAtPhraseEnd())); - } - builder.bodyContent(createJobOptions.contentType(), null, - null, createJobOptions.audio()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + builder.query( + "split_transcript_at_phrase_end", + String.valueOf(createJobOptions.splitTranscriptAtPhraseEnd())); + } + if (createJobOptions.speechDetectorSensitivity() != null) { + builder.query( + "speech_detector_sensitivity", + String.valueOf(createJobOptions.speechDetectorSensitivity())); + } + if (createJobOptions.sadModule() != null) { + builder.query("sad_module", String.valueOf(createJobOptions.sadModule())); + } + if (createJobOptions.backgroundAudioSuppression() != null) { + builder.query( + "background_audio_suppression", + String.valueOf(createJobOptions.backgroundAudioSuppression())); + } + if (createJobOptions.lowLatency() != null) { + builder.query("low_latency", String.valueOf(createJobOptions.lowLatency())); + } + if (createJobOptions.characterInsertionBias() != null) { + builder.query( + "character_insertion_bias", String.valueOf(createJobOptions.characterInsertionBias())); + } + builder.bodyContent(createJobOptions.contentType(), null, null, createJobOptions.audio()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Check jobs. * - * Returns the ID and status of the latest 100 outstanding jobs associated with the credentials with which it is - * called. The method also returns the creation and update times of each job, and, if a job was created with a - * callback URL and a user token, the user token for the job. To obtain the results for a job whose status is - * `completed` or not one of the latest 100 outstanding jobs, use the **Check a job** method. A job and its results - * remain available until you delete them with the **Delete a job** method or until the job's time to live expires, - * whichever comes first. + *

Returns the ID and status of the latest 100 outstanding jobs associated with the credentials + * with which it is called. The method also returns the creation and update times of each job, + * and, if a job was created with a callback URL and a user token, the user token for the job. To + * obtain the results for a job whose status is `completed` or not one of the latest 100 + * outstanding jobs, use the [Check a job[(#checkjob) method. A job and its results remain + * available until you delete them with the [Delete a job](#deletejob) method or until the job's + * time to live expires, whichever comes first. * - * **See also:** [Checking the status of the latest + *

**See also:** [Checking the status of the latest * jobs](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#jobs). * * @param checkJobsOptions the {@link CheckJobsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJobs} */ public ServiceCall checkJobs(CheckJobsOptions checkJobsOptions) { - String[] pathSegments = { "v1/recognitions" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/recognitions")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "checkJobs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (checkJobsOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Check jobs. * - * Returns the ID and status of the latest 100 outstanding jobs associated with the credentials with which it is - * called. The method also returns the creation and update times of each job, and, if a job was created with a - * callback URL and a user token, the user token for the job. To obtain the results for a job whose status is - * `completed` or not one of the latest 100 outstanding jobs, use the **Check a job** method. A job and its results - * remain available until you delete them with the **Delete a job** method or until the job's time to live expires, - * whichever comes first. + *

Returns the ID and status of the latest 100 outstanding jobs associated with the credentials + * with which it is called. The method also returns the creation and update times of each job, + * and, if a job was created with a callback URL and a user token, the user token for the job. To + * obtain the results for a job whose status is `completed` or not one of the latest 100 + * outstanding jobs, use the [Check a job[(#checkjob) method. A job and its results remain + * available until you delete them with the [Delete a job](#deletejob) method or until the job's + * time to live expires, whichever comes first. * - * **See also:** [Checking the status of the latest + *

**See also:** [Checking the status of the latest * jobs](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#jobs). * - * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJobs} */ public ServiceCall checkJobs() { return checkJobs(null); @@ -766,64 +944,70 @@ public ServiceCall checkJobs() { /** * Check a job. * - * Returns information about the specified job. The response always includes the status of the job and its creation - * and update times. If the status is `completed`, the response includes the results of the recognition request. You - * must use credentials for the instance of the service that owns a job to list information about it. + *

Returns information about the specified job. The response always includes the status of the + * job and its creation and update times. If the status is `completed`, the response includes the + * results of the recognition request. You must use credentials for the instance of the service + * that owns a job to list information about it. * - * You can use the method to retrieve the results of any job, regardless of whether it was submitted with a callback - * URL and the `recognitions.completed_with_results` event, and you can retrieve the results multiple times for as - * long as they remain available. Use the **Check jobs** method to request information about the most recent jobs - * associated with the calling credentials. + *

You can use the method to retrieve the results of any job, regardless of whether it was + * submitted with a callback URL and the `recognitions.completed_with_results` event, and you can + * retrieve the results multiple times for as long as they remain available. Use the [Check + * jobs](#checkjobs) method to request information about the most recent jobs associated with the + * calling credentials. * - * **See also:** [Checking the status and retrieving the results of a + *

**See also:** [Checking the status and retrieving the results of a * job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#job). * * @param checkJobOptions the {@link CheckJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJob} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJob} */ public ServiceCall checkJob(CheckJobOptions checkJobOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(checkJobOptions, - "checkJobOptions cannot be null"); - String[] pathSegments = { "v1/recognitions" }; - String[] pathParameters = { checkJobOptions.id() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + checkJobOptions, "checkJobOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("id", checkJobOptions.id()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/recognitions/{id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "checkJob"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a job. * - * Deletes the specified job. You cannot delete a job that the service is actively processing. Once you delete a job, - * its results are no longer available. The service automatically deletes a job and its results when the time to live - * for the results expires. You must use credentials for the instance of the service that owns a job to delete it. + *

Deletes the specified job. You cannot delete a job that the service is actively processing. + * Once you delete a job, its results are no longer available. The service automatically deletes a + * job and its results when the time to live for the results expires. You must use credentials for + * the instance of the service that owns a job to delete it. * - * **See also:** [Deleting a job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#delete-async). + *

**See also:** [Deleting a + * job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#delete-async). * * @param deleteJobOptions the {@link DeleteJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteJob(DeleteJobOptions deleteJobOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteJobOptions, - "deleteJobOptions cannot be null"); - String[] pathSegments = { "v1/recognitions" }; - String[] pathParameters = { deleteJobOptions.id() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteJobOptions, "deleteJobOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("id", deleteJobOptions.id()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/recognitions/{id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteJob"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -831,26 +1015,73 @@ public ServiceCall deleteJob(DeleteJobOptions deleteJobOptions) { /** * Create a custom language model. * - * Creates a new custom language model for a specified base model. The custom language model can be used only with the - * base model for which it is created. The model is owned by the instance of the service whose credentials are used to - * create it. - * - * You can create a maximum of 1024 custom language models per owning credentials. The service returns an error if you - * attempt to create more than 1024 models. You do not lose any models, but you cannot create any more until your - * model count is below the limit. - * - * **See also:** [Create a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#createModel-language). - * - * @param createLanguageModelOptions the {@link CreateLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModel} + *

Creates a new custom language model for a specified base model. The custom language model + * can be used only with the base model for which it is created. The model is owned by the + * instance of the service whose credentials are used to create it. + * + *

You can create a maximum of 1024 custom language models per owning credentials. The service + * returns an error if you attempt to create more than 1024 models. You do not lose any models, + * but you cannot create any more until your model count is below the limit. + * + *

**Important:** Effective **31 July 2023**, all previous-generation models will be removed + * from the service and the documentation. Most previous-generation models were deprecated on 15 + * March 2022. You must migrate to the equivalent large speech model or next-generation model by + * 31 July 2023. For more information, see [Migrating to large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). + * + *

**See also:** * [Create a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#createModel-language) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support) + * + *

### Large speech models and Next-generation models + * + *

The service supports large speech models and next-generation `Multimedia` (16 kHz) and + * `Telephony` (8 kHz) models for many languages. Large speech models and next-generation models + * have higher throughput than the service's previous generation of `Broadband` and `Narrowband` + * models. When you use large speech models and next-generation models, the service can return + * transcriptions more quickly and also provide noticeably better transcription accuracy. + * + *

You specify a large speech model or next-generation model by using the `model` query + * parameter, as you do a previous-generation model. Only the next-generation models support the + * `low_latency` parameter, and all large speech models and next-generation models support the + * `character_insertion_bias` parameter. These parameters are not available with + * previous-generation models. + * + *

Large speech models and next-generation models do not support all of the speech recognition + * parameters that are available for use with previous-generation models. Next-generation models + * do not support the following parameters: * `acoustic_customization_id` * `keywords` and + * `keywords_threshold` * `processing_metrics` and `processing_metrics_interval` * + * `word_alternatives_threshold` + * + *

**Important:** Effective **31 July 2023**, all previous-generation models will be removed + * from the service and the documentation. Most previous-generation models were deprecated on 15 + * March 2022. You must migrate to the equivalent large speech model or next-generation model by + * 31 July 2023. For more information, see [Migrating to large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). + * + *

**See also:** * [Large speech languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages) + * * [Supported features for large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages#models-lsm-supported-features) + * * [Next-generation languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng) * [Supported + * features for next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-features). + * + * @param createLanguageModelOptions the {@link CreateLanguageModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link LanguageModel} */ - public ServiceCall createLanguageModel(CreateLanguageModelOptions createLanguageModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createLanguageModelOptions, - "createLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createLanguageModel"); + public ServiceCall createLanguageModel( + CreateLanguageModelOptions createLanguageModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createLanguageModelOptions, "createLanguageModelOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "createLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } @@ -865,57 +1096,65 @@ public ServiceCall createLanguageModel(CreateLanguageModelOptions contentJson.addProperty("description", createLanguageModelOptions.description()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom language models. * - * Lists information about all custom language models that are owned by an instance of the service. Use the `language` - * parameter to see all custom language models for the specified language. Omit the parameter to see all custom - * language models for all languages. You must use credentials for the instance of the service that owns a model to - * list information about it. + *

Lists information about all custom language models that are owned by an instance of the + * service. Use the `language` parameter to see all custom language models for the specified + * language. Omit the parameter to see all custom language models for all languages. You must use + * credentials for the instance of the service that owns a model to list information about it. * - * **See also:** [Listing custom language - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language). + *

**See also:** * [Listing custom language + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * - * @param listLanguageModelsOptions the {@link ListLanguageModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModels} + * @param listLanguageModelsOptions the {@link ListLanguageModelsOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link LanguageModels} */ - public ServiceCall listLanguageModels(ListLanguageModelsOptions listLanguageModelsOptions) { - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listLanguageModels"); + public ServiceCall listLanguageModels( + ListLanguageModelsOptions listLanguageModelsOptions) { + if (listLanguageModelsOptions == null) { + listLanguageModelsOptions = new ListLanguageModelsOptions.Builder().build(); + } + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "listLanguageModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listLanguageModelsOptions != null) { - if (listLanguageModelsOptions.language() != null) { - builder.query("language", listLanguageModelsOptions.language()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + if (listLanguageModelsOptions.language() != null) { + builder.query("language", String.valueOf(listLanguageModelsOptions.language())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom language models. * - * Lists information about all custom language models that are owned by an instance of the service. Use the `language` - * parameter to see all custom language models for the specified language. Omit the parameter to see all custom - * language models for all languages. You must use credentials for the instance of the service that owns a model to - * list information about it. + *

Lists information about all custom language models that are owned by an instance of the + * service. Use the `language` parameter to see all custom language models for the specified + * language. Omit the parameter to see all custom language models for all languages. You must use + * credentials for the instance of the service that owns a model to list information about it. * - * **See also:** [Listing custom language - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language). + *

**See also:** * [Listing custom language + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * - * @return a {@link ServiceCall} with a response type of {@link LanguageModels} + * @return a {@link ServiceCall} with a result of type {@link LanguageModels} */ public ServiceCall listLanguageModels() { return listLanguageModels(null); @@ -924,60 +1163,72 @@ public ServiceCall listLanguageModels() { /** * Get a custom language model. * - * Gets information about a specified custom language model. You must use credentials for the instance of the service - * that owns a model to list information about it. + *

Gets information about a specified custom language model. You must use credentials for the + * instance of the service that owns a model to list information about it. * - * **See also:** [Listing custom language - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language). + *

**See also:** * [Listing custom language + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * - * @param getLanguageModelOptions the {@link GetLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModel} + * @param getLanguageModelOptions the {@link GetLanguageModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link LanguageModel} */ - public ServiceCall getLanguageModel(GetLanguageModelOptions getLanguageModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getLanguageModelOptions, - "getLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { getLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getLanguageModel"); + public ServiceCall getLanguageModel( + GetLanguageModelOptions getLanguageModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getLanguageModelOptions, "getLanguageModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getLanguageModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "getLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a custom language model. * - * Deletes an existing custom language model. The custom model cannot be deleted if another request, such as adding a - * corpus or grammar to the model, is currently being processed. You must use credentials for the instance of the - * service that owns a model to delete it. + *

Deletes an existing custom language model. The custom model cannot be deleted if another + * request, such as adding a corpus or grammar to the model, is currently being processed. You + * must use credentials for the instance of the service that owns a model to delete it. * - * **See also:** [Deleting a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#deleteModel-language). + *

**See also:** * [Deleting a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#deleteModel-language) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * - * @param deleteLanguageModelOptions the {@link DeleteLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteLanguageModelOptions the {@link DeleteLanguageModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall deleteLanguageModel(DeleteLanguageModelOptions deleteLanguageModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteLanguageModelOptions, - "deleteLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { deleteLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteLanguageModel"); + public ServiceCall deleteLanguageModel( + DeleteLanguageModelOptions deleteLanguageModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteLanguageModelOptions, "deleteLanguageModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteLanguageModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -985,90 +1236,121 @@ public ServiceCall deleteLanguageModel(DeleteLanguageModelOptions deleteLa /** * Train a custom language model. * - * Initiates the training of a custom language model with new resources such as corpora, grammars, and custom words. - * After adding, modifying, or deleting resources for a custom language model, use this method to begin the actual - * training of the model on the latest data. You can specify whether the custom language model is to be trained with - * all words from its words resource or only with words that were added or modified by the user directly. You must use - * credentials for the instance of the service that owns a model to train it. - * - * The training method is asynchronous. It can take on the order of minutes to complete depending on the amount of - * data on which the service is being trained and the current load on the service. The method returns an HTTP 200 - * response code to indicate that the training process has begun. - * - * You can monitor the status of the training by using the **Get a custom language model** method to poll the model's - * status. Use a loop to check the status every 10 seconds. The method returns a `LanguageModel` object that includes - * `status` and `progress` fields. A status of `available` means that the custom model is trained and ready to use. - * The service cannot accept subsequent training requests or requests to add new resources until the existing request - * completes. - * - * **See also:** [Train the custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#trainModel-language). - * - * ### Training failures - * - * Training can fail to start for the following reasons: - * * The service is currently handling another request for the custom model, such as another training request or a - * request to add a corpus or grammar to the model. - * * No training data have been added to the custom model. - * * The custom model contains one or more invalid corpora, grammars, or words (for example, a custom word has an - * invalid sounds-like pronunciation). You can correct the invalid resources or set the `strict` parameter to `false` - * to exclude the invalid resources from the training. The model must contain at least one valid resource for training - * to succeed. - * - * @param trainLanguageModelOptions the {@link TrainLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingResponse} + *

Initiates the training of a custom language model with new resources such as corpora, + * grammars, and custom words. After adding, modifying, or deleting resources for a custom + * language model, use this method to begin the actual training of the model on the latest data. + * You can specify whether the custom language model is to be trained with all words from its + * words resource or only with words that were added or modified by the user directly. You must + * use credentials for the instance of the service that owns a model to train it. + * + *

The training method is asynchronous. It can take on the order of minutes to complete + * depending on the amount of data on which the service is being trained and the current load on + * the service. The method returns an HTTP 200 response code to indicate that the training process + * has begun. + * + *

You can monitor the status of the training by using the [Get a custom language + * model](#getlanguagemodel) method to poll the model's status. Use a loop to check the status + * every 10 seconds. If you added custom words directly to a custom model that is based on a + * next-generation model, allow for some minutes of extra training time for the model. + * + *

The method returns a `LanguageModel` object that includes `status` and `progress` fields. A + * status of `available` means that the custom model is trained and ready to use. The service + * cannot accept subsequent training requests or requests to add new resources until the existing + * request completes. + * + *

For custom models that are based on improved base language models, training also performs an + * automatic upgrade to a newer version of the base model. You do not need to use the [Upgrade a + * custom language model](#upgradelanguagemodel) method to perform the upgrade. + * + *

**See also:** * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support) * + * [Train the custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#trainModel-language) + * * [Upgrading custom language models that are based on improved next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language-ng) + * + *

### Training failures + * + *

Training can fail to start for the following reasons: * The service is currently handling + * another request for the custom model, such as another training request or a request to add a + * corpus or grammar to the model. * No training data have been added to the custom model. * The + * custom model contains one or more invalid corpora, grammars, or words (for example, a custom + * word has an invalid sounds-like pronunciation). You can correct the invalid resources or set + * the `strict` parameter to `false` to exclude the invalid resources from the training. The model + * must contain at least one valid resource for training to succeed. + * + * @param trainLanguageModelOptions the {@link TrainLanguageModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link TrainingResponse} */ - public ServiceCall trainLanguageModel(TrainLanguageModelOptions trainLanguageModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(trainLanguageModelOptions, - "trainLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "train" }; - String[] pathParameters = { trainLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "trainLanguageModel"); + public ServiceCall trainLanguageModel( + TrainLanguageModelOptions trainLanguageModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + trainLanguageModelOptions, "trainLanguageModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", trainLanguageModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/train", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "trainLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (trainLanguageModelOptions.wordTypeToAdd() != null) { - builder.query("word_type_to_add", trainLanguageModelOptions.wordTypeToAdd()); + builder.query("word_type_to_add", String.valueOf(trainLanguageModelOptions.wordTypeToAdd())); } if (trainLanguageModelOptions.customizationWeight() != null) { - builder.query("customization_weight", String.valueOf(trainLanguageModelOptions.customizationWeight())); + builder.query( + "customization_weight", String.valueOf(trainLanguageModelOptions.customizationWeight())); + } + if (trainLanguageModelOptions.strict() != null) { + builder.query("strict", String.valueOf(trainLanguageModelOptions.strict())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + if (trainLanguageModelOptions.force() != null) { + builder.query("force", String.valueOf(trainLanguageModelOptions.force())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Reset a custom language model. * - * Resets a custom language model by removing all corpora, grammars, and words from the model. Resetting a custom - * language model initializes the model to its state when it was first created. Metadata such as the name and language - * of the model are preserved, but the model's words resource is removed and must be re-created. You must use - * credentials for the instance of the service that owns a model to reset it. + *

Resets a custom language model by removing all corpora, grammars, and words from the model. + * Resetting a custom language model initializes the model to its state when it was first created. + * Metadata such as the name and language of the model are preserved, but the model's words + * resource is removed and must be re-created. You must use credentials for the instance of the + * service that owns a model to reset it. * - * **See also:** [Resetting a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#resetModel-language). + *

**See also:** * [Resetting a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#resetModel-language) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * - * @param resetLanguageModelOptions the {@link ResetLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param resetLanguageModelOptions the {@link ResetLanguageModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result */ public ServiceCall resetLanguageModel(ResetLanguageModelOptions resetLanguageModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(resetLanguageModelOptions, - "resetLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "reset" }; - String[] pathParameters = { resetLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "resetLanguageModel"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + resetLanguageModelOptions, "resetLanguageModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", resetLanguageModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/reset", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "resetLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1076,37 +1358,55 @@ public ServiceCall resetLanguageModel(ResetLanguageModelOptions resetLangu /** * Upgrade a custom language model. * - * Initiates the upgrade of a custom language model to the latest version of its base language model. The upgrade - * method is asynchronous. It can take on the order of minutes to complete depending on the amount of data in the - * custom model and the current load on the service. A custom model must be in the `ready` or `available` state to be - * upgraded. You must use credentials for the instance of the service that owns a model to upgrade it. - * - * The method returns an HTTP 200 response code to indicate that the upgrade process has begun successfully. You can - * monitor the status of the upgrade by using the **Get a custom language model** method to poll the model's status. - * The method returns a `LanguageModel` object that includes `status` and `progress` fields. Use a loop to check the - * status every 10 seconds. While it is being upgraded, the custom model has the status `upgrading`. When the upgrade - * is complete, the model resumes the status that it had prior to upgrade. The service cannot accept subsequent - * requests for the model until the upgrade completes. - * - * **See also:** [Upgrading a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customUpgrade#upgradeLanguage). - * - * @param upgradeLanguageModelOptions the {@link UpgradeLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + *

Initiates the upgrade of a custom language model to the latest version of its base language + * model. The upgrade method is asynchronous. It can take on the order of minutes to complete + * depending on the amount of data in the custom model and the current load on the service. A + * custom model must be in the `ready` or `available` state to be upgraded. You must use + * credentials for the instance of the service that owns a model to upgrade it. + * + *

The method returns an HTTP 200 response code to indicate that the upgrade process has begun + * successfully. You can monitor the status of the upgrade by using the [Get a custom language + * model](#getlanguagemodel) method to poll the model's status. The method returns a + * `LanguageModel` object that includes `status` and `progress` fields. Use a loop to check the + * status every 10 seconds. + * + *

While it is being upgraded, the custom model has the status `upgrading`. When the upgrade is + * complete, the model resumes the status that it had prior to upgrade. The service cannot accept + * subsequent requests for the model until the upgrade completes. + * + *

For custom models that are based on improved base language models, the [Train a custom + * language model](#trainlanguagemodel) method also performs an automatic upgrade to a newer + * version of the base model. You do not need to use the upgrade method. + * + *

**See also:** * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support) * + * [Upgrading a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language) + * * [Upgrading custom language models that are based on improved next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language-ng). + * + * @param upgradeLanguageModelOptions the {@link UpgradeLanguageModelOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall upgradeLanguageModel(UpgradeLanguageModelOptions upgradeLanguageModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(upgradeLanguageModelOptions, - "upgradeLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "upgrade_model" }; - String[] pathParameters = { upgradeLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "upgradeLanguageModel"); + public ServiceCall upgradeLanguageModel( + UpgradeLanguageModelOptions upgradeLanguageModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + upgradeLanguageModelOptions, "upgradeLanguageModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", upgradeLanguageModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/upgrade_model", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "upgradeLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1114,85 +1414,113 @@ public ServiceCall upgradeLanguageModel(UpgradeLanguageModelOptions upgrad /** * List corpora. * - * Lists information about all corpora from a custom language model. The information includes the total number of - * words and out-of-vocabulary (OOV) words, name, and status of each corpus. You must use credentials for the instance - * of the service that owns a model to list its corpora. + *

Lists information about all corpora from a custom language model. The information includes + * the name, status, and total number of words for each corpus. _For custom models that are based + * on previous-generation models_, it also includes the number of out-of-vocabulary (OOV) words + * from the corpus. You must use credentials for the instance of the service that owns a model to + * list its corpora. * - * **See also:** [Listing corpora for a custom language + *

**See also:** [Listing corpora for a custom language * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageCorpora#listCorpora). * * @param listCorporaOptions the {@link ListCorporaOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Corpora} + * @return a {@link ServiceCall} with a result of type {@link Corpora} */ public ServiceCall listCorpora(ListCorporaOptions listCorporaOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listCorporaOptions, - "listCorporaOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { listCorporaOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listCorporaOptions, "listCorporaOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listCorporaOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/corpora", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listCorpora"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Add a corpus. * - * Adds a single corpus text file of new training data to a custom language model. Use multiple requests to submit - * multiple corpus text files. You must use credentials for the instance of the service that owns a model to add a - * corpus to it. Adding a corpus does not affect the custom language model until you train the model for the new data - * by using the **Train a custom language model** method. - * - * Submit a plain text file that contains sample sentences from the domain of interest to enable the service to - * extract words in context. The more sentences you add that represent the context in which speakers use words from - * the domain, the better the service's recognition accuracy. - * - * The call returns an HTTP 201 response code if the corpus is valid. The service then asynchronously processes the - * contents of the corpus and automatically extracts new words that it finds. This can take on the order of a minute - * or two to complete depending on the total number of words and the number of new words in the corpus, as well as the - * current load on the service. You cannot submit requests to add additional resources to the custom model or to train - * the model until the service's analysis of the corpus for the current request completes. Use the **List a corpus** - * method to check the status of the analysis. - * - * The service auto-populates the model's words resource with words from the corpus that are not found in its base - * vocabulary. These are referred to as out-of-vocabulary (OOV) words. You can use the **List custom words** method to - * examine the words resource. You can use other words method to eliminate typos and modify how words are pronounced - * as needed. - * - * To add a corpus file that has the same name as an existing corpus, set the `allow_overwrite` parameter to `true`; - * otherwise, the request fails. Overwriting an existing corpus causes the service to process the corpus text file and - * extract OOV words anew. Before doing so, it removes any OOV words associated with the existing corpus from the - * model's words resource unless they were also added by another corpus or grammar, or they have been modified in some - * way with the **Add custom words** or **Add a custom word** method. - * - * The service limits the overall amount of data that you can add to a custom model to a maximum of 10 million total - * words from all sources combined. Also, you can add no more than 90 thousand custom (OOV) words to a model. This - * includes words that the service extracts from corpora and grammars, and words that you add directly. - * - * **See also:** - * * [Working with - * corpora](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingCorpora) - * * [Add a corpus to the custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addCorpus). + *

Adds a single corpus text file of new training data to a custom language model. Use multiple + * requests to submit multiple corpus text files. You must use credentials for the instance of the + * service that owns a model to add a corpus to it. Adding a corpus does not affect the custom + * language model until you train the model for the new data by using the [Train a custom language + * model](#trainlanguagemodel) method. + * + *

Submit a plain text file that contains sample sentences from the domain of interest to + * enable the service to parse the words in context. The more sentences you add that represent the + * context in which speakers use words from the domain, the better the service's recognition + * accuracy. + * + *

The call returns an HTTP 201 response code if the corpus is valid. The service then + * asynchronously processes and automatically extracts data from the contents of the corpus. This + * operation can take on the order of minutes to complete depending on the current load on the + * service, the total number of words in the corpus, and, _for custom models that are based on + * previous-generation models_, the number of new (out-of-vocabulary) words in the corpus. You + * cannot submit requests to add additional resources to the custom model or to train the model + * until the service's analysis of the corpus for the current request completes. Use the [Get a + * corpus](#getcorpus) method to check the status of the analysis. + * + *

_For custom models that are based on large speech models_, the service parses and extracts + * word sequences from one or multiple corpora files. The characters help the service learn and + * predict character sequences from audio. + * + *

_For custom models that are based on previous-generation models_, the service auto-populates + * the model's words resource with words from the corpus that are not found in its base + * vocabulary. These words are referred to as out-of-vocabulary (OOV) words. After adding a + * corpus, you must validate the words resource to ensure that each OOV word's definition is + * complete and valid. You can use the [List custom words](#listwords) method to examine the words + * resource. You can use other words method to eliminate typos and modify how words are pronounced + * and displayed as needed. + * + *

To add a corpus file that has the same name as an existing corpus, set the `allow_overwrite` + * parameter to `true`; otherwise, the request fails. Overwriting an existing corpus causes the + * service to process the corpus text file and extract its data anew. _For a custom model that is + * based on a previous-generation model_, the service first removes any OOV words that are + * associated with the existing corpus from the model's words resource unless they were also added + * by another corpus or grammar, or they have been modified in some way with the [Add custom + * words](#addwords) or [Add a custom word](#addword) method. + * + *

The service limits the overall amount of data that you can add to a custom model to a + * maximum of 10 million total words from all sources combined. _For a custom model that is based + * on a previous-generation model_, you can add no more than 90 thousand custom (OOV) words to a + * model. This includes words that the service extracts from corpora and grammars, and words that + * you add directly. + * + *

**See also:** * [Add a corpus to the custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addCorpus) + * * [Working with corpora for previous-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingCorpora) + * * [Working with corpora for large speech models and next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#workingCorpora-ng) + * * [Validating a words resource for previous-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel) + * * [Validating a words resource for large speech models and next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#validateModel-ng). * * @param addCorpusOptions the {@link AddCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addCorpusOptions, - "addCorpusOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { addCorpusOptions.customizationId(), addCorpusOptions.corpusName() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + addCorpusOptions, "addCorpusOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addCorpusOptions.customizationId()); + pathParamsMap.put("corpus_name", addCorpusOptions.corpusName()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/corpora/{corpus_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addCorpus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1201,7 +1529,10 @@ public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { if (addCorpusOptions.allowOverwrite() != null) { builder.query("allow_overwrite", String.valueOf(addCorpusOptions.allowOverwrite())); } + + // hand edit replacement for corpus file serialization builder.body(RequestUtils.inputStreamBody(addCorpusOptions.corpusFile(), "text/plain")); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1209,63 +1540,78 @@ public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { /** * Get a corpus. * - * Gets information about a corpus from a custom language model. The information includes the total number of words - * and out-of-vocabulary (OOV) words, name, and status of the corpus. You must use credentials for the instance of the - * service that owns a model to list its corpora. + *

Gets information about a corpus from a custom language model. The information includes the + * name, status, and total number of words for the corpus. _For custom models that are based on + * previous-generation models_, it also includes the number of out-of-vocabulary (OOV) words from + * the corpus. You must use credentials for the instance of the service that owns a model to list + * its corpora. * - * **See also:** [Listing corpora for a custom language + *

**See also:** [Listing corpora for a custom language * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageCorpora#listCorpora). * * @param getCorpusOptions the {@link GetCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Corpus} + * @return a {@link ServiceCall} with a result of type {@link Corpus} */ public ServiceCall getCorpus(GetCorpusOptions getCorpusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getCorpusOptions, - "getCorpusOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { getCorpusOptions.customizationId(), getCorpusOptions.corpusName() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getCorpusOptions, "getCorpusOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getCorpusOptions.customizationId()); + pathParamsMap.put("corpus_name", getCorpusOptions.corpusName()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/corpora/{corpus_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getCorpus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a corpus. * - * Deletes an existing corpus from a custom language model. The service removes any out-of-vocabulary (OOV) words that - * are associated with the corpus from the custom model's words resource unless they were also added by another corpus - * or grammar, or they were modified in some way with the **Add custom words** or **Add a custom word** method. - * Removing a corpus does not affect the custom model until you train the model with the **Train a custom language - * model** method. You must use credentials for the instance of the service that owns a model to delete its corpora. + *

Deletes an existing corpus from a custom language model. Removing a corpus does not affect + * the custom model until you train the model with the [Train a custom language + * model](#trainlanguagemodel) method. You must use credentials for the instance of the service + * that owns a model to delete its corpora. + * + *

_For custom models that are based on previous-generation models_, the service removes any + * out-of-vocabulary (OOV) words that are associated with the corpus from the custom model's words + * resource unless they were also added by another corpus or grammar, or they were modified in + * some way with the [Add custom words](#addwords) or [Add a custom word](#addword) method. * - * **See also:** [Deleting a corpus from a custom language + *

**See also:** [Deleting a corpus from a custom language * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageCorpora#deleteCorpus). * * @param deleteCorpusOptions the {@link DeleteCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteCorpus(DeleteCorpusOptions deleteCorpusOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCorpusOptions, - "deleteCorpusOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { deleteCorpusOptions.customizationId(), deleteCorpusOptions.corpusName() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteCorpus"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteCorpusOptions, "deleteCorpusOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteCorpusOptions.customizationId()); + pathParamsMap.put("corpus_name", deleteCorpusOptions.corpusName()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/corpora/{corpus_name}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteCorpus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1273,106 +1619,142 @@ public ServiceCall deleteCorpus(DeleteCorpusOptions deleteCorpusOptions) { /** * List custom words. * - * Lists information about custom words from a custom language model. You can list all words from the custom model's - * words resource, only custom words that were added or modified by the user, or only out-of-vocabulary (OOV) words - * that were extracted from corpora or are recognized by grammars. You can also indicate the order in which the - * service is to return words; by default, the service lists words in ascending alphabetical order. You must use - * credentials for the instance of the service that owns a model to list information about its words. + *

Lists information about custom words from a custom language model. You can list all words + * from the custom model's words resource, only custom words that were added or modified by the + * user, or, _for a custom model that is based on a previous-generation model_, only + * out-of-vocabulary (OOV) words that were extracted from corpora or are recognized by grammars. + * _For a custom model that is based on a next-generation model_, you can list all words or only + * those words that were added directly by a user, which return the same results. + * + *

You can also indicate the order in which the service is to return words; by default, the + * service lists words in ascending alphabetical order. You must use credentials for the instance + * of the service that owns a model to list information about its words. * - * **See also:** [Listing words from a custom language + *

**See also:** [Listing words from a custom language * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#listWords). * * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Words} + * @return a {@link ServiceCall} with a result of type {@link Words} */ public ServiceCall listWords(ListWordsOptions listWordsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listWordsOptions, - "listWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { listWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listWordsOptions, "listWordsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listWordsOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (listWordsOptions.wordType() != null) { - builder.query("word_type", listWordsOptions.wordType()); + builder.query("word_type", String.valueOf(listWordsOptions.wordType())); } if (listWordsOptions.sort() != null) { - builder.query("sort", listWordsOptions.sort()); + builder.query("sort", String.valueOf(listWordsOptions.sort())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Add custom words. * - * Adds one or more custom words to a custom language model. The service populates the words resource for a custom - * model with out-of-vocabulary (OOV) words from each corpus or grammar that is added to the model. You can use this - * method to add additional words or to modify existing words in the words resource. The words resource for a model - * can contain a maximum of 90 thousand custom (OOV) words. This includes words that the service extracts from corpora - * and grammars and words that you add directly. - * - * You must use credentials for the instance of the service that owns a model to add or modify custom words for the - * model. Adding or modifying custom words does not affect the custom model until you train the model for the new data - * by using the **Train a custom language model** method. - * - * You add custom words by providing a `CustomWords` object, which is an array of `CustomWord` objects, one per word. - * You must use the object's `word` parameter to identify the word that is to be added. You can also provide one or - * both of the optional `sounds_like` and `display_as` fields for each word. - * * The `sounds_like` field provides an array of one or more pronunciations for the word. Use the parameter to - * specify how the word can be pronounced by users. Use the parameter for words that are difficult to pronounce, - * foreign words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound like `i triple - * e`. You can specify a maximum of five sounds-like pronunciations for a word. - * * The `display_as` field provides a different way of spelling the word in a transcript. Use the parameter when you - * want the word to appear different from its usual representation or from its spelling in training data. For example, - * you might indicate that the word `IBM(trademark)` is to be displayed as `IBM™`. - * - * If you add a custom word that already exists in the words resource for the custom model, the new definition - * overwrites the existing data for the word. If the service encounters an error with the input data, it returns a - * failure code and does not add any of the words to the words resource. - * - * The call returns an HTTP 201 response code if the input data is valid. It then asynchronously processes the words - * to add them to the model's words resource. The time that it takes for the analysis to complete depends on the - * number of new words that you add but is generally faster than adding a corpus or grammar. - * - * You can monitor the status of the request by using the **List a custom language model** method to poll the model's - * status. Use a loop to check the status every 10 seconds. The method returns a `Customization` object that includes - * a `status` field. A status of `ready` means that the words have been added to the custom model. The service cannot + *

Adds one or more custom words to a custom language model. You can use this method to add + * words or to modify existing words in a custom model's words resource. _For custom models that + * are based on previous-generation models_, the service populates the words resource for a custom + * model with out-of-vocabulary (OOV) words from each corpus or grammar that is added to the + * model. You can use this method to modify OOV words in the model's words resource. + * + *

_For a custom model that is based on a previous-generation model_, the words resource for a + * model can contain a maximum of 90 thousand custom (OOV) words. This includes words that the + * service extracts from corpora and grammars and words that you add directly. + * + *

You must use credentials for the instance of the service that owns a model to add or modify + * custom words for the model. Adding or modifying custom words does not affect the custom model + * until you train the model for the new data by using the [Train a custom language + * model](#trainlanguagemodel) method. + * + *

You add custom words by providing a `CustomWords` object, which is an array of `CustomWord` + * objects, one per word. Use the object's `word` parameter to identify the word that is to be + * added. You can also provide one or both of the optional `display_as` or `sounds_like` fields + * for each word. * The `display_as` field provides a different way of spelling the word in a + * transcript. Use the parameter when you want the word to appear different from its usual + * representation or from its spelling in training data. For example, you might indicate that the + * word `IBM` is to be displayed as `IBM&trade;`. * The `sounds_like` field provides an array + * of one or more pronunciations for the word. Use the parameter to specify how the word can be + * pronounced by users. Use the parameter for words that are difficult to pronounce, foreign + * words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound like + * `I triple E`. You can specify a maximum of five sounds-like pronunciations for a word. _For a + * custom model that is based on a previous-generation model_, if you omit the `sounds_like` + * field, the service attempts to set the field to its pronunciation of the word. It cannot + * generate a pronunciation for all words, so you must review the word's definition to ensure that + * it is complete and valid. * The `mapping_only` field provides parameter for custom words. You + * can use the 'mapping_only' key in custom words as a form of post processing. This key parameter + * has a boolean value to determine whether 'sounds_like' (for non-Japanese models) or word (for + * Japanese) is not used for the model fine-tuning, but for the replacement for 'display_as'. This + * feature helps you when you use custom words exclusively to map 'sounds_like' (or word) to + * 'display_as' value. When you use custom words solely for post-processing purposes that does not + * need fine-tuning. + * + *

If you add a custom word that already exists in the words resource for the custom model, the + * new definition overwrites the existing data for the word. If the service encounters an error + * with the input data, it returns a failure code and does not add any of the words to the words + * resource. + * + *

The call returns an HTTP 201 response code if the input data is valid. It then + * asynchronously processes the words to add them to the model's words resource. The time that it + * takes for the analysis to complete depends on the number of new words that you add but is + * generally faster than adding a corpus or grammar. + * + *

You can monitor the status of the request by using the [Get a custom language + * model](#getlanguagemodel) method to poll the model's status. Use a loop to check the status + * every 10 seconds. The method returns a `Customization` object that includes a `status` field. A + * status of `ready` means that the words have been added to the custom model. The service cannot * accept requests to add new data or to train the model until the existing request completes. * - * You can use the **List custom words** or **List a custom word** method to review the words that you add. Words with - * an invalid `sounds_like` field include an `error` field that describes the problem. You can use other words-related - * methods to correct errors, eliminate typos, and modify how words are pronounced as needed. - * - * **See also:** - * * [Working with custom - * words](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) - * * [Add words to the custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords). + *

You can use the [List custom words](#listwords) or [Get a custom word](#getword) method to + * review the words that you add. Words with an invalid `sounds_like` field include an `error` + * field that describes the problem. You can use other words-related methods to correct errors, + * eliminate typos, and modify how words are pronounced as needed. + * + *

**See also:** * [Add words to the custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords) + * * [Working with custom words for previous-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) + * * [Working with custom words for large speech models and next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#workingWords-ng) + * * [Validating a words resource for previous-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel) + * * [Validating a words resource for large speech models and next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#validateModel-ng). * * @param addWordsOptions the {@link AddWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWords(AddWordsOptions addWordsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addWordsOptions, - "addWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + addWordsOptions, "addWordsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordsOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("words", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addWordsOptions.words())); + contentJson.add( + "words", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addWordsOptions.words())); builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); @@ -1381,46 +1763,66 @@ public ServiceCall addWords(AddWordsOptions addWordsOptions) { /** * Add a custom word. * - * Adds a custom word to a custom language model. The service populates the words resource for a custom model with - * out-of-vocabulary (OOV) words from each corpus or grammar that is added to the model. You can use this method to - * add a word or to modify an existing word in the words resource. The words resource for a model can contain a - * maximum of 90 thousand custom (OOV) words. This includes words that the service extracts from corpora and grammars - * and words that you add directly. - * - * You must use credentials for the instance of the service that owns a model to add or modify a custom word for the - * model. Adding or modifying a custom word does not affect the custom model until you train the model for the new - * data by using the **Train a custom language model** method. - * - * Use the `word_name` parameter to specify the custom word that is to be added or modified. Use the `CustomWord` - * object to provide one or both of the optional `sounds_like` and `display_as` fields for the word. - * * The `sounds_like` field provides an array of one or more pronunciations for the word. Use the parameter to - * specify how the word can be pronounced by users. Use the parameter for words that are difficult to pronounce, - * foreign words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound like `i triple - * e`. You can specify a maximum of five sounds-like pronunciations for a word. - * * The `display_as` field provides a different way of spelling the word in a transcript. Use the parameter when you - * want the word to appear different from its usual representation or from its spelling in training data. For example, - * you might indicate that the word `IBM(trademark)` is to be displayed as `IBM™`. - * - * If you add a custom word that already exists in the words resource for the custom model, the new definition - * overwrites the existing data for the word. If the service encounters an error, it does not add the word to the - * words resource. Use the **List a custom word** method to review the word that you add. - * - * **See also:** - * * [Working with custom - * words](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) - * * [Add words to the custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords). + *

Adds a custom word to a custom language model. You can use this method to add a word or to + * modify an existing word in the words resource. _For custom models that are based on + * previous-generation models_, the service populates the words resource for a custom model with + * out-of-vocabulary (OOV) words from each corpus or grammar that is added to the model. You can + * use this method to modify OOV words in the model's words resource. + * + *

_For a custom model that is based on a previous-generation models_, the words resource for a + * model can contain a maximum of 90 thousand custom (OOV) words. This includes words that the + * service extracts from corpora and grammars and words that you add directly. + * + *

You must use credentials for the instance of the service that owns a model to add or modify + * a custom word for the model. Adding or modifying a custom word does not affect the custom model + * until you train the model for the new data by using the [Train a custom language + * model](#trainlanguagemodel) method. + * + *

Use the `word_name` parameter to specify the custom word that is to be added or modified. + * Use the `CustomWord` object to provide one or both of the optional `display_as` or + * `sounds_like` fields for the word. * The `display_as` field provides a different way of + * spelling the word in a transcript. Use the parameter when you want the word to appear different + * from its usual representation or from its spelling in training data. For example, you might + * indicate that the word `IBM` is to be displayed as `IBM&trade;`. * The `sounds_like` field + * provides an array of one or more pronunciations for the word. Use the parameter to specify how + * the word can be pronounced by users. Use the parameter for words that are difficult to + * pronounce, foreign words, acronyms, and so on. For example, you might specify that the word + * `IEEE` can sound like `i triple e`. You can specify a maximum of five sounds-like + * pronunciations for a word. _For custom models that are based on previous-generation models_, if + * you omit the `sounds_like` field, the service attempts to set the field to its pronunciation of + * the word. It cannot generate a pronunciation for all words, so you must review the word's + * definition to ensure that it is complete and valid. + * + *

If you add a custom word that already exists in the words resource for the custom model, the + * new definition overwrites the existing data for the word. If the service encounters an error, + * it does not add the word to the words resource. Use the [Get a custom word](#getword) method to + * review the word that you add. + * + *

**See also:** * [Add words to the custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords) + * * [Working with custom words for previous-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) + * * [Working with custom words for large speech models and next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#workingWords-ng) + * * [Validating a words resource for previous-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel) + * * [Validating a words resource for large speech models and next-generation + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#validateModel-ng). * * @param addWordOptions the {@link AddWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWord(AddWordOptions addWordOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addWordOptions, - "addWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordOptions.customizationId(), addWordOptions.wordName() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull(addWordOptions, "addWordOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordOptions.customizationId()); + pathParamsMap.put("word_name", addWordOptions.wordName()); + RequestBuilder builder = + RequestBuilder.put( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1430,9 +1832,17 @@ public ServiceCall addWord(AddWordOptions addWordOptions) { if (addWordOptions.word() != null) { contentJson.addProperty("word", addWordOptions.word()); } + if (addWordOptions.mappingOnly() != null) { + contentJson.add( + "mapping_only", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(addWordOptions.mappingOnly())); + } if (addWordOptions.soundsLike() != null) { - contentJson.add("sounds_like", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addWordOptions - .soundsLike())); + contentJson.add( + "sounds_like", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(addWordOptions.soundsLike())); } if (addWordOptions.displayAs() != null) { contentJson.addProperty("display_as", addWordOptions.displayAs()); @@ -1445,62 +1855,69 @@ public ServiceCall addWord(AddWordOptions addWordOptions) { /** * Get a custom word. * - * Gets information about a custom word from a custom language model. You must use credentials for the instance of the - * service that owns a model to list information about its words. + *

Gets information about a custom word from a custom language model. You must use credentials + * for the instance of the service that owns a model to list information about its words. * - * **See also:** [Listing words from a custom language + *

**See also:** [Listing words from a custom language * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#listWords). * * @param getWordOptions the {@link GetWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Word} + * @return a {@link ServiceCall} with a result of type {@link Word} */ public ServiceCall getWord(GetWordOptions getWordOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getWordOptions, - "getWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.wordName() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull(getWordOptions, "getWordOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getWordOptions.customizationId()); + pathParamsMap.put("word_name", getWordOptions.wordName()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a custom word. * - * Deletes a custom word from a custom language model. You can remove any word that you added to the custom model's - * words resource via any means. However, if the word also exists in the service's base vocabulary, the service - * removes only the custom pronunciation for the word; the word remains in the base vocabulary. Removing a custom word - * does not affect the custom model until you train the model with the **Train a custom language model** method. You + *

Deletes a custom word from a custom language model. You can remove any word that you added + * to the custom model's words resource via any means. However, if the word also exists in the + * service's base vocabulary, the service removes the word only from the words resource; the word + * remains in the base vocabulary. Removing a custom word does not affect the custom model until + * you train the model with the [Train a custom language model](#trainlanguagemodel) method. You * must use credentials for the instance of the service that owns a model to delete its words. * - * **See also:** [Deleting a word from a custom language + *

**See also:** [Deleting a word from a custom language * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#deleteWord). * * @param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteWordOptions, - "deleteWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { deleteWordOptions.customizationId(), deleteWordOptions.wordName() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteWordOptions, "deleteWordOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteWordOptions.customizationId()); + pathParamsMap.put("word_name", deleteWordOptions.wordName()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1508,80 +1925,100 @@ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { /** * List grammars. * - * Lists information about all grammars from a custom language model. The information includes the total number of - * out-of-vocabulary (OOV) words, name, and status of each grammar. You must use credentials for the instance of the - * service that owns a model to list its grammars. + *

Lists information about all grammars from a custom language model. For each grammar, the + * information includes the name, status, and (for grammars that are based on previous-generation + * models) the total number of out-of-vocabulary (OOV) words. You must use credentials for the + * instance of the service that owns a model to list its grammars. * - * **See also:** [Listing grammars from a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#listGrammars). + *

**See also:** * [Listing grammars from a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#listGrammars) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * * @param listGrammarsOptions the {@link ListGrammarsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Grammars} + * @return a {@link ServiceCall} with a result of type {@link Grammars} */ public ServiceCall listGrammars(ListGrammarsOptions listGrammarsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listGrammarsOptions, - "listGrammarsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "grammars" }; - String[] pathParameters = { listGrammarsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listGrammars"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listGrammarsOptions, "listGrammarsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listGrammarsOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/grammars", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "listGrammars"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Add a grammar. * - * Adds a single grammar file to a custom language model. Submit a plain text file in UTF-8 format that defines the - * grammar. Use multiple requests to submit multiple grammar files. You must use credentials for the instance of the - * service that owns a model to add a grammar to it. Adding a grammar does not affect the custom language model until - * you train the model for the new data by using the **Train a custom language model** method. - * - * The call returns an HTTP 201 response code if the grammar is valid. The service then asynchronously processes the - * contents of the grammar and automatically extracts new words that it finds. This can take a few seconds to complete - * depending on the size and complexity of the grammar, as well as the current load on the service. You cannot submit - * requests to add additional resources to the custom model or to train the model until the service's analysis of the - * grammar for the current request completes. Use the **Get a grammar** method to check the status of the analysis. - * - * The service populates the model's words resource with any word that is recognized by the grammar that is not found - * in the model's base vocabulary. These are referred to as out-of-vocabulary (OOV) words. You can use the **List - * custom words** method to examine the words resource and use other words-related methods to eliminate typos and - * modify how words are pronounced as needed. - * - * To add a grammar that has the same name as an existing grammar, set the `allow_overwrite` parameter to `true`; - * otherwise, the request fails. Overwriting an existing grammar causes the service to process the grammar file and - * extract OOV words anew. Before doing so, it removes any OOV words associated with the existing grammar from the - * model's words resource unless they were also added by another resource or they have been modified in some way with - * the **Add custom words** or **Add a custom word** method. - * - * The service limits the overall amount of data that you can add to a custom model to a maximum of 10 million total - * words from all sources combined. Also, you can add no more than 90 thousand OOV words to a model. This includes - * words that the service extracts from corpora and grammars and words that you add directly. - * - * **See also:** - * * [Understanding + *

Adds a single grammar file to a custom language model. Submit a plain text file in UTF-8 + * format that defines the grammar. Use multiple requests to submit multiple grammar files. You + * must use credentials for the instance of the service that owns a model to add a grammar to it. + * Adding a grammar does not affect the custom language model until you train the model for the + * new data by using the [Train a custom language model](#trainlanguagemodel) method. + * + *

The call returns an HTTP 201 response code if the grammar is valid. The service then + * asynchronously processes the contents of the grammar and automatically extracts new words that + * it finds. This operation can take a few seconds or minutes to complete depending on the size + * and complexity of the grammar, as well as the current load on the service. You cannot submit + * requests to add additional resources to the custom model or to train the model until the + * service's analysis of the grammar for the current request completes. Use the [Get a + * grammar](#getgrammar) method to check the status of the analysis. + * + *

_For grammars that are based on previous-generation models,_ the service populates the + * model's words resource with any word that is recognized by the grammar that is not found in the + * model's base vocabulary. These are referred to as out-of-vocabulary (OOV) words. You can use + * the [List custom words](#listwords) method to examine the words resource and use other + * words-related methods to eliminate typos and modify how words are pronounced as needed. _For + * grammars that are based on next-generation models,_ the service extracts no OOV words from the + * grammars. + * + *

To add a grammar that has the same name as an existing grammar, set the `allow_overwrite` + * parameter to `true`; otherwise, the request fails. Overwriting an existing grammar causes the + * service to process the grammar file and extract OOV words anew. Before doing so, it removes any + * OOV words associated with the existing grammar from the model's words resource unless they were + * also added by another resource or they have been modified in some way with the [Add custom + * words](#addwords) or [Add a custom word](#addword) method. + * + *

_For grammars that are based on previous-generation models,_ the service limits the overall + * amount of data that you can add to a custom model to a maximum of 10 million total words from + * all sources combined. Also, you can add no more than 90 thousand OOV words to a model. This + * includes words that the service extracts from corpora and grammars and words that you add + * directly. + * + *

**See also:** * [Understanding * grammars](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarUnderstand#grammarUnderstand) * * [Add a grammar to the custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarAdd#addGrammar). + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarAdd#addGrammar) * + * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * * @param addGrammarOptions the {@link AddGrammarOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addGrammar(AddGrammarOptions addGrammarOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addGrammarOptions, - "addGrammarOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "grammars" }; - String[] pathParameters = { addGrammarOptions.customizationId(), addGrammarOptions.grammarName() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + addGrammarOptions, "addGrammarOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addGrammarOptions.customizationId()); + pathParamsMap.put("grammar_name", addGrammarOptions.grammarName()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/grammars/{grammar_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addGrammar"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1591,8 +2028,8 @@ public ServiceCall addGrammar(AddGrammarOptions addGrammarOptions) { if (addGrammarOptions.allowOverwrite() != null) { builder.query("allow_overwrite", String.valueOf(addGrammarOptions.allowOverwrite())); } - builder.bodyContent(addGrammarOptions.contentType(), null, - null, addGrammarOptions.grammarFile()); + builder.bodyContent( + addGrammarOptions.contentType(), null, null, addGrammarOptions.grammarFile()); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1600,63 +2037,80 @@ public ServiceCall addGrammar(AddGrammarOptions addGrammarOptions) { /** * Get a grammar. * - * Gets information about a grammar from a custom language model. The information includes the total number of - * out-of-vocabulary (OOV) words, name, and status of the grammar. You must use credentials for the instance of the - * service that owns a model to list its grammars. + *

Gets information about a grammar from a custom language model. For each grammar, the + * information includes the name, status, and (for grammars that are based on previous-generation + * models) the total number of out-of-vocabulary (OOV) words. You must use credentials for the + * instance of the service that owns a model to list its grammars. * - * **See also:** [Listing grammars from a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#listGrammars). + *

**See also:** * [Listing grammars from a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#listGrammars) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * * @param getGrammarOptions the {@link GetGrammarOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Grammar} + * @return a {@link ServiceCall} with a result of type {@link Grammar} */ public ServiceCall getGrammar(GetGrammarOptions getGrammarOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getGrammarOptions, - "getGrammarOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "grammars" }; - String[] pathParameters = { getGrammarOptions.customizationId(), getGrammarOptions.grammarName() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getGrammarOptions, "getGrammarOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getGrammarOptions.customizationId()); + pathParamsMap.put("grammar_name", getGrammarOptions.grammarName()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/grammars/{grammar_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getGrammar"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a grammar. * - * Deletes an existing grammar from a custom language model. The service removes any out-of-vocabulary (OOV) words - * associated with the grammar from the custom model's words resource unless they were also added by another resource - * or they were modified in some way with the **Add custom words** or **Add a custom word** method. Removing a grammar - * does not affect the custom model until you train the model with the **Train a custom language model** method. You - * must use credentials for the instance of the service that owns a model to delete its grammar. - * - * **See also:** [Deleting a grammar from a custom language - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#deleteGrammar). - * - * @param deleteGrammarOptions the {@link DeleteGrammarOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + *

Deletes an existing grammar from a custom language model. _For grammars that are based on + * previous-generation models,_ the service removes any out-of-vocabulary (OOV) words associated + * with the grammar from the custom model's words resource unless they were also added by another + * resource or they were modified in some way with the [Add custom words](#addwords) or [Add a + * custom word](#addword) method. Removing a grammar does not affect the custom model until you + * train the model with the [Train a custom language model](#trainlanguagemodel) method. You must + * use credentials for the instance of the service that owns a model to delete its grammar. + * + *

**See also:** * [Deleting a grammar from a custom language + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#deleteGrammar) + * * [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). + * + * @param deleteGrammarOptions the {@link DeleteGrammarOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteGrammar(DeleteGrammarOptions deleteGrammarOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteGrammarOptions, - "deleteGrammarOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "grammars" }; - String[] pathParameters = { deleteGrammarOptions.customizationId(), deleteGrammarOptions.grammarName() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteGrammar"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteGrammarOptions, "deleteGrammarOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteGrammarOptions.customizationId()); + pathParamsMap.put("grammar_name", deleteGrammarOptions.grammarName()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/grammars/{grammar_name}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteGrammar"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1664,26 +2118,39 @@ public ServiceCall deleteGrammar(DeleteGrammarOptions deleteGrammarOptions /** * Create a custom acoustic model. * - * Creates a new custom acoustic model for a specified base model. The custom acoustic model can be used only with the - * base model for which it is created. The model is owned by the instance of the service whose credentials are used to - * create it. + *

Creates a new custom acoustic model for a specified base model. The custom acoustic model + * can be used only with the base model for which it is created. The model is owned by the + * instance of the service whose credentials are used to create it. + * + *

You can create a maximum of 1024 custom acoustic models per owning credentials. The service + * returns an error if you attempt to create more than 1024 models. You do not lose any models, + * but you cannot create any more until your model count is below the limit. * - * You can create a maximum of 1024 custom acoustic models per owning credentials. The service returns an error if you - * attempt to create more than 1024 models. You do not lose any models, but you cannot create any more until your - * model count is below the limit. + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Create a custom acoustic + *

**Important:** Effective **31 July 2023**, all previous-generation models will be removed + * from the service and the documentation. Most previous-generation models were deprecated on 15 + * March 2022. You must migrate to the equivalent large speech model or next-generation model by + * 31 July 2023. For more information, see [Migrating to large speech + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). + * + *

**See also:** [Create a custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#createModel-acoustic). * - * @param createAcousticModelOptions the {@link CreateAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModel} + * @param createAcousticModelOptions the {@link CreateAcousticModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link AcousticModel} */ - public ServiceCall createAcousticModel(CreateAcousticModelOptions createAcousticModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createAcousticModelOptions, - "createAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createAcousticModel"); + public ServiceCall createAcousticModel( + CreateAcousticModelOptions createAcousticModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createAcousticModelOptions, "createAcousticModelOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/acoustic_customizations")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "createAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } @@ -1695,57 +2162,68 @@ public ServiceCall createAcousticModel(CreateAcousticModelOptions contentJson.addProperty("description", createAcousticModelOptions.description()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom acoustic models. * - * Lists information about all custom acoustic models that are owned by an instance of the service. Use the `language` - * parameter to see all custom acoustic models for the specified language. Omit the parameter to see all custom - * acoustic models for all languages. You must use credentials for the instance of the service that owns a model to - * list information about it. + *

Lists information about all custom acoustic models that are owned by an instance of the + * service. Use the `language` parameter to see all custom acoustic models for the specified + * language. Omit the parameter to see all custom acoustic models for all languages. You must use + * credentials for the instance of the service that owns a model to list information about it. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Listing custom acoustic + *

**See also:** [Listing custom acoustic * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#listModels-acoustic). * - * @param listAcousticModelsOptions the {@link ListAcousticModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModels} + * @param listAcousticModelsOptions the {@link ListAcousticModelsOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link AcousticModels} */ - public ServiceCall listAcousticModels(ListAcousticModelsOptions listAcousticModelsOptions) { - String[] pathSegments = { "v1/acoustic_customizations" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listAcousticModels"); + public ServiceCall listAcousticModels( + ListAcousticModelsOptions listAcousticModelsOptions) { + if (listAcousticModelsOptions == null) { + listAcousticModelsOptions = new ListAcousticModelsOptions.Builder().build(); + } + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/acoustic_customizations")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "listAcousticModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listAcousticModelsOptions != null) { - if (listAcousticModelsOptions.language() != null) { - builder.query("language", listAcousticModelsOptions.language()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + if (listAcousticModelsOptions.language() != null) { + builder.query("language", String.valueOf(listAcousticModelsOptions.language())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom acoustic models. * - * Lists information about all custom acoustic models that are owned by an instance of the service. Use the `language` - * parameter to see all custom acoustic models for the specified language. Omit the parameter to see all custom - * acoustic models for all languages. You must use credentials for the instance of the service that owns a model to - * list information about it. + *

Lists information about all custom acoustic models that are owned by an instance of the + * service. Use the `language` parameter to see all custom acoustic models for the specified + * language. Omit the parameter to see all custom acoustic models for all languages. You must use + * credentials for the instance of the service that owns a model to list information about it. * - * **See also:** [Listing custom acoustic + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. + * + *

**See also:** [Listing custom acoustic * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#listModels-acoustic). * - * @return a {@link ServiceCall} with a response type of {@link AcousticModels} + * @return a {@link ServiceCall} with a result of type {@link AcousticModels} */ public ServiceCall listAcousticModels() { return listAcousticModels(null); @@ -1754,60 +2232,74 @@ public ServiceCall listAcousticModels() { /** * Get a custom acoustic model. * - * Gets information about a specified custom acoustic model. You must use credentials for the instance of the service - * that owns a model to list information about it. + *

Gets information about a specified custom acoustic model. You must use credentials for the + * instance of the service that owns a model to list information about it. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Listing custom acoustic + *

**See also:** [Listing custom acoustic * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#listModels-acoustic). * - * @param getAcousticModelOptions the {@link GetAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModel} + * @param getAcousticModelOptions the {@link GetAcousticModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link AcousticModel} */ - public ServiceCall getAcousticModel(GetAcousticModelOptions getAcousticModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getAcousticModelOptions, - "getAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations" }; - String[] pathParameters = { getAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getAcousticModel"); + public ServiceCall getAcousticModel( + GetAcousticModelOptions getAcousticModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getAcousticModelOptions, "getAcousticModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getAcousticModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/acoustic_customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "getAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a custom acoustic model. * - * Deletes an existing custom acoustic model. The custom model cannot be deleted if another request, such as adding an - * audio resource to the model, is currently being processed. You must use credentials for the instance of the service - * that owns a model to delete it. + *

Deletes an existing custom acoustic model. The custom model cannot be deleted if another + * request, such as adding an audio resource to the model, is currently being processed. You must + * use credentials for the instance of the service that owns a model to delete it. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Deleting a custom acoustic + *

**See also:** [Deleting a custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#deleteModel-acoustic). * - * @param deleteAcousticModelOptions the {@link DeleteAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteAcousticModelOptions the {@link DeleteAcousticModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall deleteAcousticModel(DeleteAcousticModelOptions deleteAcousticModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteAcousticModelOptions, - "deleteAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations" }; - String[] pathParameters = { deleteAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteAcousticModel"); + public ServiceCall deleteAcousticModel( + DeleteAcousticModelOptions deleteAcousticModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteAcousticModelOptions, "deleteAcousticModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteAcousticModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/acoustic_customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1815,101 +2307,137 @@ public ServiceCall deleteAcousticModel(DeleteAcousticModelOptions deleteAc /** * Train a custom acoustic model. * - * Initiates the training of a custom acoustic model with new or changed audio resources. After adding or deleting - * audio resources for a custom acoustic model, use this method to begin the actual training of the model on the - * latest audio data. The custom acoustic model does not reflect its changed data until you train it. You must use - * credentials for the instance of the service that owns a model to train it. - * - * The training method is asynchronous. It can take on the order of minutes or hours to complete depending on the - * total amount of audio data on which the custom acoustic model is being trained and the current load on the service. - * Typically, training a custom acoustic model takes approximately two to four times the length of its audio data. The - * range of time depends on the model being trained and the nature of the audio, such as whether the audio is clean or - * noisy. The method returns an HTTP 200 response code to indicate that the training process has begun. - * - * You can monitor the status of the training by using the **Get a custom acoustic model** method to poll the model's - * status. Use a loop to check the status once a minute. The method returns an `AcousticModel` object that includes - * `status` and `progress` fields. A status of `available` indicates that the custom model is trained and ready to - * use. The service cannot train a model while it is handling another request for the model. The service cannot accept - * subsequent training requests, or requests to add new audio resources, until the existing training request - * completes. - * - * You can use the optional `custom_language_model_id` parameter to specify the GUID of a separately created custom - * language model that is to be used during training. Train with a custom language model if you have verbatim - * transcriptions of the audio files that you have added to the custom model or you have either corpora (text files) - * or a list of words that are relevant to the contents of the audio files. Both of the custom models must be based on - * the same version of the same base model for training to succeed. - * - * **See also:** - * * [Train the custom acoustic + *

Initiates the training of a custom acoustic model with new or changed audio resources. After + * adding or deleting audio resources for a custom acoustic model, use this method to begin the + * actual training of the model on the latest audio data. The custom acoustic model does not + * reflect its changed data until you train it. You must use credentials for the instance of the + * service that owns a model to train it. + * + *

The training method is asynchronous. Training time depends on the cumulative amount of audio + * data that the custom acoustic model contains and the current load on the service. When you + * train or retrain a model, the service uses all of the model's audio data in the training. + * Training a custom acoustic model takes approximately as long as the length of its cumulative + * audio data. For example, it takes approximately 2 hours to train a model that contains a total + * of 2 hours of audio. The method returns an HTTP 200 response code to indicate that the training + * process has begun. + * + *

You can monitor the status of the training by using the [Get a custom acoustic + * model](#getacousticmodel) method to poll the model's status. Use a loop to check the status + * once a minute. The method returns an `AcousticModel` object that includes `status` and + * `progress` fields. A status of `available` indicates that the custom model is trained and ready + * to use. The service cannot train a model while it is handling another request for the model. + * The service cannot accept subsequent training requests, or requests to add new audio resources, + * until the existing training request completes. + * + *

You can use the optional `custom_language_model_id` parameter to specify the GUID of a + * separately created custom language model that is to be used during training. Train with a + * custom language model if you have verbatim transcriptions of the audio files that you have + * added to the custom model or you have either corpora (text files) or a list of words that are + * relevant to the contents of the audio files. For training to succeed, both of the custom models + * must be based on the same version of the same base model, and the custom language model must be + * fully trained and available. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. + * + *

**See also:** * [Train the custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#trainModel-acoustic) * * [Using custom acoustic and custom language models * together](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-useBoth#useBoth) * - * ### Training failures - * - * Training can fail to start for the following reasons: - * * The service is currently handling another request for the custom model, such as another training request or a - * request to add audio resources to the model. - * * The custom model contains less than 10 minutes or more than 200 hours of audio data. - * * You passed an incompatible custom language model with the `custom_language_model_id` query parameter. Both custom - * models must be based on the same version of the same base model. - * * The custom model contains one or more invalid audio resources. You can correct the invalid audio resources or set - * the `strict` parameter to `false` to exclude the invalid resources from the training. The model must contain at - * least one valid resource for training to succeed. - * - * @param trainAcousticModelOptions the {@link TrainAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingResponse} + *

### Training failures + * + *

Training can fail to start for the following reasons: * The service is currently handling + * another request for the custom model, such as another training request or a request to add + * audio resources to the model. * The custom model contains less than 10 minutes of audio that + * includes speech, not silence. * The custom model contains more than 50 hours of audio (for IBM + * Cloud) or more that 200 hours of audio (for IBM Cloud Pak for Data). **Note:** For IBM Cloud, + * the maximum hours of audio for a custom acoustic model was reduced from 200 to 50 hours in + * August and September 2022. For more information, see [Maximum hours of + * audio](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audioResources#audioMaximum). + * * You passed a custom language model with the `custom_language_model_id` query parameter that + * is not in the available state. A custom language model must be fully trained and available to + * be used to train a custom acoustic model. * You passed an incompatible custom language model + * with the `custom_language_model_id` query parameter. Both custom models must be based on the + * same version of the same base model. * The custom model contains one or more invalid audio + * resources. You can correct the invalid audio resources or set the `strict` parameter to `false` + * to exclude the invalid resources from the training. The model must contain at least one valid + * resource for training to succeed. + * + * @param trainAcousticModelOptions the {@link TrainAcousticModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link TrainingResponse} */ - public ServiceCall trainAcousticModel(TrainAcousticModelOptions trainAcousticModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(trainAcousticModelOptions, - "trainAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "train" }; - String[] pathParameters = { trainAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "trainAcousticModel"); + public ServiceCall trainAcousticModel( + TrainAcousticModelOptions trainAcousticModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + trainAcousticModelOptions, "trainAcousticModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", trainAcousticModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/train", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "trainAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (trainAcousticModelOptions.customLanguageModelId() != null) { - builder.query("custom_language_model_id", trainAcousticModelOptions.customLanguageModelId()); + builder.query( + "custom_language_model_id", + String.valueOf(trainAcousticModelOptions.customLanguageModelId())); + } + if (trainAcousticModelOptions.strict() != null) { + builder.query("strict", String.valueOf(trainAcousticModelOptions.strict())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Reset a custom acoustic model. * - * Resets a custom acoustic model by removing all audio resources from the model. Resetting a custom acoustic model - * initializes the model to its state when it was first created. Metadata such as the name and language of the model - * are preserved, but the model's audio resources are removed and must be re-created. The service cannot reset a model - * while it is handling another request for the model. The service cannot accept subsequent requests for the model - * until the existing reset request completes. You must use credentials for the instance of the service that owns a - * model to reset it. + *

Resets a custom acoustic model by removing all audio resources from the model. Resetting a + * custom acoustic model initializes the model to its state when it was first created. Metadata + * such as the name and language of the model are preserved, but the model's audio resources are + * removed and must be re-created. The service cannot reset a model while it is handling another + * request for the model. The service cannot accept subsequent requests for the model until the + * existing reset request completes. You must use credentials for the instance of the service that + * owns a model to reset it. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Resetting a custom acoustic + *

**See also:** [Resetting a custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#resetModel-acoustic). * - * @param resetAcousticModelOptions the {@link ResetAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param resetAcousticModelOptions the {@link ResetAcousticModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result */ public ServiceCall resetAcousticModel(ResetAcousticModelOptions resetAcousticModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(resetAcousticModelOptions, - "resetAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "reset" }; - String[] pathParameters = { resetAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "resetAcousticModel"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + resetAcousticModelOptions, "resetAcousticModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", resetAcousticModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/reset", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "resetAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1917,45 +2445,62 @@ public ServiceCall resetAcousticModel(ResetAcousticModelOptions resetAcous /** * Upgrade a custom acoustic model. * - * Initiates the upgrade of a custom acoustic model to the latest version of its base language model. The upgrade - * method is asynchronous. It can take on the order of minutes or hours to complete depending on the amount of data in - * the custom model and the current load on the service; typically, upgrade takes approximately twice the length of - * the total audio contained in the custom model. A custom model must be in the `ready` or `available` state to be - * upgraded. You must use credentials for the instance of the service that owns a model to upgrade it. - * - * The method returns an HTTP 200 response code to indicate that the upgrade process has begun successfully. You can - * monitor the status of the upgrade by using the **Get a custom acoustic model** method to poll the model's status. - * The method returns an `AcousticModel` object that includes `status` and `progress` fields. Use a loop to check the - * status once a minute. While it is being upgraded, the custom model has the status `upgrading`. When the upgrade is - * complete, the model resumes the status that it had prior to upgrade. The service cannot upgrade a model while it is - * handling another request for the model. The service cannot accept subsequent requests for the model until the - * existing upgrade request completes. - * - * If the custom acoustic model was trained with a separately created custom language model, you must use the - * `custom_language_model_id` parameter to specify the GUID of that custom language model. The custom language model - * must be upgraded before the custom acoustic model can be upgraded. Omit the parameter if the custom acoustic model - * was not trained with a custom language model. - * - * **See also:** [Upgrading a custom acoustic - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customUpgrade#upgradeAcoustic). - * - * @param upgradeAcousticModelOptions the {@link UpgradeAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + *

Initiates the upgrade of a custom acoustic model to the latest version of its base language + * model. The upgrade method is asynchronous. It can take on the order of minutes or hours to + * complete depending on the amount of data in the custom model and the current load on the + * service; typically, upgrade takes approximately twice the length of the total audio contained + * in the custom model. A custom model must be in the `ready` or `available` state to be upgraded. + * You must use credentials for the instance of the service that owns a model to upgrade it. + * + *

The method returns an HTTP 200 response code to indicate that the upgrade process has begun + * successfully. You can monitor the status of the upgrade by using the [Get a custom acoustic + * model](#getacousticmodel) method to poll the model's status. The method returns an + * `AcousticModel` object that includes `status` and `progress` fields. Use a loop to check the + * status once a minute. + * + *

While it is being upgraded, the custom model has the status `upgrading`. When the upgrade is + * complete, the model resumes the status that it had prior to upgrade. The service cannot upgrade + * a model while it is handling another request for the model. The service cannot accept + * subsequent requests for the model until the existing upgrade request completes. + * + *

If the custom acoustic model was trained with a separately created custom language model, + * you must use the `custom_language_model_id` parameter to specify the GUID of that custom + * language model. The custom language model must be upgraded before the custom acoustic model can + * be upgraded. Omit the parameter if the custom acoustic model was not trained with a custom + * language model. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. + * + *

**See also:** [Upgrading a custom acoustic + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-acoustic). + * + * @param upgradeAcousticModelOptions the {@link UpgradeAcousticModelOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall upgradeAcousticModel(UpgradeAcousticModelOptions upgradeAcousticModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(upgradeAcousticModelOptions, - "upgradeAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "upgrade_model" }; - String[] pathParameters = { upgradeAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "upgradeAcousticModel"); + public ServiceCall upgradeAcousticModel( + UpgradeAcousticModelOptions upgradeAcousticModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + upgradeAcousticModelOptions, "upgradeAcousticModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", upgradeAcousticModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/upgrade_model", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "upgradeAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (upgradeAcousticModelOptions.customLanguageModelId() != null) { - builder.query("custom_language_model_id", upgradeAcousticModelOptions.customLanguageModelId()); + builder.query( + "custom_language_model_id", + String.valueOf(upgradeAcousticModelOptions.customLanguageModelId())); } if (upgradeAcousticModelOptions.force() != null) { builder.query("force", String.valueOf(upgradeAcousticModelOptions.force())); @@ -1967,136 +2512,154 @@ public ServiceCall upgradeAcousticModel(UpgradeAcousticModelOptions upgrad /** * List audio resources. * - * Lists information about all audio resources from a custom acoustic model. The information includes the name of the - * resource and information about its audio data, such as its duration. It also includes the status of the audio - * resource, which is important for checking the service's analysis of the resource in response to a request to add it - * to the custom acoustic model. You must use credentials for the instance of the service that owns a model to list - * its audio resources. + *

Lists information about all audio resources from a custom acoustic model. The information + * includes the name of the resource and information about its audio data, such as its duration. + * It also includes the status of the audio resource, which is important for checking the + * service's analysis of the resource in response to a request to add it to the custom acoustic + * model. You must use credentials for the instance of the service that owns a model to list its + * audio resources. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Listing audio resources for a custom acoustic + *

**See also:** [Listing audio resources for a custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#listAudio). * * @param listAudioOptions the {@link ListAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AudioResources} + * @return a {@link ServiceCall} with a result of type {@link AudioResources} */ public ServiceCall listAudio(ListAudioOptions listAudioOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listAudioOptions, - "listAudioOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "audio" }; - String[] pathParameters = { listAudioOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listAudioOptions, "listAudioOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listAudioOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listAudio"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Add an audio resource. * - * Adds an audio resource to a custom acoustic model. Add audio content that reflects the acoustic characteristics of - * the audio that you plan to transcribe. You must use credentials for the instance of the service that owns a model - * to add an audio resource to it. Adding audio data does not affect the custom acoustic model until you train the - * model for the new data by using the **Train a custom acoustic model** method. - * - * You can add individual audio files or an archive file that contains multiple audio files. Adding multiple audio - * files via a single archive file is significantly more efficient than adding each file individually. You can add - * audio resources in any format that the service supports for speech recognition. - * - * You can use this method to add any number of audio resources to a custom model by calling the method once for each - * audio or archive file. You can add multiple different audio resources at the same time. You must add a minimum of - * 10 minutes and a maximum of 200 hours of audio that includes speech, not just silence, to a custom acoustic model - * before you can train it. No audio resource, audio- or archive-type, can be larger than 100 MB. To add an audio - * resource that has the same name as an existing audio resource, set the `allow_overwrite` parameter to `true`; - * otherwise, the request fails. - * - * The method is asynchronous. It can take several seconds to complete depending on the duration of the audio and, in - * the case of an archive file, the total number of audio files being processed. The service returns a 201 response - * code if the audio is valid. It then asynchronously analyzes the contents of the audio file or files and - * automatically extracts information about the audio such as its length, sampling rate, and encoding. You cannot - * submit requests to train or upgrade the model until the service's analysis of all audio resources for current - * requests completes. - * - * To determine the status of the service's analysis of the audio, use the **Get an audio resource** method to poll - * the status of the audio. The method accepts the customization ID of the custom model and the name of the audio - * resource, and it returns the status of the resource. Use a loop to check the status of the audio every few seconds - * until it becomes `ok`. - * - * **See also:** [Add audio to the custom acoustic + *

Adds an audio resource to a custom acoustic model. Add audio content that reflects the + * acoustic characteristics of the audio that you plan to transcribe. You must use credentials for + * the instance of the service that owns a model to add an audio resource to it. Adding audio data + * does not affect the custom acoustic model until you train the model for the new data by using + * the [Train a custom acoustic model](#trainacousticmodel) method. + * + *

You can add individual audio files or an archive file that contains multiple audio files. + * Adding multiple audio files via a single archive file is significantly more efficient than + * adding each file individually. You can add audio resources in any format that the service + * supports for speech recognition. + * + *

You can use this method to add any number of audio resources to a custom model by calling + * the method once for each audio or archive file. You can add multiple different audio resources + * at the same time. You must add a minimum of 10 minutes of audio that includes speech, not just + * silence, to a custom acoustic model before you can train it. No audio resource, audio- or + * archive-type, can be larger than 100 MB. To add an audio resource that has the same name as an + * existing audio resource, set the `allow_overwrite` parameter to `true`; otherwise, the request + * fails. A custom model can contain no more than 50 hours of audio (for IBM Cloud) or 200 hours + * of audio (for IBM Cloud Pak for Data). **Note:** For IBM Cloud, the maximum hours of audio for + * a custom acoustic model was reduced from 200 to 50 hours in August and September 2022. For more + * information, see [Maximum hours of + * audio](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audioResources#audioMaximum). + * + *

The method is asynchronous. It can take several seconds or minutes to complete depending on + * the duration of the audio and, in the case of an archive file, the total number of audio files + * being processed. The service returns a 201 response code if the audio is valid. It then + * asynchronously analyzes the contents of the audio file or files and automatically extracts + * information about the audio such as its length, sampling rate, and encoding. You cannot submit + * requests to train or upgrade the model until the service's analysis of all audio resources for + * current requests completes. + * + *

To determine the status of the service's analysis of the audio, use the [Get an audio + * resource](#getaudio) method to poll the status of the audio. The method accepts the + * customization ID of the custom model and the name of the audio resource, and it returns the + * status of the resource. Use a loop to check the status of the audio every few seconds until it + * becomes `ok`. + * + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. + * + *

**See also:** [Add audio to the custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#addAudio). * - * ### Content types for audio-type resources - * - * You can add an individual audio file in any format that the service supports for speech recognition. For an - * audio-type resource, use the `Content-Type` parameter to specify the audio format (MIME type) of the audio file, - * including specifying the sampling rate, channels, and endianness where indicated. - * * `audio/alaw` (Specify the sampling rate (`rate`) of the audio.) - * * `audio/basic` (Use only with narrowband models.) - * * `audio/flac` - * * `audio/g729` (Use only with narrowband models.) - * * `audio/l16` (Specify the sampling rate (`rate`) and optionally the number of channels (`channels`) and endianness - * (`endianness`) of the audio.) - * * `audio/mp3` - * * `audio/mpeg` - * * `audio/mulaw` (Specify the sampling rate (`rate`) of the audio.) - * * `audio/ogg` (The service automatically detects the codec of the input audio.) - * * `audio/ogg;codecs=opus` - * * `audio/ogg;codecs=vorbis` - * * `audio/wav` (Provide audio with a maximum of nine channels.) - * * `audio/webm` (The service automatically detects the codec of the input audio.) - * * `audio/webm;codecs=opus` - * * `audio/webm;codecs=vorbis` - * - * The sampling rate of an audio file must match the sampling rate of the base model for the custom model: for - * broadband models, at least 16 kHz; for narrowband models, at least 8 kHz. If the sampling rate of the audio is - * higher than the minimum required rate, the service down-samples the audio to the appropriate rate. If the sampling - * rate of the audio is lower than the minimum required rate, the service labels the audio file as `invalid`. - * - * **See also:** [Audio - * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats#audio-formats). - * - * ### Content types for archive-type resources - * - * You can add an archive file (**.zip** or **.tar.gz** file) that contains audio files in any format that the - * service supports for speech recognition. For an archive-type resource, use the `Content-Type` parameter to specify - * the media type of the archive file: - * * `application/zip` for a **.zip** file - * * `application/gzip` for a **.tar.gz** file. - * - * When you add an archive-type resource, the `Contained-Content-Type` header is optional depending on the format of - * the files that you are adding: - * * For audio files of type `audio/alaw`, `audio/basic`, `audio/l16`, or `audio/mulaw`, you must use the - * `Contained-Content-Type` header to specify the format of the contained audio files. Include the `rate`, `channels`, - * and `endianness` parameters where necessary. In this case, all audio files contained in the archive file must have - * the same audio format. - * * For audio files of all other types, you can omit the `Contained-Content-Type` header. In this case, the audio - * files contained in the archive file can have any of the formats not listed in the previous bullet. The audio files - * do not need to have the same format. - * - * Do not use the `Contained-Content-Type` header when adding an audio-type resource. - * - * ### Naming restrictions for embedded audio files - * - * The name of an audio file that is contained in an archive-type resource can include a maximum of 128 characters. - * This includes the file extension and all elements of the name (for example, slashes). + *

### Content types for audio-type resources + * + *

You can add an individual audio file in any format that the service supports for speech + * recognition. For an audio-type resource, use the `Content-Type` parameter to specify the audio + * format (MIME type) of the audio file, including specifying the sampling rate, channels, and + * endianness where indicated. * `audio/alaw` (Specify the sampling rate (`rate`) of the audio.) * + * `audio/basic` (Use only with narrowband models.) * `audio/flac` * `audio/g729` (Use only with + * narrowband models.) * `audio/l16` (Specify the sampling rate (`rate`) and optionally the number + * of channels (`channels`) and endianness (`endianness`) of the audio.) * `audio/mp3` * + * `audio/mpeg` * `audio/mulaw` (Specify the sampling rate (`rate`) of the audio.) * `audio/ogg` + * (The service automatically detects the codec of the input audio.) * `audio/ogg;codecs=opus` * + * `audio/ogg;codecs=vorbis` * `audio/wav` (Provide audio with a maximum of nine channels.) * + * `audio/webm` (The service automatically detects the codec of the input audio.) * + * `audio/webm;codecs=opus` * `audio/webm;codecs=vorbis` + * + *

The sampling rate of an audio file must match the sampling rate of the base model for the + * custom model: for broadband models, at least 16 kHz; for narrowband models, at least 8 kHz. If + * the sampling rate of the audio is higher than the minimum required rate, the service + * down-samples the audio to the appropriate rate. If the sampling rate of the audio is lower than + * the minimum required rate, the service labels the audio file as `invalid`. + * + *

**See also:** [Supported audio + * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats). + * + *

### Content types for archive-type resources + * + *

You can add an archive file (**.zip** or **.tar.gz** file) that contains audio files in any + * format that the service supports for speech recognition. For an archive-type resource, use the + * `Content-Type` parameter to specify the media type of the archive file: * `application/zip` for + * a **.zip** file * `application/gzip` for a **.tar.gz** file. + * + *

When you add an archive-type resource, the `Contained-Content-Type` header is optional + * depending on the format of the files that you are adding: * For audio files of type + * `audio/alaw`, `audio/basic`, `audio/l16`, or `audio/mulaw`, you must use the + * `Contained-Content-Type` header to specify the format of the contained audio files. Include the + * `rate`, `channels`, and `endianness` parameters where necessary. In this case, all audio files + * contained in the archive file must have the same audio format. * For audio files of all other + * types, you can omit the `Contained-Content-Type` header. In this case, the audio files + * contained in the archive file can have any of the formats not listed in the previous bullet. + * The audio files do not need to have the same format. + * + *

Do not use the `Contained-Content-Type` header when adding an audio-type resource. + * + *

### Naming restrictions for embedded audio files + * + *

The name of an audio file that is contained in an archive-type resource can include a + * maximum of 128 characters. This includes the file extension and all elements of the name (for + * example, slashes). * * @param addAudioOptions the {@link AddAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addAudio(AddAudioOptions addAudioOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addAudioOptions, - "addAudioOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "audio" }; - String[] pathParameters = { addAudioOptions.customizationId(), addAudioOptions.audioName() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + addAudioOptions, "addAudioOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addAudioOptions.customizationId()); + pathParamsMap.put("audio_name", addAudioOptions.audioName()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio/{audio_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addAudio"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -2111,8 +2674,7 @@ public ServiceCall addAudio(AddAudioOptions addAudioOptions) { if (addAudioOptions.allowOverwrite() != null) { builder.query("allow_overwrite", String.valueOf(addAudioOptions.allowOverwrite())); } - builder.bodyContent(addAudioOptions.contentType(), null, - null, addAudioOptions.audioResource()); + builder.bodyContent(addAudioOptions.contentType(), null, null, addAudioOptions.audioResource()); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2120,77 +2682,95 @@ public ServiceCall addAudio(AddAudioOptions addAudioOptions) { /** * Get an audio resource. * - * Gets information about an audio resource from a custom acoustic model. The method returns an `AudioListing` object - * whose fields depend on the type of audio resource that you specify with the method's `audio_name` parameter: - * * **For an audio-type resource,** the object's fields match those of an `AudioResource` object: `duration`, `name`, - * `details`, and `status`. - * * **For an archive-type resource,** the object includes a `container` field whose fields match those of an - * `AudioResource` object. It also includes an `audio` field, which contains an array of `AudioResource` objects that - * provides information about the audio files that are contained in the archive. + *

Gets information about an audio resource from a custom acoustic model. The method returns an + * `AudioListing` object whose fields depend on the type of audio resource that you specify with + * the method's `audio_name` parameter: * _For an audio-type resource_, the object's fields match + * those of an `AudioResource` object: `duration`, `name`, `details`, and `status`. * _For an + * archive-type resource_, the object includes a `container` field whose fields match those of an + * `AudioResource` object. It also includes an `audio` field, which contains an array of + * `AudioResource` objects that provides information about the audio files that are contained in + * the archive. + * + *

The information includes the status of the specified audio resource. The status is important + * for checking the service's analysis of a resource that you add to the custom model. * _For an + * audio-type resource_, the `status` field is located in the `AudioListing` object. * _For an + * archive-type resource_, the `status` field is located in the `AudioResource` object that is + * returned in the `container` field. * - * The information includes the status of the specified audio resource. The status is important for checking the - * service's analysis of a resource that you add to the custom model. - * * For an audio-type resource, the `status` field is located in the `AudioListing` object. - * * For an archive-type resource, the `status` field is located in the `AudioResource` object that is returned in the - * `container` field. + *

You must use credentials for the instance of the service that owns a model to list its audio + * resources. * - * You must use credentials for the instance of the service that owns a model to list its audio resources. + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Listing audio resources for a custom acoustic + *

**See also:** [Listing audio resources for a custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#listAudio). * * @param getAudioOptions the {@link GetAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AudioListing} + * @return a {@link ServiceCall} with a result of type {@link AudioListing} */ public ServiceCall getAudio(GetAudioOptions getAudioOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getAudioOptions, - "getAudioOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "audio" }; - String[] pathParameters = { getAudioOptions.customizationId(), getAudioOptions.audioName() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getAudioOptions, "getAudioOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getAudioOptions.customizationId()); + pathParamsMap.put("audio_name", getAudioOptions.audioName()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio/{audio_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getAudio"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete an audio resource. * - * Deletes an existing audio resource from a custom acoustic model. Deleting an archive-type audio resource removes - * the entire archive of files. The service does not allow deletion of individual files from an archive resource. + *

Deletes an existing audio resource from a custom acoustic model. Deleting an archive-type + * audio resource removes the entire archive of files. The service does not allow deletion of + * individual files from an archive resource. + * + *

Removing an audio resource does not affect the custom model until you train the model on its + * updated data by using the [Train a custom acoustic model](#trainacousticmodel) method. You can + * delete an existing audio resource from a model while a different resource is being added to the + * model. You must use credentials for the instance of the service that owns a model to delete its + * audio resources. * - * Removing an audio resource does not affect the custom model until you train the model on its updated data by using - * the **Train a custom acoustic model** method. You can delete an existing audio resource from a model while a - * different resource is being added to the model. You must use credentials for the instance of the service that owns - * a model to delete its audio resources. + *

**Note:** Acoustic model customization is supported only for use with previous-generation + * models. It is not supported for large speech models and next-generation models. * - * **See also:** [Deleting an audio resource from a custom acoustic + *

**See also:** [Deleting an audio resource from a custom acoustic * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#deleteAudio). * * @param deleteAudioOptions the {@link DeleteAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteAudio(DeleteAudioOptions deleteAudioOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteAudioOptions, - "deleteAudioOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "audio" }; - String[] pathParameters = { deleteAudioOptions.customizationId(), deleteAudioOptions.audioName() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteAudioOptions, "deleteAudioOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteAudioOptions.customizationId()); + pathParamsMap.put("audio_name", deleteAudioOptions.audioName()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio/{audio_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteAudio"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2198,32 +2778,77 @@ public ServiceCall deleteAudio(DeleteAudioOptions deleteAudioOptions) { /** * Delete labeled data. * - * Deletes all data that is associated with a specified customer ID. The method deletes all data for the customer ID, - * regardless of the method by which the information was added. The method has no effect if no data is associated with - * the customer ID. You must issue the request with credentials for the same instance of the service that was used to - * associate the customer ID with the data. + *

Deletes all data that is associated with a specified customer ID. The method deletes all + * data for the customer ID, regardless of the method by which the information was added. The + * method has no effect if no data is associated with the customer ID. You must issue the request + * with credentials for the same instance of the service that was used to associate the customer + * ID with the data. You associate a customer ID with data by passing the `X-Watson-Metadata` + * header with a request that passes the data. * - * You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes the - * data. + *

**Note:** If you delete an instance of the service from the service console, all data + * associated with that service instance is automatically deleted. This includes all custom + * language models, corpora, grammars, and words; all custom acoustic models and audio resources; + * all registered endpoints for the asynchronous HTTP interface; and all data related to speech + * recognition requests. * - * **See also:** [Information + *

**See also:** [Information * security](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-information-security#information-security). * - * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, - "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteUserData"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteUserDataOptions, "deleteUserDataOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } + /** + * Spoken language identification. + * + *

Detects the spoken language in audio streams. The endpoint is `/v1/detect_language` and user + * can optionally include `lid_confidence` parameter to set a custom confidence threshold for + * detection. The model continuously processes incoming audio and returns the identified language + * when it reaches a confidence level higher than the specified threshold (0.99 by default). See + * [Spoken language + * identification](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speech-language-identification). + * + * @param detectLanguageOptions the {@link DetectLanguageOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link LanguageDetectionResults} + */ + public ServiceCall detectLanguage( + DetectLanguageOptions detectLanguageOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + detectLanguageOptions, "detectLanguageOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/detect_language")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "detectLanguage"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (detectLanguageOptions.contentType() != null) { + builder.header("Content-Type", detectLanguageOptions.contentType()); + } + builder.query("lid_confidence", String.valueOf(detectLanguageOptions.lidConfidence())); + builder.bodyContent( + detectLanguageOptions.contentType(), null, null, detectLanguageOptions.audio()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java index 6ae8118266c..3c4cf150b89 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,28 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about an existing custom acoustic model. - */ +/** Information about an existing custom acoustic model. */ public class AcousticModel extends GenericModel { /** - * The current status of the custom acoustic model: - * * `pending`: The model was created but is waiting either for valid training data to be added or for the service to - * finish analyzing added data. - * * `ready`: The model contains valid data and is ready to be trained. If the model contains a mix of valid and - * invalid resources, you need to set the `strict` parameter to `false` for the training to proceed. - * * `training`: The model is currently being trained. - * * `available`: The model is trained and ready to use. - * * `upgrading`: The model is currently being upgraded. - * * `failed`: Training of the model failed. + * The current status of the custom acoustic model: * `pending`: The model was created but is + * waiting either for valid training data to be added or for the service to finish analyzing added + * data. * `ready`: The model contains valid data and is ready to be trained. If the model + * contains a mix of valid and invalid resources, you need to set the `strict` parameter to + * `false` for the training to proceed. * `training`: The model is currently being trained. * + * `available`: The model is trained and ready to use. * `upgrading`: The model is currently being + * upgraded. * `failed`: Training of the model failed. */ public interface Status { /** pending. */ @@ -50,6 +46,7 @@ public interface Status { @SerializedName("customization_id") protected String customizationId; + protected String created; protected String updated; protected String language; @@ -57,17 +54,22 @@ public interface Status { protected String owner; protected String name; protected String description; + @SerializedName("base_model_name") protected String baseModelName; + protected String status; protected Long progress; protected String warnings; + protected AcousticModel() {} + /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model. The **Create a custom acoustic model** method returns - * only this field of the object; it does not return the other fields. + *

The customization ID (GUID) of the custom acoustic model. The [Create a custom acoustic + * model](#createacousticmodel) method returns only this field of the object; it does not return + * the other fields. * * @return the customizationId */ @@ -78,8 +80,8 @@ public String getCustomizationId() { /** * Gets the created. * - * The date and time in Coordinated Universal Time (UTC) at which the custom acoustic model was created. The value is - * provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + *

The date and time in Coordinated Universal Time (UTC) at which the custom acoustic model was + * created. The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). * * @return the created */ @@ -90,9 +92,10 @@ public String getCreated() { /** * Gets the updated. * - * The date and time in Coordinated Universal Time (UTC) at which the custom acoustic model was last modified. The - * `created` and `updated` fields are equal when an acoustic model is first added but has yet to be updated. The value - * is provided in full ISO 8601 format (YYYY-MM-DDThh:mm:ss.sTZD). + *

The date and time in Coordinated Universal Time (UTC) at which the custom acoustic model was + * last modified. The `created` and `updated` fields are equal when an acoustic model is first + * added but has yet to be updated. The value is provided in full ISO 8601 format + * (YYYY-MM-DDThh:mm:ss.sTZD). * * @return the updated */ @@ -103,7 +106,7 @@ public String getUpdated() { /** * Gets the language. * - * The language identifier of the custom acoustic model (for example, `en-US`). + *

The language identifier of the custom acoustic model (for example, `en-US`). * * @return the language */ @@ -114,9 +117,10 @@ public String getLanguage() { /** * Gets the versions. * - * A list of the available versions of the custom acoustic model. Each element of the array indicates a version of the - * base model with which the custom model can be used. Multiple versions exist only if the custom model has been - * upgraded; otherwise, only a single version is shown. + *

A list of the available versions of the custom acoustic model. Each element of the array + * indicates a version of the base model with which the custom model can be used. Multiple + * versions exist only if the custom model has been upgraded to a new version of its base model. + * Otherwise, only a single version is shown. * * @return the versions */ @@ -127,7 +131,8 @@ public List getVersions() { /** * Gets the owner. * - * The GUID of the credentials for the instance of the service that owns the custom acoustic model. + *

The GUID of the credentials for the instance of the service that owns the custom acoustic + * model. * * @return the owner */ @@ -138,7 +143,7 @@ public String getOwner() { /** * Gets the name. * - * The name of the custom acoustic model. + *

The name of the custom acoustic model. * * @return the name */ @@ -149,7 +154,7 @@ public String getName() { /** * Gets the description. * - * The description of the custom acoustic model. + *

The description of the custom acoustic model. * * @return the description */ @@ -160,7 +165,7 @@ public String getDescription() { /** * Gets the baseModelName. * - * The name of the language model for which the custom acoustic model was created. + *

The name of the language model for which the custom acoustic model was created. * * @return the baseModelName */ @@ -171,15 +176,13 @@ public String getBaseModelName() { /** * Gets the status. * - * The current status of the custom acoustic model: - * * `pending`: The model was created but is waiting either for valid training data to be added or for the service to - * finish analyzing added data. - * * `ready`: The model contains valid data and is ready to be trained. If the model contains a mix of valid and - * invalid resources, you need to set the `strict` parameter to `false` for the training to proceed. - * * `training`: The model is currently being trained. - * * `available`: The model is trained and ready to use. - * * `upgrading`: The model is currently being upgraded. - * * `failed`: Training of the model failed. + *

The current status of the custom acoustic model: * `pending`: The model was created but is + * waiting either for valid training data to be added or for the service to finish analyzing added + * data. * `ready`: The model contains valid data and is ready to be trained. If the model + * contains a mix of valid and invalid resources, you need to set the `strict` parameter to + * `false` for the training to proceed. * `training`: The model is currently being trained. * + * `available`: The model is trained and ready to use. * `upgrading`: The model is currently being + * upgraded. * `failed`: Training of the model failed. * * @return the status */ @@ -190,9 +193,10 @@ public String getStatus() { /** * Gets the progress. * - * A percentage that indicates the progress of the custom acoustic model's current training. A value of `100` means - * that the model is fully trained. **Note:** The `progress` field does not currently reflect the progress of the - * training. The field changes from `0` to `100` when training is complete. + *

A percentage that indicates the progress of the custom acoustic model's current training. A + * value of `100` means that the model is fully trained. **Note:** The `progress` field does not + * currently reflect the progress of the training. The field changes from `0` to `100` when + * training is complete. * * @return the progress */ @@ -203,8 +207,9 @@ public Long getProgress() { /** * Gets the warnings. * - * If the request included unknown parameters, the following message: `Unexpected query parameter(s) ['parameters'] - * detected`, where `parameters` is a list that includes a quoted string for each unknown parameter. + *

If the request included unknown parameters, the following message: `Unexpected query + * parameter(s) ['parameters'] detected`, where `parameters` is a list that includes a quoted + * string for each unknown parameter. * * @return the warnings */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java index 3ab151aa7d0..81dfdf516de 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,25 +10,25 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about existing custom acoustic models. - */ +/** Information about existing custom acoustic models. */ public class AcousticModels extends GenericModel { protected List customizations; + protected AcousticModels() {} + /** * Gets the customizations. * - * An array of `AcousticModel` objects that provides information about each available custom acoustic model. The array - * is empty if the requesting credentials own no custom acoustic models (if no language is specified) or own no custom - * acoustic models for the specified language. + *

An array of `AcousticModel` objects that provides information about each available custom + * acoustic model. The array is empty if the requesting credentials own no custom acoustic models + * (if no language is specified) or own no custom acoustic models for the specified language. * * @return the customizations */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java index 568464ad85f..3fdded026ec 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,33 +10,32 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; 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 addAudio options. - */ +/** The addAudio options. */ public class AddAudioOptions extends GenericModel { /** - * **For an archive-type resource,** specify the format of the audio files that are contained in the archive file if - * they are of type `audio/alaw`, `audio/basic`, `audio/l16`, or `audio/mulaw`. Include the `rate`, `channels`, and - * `endianness` parameters where necessary. In this case, all audio files that are contained in the archive file must - * be of the indicated type. + * _For an archive-type resource_, specify the format of the audio files that are contained in the + * archive file if they are of type `audio/alaw`, `audio/basic`, `audio/l16`, or `audio/mulaw`. + * Include the `rate`, `channels`, and `endianness` parameters where necessary. In this case, all + * audio files that are contained in the archive file must be of the indicated type. * - * For all other audio formats, you can omit the header. In this case, the audio files can be of multiple types as - * long as they are not of the types listed in the previous paragraph. + *

For all other audio formats, you can omit the header. In this case, the audio files can be + * of multiple types as long as they are not of the types listed in the previous paragraph. * - * The parameter accepts all of the audio formats that are supported for use with speech recognition. For more - * information, see **Content types for audio-type resources** in the method description. + *

The parameter accepts all of the audio formats that are supported for use with speech + * recognition. For more information, see **Content types for audio-type resources** in the method + * description. * - * **For an audio-type resource,** omit the header. + *

_For an audio-type resource_, omit the header. */ public interface ContainedContentType { /** audio/alaw. */ @@ -78,9 +77,7 @@ public interface ContainedContentType { protected String containedContentType; protected Boolean allowOverwrite; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String audioName; @@ -89,6 +86,11 @@ public static class Builder { private String containedContentType; private Boolean allowOverwrite; + /** + * Instantiates a new Builder from an existing AddAudioOptions instance. + * + * @param addAudioOptions the instance to initialize the Builder with + */ private Builder(AddAudioOptions addAudioOptions) { this.customizationId = addAudioOptions.customizationId; this.audioName = addAudioOptions.audioName; @@ -98,11 +100,8 @@ private Builder(AddAudioOptions addAudioOptions) { this.allowOverwrite = addAudioOptions.allowOverwrite; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -120,7 +119,7 @@ public Builder(String customizationId, String audioName, InputStream audioResour /** * Builds a AddAudioOptions. * - * @return the addAudioOptions + * @return the new AddAudioOptions instance */ public AddAudioOptions build() { return new AddAudioOptions(this); @@ -197,7 +196,6 @@ public Builder allowOverwrite(Boolean allowOverwrite) { * * @param audioResource the audioResource * @return the AddAudioOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder audioResource(File audioResource) throws FileNotFoundException { @@ -206,13 +204,14 @@ public Builder audioResource(File audioResource) throws FileNotFoundException { } } + protected AddAudioOptions() {} + protected AddAudioOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.audioName, - "audioName cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audioResource, - "audioResource cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.audioName, "audioName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.audioResource, "audioResource cannot be null"); customizationId = builder.customizationId; audioName = builder.audioName; audioResource = builder.audioResource; @@ -233,8 +232,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -245,14 +245,14 @@ public String customizationId() { /** * Gets the audioName. * - * The name of the new audio resource for the custom acoustic model. Use a localized name that matches the language of - * the custom model and reflects the contents of the resource. - * * Include a maximum of 128 characters in the name. - * * Do not use characters that need to be URL-encoded. For example, do not use spaces, slashes, backslashes, colons, - * ampersands, double quotes, plus signs, equals signs, questions marks, and so on in the name. (The service does not - * prevent the use of these characters. But because they must be URL-encoded wherever used, their use is strongly - * discouraged.) - * * Do not use the name of an audio resource that has already been added to the custom model. + *

The name of the new audio resource for the custom acoustic model. Use a localized name that + * matches the language of the custom model and reflects the contents of the resource. * Include a + * maximum of 128 characters in the name. * Do not use characters that need to be URL-encoded. For + * example, do not use spaces, slashes, backslashes, colons, ampersands, double quotes, plus + * signs, equals signs, questions marks, and so on in the name. (The service does not prevent the + * use of these characters. But because they must be URL-encoded wherever used, their use is + * strongly discouraged.) * Do not use the name of an audio resource that has already been added + * to the custom model. * * @return the audioName */ @@ -263,9 +263,10 @@ public String audioName() { /** * Gets the audioResource. * - * The audio resource that is to be added to the custom acoustic model, an individual audio file or an archive file. + *

The audio resource that is to be added to the custom acoustic model, an individual audio + * file or an archive file. * - * With the `curl` command, use the `--data-binary` option to upload the file for the request. + *

With the `curl` command, use the `--data-binary` option to upload the file for the request. * * @return the audioResource */ @@ -276,11 +277,11 @@ public InputStream audioResource() { /** * Gets the contentType. * - * For an audio-type resource, the format (MIME type) of the audio. For more information, see **Content types for - * audio-type resources** in the method description. + *

For an audio-type resource, the format (MIME type) of the audio. For more information, see + * **Content types for audio-type resources** in the method description. * - * For an archive-type resource, the media type of the archive file. For more information, see **Content types for - * archive-type resources** in the method description. + *

For an archive-type resource, the media type of the archive file. For more information, see + * **Content types for archive-type resources** in the method description. * * @return the contentType */ @@ -291,18 +292,20 @@ public String contentType() { /** * Gets the containedContentType. * - * **For an archive-type resource,** specify the format of the audio files that are contained in the archive file if - * they are of type `audio/alaw`, `audio/basic`, `audio/l16`, or `audio/mulaw`. Include the `rate`, `channels`, and - * `endianness` parameters where necessary. In this case, all audio files that are contained in the archive file must - * be of the indicated type. + *

_For an archive-type resource_, specify the format of the audio files that are contained in + * the archive file if they are of type `audio/alaw`, `audio/basic`, `audio/l16`, or + * `audio/mulaw`. Include the `rate`, `channels`, and `endianness` parameters where necessary. In + * this case, all audio files that are contained in the archive file must be of the indicated + * type. * - * For all other audio formats, you can omit the header. In this case, the audio files can be of multiple types as - * long as they are not of the types listed in the previous paragraph. + *

For all other audio formats, you can omit the header. In this case, the audio files can be + * of multiple types as long as they are not of the types listed in the previous paragraph. * - * The parameter accepts all of the audio formats that are supported for use with speech recognition. For more - * information, see **Content types for audio-type resources** in the method description. + *

The parameter accepts all of the audio formats that are supported for use with speech + * recognition. For more information, see **Content types for audio-type resources** in the method + * description. * - * **For an audio-type resource,** omit the header. + *

_For an audio-type resource_, omit the header. * * @return the containedContentType */ @@ -313,9 +316,9 @@ public String containedContentType() { /** * Gets the allowOverwrite. * - * If `true`, the specified audio resource overwrites an existing audio resource with the same name. If `false`, the - * request fails if an audio resource with the same name already exists. The parameter has no effect if an audio - * resource with the same name does not already exist. + *

If `true`, the specified audio resource overwrites an existing audio resource with the same + * name. If `false`, the request fails if an audio resource with the same name already exists. The + * parameter has no effect if an audio resource with the same name does not already exist. * * @return the allowOverwrite */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java index 05a93050802..d302ff9f437 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,18 +10,16 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; 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 addCorpus options. - */ +/** The addCorpus options. */ public class AddCorpusOptions extends GenericModel { protected String customizationId; @@ -29,15 +27,18 @@ public class AddCorpusOptions extends GenericModel { protected InputStream corpusFile; protected Boolean allowOverwrite; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String corpusName; private InputStream corpusFile; private Boolean allowOverwrite; + /** + * Instantiates a new Builder from an existing AddCorpusOptions instance. + * + * @param addCorpusOptions the instance to initialize the Builder with + */ private Builder(AddCorpusOptions addCorpusOptions) { this.customizationId = addCorpusOptions.customizationId; this.corpusName = addCorpusOptions.corpusName; @@ -45,11 +46,8 @@ private Builder(AddCorpusOptions addCorpusOptions) { this.allowOverwrite = addCorpusOptions.allowOverwrite; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -67,7 +65,7 @@ public Builder(String customizationId, String corpusName, InputStream corpusFile /** * Builds a AddCorpusOptions. * - * @return the addCorpusOptions + * @return the new AddCorpusOptions instance */ public AddCorpusOptions build() { return new AddCorpusOptions(this); @@ -122,7 +120,6 @@ public Builder allowOverwrite(Boolean allowOverwrite) { * * @param corpusFile the corpusFile * @return the AddCorpusOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder corpusFile(File corpusFile) throws FileNotFoundException { @@ -131,13 +128,14 @@ public Builder corpusFile(File corpusFile) throws FileNotFoundException { } } + protected AddCorpusOptions() {} + protected AddCorpusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.corpusName, - "corpusName cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.corpusFile, - "corpusFile cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.corpusName, "corpusName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.corpusFile, "corpusFile cannot be null"); customizationId = builder.customizationId; corpusName = builder.corpusName; corpusFile = builder.corpusFile; @@ -156,8 +154,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -168,17 +167,16 @@ public String customizationId() { /** * Gets the corpusName. * - * The name of the new corpus for the custom language model. Use a localized name that matches the language of the - * custom model and reflects the contents of the corpus. - * * Include a maximum of 128 characters in the name. - * * Do not use characters that need to be URL-encoded. For example, do not use spaces, slashes, backslashes, colons, - * ampersands, double quotes, plus signs, equals signs, questions marks, and so on in the name. (The service does not - * prevent the use of these characters. But because they must be URL-encoded wherever used, their use is strongly - * discouraged.) - * * Do not use the name of an existing corpus or grammar that is already defined for the custom model. - * * Do not use the name `user`, which is reserved by the service to denote custom words that are added or modified by - * the user. - * * Do not use the name `base_lm` or `default_lm`. Both names are reserved for future use by the service. + *

The name of the new corpus for the custom language model. Use a localized name that matches + * the language of the custom model and reflects the contents of the corpus. * Include a maximum + * of 128 characters in the name. * Do not use characters that need to be URL-encoded. For + * example, do not use spaces, slashes, backslashes, colons, ampersands, double quotes, plus + * signs, equals signs, questions marks, and so on in the name. (The service does not prevent the + * use of these characters. But because they must be URL-encoded wherever used, their use is + * strongly discouraged.) * Do not use the name of an existing corpus or grammar that is already + * defined for the custom model. * Do not use the name `user`, which is reserved by the service to + * denote custom words that are added or modified by the user. * Do not use the name `base_lm` or + * `default_lm`. Both names are reserved for future use by the service. * * @return the corpusName */ @@ -189,14 +187,16 @@ public String corpusName() { /** * Gets the corpusFile. * - * A plain text file that contains the training data for the corpus. Encode the file in UTF-8 if it contains non-ASCII - * characters; the service assumes UTF-8 encoding if it encounters non-ASCII characters. + *

A plain text file that contains the training data for the corpus. Encode the file in UTF-8 + * if it contains non-ASCII characters; the service assumes UTF-8 encoding if it encounters + * non-ASCII characters. * - * Make sure that you know the character encoding of the file. You must use that encoding when working with the words - * in the custom language model. For more information, see [Character - * encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding). + *

Make sure that you know the character encoding of the file. You must use that same encoding + * when working with the words in the custom language model. For more information, see [Character + * encoding for custom + * words](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#charEncoding). * - * With the `curl` command, use the `--data-binary` option to upload the file for the request. + *

With the `curl` command, use the `--data-binary` option to upload the file for the request. * * @return the corpusFile */ @@ -207,9 +207,9 @@ public InputStream corpusFile() { /** * Gets the allowOverwrite. * - * If `true`, the specified corpus overwrites an existing corpus with the same name. If `false`, the request fails if - * a corpus with the same name already exists. The parameter has no effect if a corpus with the same name does not - * already exist. + *

If `true`, the specified corpus overwrites an existing corpus with the same name. If + * `false`, the request fails if a corpus with the same name already exists. The parameter has no + * effect if a corpus with the same name does not already exist. * * @return the allowOverwrite */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java index 0414a6d3cfd..624b969f57d 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,18 +10,16 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; 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 addGrammar options. - */ +/** The addGrammar options. */ public class AddGrammarOptions extends GenericModel { protected String customizationId; @@ -30,9 +28,7 @@ public class AddGrammarOptions extends GenericModel { protected String contentType; protected Boolean allowOverwrite; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String grammarName; @@ -40,6 +36,11 @@ public static class Builder { private String contentType; private Boolean allowOverwrite; + /** + * Instantiates a new Builder from an existing AddGrammarOptions instance. + * + * @param addGrammarOptions the instance to initialize the Builder with + */ private Builder(AddGrammarOptions addGrammarOptions) { this.customizationId = addGrammarOptions.customizationId; this.grammarName = addGrammarOptions.grammarName; @@ -48,11 +49,8 @@ private Builder(AddGrammarOptions addGrammarOptions) { this.allowOverwrite = addGrammarOptions.allowOverwrite; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -62,7 +60,8 @@ public Builder() { * @param grammarFile the grammarFile * @param contentType the contentType */ - public Builder(String customizationId, String grammarName, InputStream grammarFile, String contentType) { + public Builder( + String customizationId, String grammarName, InputStream grammarFile, String contentType) { this.customizationId = customizationId; this.grammarName = grammarName; this.grammarFile = grammarFile; @@ -72,7 +71,7 @@ public Builder(String customizationId, String grammarName, InputStream grammarFi /** * Builds a AddGrammarOptions. * - * @return the addGrammarOptions + * @return the new AddGrammarOptions instance */ public AddGrammarOptions build() { return new AddGrammarOptions(this); @@ -138,7 +137,6 @@ public Builder allowOverwrite(Boolean allowOverwrite) { * * @param grammarFile the grammarFile * @return the AddGrammarOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder grammarFile(File grammarFile) throws FileNotFoundException { @@ -147,15 +145,17 @@ public Builder grammarFile(File grammarFile) throws FileNotFoundException { } } + protected AddGrammarOptions() {} + protected AddGrammarOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.grammarName, - "grammarName cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.grammarFile, - "grammarFile cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.contentType, - "contentType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.grammarName, "grammarName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.grammarFile, "grammarFile cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.contentType, "contentType cannot be null"); customizationId = builder.customizationId; grammarName = builder.grammarName; grammarFile = builder.grammarFile; @@ -175,8 +175,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -187,17 +188,16 @@ public String customizationId() { /** * Gets the grammarName. * - * The name of the new grammar for the custom language model. Use a localized name that matches the language of the - * custom model and reflects the contents of the grammar. - * * Include a maximum of 128 characters in the name. - * * Do not use characters that need to be URL-encoded. For example, do not use spaces, slashes, backslashes, colons, - * ampersands, double quotes, plus signs, equals signs, questions marks, and so on in the name. (The service does not - * prevent the use of these characters. But because they must be URL-encoded wherever used, their use is strongly - * discouraged.) - * * Do not use the name of an existing grammar or corpus that is already defined for the custom model. - * * Do not use the name `user`, which is reserved by the service to denote custom words that are added or modified by - * the user. - * * Do not use the name `base_lm` or `default_lm`. Both names are reserved for future use by the service. + *

The name of the new grammar for the custom language model. Use a localized name that matches + * the language of the custom model and reflects the contents of the grammar. * Include a maximum + * of 128 characters in the name. * Do not use characters that need to be URL-encoded. For + * example, do not use spaces, slashes, backslashes, colons, ampersands, double quotes, plus + * signs, equals signs, questions marks, and so on in the name. (The service does not prevent the + * use of these characters. But because they must be URL-encoded wherever used, their use is + * strongly discouraged.) * Do not use the name of an existing grammar or corpus that is already + * defined for the custom model. * Do not use the name `user`, which is reserved by the service to + * denote custom words that are added or modified by the user. * Do not use the name `base_lm` or + * `default_lm`. Both names are reserved for future use by the service. * * @return the grammarName */ @@ -208,11 +208,12 @@ public String grammarName() { /** * Gets the grammarFile. * - * A plain text file that contains the grammar in the format specified by the `Content-Type` header. Encode the file - * in UTF-8 (ASCII is a subset of UTF-8). Using any other encoding can lead to issues when compiling the grammar or to - * unexpected results in decoding. The service ignores an encoding that is specified in the header of the grammar. + *

A plain text file that contains the grammar in the format specified by the `Content-Type` + * header. Encode the file in UTF-8 (ASCII is a subset of UTF-8). Using any other encoding can + * lead to issues when compiling the grammar or to unexpected results in decoding. The service + * ignores an encoding that is specified in the header of the grammar. * - * With the `curl` command, use the `--data-binary` option to upload the file for the request. + *

With the `curl` command, use the `--data-binary` option to upload the file for the request. * * @return the grammarFile */ @@ -223,10 +224,10 @@ public InputStream grammarFile() { /** * Gets the contentType. * - * The format (MIME type) of the grammar file: - * * `application/srgs` for Augmented Backus-Naur Form (ABNF), which uses a plain-text representation that is similar - * to traditional BNF grammars. - * * `application/srgs+xml` for XML Form, which uses XML elements to represent the grammar. + *

The format (MIME type) of the grammar file: * `application/srgs` for Augmented Backus-Naur + * Form (ABNF), which uses a plain-text representation that is similar to traditional BNF + * grammars. * `application/srgs+xml` for XML Form, which uses XML elements to represent the + * grammar. * * @return the contentType */ @@ -237,9 +238,9 @@ public String contentType() { /** * Gets the allowOverwrite. * - * If `true`, the specified grammar overwrites an existing grammar with the same name. If `false`, the request fails - * if a grammar with the same name already exists. The parameter has no effect if a grammar with the same name does - * not already exist. + *

If `true`, the specified grammar overwrites an existing grammar with the same name. If + * `false`, the request fails if a grammar with the same name already exists. The parameter has no + * effect if a grammar with the same name does not already exist. * * @return the allowOverwrite */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java index 23592563744..5a0f1767848 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,47 +10,48 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addWord options. - */ +/** The addWord options. */ public class AddWordOptions extends GenericModel { protected String customizationId; protected String wordName; protected String word; + protected List mappingOnly; protected List soundsLike; protected String displayAs; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String wordName; private String word; + private List mappingOnly; private List soundsLike; private String displayAs; + /** + * Instantiates a new Builder from an existing AddWordOptions instance. + * + * @param addWordOptions the instance to initialize the Builder with + */ private Builder(AddWordOptions addWordOptions) { this.customizationId = addWordOptions.customizationId; this.wordName = addWordOptions.wordName; this.word = addWordOptions.word; + this.mappingOnly = addWordOptions.mappingOnly; this.soundsLike = addWordOptions.soundsLike; this.displayAs = addWordOptions.displayAs; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -66,21 +67,35 @@ public Builder(String customizationId, String wordName) { /** * Builds a AddWordOptions. * - * @return the addWordOptions + * @return the new AddWordOptions instance */ public AddWordOptions build() { return new AddWordOptions(this); } /** - * Adds an soundsLike to soundsLike. + * Adds a new element to mappingOnly. + * + * @param mappingOnly the new element to be added + * @return the AddWordOptions builder + */ + public Builder addMappingOnly(String mappingOnly) { + com.ibm.cloud.sdk.core.util.Validator.notNull(mappingOnly, "mappingOnly cannot be null"); + if (this.mappingOnly == null) { + this.mappingOnly = new ArrayList(); + } + this.mappingOnly.add(mappingOnly); + return this; + } + + /** + * Adds a new element to soundsLike. * - * @param soundsLike the new soundsLike + * @param soundsLike the new element to be added * @return the AddWordOptions builder */ public Builder addSoundsLike(String soundsLike) { - com.ibm.cloud.sdk.core.util.Validator.notNull(soundsLike, - "soundsLike cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(soundsLike, "soundsLike cannot be null"); if (this.soundsLike == null) { this.soundsLike = new ArrayList(); } @@ -122,8 +137,18 @@ public Builder word(String word) { } /** - * Set the soundsLike. - * Existing soundsLike will be replaced. + * Set the mappingOnly. Existing mappingOnly will be replaced. + * + * @param mappingOnly the mappingOnly + * @return the AddWordOptions builder + */ + public Builder mappingOnly(List mappingOnly) { + this.mappingOnly = mappingOnly; + return this; + } + + /** + * Set the soundsLike. Existing soundsLike will be replaced. * * @param soundsLike the soundsLike * @return the AddWordOptions builder @@ -145,14 +170,16 @@ public Builder displayAs(String displayAs) { } } + protected AddWordOptions() {} + protected AddWordOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.wordName, - "wordName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.wordName, "wordName cannot be empty"); customizationId = builder.customizationId; wordName = builder.wordName; word = builder.word; + mappingOnly = builder.mappingOnly; soundsLike = builder.soundsLike; displayAs = builder.displayAs; } @@ -169,8 +196,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -181,8 +209,10 @@ public String customizationId() { /** * Gets the wordName. * - * The custom word that is to be added to or updated in the custom language model. Do not include spaces in the word. - * Use a `-` (dash) or `_` (underscore) to connect the tokens of compound words. URL-encode the word if it includes + *

The custom word that is to be added to or updated in the custom language model. Do not use + * characters that need to be URL-encoded, for example, spaces, slashes, backslashes, colons, + * ampersands, double quotes, plus signs, equals signs, or question marks. Use a `-` (dash) or `_` + * (underscore) to connect the tokens of compound words. URL-encode the word if it includes * non-ASCII characters. For more information, see [Character * encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding). * @@ -195,11 +225,14 @@ public String wordName() { /** * Gets the word. * - * For the **Add custom words** method, you must specify the custom word that is to be added to or updated in the - * custom model. Do not include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of - * compound words. + *

For the [Add custom words](#addwords) method, you must specify the custom word that is to be + * added to or updated in the custom model. Do not use characters that need to be URL-encoded, for + * example, spaces, slashes, backslashes, colons, ampersands, double quotes, plus signs, equals + * signs, or question marks. Use a `-` (dash) or `_` (underscore) to connect the tokens of + * compound words. A Japanese custom word can include at most 25 characters, not including leading + * or trailing spaces. * - * Omit this parameter for the **Add a custom word** method. + *

Omit this parameter for the [Add a custom word](#addword) method. * * @return the word */ @@ -207,19 +240,37 @@ public String word() { return word; } + /** + * Gets the mappingOnly. + * + *

Parameter for custom words. You can use the 'mapping_only' key in custom words as a form of + * post processing. This key parameter has a boolean value to determine whether 'sounds_like' (for + * non-Japanese models) or word (for Japanese) is not used for the model fine-tuning, but for the + * replacement for 'display_as'. This feature helps you when you use custom words exclusively to + * map 'sounds_like' (or word) to 'display_as' value. When you use custom words solely for + * post-processing purposes that does not need fine-tuning. + * + * @return the mappingOnly + */ + public List mappingOnly() { + return mappingOnly; + } + /** * Gets the soundsLike. * - * An array of sounds-like pronunciations for the custom word. Specify how words that are difficult to pronounce, - * foreign words, acronyms, and so on can be pronounced by users. - * * For a word that is not in the service's base vocabulary, omit the parameter to have the service automatically - * generate a sounds-like pronunciation for the word. - * * For a word that is in the service's base vocabulary, use the parameter to specify additional pronunciations for - * the word. You cannot override the default pronunciation of a word; pronunciations you add augment the pronunciation - * from the base vocabulary. + *

As array of sounds-like pronunciations for the custom word. Specify how words that are + * difficult to pronounce, foreign words, acronyms, and so on can be pronounced by users. * _For + * custom models that are based on previous-generation models_, for a word that is not in the + * service's base vocabulary, omit the parameter to have the service automatically generate a + * sounds-like pronunciation for the word. * For a word that is in the service's base vocabulary, + * use the parameter to specify additional pronunciations for the word. You cannot override the + * default pronunciation of a word; pronunciations you add augment the pronunciation from the base + * vocabulary. * - * A word can have at most five sounds-like pronunciations. A pronunciation can include at most 40 characters not - * including spaces. + *

A word can have at most five sounds-like pronunciations. A pronunciation can include at most + * 40 characters, not including leading or trailing spaces. A Japanese pronunciation can include + * at most 25 characters, not including leading or trailing spaces. * * @return the soundsLike */ @@ -230,9 +281,12 @@ public List soundsLike() { /** * Gets the displayAs. * - * An alternative spelling for the custom word when it appears in a transcript. Use the parameter when you want the - * word to have a spelling that is different from its usual representation or from its spelling in corpora training - * data. + *

An alternative spelling for the custom word when it appears in a transcript. Use the + * parameter when you want the word to have a spelling that is different from its usual + * representation or from its spelling in corpora training data. + * + *

_For custom models that are based on next-generation models_, the service uses the spelling + * of the word as the display-as value if you omit the field. * * @return the displayAs */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java index a7d3f4e1f17..b8ed50e4b53 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,36 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addWords options. - */ +/** The addWords options. */ public class AddWordsOptions extends GenericModel { protected String customizationId; protected List words; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private List words; + /** + * Instantiates a new Builder from an existing AddWordsOptions instance. + * + * @param addWordsOptions the instance to initialize the Builder with + */ private Builder(AddWordsOptions addWordsOptions) { this.customizationId = addWordsOptions.customizationId; this.words = addWordsOptions.words; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,21 +55,20 @@ public Builder(String customizationId, List words) { /** * Builds a AddWordsOptions. * - * @return the addWordsOptions + * @return the new AddWordsOptions instance */ public AddWordsOptions build() { return new AddWordsOptions(this); } /** - * Adds an words to words. + * Adds a new element to words. * - * @param words the new words + * @param words the new element to be added * @return the AddWordsOptions builder */ public Builder addWords(CustomWord words) { - com.ibm.cloud.sdk.core.util.Validator.notNull(words, - "words cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(words, "words cannot be null"); if (this.words == null) { this.words = new ArrayList(); } @@ -91,8 +88,7 @@ public Builder customizationId(String customizationId) { } /** - * Set the words. - * Existing words will be replaced. + * Set the words. Existing words will be replaced. * * @param words the words * @return the AddWordsOptions builder @@ -103,11 +99,12 @@ public Builder words(List words) { } } + protected AddWordsOptions() {} + protected AddWordsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, - "words cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, "words cannot be null"); customizationId = builder.customizationId; words = builder.words; } @@ -124,8 +121,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -136,8 +134,8 @@ public String customizationId() { /** * Gets the words. * - * An array of `CustomWord` objects that provides information about each custom word that is to be added to or updated - * in the custom language model. + *

An array of `CustomWord` objects that provides information about each custom word that is to + * be added to or updated in the custom language model. * * @return the words */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java index d50ab807baf..b51fe9da578 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,20 +10,18 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about an audio resource from a custom acoustic model. - */ +/** Information about an audio resource from a custom acoustic model. */ public class AudioDetails extends GenericModel { /** - * The type of the audio resource: - * * `audio` for an individual audio file - * * `archive` for an archive (**.zip** or **.tar.gz**) file that contains audio files - * * `undetermined` for a resource that the service cannot validate (for example, if the user mistakenly passes a file + * The type of the audio resource: * `audio` for an individual audio file * `archive` for an + * archive (**.zip** or **.tar.gz**) file that contains audio files * `undetermined` for a + * resource that the service cannot validate (for example, if the user mistakenly passes a file * that does not contain audio, such as a JPEG file). */ public interface Type { @@ -36,11 +34,10 @@ public interface Type { } /** - * **For an archive-type resource,** the format of the compressed archive: - * * `zip` for a **.zip** file - * * `gzip` for a **.tar.gz** file + * _For an archive-type resource_, the format of the compressed archive: * `zip` for a **.zip** + * file * `gzip` for a **.tar.gz** file * - * Omitted for an audio-type resource. + *

Omitted for an audio-type resource. */ public interface Compression { /** zip. */ @@ -54,13 +51,14 @@ public interface Compression { protected Long frequency; protected String compression; + protected AudioDetails() {} + /** * Gets the type. * - * The type of the audio resource: - * * `audio` for an individual audio file - * * `archive` for an archive (**.zip** or **.tar.gz**) file that contains audio files - * * `undetermined` for a resource that the service cannot validate (for example, if the user mistakenly passes a file + *

The type of the audio resource: * `audio` for an individual audio file * `archive` for an + * archive (**.zip** or **.tar.gz**) file that contains audio files * `undetermined` for a + * resource that the service cannot validate (for example, if the user mistakenly passes a file * that does not contain audio, such as a JPEG file). * * @return the type @@ -72,7 +70,8 @@ public String getType() { /** * Gets the codec. * - * **For an audio-type resource,** the codec in which the audio is encoded. Omitted for an archive-type resource. + *

_For an audio-type resource_, the codec in which the audio is encoded. Omitted for an + * archive-type resource. * * @return the codec */ @@ -83,8 +82,8 @@ public String getCodec() { /** * Gets the frequency. * - * **For an audio-type resource,** the sampling rate of the audio in Hertz (samples per second). Omitted for an - * archive-type resource. + *

_For an audio-type resource_, the sampling rate of the audio in Hertz (samples per second). + * Omitted for an archive-type resource. * * @return the frequency */ @@ -95,11 +94,10 @@ public Long getFrequency() { /** * Gets the compression. * - * **For an archive-type resource,** the format of the compressed archive: - * * `zip` for a **.zip** file - * * `gzip` for a **.tar.gz** file + *

_For an archive-type resource_, the format of the compressed archive: * `zip` for a **.zip** + * file * `gzip` for a **.tar.gz** file * - * Omitted for an audio-type resource. + *

Omitted for an audio-type resource. * * @return the compression */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java index 5e46c58e91f..0cbaf3a2f23 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,26 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about an audio resource from a custom acoustic model. - */ +/** Information about an audio resource from a custom acoustic model. */ public class AudioListing extends GenericModel { /** - * **For an audio-type resource,** the status of the resource: - * * `ok`: The service successfully analyzed the audio data. The data can be used to train the custom model. - * * `being_processed`: The service is still analyzing the audio data. The service cannot accept requests to add new - * audio resources or to train the custom model until its analysis is complete. - * * `invalid`: The audio data is not valid for training the custom model (possibly because it has the wrong format or - * sampling rate, or because it is corrupted). + * _For an audio-type resource_, the status of the resource: * `ok`: The service successfully + * analyzed the audio data. The data can be used to train the custom model. * `being_processed`: + * The service is still analyzing the audio data. The service cannot accept requests to add new + * audio resources or to train the custom model until its analysis is complete. * `invalid`: The + * audio data is not valid for training the custom model (possibly because it has the wrong format + * or sampling rate, or because it is corrupted). * - * Omitted for an archive-type resource. + *

Omitted for an archive-type resource. */ public interface Status { /** ok. */ @@ -47,10 +45,13 @@ public interface Status { protected AudioResource container; protected List audio; + protected AudioListing() {} + /** * Gets the duration. * - * **For an audio-type resource,** the total seconds of audio in the resource. Omitted for an archive-type resource. + *

_For an audio-type resource_, the total seconds of audio in the resource. Omitted for an + * archive-type resource. * * @return the duration */ @@ -61,7 +62,8 @@ public Long getDuration() { /** * Gets the name. * - * **For an audio-type resource,** the user-specified name of the resource. Omitted for an archive-type resource. + *

_For an audio-type resource_, the user-specified name of the resource. Omitted for an + * archive-type resource. * * @return the name */ @@ -72,8 +74,9 @@ public String getName() { /** * Gets the details. * - * **For an audio-type resource,** an `AudioDetails` object that provides detailed information about the resource. The - * object is empty until the service finishes processing the audio. Omitted for an archive-type resource. + *

_For an audio-type resource_, an `AudioDetails` object that provides detailed information + * about the resource. The object is empty until the service finishes processing the audio. + * Omitted for an archive-type resource. * * @return the details */ @@ -84,14 +87,14 @@ public AudioDetails getDetails() { /** * Gets the status. * - * **For an audio-type resource,** the status of the resource: - * * `ok`: The service successfully analyzed the audio data. The data can be used to train the custom model. - * * `being_processed`: The service is still analyzing the audio data. The service cannot accept requests to add new - * audio resources or to train the custom model until its analysis is complete. - * * `invalid`: The audio data is not valid for training the custom model (possibly because it has the wrong format or - * sampling rate, or because it is corrupted). + *

_For an audio-type resource_, the status of the resource: * `ok`: The service successfully + * analyzed the audio data. The data can be used to train the custom model. * `being_processed`: + * The service is still analyzing the audio data. The service cannot accept requests to add new + * audio resources or to train the custom model until its analysis is complete. * `invalid`: The + * audio data is not valid for training the custom model (possibly because it has the wrong format + * or sampling rate, or because it is corrupted). * - * Omitted for an archive-type resource. + *

Omitted for an archive-type resource. * * @return the status */ @@ -102,8 +105,8 @@ public String getStatus() { /** * Gets the container. * - * **For an archive-type resource,** an object of type `AudioResource` that provides information about the resource. - * Omitted for an audio-type resource. + *

_For an archive-type resource_, an object of type `AudioResource` that provides information + * about the resource. Omitted for an audio-type resource. * * @return the container */ @@ -114,8 +117,9 @@ public AudioResource getContainer() { /** * Gets the audio. * - * **For an archive-type resource,** an array of `AudioResource` objects that provides information about the - * audio-type resources that are contained in the resource. Omitted for an audio-type resource. + *

_For an archive-type resource_, an array of `AudioResource` objects that provides + * information about the audio-type resources that are contained in the resource. Omitted for an + * audio-type resource. * * @return the audio */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java index 47e71a18ab0..8d5215cce88 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,6 +10,7 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; @@ -22,14 +23,18 @@ public class AudioMetrics extends GenericModel { @SerializedName("sampling_interval") protected Float samplingInterval; + protected AudioMetricsDetails accumulated; + protected AudioMetrics() {} + /** * Gets the samplingInterval. * - * The interval in seconds (typically 0.1 seconds) at which the service calculated the audio metrics. In other words, - * how often the service calculated the metrics. A single unit in each histogram (see the `AudioMetricsHistogramBin` - * object) is calculated based on a `sampling_interval` length of audio. + *

The interval in seconds (typically 0.1 seconds) at which the service calculated the audio + * metrics. In other words, how often the service calculated the metrics. A single unit in each + * histogram (see the `AudioMetricsHistogramBin` object) is calculated based on a + * `sampling_interval` length of audio. * * @return the samplingInterval */ @@ -40,7 +45,7 @@ public Float getSamplingInterval() { /** * Gets the accumulated. * - * Detailed information about the signal characteristics of the input audio. + *

Detailed information about the signal characteristics of the input audio. * * @return the accumulated */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java index 79350ba7270..da9a1d6e18c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,43 +10,51 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Detailed information about the signal characteristics of the input audio. - */ +/** Detailed information about the signal characteristics of the input audio. */ public class AudioMetricsDetails extends GenericModel { @SerializedName("final") protected Boolean xFinal; + @SerializedName("end_time") protected Float endTime; + @SerializedName("signal_to_noise_ratio") protected Float signalToNoiseRatio; + @SerializedName("speech_ratio") protected Float speechRatio; + @SerializedName("high_frequency_loss") protected Float highFrequencyLoss; + @SerializedName("direct_current_offset") protected List directCurrentOffset; + @SerializedName("clipping_rate") protected List clippingRate; + @SerializedName("speech_level") protected List speechLevel; + @SerializedName("non_speech_level") protected List nonSpeechLevel; + protected AudioMetricsDetails() {} + /** * Gets the xFinal. * - * If `true`, indicates the end of the audio stream, meaning that transcription is complete. Currently, the field is - * always `true`. The service returns metrics just once per audio stream. The results provide aggregated audio metrics - * that pertain to the complete audio stream. + *

If `true`, indicates the end of the audio stream, meaning that transcription is complete. + * Currently, the field is always `true`. The service returns metrics just once per audio stream. + * The results provide aggregated audio metrics that pertain to the complete audio stream. * * @return the xFinal */ @@ -57,7 +65,7 @@ public Boolean isXFinal() { /** * Gets the endTime. * - * The end time in seconds of the block of audio to which the metrics apply. + *

The end time in seconds of the block of audio to which the metrics apply. * * @return the endTime */ @@ -68,9 +76,9 @@ public Float getEndTime() { /** * Gets the signalToNoiseRatio. * - * The signal-to-noise ratio (SNR) for the audio signal. The value indicates the ratio of speech to noise in the - * audio. A valid value lies in the range of 0 to 100 decibels (dB). The service omits the field if it cannot compute - * the SNR for the audio. + *

The signal-to-noise ratio (SNR) for the audio signal. The value indicates the ratio of + * speech to noise in the audio. A valid value lies in the range of 0 to 100 decibels (dB). The + * service omits the field if it cannot compute the SNR for the audio. * * @return the signalToNoiseRatio */ @@ -81,7 +89,8 @@ public Float getSignalToNoiseRatio() { /** * Gets the speechRatio. * - * The ratio of speech to non-speech segments in the audio signal. The value lies in the range of 0.0 to 1.0. + *

The ratio of speech to non-speech segments in the audio signal. The value lies in the range + * of 0.0 to 1.0. * * @return the speechRatio */ @@ -92,11 +101,11 @@ public Float getSpeechRatio() { /** * Gets the highFrequencyLoss. * - * The probability that the audio signal is missing the upper half of its frequency content. - * * A value close to 1.0 typically indicates artificially up-sampled audio, which negatively impacts the accuracy of - * the transcription results. - * * A value at or near 0.0 indicates that the audio signal is good and has a full spectrum. - * * A value around 0.5 means that detection of the frequency content is unreliable or not available. + *

The probability that the audio signal is missing the upper half of its frequency content. * + * A value close to 1.0 typically indicates artificially up-sampled audio, which negatively + * impacts the accuracy of the transcription results. * A value at or near 0.0 indicates that the + * audio signal is good and has a full spectrum. * A value around 0.5 means that detection of the + * frequency content is unreliable or not available. * * @return the highFrequencyLoss */ @@ -107,8 +116,8 @@ public Float getHighFrequencyLoss() { /** * Gets the directCurrentOffset. * - * An array of `AudioMetricsHistogramBin` objects that defines a histogram of the cumulative direct current (DC) - * component of the audio signal. + *

An array of `AudioMetricsHistogramBin` objects that defines a histogram of the cumulative + * direct current (DC) component of the audio signal. * * @return the directCurrentOffset */ @@ -119,11 +128,12 @@ public List getDirectCurrentOffset() { /** * Gets the clippingRate. * - * An array of `AudioMetricsHistogramBin` objects that defines a histogram of the clipping rate for the audio - * segments. The clipping rate is defined as the fraction of samples in the segment that reach the maximum or minimum - * value that is offered by the audio quantization range. The service auto-detects either a 16-bit Pulse-Code - * Modulation(PCM) audio range (-32768 to +32767) or a unit range (-1.0 to +1.0). The clipping rate is between 0.0 and - * 1.0, with higher values indicating possible degradation of speech recognition. + *

An array of `AudioMetricsHistogramBin` objects that defines a histogram of the clipping rate + * for the audio segments. The clipping rate is defined as the fraction of samples in the segment + * that reach the maximum or minimum value that is offered by the audio quantization range. The + * service auto-detects either a 16-bit Pulse-Code Modulation(PCM) audio range (-32768 to +32767) + * or a unit range (-1.0 to +1.0). The clipping rate is between 0.0 and 1.0, with higher values + * indicating possible degradation of speech recognition. * * @return the clippingRate */ @@ -134,9 +144,10 @@ public List getClippingRate() { /** * Gets the speechLevel. * - * An array of `AudioMetricsHistogramBin` objects that defines a histogram of the signal level in segments of the - * audio that contain speech. The signal level is computed as the Root-Mean-Square (RMS) value in a decibel (dB) scale - * normalized to the range 0.0 (minimum level) to 1.0 (maximum level). + *

An array of `AudioMetricsHistogramBin` objects that defines a histogram of the signal level + * in segments of the audio that contain speech. The signal level is computed as the + * Root-Mean-Square (RMS) value in a decibel (dB) scale normalized to the range 0.0 (minimum + * level) to 1.0 (maximum level). * * @return the speechLevel */ @@ -147,9 +158,10 @@ public List getSpeechLevel() { /** * Gets the nonSpeechLevel. * - * An array of `AudioMetricsHistogramBin` objects that defines a histogram of the signal level in segments of the - * audio that do not contain speech. The signal level is computed as the Root-Mean-Square (RMS) value in a decibel - * (dB) scale normalized to the range 0.0 (minimum level) to 1.0 (maximum level). + *

An array of `AudioMetricsHistogramBin` objects that defines a histogram of the signal level + * in segments of the audio that do not contain speech. The signal level is computed as the + * Root-Mean-Square (RMS) value in a decibel (dB) scale normalized to the range 0.0 (minimum + * level) to 1.0 (maximum level). * * @return the nonSpeechLevel */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java index c4e6a546558..9c277eeca70 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,14 +10,16 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * A bin with defined boundaries that indicates the number of values in a range of signal characteristics for a - * histogram. The first and last bins of a histogram are the boundary bins. They cover the intervals between negative - * infinity and the first boundary, and between the last boundary and positive infinity, respectively. + * A bin with defined boundaries that indicates the number of values in a range of signal + * characteristics for a histogram. The first and last bins of a histogram are the boundary bins. + * They cover the intervals between negative infinity and the first boundary, and between the last + * boundary and positive infinity, respectively. */ public class AudioMetricsHistogramBin extends GenericModel { @@ -25,10 +27,12 @@ public class AudioMetricsHistogramBin extends GenericModel { protected Float end; protected Long count; + protected AudioMetricsHistogramBin() {} + /** * Gets the begin. * - * The lower boundary of the bin in the histogram. + *

The lower boundary of the bin in the histogram. * * @return the begin */ @@ -39,7 +43,7 @@ public Float getBegin() { /** * Gets the end. * - * The upper boundary of the bin in the histogram. + *

The upper boundary of the bin in the histogram. * * @return the end */ @@ -50,7 +54,7 @@ public Float getEnd() { /** * Gets the count. * - * The number of values in the bin of the histogram. + *

The number of values in the bin of the histogram. * * @return the count */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java index 9b588cec5c2..cd578042150 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,23 +10,22 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about an audio resource from a custom acoustic model. - */ +/** Information about an audio resource from a custom acoustic model. */ public class AudioResource extends GenericModel { /** - * The status of the audio resource: - * * `ok`: The service successfully analyzed the audio data. The data can be used to train the custom model. - * * `being_processed`: The service is still analyzing the audio data. The service cannot accept requests to add new - * audio resources or to train the custom model until its analysis is complete. - * * `invalid`: The audio data is not valid for training the custom model (possibly because it has the wrong format or - * sampling rate, or because it is corrupted). For an archive file, the entire archive is invalid if any of its audio - * files are invalid. + * The status of the audio resource: * `ok`: The service successfully analyzed the audio data. The + * data can be used to train the custom model. * `being_processed`: The service is still analyzing + * the audio data. The service cannot accept requests to add new audio resources or to train the + * custom model until its analysis is complete. * `invalid`: The audio data is not valid for + * training the custom model (possibly because it has the wrong format or sampling rate, or + * because it is corrupted). For an archive file, the entire archive is invalid if any of its + * audio files are invalid. */ public interface Status { /** ok. */ @@ -42,10 +41,12 @@ public interface Status { protected AudioDetails details; protected String status; + protected AudioResource() {} + /** * Gets the duration. * - * The total seconds of audio in the audio resource. + *

The total seconds of audio in the audio resource. * * @return the duration */ @@ -56,10 +57,11 @@ public Long getDuration() { /** * Gets the name. * - * **For an archive-type resource,** the user-specified name of the resource. + *

_For an archive-type resource_, the user-specified name of the resource. * - * **For an audio-type resource,** the user-specified name of the resource or the name of the audio file that the user - * added for the resource. The value depends on the method that is called. + *

_For an audio-type resource_, the user-specified name of the resource or the name of the + * audio file that the user added for the resource. The value depends on the method that is + * called. * * @return the name */ @@ -70,8 +72,8 @@ public String getName() { /** * Gets the details. * - * An `AudioDetails` object that provides detailed information about the audio resource. The object is empty until the - * service finishes processing the audio. + *

An `AudioDetails` object that provides detailed information about the audio resource. The + * object is empty until the service finishes processing the audio. * * @return the details */ @@ -82,13 +84,13 @@ public AudioDetails getDetails() { /** * Gets the status. * - * The status of the audio resource: - * * `ok`: The service successfully analyzed the audio data. The data can be used to train the custom model. - * * `being_processed`: The service is still analyzing the audio data. The service cannot accept requests to add new - * audio resources or to train the custom model until its analysis is complete. - * * `invalid`: The audio data is not valid for training the custom model (possibly because it has the wrong format or - * sampling rate, or because it is corrupted). For an archive file, the entire archive is invalid if any of its audio - * files are invalid. + *

The status of the audio resource: * `ok`: The service successfully analyzed the audio data. + * The data can be used to train the custom model. * `being_processed`: The service is still + * analyzing the audio data. The service cannot accept requests to add new audio resources or to + * train the custom model until its analysis is complete. * `invalid`: The audio data is not valid + * for training the custom model (possibly because it has the wrong format or sampling rate, or + * because it is corrupted). For an archive file, the entire archive is invalid if any of its + * audio files are invalid. * * @return the status */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java index 2adfed97874..f9f2cf10233 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,27 +10,29 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about the audio resources from a custom acoustic model. - */ +/** Information about the audio resources from a custom acoustic model. */ public class AudioResources extends GenericModel { @SerializedName("total_minutes_of_audio") protected Double totalMinutesOfAudio; + protected List audio; + protected AudioResources() {} + /** * Gets the totalMinutesOfAudio. * - * The total minutes of accumulated audio summed over all of the valid audio resources for the custom acoustic model. - * You can use this value to determine whether the custom model has too little or too much audio to begin training. + *

The total minutes of accumulated audio summed over all of the valid audio resources for the + * custom acoustic model. You can use this value to determine whether the custom model has too + * little or too much audio to begin training. * * @return the totalMinutesOfAudio */ @@ -41,8 +43,8 @@ public Double getTotalMinutesOfAudio() { /** * Gets the audio. * - * An array of `AudioResource` objects that provides information about the audio resources of the custom acoustic - * model. The array is empty if the custom model has no audio resources. + *

An array of `AudioResource` objects that provides information about the audio resources of + * the custom acoustic model. The array is empty if the custom model has no audio resources. * * @return the audio */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java index aa4c83394a5..f8f6e57fb33 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The checkJob options. - */ +/** The checkJob options. */ public class CheckJobOptions extends GenericModel { protected String id; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String id; + /** + * Instantiates a new Builder from an existing CheckJobOptions instance. + * + * @param checkJobOptions the instance to initialize the Builder with + */ private Builder(CheckJobOptions checkJobOptions) { this.id = checkJobOptions.id; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String id) { /** * Builds a CheckJobOptions. * - * @return the checkJobOptions + * @return the new CheckJobOptions instance */ public CheckJobOptions build() { return new CheckJobOptions(this); @@ -67,9 +66,10 @@ public Builder id(String id) { } } + protected CheckJobOptions() {} + protected CheckJobOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.id, - "id cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.id, "id cannot be empty"); id = builder.id; } @@ -85,8 +85,8 @@ public Builder newBuilder() { /** * Gets the id. * - * The identifier of the asynchronous job that is to be used for the request. You must make the request with - * credentials for the instance of the service that owns the job. + *

The identifier of the asynchronous job that is to be used for the request. You must make the + * request with credentials for the instance of the service that owns the job. * * @return the id */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java index 323a52fd7e1..6fb9c6211bb 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,48 +10,14 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The checkJobs options. - */ +/** The checkJobs options. */ public class CheckJobsOptions extends GenericModel { - /** - * Builder. - */ - public static class Builder { - - private Builder(CheckJobsOptions checkJobsOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CheckJobsOptions. - * - * @return the checkJobsOptions - */ - public CheckJobsOptions build() { - return new CheckJobsOptions(this); - } - } - - private CheckJobsOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a CheckJobsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } + /** Construct a new instance of CheckJobsOptions. */ + public CheckJobsOptions() {} } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java index 214bfffccbc..2e6d64cd4d0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about the corpora from a custom language model. - */ +/** Information about the corpora from a custom language model. */ public class Corpora extends GenericModel { protected List corpora; + protected Corpora() {} + /** * Gets the corpora. * - * An array of `Corpus` objects that provides information about the corpora for the custom model. The array is empty - * if the custom model has no corpora. + *

An array of `Corpus` objects that provides information about the corpora for the custom + * model. The array is empty if the custom model has no corpora. * * @return the corpora */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java index d57af5c84f4..6dba06236a1 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,24 +10,21 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about a corpus from a custom language model. - */ +/** Information about a corpus from a custom language model. */ public class Corpus extends GenericModel { /** - * The status of the corpus: - * * `analyzed`: The service successfully analyzed the corpus. The custom model can be trained with data from the - * corpus. - * * `being_processed`: The service is still analyzing the corpus. The service cannot accept requests to add new - * resources or to train the custom model. - * * `undetermined`: The service encountered an error while processing the corpus. The `error` field describes the - * failure. + * The status of the corpus: * `analyzed`: The service successfully analyzed the corpus. The + * custom model can be trained with data from the corpus. * `being_processed`: The service is + * still analyzing the corpus. The service cannot accept requests to add new resources or to train + * the custom model. * `undetermined`: The service encountered an error while processing the + * corpus. The `error` field describes the failure. */ public interface Status { /** analyzed. */ @@ -39,17 +36,22 @@ public interface Status { } protected String name; + @SerializedName("total_words") protected Long totalWords; + @SerializedName("out_of_vocabulary_words") protected Long outOfVocabularyWords; + protected String status; protected String error; + protected Corpus() {} + /** * Gets the name. * - * The name of the corpus. + *

The name of the corpus. * * @return the name */ @@ -60,7 +62,8 @@ public String getName() { /** * Gets the totalWords. * - * The total number of words in the corpus. The value is `0` while the corpus is being processed. + *

The total number of words in the corpus. The value is `0` while the corpus is being + * processed. * * @return the totalWords */ @@ -71,7 +74,12 @@ public Long getTotalWords() { /** * Gets the outOfVocabularyWords. * - * The number of OOV words in the corpus. The value is `0` while the corpus is being processed. + *

_For custom models that are based on large speech models and previous-generation models_, + * the number of OOV words extracted from the corpus. The value is `0` while the corpus is being + * processed. + * + *

_For custom models that are based on next-generation models_, no OOV words are extracted + * from corpora, so the value is always `0`. * * @return the outOfVocabularyWords */ @@ -82,13 +90,11 @@ public Long getOutOfVocabularyWords() { /** * Gets the status. * - * The status of the corpus: - * * `analyzed`: The service successfully analyzed the corpus. The custom model can be trained with data from the - * corpus. - * * `being_processed`: The service is still analyzing the corpus. The service cannot accept requests to add new - * resources or to train the custom model. - * * `undetermined`: The service encountered an error while processing the corpus. The `error` field describes the - * failure. + *

The status of the corpus: * `analyzed`: The service successfully analyzed the corpus. The + * custom model can be trained with data from the corpus. * `being_processed`: The service is + * still analyzing the corpus. The service cannot accept requests to add new resources or to train + * the custom model. * `undetermined`: The service encountered an error while processing the + * corpus. The `error` field describes the failure. * * @return the status */ @@ -99,8 +105,9 @@ public String getStatus() { /** * Gets the error. * - * If the status of the corpus is `undetermined`, the following message: `Analysis of corpus 'name' failed. Please try - * adding the corpus again by setting the 'allow_overwrite' flag to 'true'`. + *

If the status of the corpus is `undetermined`, the following message: `Analysis of corpus + * 'name' failed. Please try adding the corpus again by setting the 'allow_overwrite' flag to + * 'true'`. * * @return the error */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java index d78ee134238..6eac9eeef2c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,29 +10,35 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The createAcousticModel options. - */ +/** The createAcousticModel options. */ public class CreateAcousticModelOptions extends GenericModel { /** - * The name of the base language model that is to be customized by the new custom acoustic model. The new custom model - * can be used only with the base model that it customizes. + * The name of the base language model that is to be customized by the new custom acoustic model. + * The new custom model can be used only with the base model that it customizes. * - * To determine whether a base model supports acoustic model customization, refer to [Language support for - * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). + *

To determine whether a base model supports acoustic model customization, refer to [Language + * support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). */ public interface BaseModelName { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; + /** ar-MS_BroadbandModel. */ + String AR_MS_BROADBANDMODEL = "ar-MS_BroadbandModel"; + /** de-DE. */ + String DE_DE = "de-DE"; /** de-DE_BroadbandModel. */ String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; /** en-GB_NarrowbandModel. */ @@ -43,30 +49,46 @@ public interface BaseModelName { String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; /** en-US_ShortForm_NarrowbandModel. */ String EN_US_SHORTFORM_NARROWBANDMODEL = "en-US_ShortForm_NarrowbandModel"; + /** es-AR. */ + String ES_AR = "es-AR"; /** es-AR_BroadbandModel. */ String ES_AR_BROADBANDMODEL = "es-AR_BroadbandModel"; /** es-AR_NarrowbandModel. */ String ES_AR_NARROWBANDMODEL = "es-AR_NarrowbandModel"; + /** es-CL. */ + String ES_CL = "es-CL"; /** es-CL_BroadbandModel. */ String ES_CL_BROADBANDMODEL = "es-CL_BroadbandModel"; /** es-CL_NarrowbandModel. */ String ES_CL_NARROWBANDMODEL = "es-CL_NarrowbandModel"; + /** es-CO. */ + String ES_CO = "es-CO"; /** es-CO_BroadbandModel. */ String ES_CO_BROADBANDMODEL = "es-CO_BroadbandModel"; /** es-CO_NarrowbandModel. */ String ES_CO_NARROWBANDMODEL = "es-CO_NarrowbandModel"; + /** es-ES. */ + String ES_ES = "es-ES"; /** es-ES_BroadbandModel. */ String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; /** es-ES_NarrowbandModel. */ String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; + /** es-MX. */ + String ES_MX = "es-MX"; /** es-MX_BroadbandModel. */ String ES_MX_BROADBANDMODEL = "es-MX_BroadbandModel"; /** es-MX_NarrowbandModel. */ String ES_MX_NARROWBANDMODEL = "es-MX_NarrowbandModel"; + /** es-PE. */ + String ES_PE = "es-PE"; /** es-PE_BroadbandModel. */ String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; /** fr-FR_NarrowbandModel. */ @@ -87,6 +109,8 @@ public interface BaseModelName { String NL_NL_BROADBANDMODEL = "nl-NL_BroadbandModel"; /** nl-NL_NarrowbandModel. */ String NL_NL_NARROWBANDMODEL = "nl-NL_NarrowbandModel"; + /** pt-BR. */ + String PT_BR = "pt-BR"; /** pt-BR_BroadbandModel. */ String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; /** pt-BR_NarrowbandModel. */ @@ -101,25 +125,25 @@ public interface BaseModelName { protected String baseModelName; protected String description; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String name; private String baseModelName; private String description; + /** + * Instantiates a new Builder from an existing CreateAcousticModelOptions instance. + * + * @param createAcousticModelOptions the instance to initialize the Builder with + */ private Builder(CreateAcousticModelOptions createAcousticModelOptions) { this.name = createAcousticModelOptions.name; this.baseModelName = createAcousticModelOptions.baseModelName; this.description = createAcousticModelOptions.description; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -135,7 +159,7 @@ public Builder(String name, String baseModelName) { /** * Builds a CreateAcousticModelOptions. * - * @return the createAcousticModelOptions + * @return the new CreateAcousticModelOptions instance */ public CreateAcousticModelOptions build() { return new CreateAcousticModelOptions(this); @@ -175,11 +199,12 @@ public Builder description(String description) { } } + protected CreateAcousticModelOptions() {} + protected CreateAcousticModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.baseModelName, - "baseModelName cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.baseModelName, "baseModelName cannot be null"); name = builder.name; baseModelName = builder.baseModelName; description = builder.description; @@ -197,9 +222,13 @@ public Builder newBuilder() { /** * Gets the name. * - * A user-defined name for the new custom acoustic model. Use a name that is unique among all custom acoustic models - * that you own. Use a localized name that matches the language of the custom model. Use a name that describes the - * acoustic environment of the custom model, such as `Mobile custom model` or `Noisy car custom model`. + *

A user-defined name for the new custom acoustic model. Use a localized name that matches the + * language of the custom model. Use a name that describes the acoustic environment of the custom + * model, such as `Mobile custom model` or `Noisy car custom model`. Use a name that is unique + * among all custom acoustic models that you own. + * + *

Include a maximum of 256 characters in the name. Do not use backslashes, slashes, colons, + * equal signs, ampersands, or question marks in the name. * * @return the name */ @@ -210,11 +239,12 @@ public String name() { /** * Gets the baseModelName. * - * The name of the base language model that is to be customized by the new custom acoustic model. The new custom model - * can be used only with the base model that it customizes. + *

The name of the base language model that is to be customized by the new custom acoustic + * model. The new custom model can be used only with the base model that it customizes. * - * To determine whether a base model supports acoustic model customization, refer to [Language support for - * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). + *

To determine whether a base model supports acoustic model customization, refer to [Language + * support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * * @return the baseModelName */ @@ -225,8 +255,9 @@ public String baseModelName() { /** * Gets the description. * - * A description of the new custom acoustic model. Use a localized description that matches the language of the custom - * model. + *

A recommended description of the new custom acoustic model. Use a localized description that + * matches the language of the custom model. Include a maximum of 128 characters in the + * description. * * @return the description */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java index ec8a06c2df3..d517b837d4c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2026. * * 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 @@ -10,8 +10,10 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -19,105 +21,213 @@ import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createJob options. - */ +/** The createJob options. */ public class CreateJobOptions extends GenericModel { /** - * The identifier of the model that is to be used for the recognition request. See [Languages and - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + * The model to use for speech recognition. If you omit the `model` parameter, the service uses + * the US English `en-US_BroadbandModel` by default. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_BroadbandModel`, you must + * either specify a model with the request or specify a new default model for your installation of + * the service. + * + *

**See also:** * [Using a model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use) * + * [Using the default + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use#models-use-default). */ public interface Model { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; + /** ar-MS_BroadbandModel. */ + String AR_MS_BROADBANDMODEL = "ar-MS_BroadbandModel"; + /** ar-MS_Telephony. */ + String AR_MS_TELEPHONY = "ar-MS_Telephony"; + /** cs-CZ_Telephony. */ + String CS_CZ_TELEPHONY = "cs-CZ_Telephony"; + /** de-DE. */ + String DE_DE = "de-DE"; /** de-DE_BroadbandModel. */ String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; + /** de-DE_Multimedia. */ + String DE_DE_MULTIMEDIA = "de-DE_Multimedia"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** de-DE_Telephony. */ + String DE_DE_TELEPHONY = "de-DE_Telephony"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_Multimedia. */ + String EN_AU_MULTIMEDIA = "en-AU_Multimedia"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; + /** en-AU_Telephony. */ + String EN_AU_TELEPHONY = "en-AU_Telephony"; + /** en-IN. */ + String EN_IN = "en-IN"; + /** en-IN_Telephony. */ + String EN_IN_TELEPHONY = "en-IN_Telephony"; + /** en-GB. */ + String EN_GB = "en-GB"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; + /** en-GB_Multimedia. */ + String EN_GB_MULTIMEDIA = "en-GB_Multimedia"; /** en-GB_NarrowbandModel. */ String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; + /** en-GB_Telephony. */ + String EN_GB_TELEPHONY = "en-GB_Telephony"; + /** en-US. */ + String EN_US = "en-US"; /** en-US_BroadbandModel. */ String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; + /** en-US_Multimedia. */ + String EN_US_MULTIMEDIA = "en-US_Multimedia"; /** en-US_NarrowbandModel. */ String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; /** en-US_ShortForm_NarrowbandModel. */ String EN_US_SHORTFORM_NARROWBANDMODEL = "en-US_ShortForm_NarrowbandModel"; + /** en-US_Telephony. */ + String EN_US_TELEPHONY = "en-US_Telephony"; + /** en-WW_Medical_Telephony. */ + String EN_WW_MEDICAL_TELEPHONY = "en-WW_Medical_Telephony"; + /** es-AR. */ + String ES_AR = "es-AR"; /** es-AR_BroadbandModel. */ String ES_AR_BROADBANDMODEL = "es-AR_BroadbandModel"; /** es-AR_NarrowbandModel. */ String ES_AR_NARROWBANDMODEL = "es-AR_NarrowbandModel"; + /** es-CL. */ + String ES_CL = "es-CL"; /** es-CL_BroadbandModel. */ String ES_CL_BROADBANDMODEL = "es-CL_BroadbandModel"; /** es-CL_NarrowbandModel. */ String ES_CL_NARROWBANDMODEL = "es-CL_NarrowbandModel"; + /** es-CO. */ + String ES_CO = "es-CO"; /** es-CO_BroadbandModel. */ String ES_CO_BROADBANDMODEL = "es-CO_BroadbandModel"; /** es-CO_NarrowbandModel. */ String ES_CO_NARROWBANDMODEL = "es-CO_NarrowbandModel"; + /** es-ES. */ + String ES_ES = "es-ES"; /** es-ES_BroadbandModel. */ String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; /** es-ES_NarrowbandModel. */ String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; + /** es-ES_Multimedia. */ + String ES_ES_MULTIMEDIA = "es-ES_Multimedia"; + /** es-ES_Telephony. */ + String ES_ES_TELEPHONY = "es-ES_Telephony"; + /** es-LA_Telephony. */ + String ES_LA_TELEPHONY = "es-LA_Telephony"; + /** es-MX. */ + String ES_MX = "es-MX"; /** es-MX_BroadbandModel. */ String ES_MX_BROADBANDMODEL = "es-MX_BroadbandModel"; /** es-MX_NarrowbandModel. */ String ES_MX_NARROWBANDMODEL = "es-MX_NarrowbandModel"; + /** es-PE. */ + String ES_PE = "es-PE"; /** es-PE_BroadbandModel. */ String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_Multimedia. */ + String FR_CA_MULTIMEDIA = "fr-CA_Multimedia"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; + /** fr-CA_Telephony. */ + String FR_CA_TELEPHONY = "fr-CA_Telephony"; + /** fr-FR. */ + String FR_FR = "fr-FR"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; + /** fr-FR_Multimedia. */ + String FR_FR_MULTIMEDIA = "fr-FR_Multimedia"; /** fr-FR_NarrowbandModel. */ String FR_FR_NARROWBANDMODEL = "fr-FR_NarrowbandModel"; + /** fr-FR_Telephony. */ + String FR_FR_TELEPHONY = "fr-FR_Telephony"; + /** hi-IN_Telephony. */ + String HI_IN_TELEPHONY = "hi-IN_Telephony"; /** it-IT_BroadbandModel. */ String IT_IT_BROADBANDMODEL = "it-IT_BroadbandModel"; /** it-IT_NarrowbandModel. */ String IT_IT_NARROWBANDMODEL = "it-IT_NarrowbandModel"; + /** it-IT_Multimedia. */ + String IT_IT_MULTIMEDIA = "it-IT_Multimedia"; + /** it-IT_Telephony. */ + String IT_IT_TELEPHONY = "it-IT_Telephony"; + /** ja-JP. */ + String JA_JP = "ja-JP"; /** ja-JP_BroadbandModel. */ String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; + /** ja-JP_Multimedia. */ + String JA_JP_MULTIMEDIA = "ja-JP_Multimedia"; /** ja-JP_NarrowbandModel. */ String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; + /** ja-JP_Telephony. */ + String JA_JP_TELEPHONY = "ja-JP_Telephony"; /** ko-KR_BroadbandModel. */ String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; + /** ko-KR_Multimedia. */ + String KO_KR_MULTIMEDIA = "ko-KR_Multimedia"; /** ko-KR_NarrowbandModel. */ String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; + /** ko-KR_Telephony. */ + String KO_KR_TELEPHONY = "ko-KR_Telephony"; + /** nl-BE_Telephony. */ + String NL_BE_TELEPHONY = "nl-BE_Telephony"; /** nl-NL_BroadbandModel. */ String NL_NL_BROADBANDMODEL = "nl-NL_BroadbandModel"; + /** nl-NL_Multimedia. */ + String NL_NL_MULTIMEDIA = "nl-NL_Multimedia"; /** nl-NL_NarrowbandModel. */ String NL_NL_NARROWBANDMODEL = "nl-NL_NarrowbandModel"; + /** nl-NL_Telephony. */ + String NL_NL_TELEPHONY = "nl-NL_Telephony"; + /** pt-BR. */ + String PT_BR = "pt-BR"; /** pt-BR_BroadbandModel. */ String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; + /** pt-BR_Multimedia. */ + String PT_BR_MULTIMEDIA = "pt-BR_Multimedia"; /** pt-BR_NarrowbandModel. */ String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; + /** pt-BR_Telephony. */ + String PT_BR_TELEPHONY = "pt-BR_Telephony"; + /** sv-SE_Telephony. */ + String SV_SE_TELEPHONY = "sv-SE_Telephony"; /** zh-CN_BroadbandModel. */ String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; /** zh-CN_NarrowbandModel. */ String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; + /** zh-CN_Telephony. */ + String ZH_CN_TELEPHONY = "zh-CN_Telephony"; } /** - * If the job includes a callback URL, a comma-separated list of notification events to which to subscribe. Valid - * events are - * * `recognitions.started` generates a callback notification when the service begins to process the job. - * * `recognitions.completed` generates a callback notification when the job is complete. You must use the **Check a - * job** method to retrieve the results before they time out or are deleted. - * * `recognitions.completed_with_results` generates a callback notification when the job is complete. The - * notification includes the results of the request. - * * `recognitions.failed` generates a callback notification if the service experiences an error while processing the - * job. - * - * The `recognitions.completed` and `recognitions.completed_with_results` events are incompatible. You can specify - * only of the two events. - * - * If the job includes a callback URL, omit the parameter to subscribe to the default events: `recognitions.started`, - * `recognitions.completed`, and `recognitions.failed`. If the job does not include a callback URL, omit the - * parameter. + * If the job includes a callback URL, a comma-separated list of notification events to which to + * subscribe. Valid events are * `recognitions.started` generates a callback notification when the + * service begins to process the job. * `recognitions.completed` generates a callback notification + * when the job is complete. You must use the [Check a job](#checkjob) method to retrieve the + * results before they time out or are deleted. * `recognitions.completed_with_results` generates + * a callback notification when the job is complete. The notification includes the results of the + * request. * `recognitions.failed` generates a callback notification if the service experiences + * an error while processing the job. + * + *

The `recognitions.completed` and `recognitions.completed_with_results` events are + * incompatible. You can specify only of the two events. + * + *

If the job includes a callback URL, omit the parameter to subscribe to the default events: + * `recognitions.started`, `recognitions.completed`, and `recognitions.failed`. If the job does + * not include a callback URL, omit the parameter. */ public interface Events { /** recognitions.started. */ @@ -137,6 +247,8 @@ public interface Events { protected String events; protected String userToken; protected Long resultsTtl; + protected Boolean speechBeginEvent; + protected String enrichments; protected String languageCustomizationId; protected String acousticCustomizationId; protected String baseModelVersion; @@ -150,8 +262,8 @@ public interface Events { protected Boolean timestamps; protected Boolean profanityFilter; protected Boolean smartFormatting; + protected Long smartFormattingVersion; protected Boolean speakerLabels; - protected String customizationId; protected String grammarName; protected Boolean redaction; protected Boolean processingMetrics; @@ -159,10 +271,13 @@ public interface Events { protected Boolean audioMetrics; protected Double endOfPhraseSilenceTime; protected Boolean splitTranscriptAtPhraseEnd; + protected Float speechDetectorSensitivity; + protected Long sadModule; + protected Float backgroundAudioSuppression; + protected Boolean lowLatency; + protected Float characterInsertionBias; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private InputStream audio; private String contentType; @@ -171,6 +286,8 @@ public static class Builder { private String events; private String userToken; private Long resultsTtl; + private Boolean speechBeginEvent; + private String enrichments; private String languageCustomizationId; private String acousticCustomizationId; private String baseModelVersion; @@ -184,8 +301,8 @@ public static class Builder { private Boolean timestamps; private Boolean profanityFilter; private Boolean smartFormatting; + private Long smartFormattingVersion; private Boolean speakerLabels; - private String customizationId; private String grammarName; private Boolean redaction; private Boolean processingMetrics; @@ -193,7 +310,17 @@ public static class Builder { private Boolean audioMetrics; private Double endOfPhraseSilenceTime; private Boolean splitTranscriptAtPhraseEnd; + private Float speechDetectorSensitivity; + private Long sadModule; + private Float backgroundAudioSuppression; + private Boolean lowLatency; + private Float characterInsertionBias; + /** + * Instantiates a new Builder from an existing CreateJobOptions instance. + * + * @param createJobOptions the instance to initialize the Builder with + */ private Builder(CreateJobOptions createJobOptions) { this.audio = createJobOptions.audio; this.contentType = createJobOptions.contentType; @@ -202,6 +329,8 @@ private Builder(CreateJobOptions createJobOptions) { this.events = createJobOptions.events; this.userToken = createJobOptions.userToken; this.resultsTtl = createJobOptions.resultsTtl; + this.speechBeginEvent = createJobOptions.speechBeginEvent; + this.enrichments = createJobOptions.enrichments; this.languageCustomizationId = createJobOptions.languageCustomizationId; this.acousticCustomizationId = createJobOptions.acousticCustomizationId; this.baseModelVersion = createJobOptions.baseModelVersion; @@ -215,8 +344,8 @@ private Builder(CreateJobOptions createJobOptions) { this.timestamps = createJobOptions.timestamps; this.profanityFilter = createJobOptions.profanityFilter; this.smartFormatting = createJobOptions.smartFormatting; + this.smartFormattingVersion = createJobOptions.smartFormattingVersion; this.speakerLabels = createJobOptions.speakerLabels; - this.customizationId = createJobOptions.customizationId; this.grammarName = createJobOptions.grammarName; this.redaction = createJobOptions.redaction; this.processingMetrics = createJobOptions.processingMetrics; @@ -224,13 +353,15 @@ private Builder(CreateJobOptions createJobOptions) { this.audioMetrics = createJobOptions.audioMetrics; this.endOfPhraseSilenceTime = createJobOptions.endOfPhraseSilenceTime; this.splitTranscriptAtPhraseEnd = createJobOptions.splitTranscriptAtPhraseEnd; + this.speechDetectorSensitivity = createJobOptions.speechDetectorSensitivity; + this.sadModule = createJobOptions.sadModule; + this.backgroundAudioSuppression = createJobOptions.backgroundAudioSuppression; + this.lowLatency = createJobOptions.lowLatency; + this.characterInsertionBias = createJobOptions.characterInsertionBias; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -244,21 +375,20 @@ public Builder(InputStream audio) { /** * Builds a CreateJobOptions. * - * @return the createJobOptions + * @return the new CreateJobOptions instance */ public CreateJobOptions build() { return new CreateJobOptions(this); } /** - * Adds an keyword to keywords. + * Adds a new element to keywords. * - * @param keyword the new keyword + * @param keyword the new element to be added * @return the CreateJobOptions builder */ public Builder addKeyword(String keyword) { - com.ibm.cloud.sdk.core.util.Validator.notNull(keyword, - "keyword cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(keyword, "keyword cannot be null"); if (this.keywords == null) { this.keywords = new ArrayList(); } @@ -343,6 +473,28 @@ public Builder resultsTtl(long resultsTtl) { return this; } + /** + * Set the speechBeginEvent. + * + * @param speechBeginEvent the speechBeginEvent + * @return the CreateJobOptions builder + */ + public Builder speechBeginEvent(Boolean speechBeginEvent) { + this.speechBeginEvent = speechBeginEvent; + return this; + } + + /** + * Set the enrichments. + * + * @param enrichments the enrichments + * @return the CreateJobOptions builder + */ + public Builder enrichments(String enrichments) { + this.enrichments = enrichments; + return this; + } + /** * Set the languageCustomizationId. * @@ -399,8 +551,7 @@ public Builder inactivityTimeout(long inactivityTimeout) { } /** - * Set the keywords. - * Existing keywords will be replaced. + * Set the keywords. Existing keywords will be replaced. * * @param keywords the keywords * @return the CreateJobOptions builder @@ -488,24 +639,24 @@ public Builder smartFormatting(Boolean smartFormatting) { } /** - * Set the speakerLabels. + * Set the smartFormattingVersion. * - * @param speakerLabels the speakerLabels + * @param smartFormattingVersion the smartFormattingVersion * @return the CreateJobOptions builder */ - public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = speakerLabels; + public Builder smartFormattingVersion(long smartFormattingVersion) { + this.smartFormattingVersion = smartFormattingVersion; return this; } /** - * Set the customizationId. + * Set the speakerLabels. * - * @param customizationId the customizationId + * @param speakerLabels the speakerLabels * @return the CreateJobOptions builder */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; + public Builder speakerLabels(Boolean speakerLabels) { + this.speakerLabels = speakerLabels; return this; } @@ -586,12 +737,66 @@ public Builder splitTranscriptAtPhraseEnd(Boolean splitTranscriptAtPhraseEnd) { return this; } + /** + * Set the speechDetectorSensitivity. + * + * @param speechDetectorSensitivity the speechDetectorSensitivity + * @return the CreateJobOptions builder + */ + public Builder speechDetectorSensitivity(Float speechDetectorSensitivity) { + this.speechDetectorSensitivity = speechDetectorSensitivity; + return this; + } + + /** + * Set the sadModule. + * + * @param sadModule the sadModule + * @return the CreateJobOptions builder + */ + public Builder sadModule(long sadModule) { + this.sadModule = sadModule; + return this; + } + + /** + * Set the backgroundAudioSuppression. + * + * @param backgroundAudioSuppression the backgroundAudioSuppression + * @return the CreateJobOptions builder + */ + public Builder backgroundAudioSuppression(Float backgroundAudioSuppression) { + this.backgroundAudioSuppression = backgroundAudioSuppression; + return this; + } + + /** + * Set the lowLatency. + * + * @param lowLatency the lowLatency + * @return the CreateJobOptions builder + */ + public Builder lowLatency(Boolean lowLatency) { + this.lowLatency = lowLatency; + return this; + } + + /** + * Set the characterInsertionBias. + * + * @param characterInsertionBias the characterInsertionBias + * @return the CreateJobOptions builder + */ + public Builder characterInsertionBias(Float characterInsertionBias) { + this.characterInsertionBias = characterInsertionBias; + return this; + } + /** * Set the audio. * * @param audio the audio * @return the CreateJobOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder audio(File audio) throws FileNotFoundException { @@ -600,9 +805,10 @@ public Builder audio(File audio) throws FileNotFoundException { } } + protected CreateJobOptions() {} + protected CreateJobOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, - "audio cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, "audio cannot be null"); audio = builder.audio; contentType = builder.contentType; model = builder.model; @@ -610,6 +816,8 @@ protected CreateJobOptions(Builder builder) { events = builder.events; userToken = builder.userToken; resultsTtl = builder.resultsTtl; + speechBeginEvent = builder.speechBeginEvent; + enrichments = builder.enrichments; languageCustomizationId = builder.languageCustomizationId; acousticCustomizationId = builder.acousticCustomizationId; baseModelVersion = builder.baseModelVersion; @@ -623,8 +831,8 @@ protected CreateJobOptions(Builder builder) { timestamps = builder.timestamps; profanityFilter = builder.profanityFilter; smartFormatting = builder.smartFormatting; + smartFormattingVersion = builder.smartFormattingVersion; speakerLabels = builder.speakerLabels; - customizationId = builder.customizationId; grammarName = builder.grammarName; redaction = builder.redaction; processingMetrics = builder.processingMetrics; @@ -632,6 +840,11 @@ protected CreateJobOptions(Builder builder) { audioMetrics = builder.audioMetrics; endOfPhraseSilenceTime = builder.endOfPhraseSilenceTime; splitTranscriptAtPhraseEnd = builder.splitTranscriptAtPhraseEnd; + speechDetectorSensitivity = builder.speechDetectorSensitivity; + sadModule = builder.sadModule; + backgroundAudioSuppression = builder.backgroundAudioSuppression; + lowLatency = builder.lowLatency; + characterInsertionBias = builder.characterInsertionBias; } /** @@ -646,7 +859,7 @@ public Builder newBuilder() { /** * Gets the audio. * - * The audio to transcribe. + *

The audio to transcribe. * * @return the audio */ @@ -657,8 +870,8 @@ public InputStream audio() { /** * Gets the contentType. * - * The format (MIME type) of the audio. For more information about specifying an audio format, see **Audio formats - * (content types)** in the method description. + *

The format (MIME type) of the audio. For more information about specifying an audio format, + * see **Audio formats (content types)** in the method description. * * @return the contentType */ @@ -669,8 +882,17 @@ public String contentType() { /** * Gets the model. * - * The identifier of the model that is to be used for the recognition request. See [Languages and - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + *

The model to use for speech recognition. If you omit the `model` parameter, the service uses + * the US English `en-US_BroadbandModel` by default. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_BroadbandModel`, you must + * either specify a model with the request or specify a new default model for your installation of + * the service. + * + *

**See also:** * [Using a model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use) * + * [Using the default + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use#models-use-default). * * @return the model */ @@ -681,12 +903,13 @@ public String model() { /** * Gets the callbackUrl. * - * A URL to which callback notifications are to be sent. The URL must already be successfully white-listed by using - * the **Register a callback** method. You can include the same callback URL with any number of job creation requests. - * Omit the parameter to poll the service for job completion and results. + *

A URL to which callback notifications are to be sent. The URL must already be successfully + * allowlisted by using the [Register a callback](#registercallback) method. You can include the + * same callback URL with any number of job creation requests. Omit the parameter to poll the + * service for job completion and results. * - * Use the `user_token` parameter to specify a unique user-specified string with each job to differentiate the - * callback notifications for the jobs. + *

Use the `user_token` parameter to specify a unique user-specified string with each job to + * differentiate the callback notifications for the jobs. * * @return the callbackUrl */ @@ -697,22 +920,21 @@ public String callbackUrl() { /** * Gets the events. * - * If the job includes a callback URL, a comma-separated list of notification events to which to subscribe. Valid - * events are - * * `recognitions.started` generates a callback notification when the service begins to process the job. - * * `recognitions.completed` generates a callback notification when the job is complete. You must use the **Check a - * job** method to retrieve the results before they time out or are deleted. - * * `recognitions.completed_with_results` generates a callback notification when the job is complete. The - * notification includes the results of the request. - * * `recognitions.failed` generates a callback notification if the service experiences an error while processing the - * job. - * - * The `recognitions.completed` and `recognitions.completed_with_results` events are incompatible. You can specify - * only of the two events. - * - * If the job includes a callback URL, omit the parameter to subscribe to the default events: `recognitions.started`, - * `recognitions.completed`, and `recognitions.failed`. If the job does not include a callback URL, omit the - * parameter. + *

If the job includes a callback URL, a comma-separated list of notification events to which + * to subscribe. Valid events are * `recognitions.started` generates a callback notification when + * the service begins to process the job. * `recognitions.completed` generates a callback + * notification when the job is complete. You must use the [Check a job](#checkjob) method to + * retrieve the results before they time out or are deleted. * + * `recognitions.completed_with_results` generates a callback notification when the job is + * complete. The notification includes the results of the request. * `recognitions.failed` + * generates a callback notification if the service experiences an error while processing the job. + * + *

The `recognitions.completed` and `recognitions.completed_with_results` events are + * incompatible. You can specify only of the two events. + * + *

If the job includes a callback URL, omit the parameter to subscribe to the default events: + * `recognitions.started`, `recognitions.completed`, and `recognitions.failed`. If the job does + * not include a callback URL, omit the parameter. * * @return the events */ @@ -723,9 +945,10 @@ public String events() { /** * Gets the userToken. * - * If the job includes a callback URL, a user-specified string that the service is to include with each callback - * notification for the job; the token allows the user to maintain an internal mapping between jobs and notification - * events. If the job does not include a callback URL, omit the parameter. + *

If the job includes a callback URL, a user-specified string that the service is to include + * with each callback notification for the job; the token allows the user to maintain an internal + * mapping between jobs and notification events. If the job does not include a callback URL, omit + * the parameter. * * @return the userToken */ @@ -736,9 +959,10 @@ public String userToken() { /** * Gets the resultsTtl. * - * The number of minutes for which the results are to be available after the job has finished. If not delivered via a - * callback, the results must be retrieved within this time. Omit the parameter to use a time to live of one week. The - * parameter is valid with or without a callback URL. + *

The number of minutes for which the results are to be available after the job has finished. + * If not delivered via a callback, the results must be retrieved within this time. Omit the + * parameter to use a time to live of one week. The parameter is valid with or without a callback + * URL. * * @return the resultsTtl */ @@ -746,16 +970,52 @@ public Long resultsTtl() { return resultsTtl; } + /** + * Gets the speechBeginEvent. + * + *

If `true`, the service returns a response object `SpeechActivity` which contains the time + * when a speech activity is detected in the stream. This can be used both in standard and low + * latency mode. This feature enables client applications to know that some words/speech has been + * detected and the service is in the process of decoding. This can be used in lieu of interim + * results in standard mode. Use `sad_module: 2` to increase accuracy and performance in detecting + * speech boundaries within the audio stream. See [Using speech recognition + * parameters](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-service-features#features-parameters). + * + * @return the speechBeginEvent + */ + public Boolean speechBeginEvent() { + return speechBeginEvent; + } + + /** + * Gets the enrichments. + * + *

Speech transcript enrichment improves readability of raw ASR transcripts by adding + * punctuation (periods, commas, question marks, exclamation points) and intelligent + * capitalization (sentence beginnings, proper nouns, acronyms, brand names). To enable + * enrichment, add the `enrichments=punctuation` parameter to your recognition request. Supported + * languages include English (US, UK, Australia, India), French (France, Canada), German, Italian, + * Portuguese (Brazil, Portugal), Spanish (Spain, Latin America, Argentina, Chile, Colombia, + * Mexico, Peru), and Japanese. See [Speech transcript + * enrichment](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speech-transcript-enrichment). + * + * @return the enrichments + */ + public String enrichments() { + return enrichments; + } + /** * Gets the languageCustomizationId. * - * The customization ID (GUID) of a custom language model that is to be used with the recognition request. The base - * model of the specified custom language model must match the model specified with the `model` parameter. You must - * make the request with credentials for the instance of the service that owns the custom model. By default, no custom - * language model is used. See [Custom - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + *

The customization ID (GUID) of a custom language model that is to be used with the + * recognition request. The base model of the specified custom language model must match the model + * specified with the `model` parameter. You must make the request with credentials for the + * instance of the service that owns the custom model. By default, no custom language model is + * used. See [Using a custom language model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageUse). * - * **Note:** Use this parameter instead of the deprecated `customization_id` parameter. + *

**Note:** Use this parameter instead of the deprecated `customization_id` parameter. * * @return the languageCustomizationId */ @@ -766,11 +1026,12 @@ public String languageCustomizationId() { /** * Gets the acousticCustomizationId. * - * The customization ID (GUID) of a custom acoustic model that is to be used with the recognition request. The base - * model of the specified custom acoustic model must match the model specified with the `model` parameter. You must - * make the request with credentials for the instance of the service that owns the custom model. By default, no custom - * acoustic model is used. See [Custom - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + *

The customization ID (GUID) of a custom acoustic model that is to be used with the + * recognition request. The base model of the specified custom acoustic model must match the model + * specified with the `model` parameter. You must make the request with credentials for the + * instance of the service that owns the custom model. By default, no custom acoustic model is + * used. See [Using a custom acoustic model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acousticUse). * * @return the acousticCustomizationId */ @@ -781,11 +1042,12 @@ public String acousticCustomizationId() { /** * Gets the baseModelVersion. * - * The version of the specified base model that is to be used with the recognition request. Multiple versions of a - * base model can exist when a model is updated for internal improvements. The parameter is intended primarily for use - * with custom models that have been upgraded for a new base model. The default value depends on whether the parameter - * is used with or without a custom model. See [Base model - * version](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#version). + *

The version of the specified base model that is to be used with the recognition request. + * Multiple versions of a base model can exist when a model is updated for internal improvements. + * The parameter is intended primarily for use with custom models that have been upgraded for a + * new base model. The default value depends on whether the parameter is used with or without a + * custom model. See [Making speech recognition requests with upgraded custom + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade-use#custom-upgrade-use-recognition). * * @return the baseModelVersion */ @@ -796,19 +1058,23 @@ public String baseModelVersion() { /** * Gets the customizationWeight. * - * If you specify the customization ID (GUID) of a custom language model with the recognition request, the - * customization weight tells the service how much weight to give to words from the custom language model compared to - * those from the base model for the current request. + *

If you specify the customization ID (GUID) of a custom language model with the recognition + * request, the customization weight tells the service how much weight to give to words from the + * custom language model compared to those from the base model for the current request. * - * Specify a value between 0.0 and 1.0. Unless a different customization weight was specified for the custom model - * when it was trained, the default value is 0.3. A customization weight that you specify overrides a weight that was - * specified when the custom model was trained. + *

Specify a value between 0.0 and 1.0. Unless a different customization weight was specified + * for the custom model when the model was trained, the default value is: * 0.5 for large speech + * models * 0.3 for previous-generation models * 0.2 for most next-generation models * 0.1 for + * next-generation English and Japanese models * - * The default value yields the best performance in general. Assign a higher value if your audio makes frequent use of - * OOV words from the custom model. Use caution when setting the weight: a higher value can improve the accuracy of - * phrases from the custom model's domain, but it can negatively affect performance on non-domain phrases. + *

A customization weight that you specify overrides a weight that was specified when the + * custom model was trained. The default value yields the best performance in general. Assign a + * higher value if your audio makes frequent use of OOV words from the custom model. Use caution + * when setting the weight: a higher value can improve the accuracy of phrases from the custom + * model's domain, but it can negatively affect performance on non-domain phrases. * - * See [Custom models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + *

See [Using customization + * weight](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageUse#weight). * * @return the customizationWeight */ @@ -819,9 +1085,10 @@ public Double customizationWeight() { /** * Gets the inactivityTimeout. * - * The time in seconds after which, if only silence (no speech) is detected in streaming audio, the connection is - * closed with a 400 error. The parameter is useful for stopping audio submission from a live microphone when a user - * simply walks away. Use `-1` for infinity. See [Inactivity + *

The time in seconds after which, if only silence (no speech) is detected in streaming audio, + * the connection is closed with a 400 error. The parameter is useful for stopping audio + * submission from a live microphone when a user simply walks away. Use `-1` for infinity. See + * [Inactivity * timeout](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#timeouts-inactivity). * * @return the inactivityTimeout @@ -833,11 +1100,17 @@ public Long inactivityTimeout() { /** * Gets the keywords. * - * An array of keyword strings to spot in the audio. Each keyword string can include one or more string tokens. - * Keywords are spotted only in the final results, not in interim hypotheses. If you specify any keywords, you must - * also specify a keywords threshold. You can spot a maximum of 1000 keywords. Omit the parameter or specify an empty - * array if you do not need to spot keywords. See [Keyword - * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). + *

An array of keyword strings to spot in the audio. Each keyword string can include one or + * more string tokens. Keywords are spotted only in the final results, not in interim hypotheses. + * If you specify any keywords, you must also specify a keywords threshold. Omit the parameter or + * specify an empty array if you do not need to spot keywords. + * + *

You can spot a maximum of 1000 keywords with a single request. A single keyword can have a + * maximum length of 1024 characters, though the maximum effective length for double-byte + * languages might be shorter. Keywords are case-insensitive. + * + *

See [Keyword + * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-spotting#keyword-spotting). * * @return the keywords */ @@ -848,11 +1121,11 @@ public List keywords() { /** * Gets the keywordsThreshold. * - * A confidence value that is the lower bound for spotting a keyword. A word is considered to match a keyword if its - * confidence is greater than or equal to the threshold. Specify a probability between 0.0 and 1.0. If you specify a - * threshold, you must also specify one or more keywords. The service performs no keyword spotting if you omit either - * parameter. See [Keyword - * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). + *

A confidence value that is the lower bound for spotting a keyword. A word is considered to + * match a keyword if its confidence is greater than or equal to the threshold. Specify a + * probability between 0.0 and 1.0. If you specify a threshold, you must also specify one or more + * keywords. The service performs no keyword spotting if you omit either parameter. See [Keyword + * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-spotting#keyword-spotting). * * @return the keywordsThreshold */ @@ -863,9 +1136,10 @@ public Float keywordsThreshold() { /** * Gets the maxAlternatives. * - * The maximum number of alternative transcripts that the service is to return. By default, the service returns a - * single transcript. If you specify a value of `0`, the service uses the default value, `1`. See [Maximum - * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#max_alternatives). + *

The maximum number of alternative transcripts that the service is to return. By default, the + * service returns a single transcript. If you specify a value of `0`, the service uses the + * default value, `1`. See [Maximum + * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metadata#max-alternatives). * * @return the maxAlternatives */ @@ -876,10 +1150,11 @@ public Long maxAlternatives() { /** * Gets the wordAlternativesThreshold. * - * A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative (also known - * as "Confusion Networks"). An alternative word is considered if its confidence is greater than or equal to the - * threshold. Specify a probability between 0.0 and 1.0. By default, the service computes no alternative words. See - * [Word alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_alternatives). + *

A confidence value that is the lower bound for identifying a hypothesis as a possible word + * alternative (also known as "Confusion Networks"). An alternative word is considered if its + * confidence is greater than or equal to the threshold. Specify a probability between 0.0 and + * 1.0. By default, the service computes no alternative words. See [Word + * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-spotting#word-alternatives). * * @return the wordAlternativesThreshold */ @@ -890,9 +1165,9 @@ public Float wordAlternativesThreshold() { /** * Gets the wordConfidence. * - * If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for each word. By default, the - * service returns no word confidence scores. See [Word - * confidence](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_confidence). + *

If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for each + * word. By default, the service returns no word confidence scores. See [Word + * confidence](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metadata#word-confidence). * * @return the wordConfidence */ @@ -903,8 +1178,9 @@ public Boolean wordConfidence() { /** * Gets the timestamps. * - * If `true`, the service returns time alignment for each word. By default, no timestamps are returned. See [Word - * timestamps](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_timestamps). + *

If `true`, the service returns time alignment for each word. By default, no timestamps are + * returned. See [Word + * timestamps](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metadata#word-timestamps). * * @return the timestamps */ @@ -915,10 +1191,13 @@ public Boolean timestamps() { /** * Gets the profanityFilter. * - * If `true`, the service filters profanity from all output except for keyword results by replacing inappropriate - * words with a series of asterisks. Set the parameter to `false` to return results with no censoring. Applies to US - * English transcription only. See [Profanity - * filtering](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#profanity_filter). + *

If `true`, the service filters profanity from all output except for keyword results by + * replacing inappropriate words with a series of asterisks. Set the parameter to `false` to + * return results with no censoring. + * + *

**Note:** The parameter can be used with US English and Japanese transcription only. See + * [Profanity + * filtering](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#profanity-filtering). * * @return the profanityFilter */ @@ -929,14 +1208,16 @@ public Boolean profanityFilter() { /** * Gets the smartFormatting. * - * If `true`, the service converts dates, times, series of digits and numbers, phone numbers, currency values, and - * internet addresses into more readable, conventional representations in the final transcript of a recognition - * request. For US English, the service also converts certain keyword strings to punctuation symbols. By default, the - * service performs no smart formatting. + *

If `true`, the service converts dates, times, series of digits and numbers, phone numbers, + * currency values, and internet addresses into more readable, conventional representations in the + * final transcript of a recognition request. For US English, the service also converts certain + * keyword strings to punctuation symbols. By default, the service performs no smart formatting. * - * **Note:** Applies to US English, Japanese, and Spanish transcription only. + *

**Note:** The parameter can be used with US English, Japanese, and Spanish (all dialects) + * transcription only. * - * See [Smart formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#smart_formatting). + *

See [Smart + * formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). * * @return the smartFormatting */ @@ -945,44 +1226,49 @@ public Boolean smartFormatting() { } /** - * Gets the speakerLabels. - * - * If `true`, the response includes labels that identify which words were spoken by which participants in a - * multi-person exchange. By default, the service returns no speaker labels. Setting `speaker_labels` to `true` forces - * the `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. + * Gets the smartFormattingVersion. * - * **Note:** Applies to US English, Japanese, and Spanish (both broadband and narrowband models) and UK English - * (narrowband model) transcription only. To determine whether a language model supports speaker labels, you can also - * use the **Get a model** method and check that the attribute `speaker_labels` is set to `true`. + *

Smart formatting version for large speech models and next-generation models is supported in + * US English, Brazilian Portuguese, French, German, Spanish and French Canadian languages. * - * See [Speaker labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#speaker_labels). - * - * @return the speakerLabels + * @return the smartFormattingVersion */ - public Boolean speakerLabels() { - return speakerLabels; + public Long smartFormattingVersion() { + return smartFormattingVersion; } /** - * Gets the customizationId. + * Gets the speakerLabels. + * + *

If `true`, the response includes labels that identify which words were spoken by which + * participants in a multi-person exchange. By default, the service returns no speaker labels. + * Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless + * of whether you specify `false` for the parameter. * _For previous-generation models,_ the + * parameter can be used with Australian English, US English, German, Japanese, Korean, and + * Spanish (both broadband and narrowband models) and UK English (narrowband model) transcription + * only. * _For large speech models and next-generation models,_ the parameter can be used with + * all available languages. * - * **Deprecated.** Use the `language_customization_id` parameter to specify the customization ID (GUID) of a custom - * language model that is to be used with the recognition request. Do not specify both parameters with a request. + *

See [Speaker + * labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speaker-labels). * - * @return the customizationId + * @return the speakerLabels */ - public String customizationId() { - return customizationId; + public Boolean speakerLabels() { + return speakerLabels; } /** * Gets the grammarName. * - * The name of a grammar that is to be used with the recognition request. If you specify a grammar, you must also use - * the `language_customization_id` parameter to specify the name of the custom language model for which the grammar is - * defined. The service recognizes only strings that are recognized by the specified grammar; it does not recognize - * other custom words from the model's words resource. See - * [Grammars](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#grammars-input). + *

The name of a grammar that is to be used with the recognition request. If you specify a + * grammar, you must also use the `language_customization_id` parameter to specify the name of the + * custom language model for which the grammar is defined. The service recognizes only strings + * that are recognized by the specified grammar; it does not recognize other custom words from the + * model's words resource. + * + *

See [Using a grammar for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarUse). * * @return the grammarName */ @@ -993,18 +1279,21 @@ public String grammarName() { /** * Gets the redaction. * - * If `true`, the service redacts, or masks, numeric data from final transcripts. The feature redacts any number that - * has three or more consecutive digits by replacing each digit with an `X` character. It is intended to redact - * sensitive numeric data, such as credit card numbers. By default, the service performs no redaction. + *

If `true`, the service redacts, or masks, numeric data from final transcripts. The feature + * redacts any number that has three or more consecutive digits by replacing each digit with an + * `X` character. It is intended to redact sensitive numeric data, such as credit card numbers. By + * default, the service performs no redaction. * - * When you enable redaction, the service automatically enables smart formatting, regardless of whether you explicitly - * disable that feature. To ensure maximum security, the service also disables keyword spotting (ignores the - * `keywords` and `keywords_threshold` parameters) and returns only a single final transcript (forces the - * `max_alternatives` parameter to be `1`). + *

When you enable redaction, the service automatically enables smart formatting, regardless of + * whether you explicitly disable that feature. To ensure maximum security, the service also + * disables keyword spotting (ignores the `keywords` and `keywords_threshold` parameters) and + * returns only a single final transcript (forces the `max_alternatives` parameter to be `1`). * - * **Note:** Applies to US English, Japanese, and Korean transcription only. + *

**Note:** The parameter can be used with US English, Japanese, and Korean transcription + * only. * - * See [Numeric redaction](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#redaction). + *

See [Numeric + * redaction](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#numeric-redaction). * * @return the redaction */ @@ -1015,13 +1304,14 @@ public Boolean redaction() { /** * Gets the processingMetrics. * - * If `true`, requests processing metrics about the service's transcription of the input audio. The service returns - * processing metrics at the interval specified by the `processing_metrics_interval` parameter. It also returns - * processing metrics for transcription events, for example, for final and interim results. By default, the service - * returns no processing metrics. + *

If `true`, requests processing metrics about the service's transcription of the input audio. + * The service returns processing metrics at the interval specified by the + * `processing_metrics_interval` parameter. It also returns processing metrics for transcription + * events, for example, for final and interim results. By default, the service returns no + * processing metrics. * - * See [Processing - * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#processing_metrics). + *

See [Processing + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#processing-metrics). * * @return the processingMetrics */ @@ -1032,18 +1322,20 @@ public Boolean processingMetrics() { /** * Gets the processingMetricsInterval. * - * Specifies the interval in real wall-clock seconds at which the service is to return processing metrics. The - * parameter is ignored unless the `processing_metrics` parameter is set to `true`. + *

Specifies the interval in real wall-clock seconds at which the service is to return + * processing metrics. The parameter is ignored unless the `processing_metrics` parameter is set + * to `true`. * - * The parameter accepts a minimum value of 0.1 seconds. The level of precision is not restricted, so you can specify - * values such as 0.25 and 0.125. + *

The parameter accepts a minimum value of 0.1 seconds. The level of precision is not + * restricted, so you can specify values such as 0.25 and 0.125. * - * The service does not impose a maximum value. If you want to receive processing metrics only for transcription - * events instead of at periodic intervals, set the value to a large number. If the value is larger than the duration - * of the audio, the service returns processing metrics only for transcription events. + *

The service does not impose a maximum value. If you want to receive processing metrics only + * for transcription events instead of at periodic intervals, set the value to a large number. If + * the value is larger than the duration of the audio, the service returns processing metrics only + * for transcription events. * - * See [Processing - * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#processing_metrics). + *

See [Processing + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#processing-metrics). * * @return the processingMetricsInterval */ @@ -1054,10 +1346,12 @@ public Float processingMetricsInterval() { /** * Gets the audioMetrics. * - * If `true`, requests detailed information about the signal characteristics of the input audio. The service returns - * audio metrics with the final transcription results. By default, the service returns no audio metrics. + *

If `true`, requests detailed information about the signal characteristics of the input + * audio. The service returns audio metrics with the final transcription results. By default, the + * service returns no audio metrics. * - * See [Audio metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#audio_metrics). + *

See [Audio + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#audio-metrics). * * @return the audioMetrics */ @@ -1068,20 +1362,21 @@ public Boolean audioMetrics() { /** * Gets the endOfPhraseSilenceTime. * - * If `true`, specifies the duration of the pause interval at which the service splits a transcript into multiple - * final results. If the service detects pauses or extended silence before it reaches the end of the audio stream, its - * response can include multiple final results. Silence indicates a point at which the speaker pauses between spoken - * words or phrases. + *

Specifies the duration of the pause interval at which the service splits a transcript into + * multiple final results. If the service detects pauses or extended silence before it reaches the + * end of the audio stream, its response can include multiple final results. Silence indicates a + * point at which the speaker pauses between spoken words or phrases. * - * Specify a value for the pause interval in the range of 0.0 to 120.0. - * * A value greater than 0 specifies the interval that the service is to use for speech recognition. - * * A value of 0 indicates that the service is to use the default interval. It is equivalent to omitting the + *

Specify a value for the pause interval in the range of 0.0 to 120.0. * A value greater than + * 0 specifies the interval that the service is to use for speech recognition. * A value of 0 + * indicates that the service is to use the default interval. It is equivalent to omitting the * parameter. * - * The default pause interval for most languages is 0.8 seconds; the default for Chinese is 0.6 seconds. + *

The default pause interval for most languages is 0.8 seconds; the default for Chinese is 0.6 + * seconds. * - * See [End of phrase silence - * time](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#silence_time). + *

See [End of phrase silence + * time](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#silence-time). * * @return the endOfPhraseSilenceTime */ @@ -1092,18 +1387,143 @@ public Double endOfPhraseSilenceTime() { /** * Gets the splitTranscriptAtPhraseEnd. * - * If `true`, directs the service to split the transcript into multiple final results based on semantic features of - * the input, for example, at the conclusion of meaningful phrases such as sentences. The service bases its - * understanding of semantic features on the base language model that you use with a request. Custom language models - * and grammars can also influence how and where the service splits a transcript. By default, the service splits - * transcripts based solely on the pause interval. + *

If `true`, directs the service to split the transcript into multiple final results based on + * semantic features of the input, for example, at the conclusion of meaningful phrases such as + * sentences. The service bases its understanding of semantic features on the base language model + * that you use with a request. Custom language models and grammars can also influence how and + * where the service splits a transcript. + * + *

By default, the service splits transcripts based solely on the pause interval. If the + * parameters are used together on the same request, `end_of_phrase_silence_time` has precedence + * over `split_transcript_at_phrase_end`. * - * See [Split transcript at phrase - * end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#split_transcript). + *

See [Split transcript at phrase + * end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#split-transcript). * * @return the splitTranscriptAtPhraseEnd */ public Boolean splitTranscriptAtPhraseEnd() { return splitTranscriptAtPhraseEnd; } + + /** + * Gets the speechDetectorSensitivity. + * + *

The sensitivity of speech activity detection that the service is to perform. Use the + * parameter to suppress word insertions from music, coughing, and other non-speech events. The + * service biases the audio it passes for speech recognition by evaluating the input audio against + * prior models of speech and non-speech activity. + * + *

Specify a value between 0.0 and 1.0: * 0.0 suppresses all audio (no speech is transcribed). + * * 0.5 (the default) provides a reasonable compromise for the level of sensitivity. * 1.0 + * suppresses no audio (speech detection sensitivity is disabled). + * + *

The values increase on a monotonic curve. Specifying one or two decimal places of precision + * (for example, `0.55`) is typically more than sufficient. + * + *

The parameter is supported with all large speech models, next-generation models and with + * most previous-generation models. See [Speech detector + * sensitivity](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-sensitivity) + * and [Language model + * support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). + * + * @return the speechDetectorSensitivity + */ + public Float speechDetectorSensitivity() { + return speechDetectorSensitivity; + } + + /** + * Gets the sadModule. + * + *

Detects speech boundaries within the audio stream with better performance, improved noise + * suppression, faster responsiveness, and increased accuracy. + * + *

Specify `sad_module: 2` + * + *

See [Speech Activity Detection + * (SAD)](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#sad). + * + * @return the sadModule + */ + public Long sadModule() { + return sadModule; + } + + /** + * Gets the backgroundAudioSuppression. + * + *

The level to which the service is to suppress background audio based on its volume to + * prevent it from being transcribed as speech. Use the parameter to suppress side conversations + * or background noise. + * + *

Specify a value in the range of 0.0 to 1.0: * 0.0 (the default) provides no suppression + * (background audio suppression is disabled). * 0.5 provides a reasonable level of audio + * suppression for general usage. * 1.0 suppresses all audio (no audio is transcribed). + * + *

The values increase on a monotonic curve. Specifying one or two decimal places of precision + * (for example, `0.55`) is typically more than sufficient. + * + *

The parameter is supported with all large speech models, next-generation models and with + * most previous-generation models. See [Background audio + * suppression](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-suppression) + * and [Language model + * support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). + * + * @return the backgroundAudioSuppression + */ + public Float backgroundAudioSuppression() { + return backgroundAudioSuppression; + } + + /** + * Gets the lowLatency. + * + *

If `true` for next-generation `Multimedia` and `Telephony` models that support low latency, + * directs the service to produce results even more quickly than it usually does. Next-generation + * models produce transcription results faster than previous-generation models. The `low_latency` + * parameter causes the models to produce results even more quickly, though the results might be + * less accurate when the parameter is used. + * + *

The parameter is not available for large speech models and previous-generation `Broadband` + * and `Narrowband` models. It is available for most next-generation models. * For a list of + * next-generation models that support low latency, see [Supported next-generation language + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported). + * * For more information about the `low_latency` parameter, see [Low + * latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency). + * + * @return the lowLatency + */ + public Boolean lowLatency() { + return lowLatency; + } + + /** + * Gets the characterInsertionBias. + * + *

For large speech models and next-generation models, an indication of whether the service is + * biased to recognize shorter or longer strings of characters when developing transcription + * hypotheses. By default, the service is optimized to produce the best balance of strings of + * different lengths. + * + *

The default bias is 0.0. The allowable range of values is -1.0 to 1.0. * Negative values + * bias the service to favor hypotheses with shorter strings of characters. * Positive values bias + * the service to favor hypotheses with longer strings of characters. + * + *

As the value approaches -1.0 or 1.0, the impact of the parameter becomes more pronounced. To + * determine the most effective value for your scenario, start by setting the value of the + * parameter to a small increment, such as -0.1, -0.05, 0.05, or 0.1, and assess how the value + * impacts the transcription results. Then experiment with different values as necessary, + * adjusting the value by small increments. + * + *

The parameter is not available for previous-generation models. + * + *

See [Character insertion + * bias](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#insertion-bias). + * + * @return the characterInsertionBias + */ + public Float characterInsertionBias() { + return characterInsertionBias; + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java index 9b81af85b39..1df17a2d56f 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,78 +10,190 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The createLanguageModel options. - */ +/** The createLanguageModel options. */ public class CreateLanguageModelOptions extends GenericModel { /** - * The name of the base language model that is to be customized by the new custom language model. The new custom model - * can be used only with the base model that it customizes. + * The name of the base language model that is to be customized by the new custom language model. + * The new custom model can be used only with the base model that it customizes. * - * To determine whether a base model supports language model customization, use the **Get a model** method and check - * that the attribute `custom_language_model` is set to `true`. You can also refer to [Language support for - * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). + *

To determine whether a base model supports language model customization, use the [Get a + * model](#getmodel) method and check that the attribute `custom_language_model` is set to `true`. + * You can also refer to [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). */ public interface BaseModelName { + /** ar-MS_Telephony. */ + String AR_MS_TELEPHONY = "ar-MS_Telephony"; + /** cs-CZ_Telephony. */ + String CS_CZ_TELEPHONY = "cs-CZ_Telephony"; + /** de-DE. */ + String DE_DE = "de-DE"; /** de-DE_BroadbandModel. */ String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; + /** de-DE_Multimedia. */ + String DE_DE_MULTIMEDIA = "de-DE_Multimedia"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** de-DE_Telephony. */ + String DE_DE_TELEPHONY = "de-DE_Telephony"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_Multimedia. */ + String EN_AU_MULTIMEDIA = "en-AU_Multimedia"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; + /** en-AU_Telephony. */ + String EN_AU_TELEPHONY = "en-AU_Telephony"; + /** en-GB. */ + String EN_GB = "en-GB"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; + /** en-GB_Multimedia. */ + String EN_GB_MULTIMEDIA = "en-GB_Multimedia"; /** en-GB_NarrowbandModel. */ String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; + /** en-GB_Telephony. */ + String EN_GB_TELEPHONY = "en-GB_Telephony"; + /** en-IN. */ + String EN_IN = "en-IN"; + /** en-IN_Telephony. */ + String EN_IN_TELEPHONY = "en-IN_Telephony"; + /** en-US. */ + String EN_US = "en-US"; /** en-US_BroadbandModel. */ String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; + /** en-US_Multimedia. */ + String EN_US_MULTIMEDIA = "en-US_Multimedia"; /** en-US_NarrowbandModel. */ String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; /** en-US_ShortForm_NarrowbandModel. */ String EN_US_SHORTFORM_NARROWBANDMODEL = "en-US_ShortForm_NarrowbandModel"; + /** en-US_Telephony. */ + String EN_US_TELEPHONY = "en-US_Telephony"; + /** en-WW_Medical_Telephony. */ + String EN_WW_MEDICAL_TELEPHONY = "en-WW_Medical_Telephony"; + /** es-AR. */ + String ES_AR = "es-AR"; /** es-AR_BroadbandModel. */ String ES_AR_BROADBANDMODEL = "es-AR_BroadbandModel"; /** es-AR_NarrowbandModel. */ String ES_AR_NARROWBANDMODEL = "es-AR_NarrowbandModel"; + /** es-CL. */ + String ES_CL = "es-CL"; /** es-CL_BroadbandModel. */ String ES_CL_BROADBANDMODEL = "es-CL_BroadbandModel"; /** es-CL_NarrowbandModel. */ String ES_CL_NARROWBANDMODEL = "es-CL_NarrowbandModel"; + /** es-CO. */ + String ES_CO = "es-CO"; /** es-CO_BroadbandModel. */ String ES_CO_BROADBANDMODEL = "es-CO_BroadbandModel"; /** es-CO_NarrowbandModel. */ String ES_CO_NARROWBANDMODEL = "es-CO_NarrowbandModel"; + /** es-ES. */ + String ES_ES = "es-ES"; /** es-ES_BroadbandModel. */ String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; /** es-ES_NarrowbandModel. */ String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; + /** es-ES_Multimedia. */ + String ES_ES_MULTIMEDIA = "es-ES_Multimedia"; + /** es-ES_Telephony. */ + String ES_ES_TELEPHONY = "es-ES_Telephony"; + /** es-LA_Telephony. */ + String ES_LA_TELEPHONY = "es-LA_Telephony"; + /** es-MX. */ + String ES_MX = "es-MX"; /** es-MX_BroadbandModel. */ String ES_MX_BROADBANDMODEL = "es-MX_BroadbandModel"; /** es-MX_NarrowbandModel. */ String ES_MX_NARROWBANDMODEL = "es-MX_NarrowbandModel"; + /** es-PE. */ + String ES_PE = "es-PE"; /** es-PE_BroadbandModel. */ String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_Multimedia. */ + String FR_CA_MULTIMEDIA = "fr-CA_Multimedia"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; + /** fr-CA_Telephony. */ + String FR_CA_TELEPHONY = "fr-CA_Telephony"; + /** fr-FR. */ + String FR_FR = "fr-FR"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; + /** fr-FR_Multimedia. */ + String FR_FR_MULTIMEDIA = "fr-FR_Multimedia"; /** fr-FR_NarrowbandModel. */ String FR_FR_NARROWBANDMODEL = "fr-FR_NarrowbandModel"; + /** fr-FR_Telephony. */ + String FR_FR_TELEPHONY = "fr-FR_Telephony"; + /** hi-IN_Telephony. */ + String HI_IN_TELEPHONY = "hi-IN_Telephony"; + /** it-IT_BroadbandModel. */ + String IT_IT_BROADBANDMODEL = "it-IT_BroadbandModel"; + /** it-IT_NarrowbandModel. */ + String IT_IT_NARROWBANDMODEL = "it-IT_NarrowbandModel"; + /** it-IT_Multimedia. */ + String IT_IT_MULTIMEDIA = "it-IT_Multimedia"; + /** it-IT_Telephony. */ + String IT_IT_TELEPHONY = "it-IT_Telephony"; + /** ja-JP. */ + String JA_JP = "ja-JP"; /** ja-JP_BroadbandModel. */ String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; + /** ja-JP_Multimedia. */ + String JA_JP_MULTIMEDIA = "ja-JP_Multimedia"; /** ja-JP_NarrowbandModel. */ String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; + /** ja-JP_Telephony. */ + String JA_JP_TELEPHONY = "ja-JP_Telephony"; /** ko-KR_BroadbandModel. */ String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; + /** ko-KR_Multimedia. */ + String KO_KR_MULTIMEDIA = "ko-KR_Multimedia"; /** ko-KR_NarrowbandModel. */ String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; + /** ko-KR_Telephony. */ + String KO_KR_TELEPHONY = "ko-KR_Telephony"; + /** nl-BE_Telephony. */ + String NL_BE_TELEPHONY = "nl-BE_Telephony"; + /** nl-NL_BroadbandModel. */ + String NL_NL_BROADBANDMODEL = "nl-NL_BroadbandModel"; + /** nl-NL_Multimedia. */ + String NL_NL_MULTIMEDIA = "nl-NL_Multimedia"; + /** nl-NL_NarrowbandModel. */ + String NL_NL_NARROWBANDMODEL = "nl-NL_NarrowbandModel"; + /** nl-NL_Telephony. */ + String NL_NL_TELEPHONY = "nl-NL_Telephony"; + /** pt-BR. */ + String PT_BR = "pt-BR"; /** pt-BR_BroadbandModel. */ String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; + /** pt-BR_Multimedia. */ + String PT_BR_MULTIMEDIA = "pt-BR_Multimedia"; /** pt-BR_NarrowbandModel. */ String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; + /** pt-BR_Telephony. */ + String PT_BR_TELEPHONY = "pt-BR_Telephony"; + /** sv-SE_Telephony. */ + String SV_SE_TELEPHONY = "sv-SE_Telephony"; + /** zh-CN_Telephony. */ + String ZH_CN_TELEPHONY = "zh-CN_Telephony"; } protected String name; @@ -89,15 +201,18 @@ public interface BaseModelName { protected String dialect; protected String description; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String name; private String baseModelName; private String dialect; private String description; + /** + * Instantiates a new Builder from an existing CreateLanguageModelOptions instance. + * + * @param createLanguageModelOptions the instance to initialize the Builder with + */ private Builder(CreateLanguageModelOptions createLanguageModelOptions) { this.name = createLanguageModelOptions.name; this.baseModelName = createLanguageModelOptions.baseModelName; @@ -105,11 +220,8 @@ private Builder(CreateLanguageModelOptions createLanguageModelOptions) { this.description = createLanguageModelOptions.description; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -125,7 +237,7 @@ public Builder(String name, String baseModelName) { /** * Builds a CreateLanguageModelOptions. * - * @return the createLanguageModelOptions + * @return the new CreateLanguageModelOptions instance */ public CreateLanguageModelOptions build() { return new CreateLanguageModelOptions(this); @@ -176,11 +288,12 @@ public Builder description(String description) { } } + protected CreateLanguageModelOptions() {} + protected CreateLanguageModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.baseModelName, - "baseModelName cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.baseModelName, "baseModelName cannot be null"); name = builder.name; baseModelName = builder.baseModelName; dialect = builder.dialect; @@ -199,9 +312,13 @@ public Builder newBuilder() { /** * Gets the name. * - * A user-defined name for the new custom language model. Use a name that is unique among all custom language models - * that you own. Use a localized name that matches the language of the custom model. Use a name that describes the - * domain of the custom model, such as `Medical custom model` or `Legal custom model`. + *

A user-defined name for the new custom language model. Use a localized name that matches the + * language of the custom model. Use a name that describes the domain of the custom model, such as + * `Medical custom model` or `Legal custom model`. Use a name that is unique among all custom + * language models that you own. + * + *

Include a maximum of 256 characters in the name. Do not use backslashes, slashes, colons, + * equal signs, ampersands, or question marks in the name. * * @return the name */ @@ -212,12 +329,13 @@ public String name() { /** * Gets the baseModelName. * - * The name of the base language model that is to be customized by the new custom language model. The new custom model - * can be used only with the base model that it customizes. + *

The name of the base language model that is to be customized by the new custom language + * model. The new custom model can be used only with the base model that it customizes. * - * To determine whether a base model supports language model customization, use the **Get a model** method and check - * that the attribute `custom_language_model` is set to `true`. You can also refer to [Language support for - * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). + *

To determine whether a base model supports language model customization, use the [Get a + * model](#getmodel) method and check that the attribute `custom_language_model` is set to `true`. + * You can also refer to [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). * * @return the baseModelName */ @@ -228,22 +346,19 @@ public String baseModelName() { /** * Gets the dialect. * - * The dialect of the specified language that is to be used with the custom language model. For most languages, the - * dialect matches the language of the base model by default. For example, `en-US` is used for either of the US - * English language models. - * - * For a Spanish language, the service creates a custom language model that is suited for speech in one of the - * following dialects: - * * `es-ES` for Castilian Spanish (`es-ES` models) - * * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` models) - * * `es-US` for Mexican (North American) Spanish (`es-MX` models) + *

The dialect of the specified language that is to be used with the custom language model. + * _For all languages, it is always safe to omit this field._ The service automatically uses the + * language identifier from the name of the base model. For example, the service automatically + * uses `en-US` for all US English models. * - * The parameter is meaningful only for Spanish models, for which you can always safely omit the parameter to have the - * service create the correct mapping. + *

If you specify the `dialect` for a new custom model, follow these guidelines. _For + * non-Spanish previous-generation models and for next-generation models,_ you must specify a + * value that matches the five-character language identifier from the name of the base model. _For + * Spanish previous-generation models,_ you must specify one of the following values: * `es-ES` + * for Castilian Spanish (`es-ES` models) * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, + * `es-CO`, and `es-PE` models) * `es-US` for Mexican (North American) Spanish (`es-MX` models) * - * If you specify the `dialect` parameter for non-Spanish language models, its value must match the language of the - * base model. If you specify the `dialect` for Spanish language models, its value must match one of the defined - * mappings as indicated (`es-ES`, `es-LA`, or `es-MX`). All dialect values are case-insensitive. + *

All values that you pass for the `dialect` field are case-insensitive. * * @return the dialect */ @@ -254,8 +369,9 @@ public String dialect() { /** * Gets the description. * - * A description of the new custom language model. Use a localized description that matches the language of the custom - * model. + *

A recommended description of the new custom language model. Use a localized description that + * matches the language of the custom model. Include a maximum of 128 characters in the + * description. * * @return the description */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java index e3870b2f73b..ced6c0ff1fa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,63 +10,82 @@ * 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.speech_to_text.v1.model; -import java.util.ArrayList; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; -/** - * Information about a word that is to be added to a custom language model. - */ +/** Information about a word that is to be added to a custom language model. */ public class CustomWord extends GenericModel { protected String word; + + @SerializedName("mapping_only") + protected List mappingOnly; + @SerializedName("sounds_like") protected List soundsLike; + @SerializedName("display_as") protected String displayAs; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String word; + private List mappingOnly; private List soundsLike; private String displayAs; + /** + * Instantiates a new Builder from an existing CustomWord instance. + * + * @param customWord the instance to initialize the Builder with + */ private Builder(CustomWord customWord) { this.word = customWord.word; + this.mappingOnly = customWord.mappingOnly; this.soundsLike = customWord.soundsLike; this.displayAs = customWord.displayAs; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a CustomWord. * - * @return the customWord + * @return the new CustomWord instance */ public CustomWord build() { return new CustomWord(this); } /** - * Adds an soundsLike to soundsLike. + * Adds a new element to mappingOnly. * - * @param soundsLike the new soundsLike + * @param mappingOnly the new element to be added + * @return the CustomWord builder + */ + public Builder addMappingOnly(String mappingOnly) { + com.ibm.cloud.sdk.core.util.Validator.notNull(mappingOnly, "mappingOnly cannot be null"); + if (this.mappingOnly == null) { + this.mappingOnly = new ArrayList(); + } + this.mappingOnly.add(mappingOnly); + return this; + } + + /** + * Adds a new element to soundsLike. + * + * @param soundsLike the new element to be added * @return the CustomWord builder */ public Builder addSoundsLike(String soundsLike) { - com.ibm.cloud.sdk.core.util.Validator.notNull(soundsLike, - "soundsLike cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(soundsLike, "soundsLike cannot be null"); if (this.soundsLike == null) { this.soundsLike = new ArrayList(); } @@ -86,8 +105,18 @@ public Builder word(String word) { } /** - * Set the soundsLike. - * Existing soundsLike will be replaced. + * Set the mappingOnly. Existing mappingOnly will be replaced. + * + * @param mappingOnly the mappingOnly + * @return the CustomWord builder + */ + public Builder mappingOnly(List mappingOnly) { + this.mappingOnly = mappingOnly; + return this; + } + + /** + * Set the soundsLike. Existing soundsLike will be replaced. * * @param soundsLike the soundsLike * @return the CustomWord builder @@ -109,8 +138,11 @@ public Builder displayAs(String displayAs) { } } + protected CustomWord() {} + protected CustomWord(Builder builder) { word = builder.word; + mappingOnly = builder.mappingOnly; soundsLike = builder.soundsLike; displayAs = builder.displayAs; } @@ -127,11 +159,14 @@ public Builder newBuilder() { /** * Gets the word. * - * For the **Add custom words** method, you must specify the custom word that is to be added to or updated in the - * custom model. Do not include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of - * compound words. + *

For the [Add custom words](#addwords) method, you must specify the custom word that is to be + * added to or updated in the custom model. Do not use characters that need to be URL-encoded, for + * example, spaces, slashes, backslashes, colons, ampersands, double quotes, plus signs, equals + * signs, or question marks. Use a `-` (dash) or `_` (underscore) to connect the tokens of + * compound words. A Japanese custom word can include at most 25 characters, not including leading + * or trailing spaces. * - * Omit this parameter for the **Add a custom word** method. + *

Omit this parameter for the [Add a custom word](#addword) method. * * @return the word */ @@ -139,19 +174,37 @@ public String word() { return word; } + /** + * Gets the mappingOnly. + * + *

Parameter for custom words. You can use the 'mapping_only' key in custom words as a form of + * post processing. This key parameter has a boolean value to determine whether 'sounds_like' (for + * non-Japanese models) or word (for Japanese) is not used for the model fine-tuning, but for the + * replacement for 'display_as'. This feature helps you when you use custom words exclusively to + * map 'sounds_like' (or word) to 'display_as' value. When you use custom words solely for + * post-processing purposes that does not need fine-tuning. + * + * @return the mappingOnly + */ + public List mappingOnly() { + return mappingOnly; + } + /** * Gets the soundsLike. * - * An array of sounds-like pronunciations for the custom word. Specify how words that are difficult to pronounce, - * foreign words, acronyms, and so on can be pronounced by users. - * * For a word that is not in the service's base vocabulary, omit the parameter to have the service automatically - * generate a sounds-like pronunciation for the word. - * * For a word that is in the service's base vocabulary, use the parameter to specify additional pronunciations for - * the word. You cannot override the default pronunciation of a word; pronunciations you add augment the pronunciation - * from the base vocabulary. + *

As array of sounds-like pronunciations for the custom word. Specify how words that are + * difficult to pronounce, foreign words, acronyms, and so on can be pronounced by users. * _For + * custom models that are based on previous-generation models_, for a word that is not in the + * service's base vocabulary, omit the parameter to have the service automatically generate a + * sounds-like pronunciation for the word. * For a word that is in the service's base vocabulary, + * use the parameter to specify additional pronunciations for the word. You cannot override the + * default pronunciation of a word; pronunciations you add augment the pronunciation from the base + * vocabulary. * - * A word can have at most five sounds-like pronunciations. A pronunciation can include at most 40 characters not - * including spaces. + *

A word can have at most five sounds-like pronunciations. A pronunciation can include at most + * 40 characters, not including leading or trailing spaces. A Japanese pronunciation can include + * at most 25 characters, not including leading or trailing spaces. * * @return the soundsLike */ @@ -162,9 +215,12 @@ public List soundsLike() { /** * Gets the displayAs. * - * An alternative spelling for the custom word when it appears in a transcript. Use the parameter when you want the - * word to have a spelling that is different from its usual representation or from its spelling in corpora training - * data. + *

An alternative spelling for the custom word when it appears in a transcript. Use the + * parameter when you want the word to have a spelling that is different from its usual + * representation or from its spelling in corpora training data. + * + *

_For custom models that are based on next-generation models_, the service uses the spelling + * of the word as the display-as value if you omit the field. * * @return the displayAs */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java index 8474ff9757b..0ae5fa6aa46 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteAcousticModel options. - */ +/** The deleteAcousticModel options. */ public class DeleteAcousticModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing DeleteAcousticModelOptions instance. + * + * @param deleteAcousticModelOptions the instance to initialize the Builder with + */ private Builder(DeleteAcousticModelOptions deleteAcousticModelOptions) { this.customizationId = deleteAcousticModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a DeleteAcousticModelOptions. * - * @return the deleteAcousticModelOptions + * @return the new DeleteAcousticModelOptions instance */ public DeleteAcousticModelOptions build() { return new DeleteAcousticModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected DeleteAcousticModelOptions() {} + protected DeleteAcousticModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java index 4f00b8f49eb..3000e4b7fd6 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteAudio options. - */ +/** The deleteAudio options. */ public class DeleteAudioOptions extends GenericModel { protected String customizationId; protected String audioName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String audioName; + /** + * Instantiates a new Builder from an existing DeleteAudioOptions instance. + * + * @param deleteAudioOptions the instance to initialize the Builder with + */ private Builder(DeleteAudioOptions deleteAudioOptions) { this.customizationId = deleteAudioOptions.customizationId; this.audioName = deleteAudioOptions.audioName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String audioName) { /** * Builds a DeleteAudioOptions. * - * @return the deleteAudioOptions + * @return the new DeleteAudioOptions instance */ public DeleteAudioOptions build() { return new DeleteAudioOptions(this); @@ -83,11 +82,12 @@ public Builder audioName(String audioName) { } } + protected DeleteAudioOptions() {} + protected DeleteAudioOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.audioName, - "audioName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.audioName, "audioName cannot be empty"); customizationId = builder.customizationId; audioName = builder.audioName; } @@ -104,8 +104,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,7 +117,7 @@ public String customizationId() { /** * Gets the audioName. * - * The name of the audio resource for the custom acoustic model. + *

The name of the audio resource for the custom acoustic model. * * @return the audioName */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java index 9a879d2f0ec..38da85caf58 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteCorpus options. - */ +/** The deleteCorpus options. */ public class DeleteCorpusOptions extends GenericModel { protected String customizationId; protected String corpusName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String corpusName; + /** + * Instantiates a new Builder from an existing DeleteCorpusOptions instance. + * + * @param deleteCorpusOptions the instance to initialize the Builder with + */ private Builder(DeleteCorpusOptions deleteCorpusOptions) { this.customizationId = deleteCorpusOptions.customizationId; this.corpusName = deleteCorpusOptions.corpusName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String corpusName) { /** * Builds a DeleteCorpusOptions. * - * @return the deleteCorpusOptions + * @return the new DeleteCorpusOptions instance */ public DeleteCorpusOptions build() { return new DeleteCorpusOptions(this); @@ -83,11 +82,13 @@ public Builder corpusName(String corpusName) { } } + protected DeleteCorpusOptions() {} + protected DeleteCorpusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.corpusName, - "corpusName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.corpusName, "corpusName cannot be empty"); customizationId = builder.customizationId; corpusName = builder.corpusName; } @@ -104,8 +105,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,7 +118,7 @@ public String customizationId() { /** * Gets the corpusName. * - * The name of the corpus for the custom language model. + *

The name of the corpus for the custom language model. * * @return the corpusName */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java index 334786a132d..d0ea19aae03 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteGrammar options. - */ +/** The deleteGrammar options. */ public class DeleteGrammarOptions extends GenericModel { protected String customizationId; protected String grammarName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String grammarName; + /** + * Instantiates a new Builder from an existing DeleteGrammarOptions instance. + * + * @param deleteGrammarOptions the instance to initialize the Builder with + */ private Builder(DeleteGrammarOptions deleteGrammarOptions) { this.customizationId = deleteGrammarOptions.customizationId; this.grammarName = deleteGrammarOptions.grammarName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String grammarName) { /** * Builds a DeleteGrammarOptions. * - * @return the deleteGrammarOptions + * @return the new DeleteGrammarOptions instance */ public DeleteGrammarOptions build() { return new DeleteGrammarOptions(this); @@ -83,11 +82,13 @@ public Builder grammarName(String grammarName) { } } + protected DeleteGrammarOptions() {} + protected DeleteGrammarOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.grammarName, - "grammarName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.grammarName, "grammarName cannot be empty"); customizationId = builder.customizationId; grammarName = builder.grammarName; } @@ -104,8 +105,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,7 +118,7 @@ public String customizationId() { /** * Gets the grammarName. * - * The name of the grammar for the custom language model. + *

The name of the grammar for the custom language model. * * @return the grammarName */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java index 25f71ccd2e1..5c8b627c4df 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteJob options. - */ +/** The deleteJob options. */ public class DeleteJobOptions extends GenericModel { protected String id; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String id; + /** + * Instantiates a new Builder from an existing DeleteJobOptions instance. + * + * @param deleteJobOptions the instance to initialize the Builder with + */ private Builder(DeleteJobOptions deleteJobOptions) { this.id = deleteJobOptions.id; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String id) { /** * Builds a DeleteJobOptions. * - * @return the deleteJobOptions + * @return the new DeleteJobOptions instance */ public DeleteJobOptions build() { return new DeleteJobOptions(this); @@ -67,9 +66,10 @@ public Builder id(String id) { } } + protected DeleteJobOptions() {} + protected DeleteJobOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.id, - "id cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.id, "id cannot be empty"); id = builder.id; } @@ -85,8 +85,8 @@ public Builder newBuilder() { /** * Gets the id. * - * The identifier of the asynchronous job that is to be used for the request. You must make the request with - * credentials for the instance of the service that owns the job. + *

The identifier of the asynchronous job that is to be used for the request. You must make the + * request with credentials for the instance of the service that owns the job. * * @return the id */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java index 08c9f6d1e6d..4b62168fa7c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteLanguageModel options. - */ +/** The deleteLanguageModel options. */ public class DeleteLanguageModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing DeleteLanguageModelOptions instance. + * + * @param deleteLanguageModelOptions the instance to initialize the Builder with + */ private Builder(DeleteLanguageModelOptions deleteLanguageModelOptions) { this.customizationId = deleteLanguageModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a DeleteLanguageModelOptions. * - * @return the deleteLanguageModelOptions + * @return the new DeleteLanguageModelOptions instance */ public DeleteLanguageModelOptions build() { return new DeleteLanguageModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected DeleteLanguageModelOptions() {} + protected DeleteLanguageModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java index e3e9944bb73..5ec4a6e2f81 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteUserData options. - */ +/** The deleteUserData options. */ public class DeleteUserDataOptions extends GenericModel { protected String customerId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customerId; + /** + * Instantiates a new Builder from an existing DeleteUserDataOptions instance. + * + * @param deleteUserDataOptions the instance to initialize the Builder with + */ private Builder(DeleteUserDataOptions deleteUserDataOptions) { this.customerId = deleteUserDataOptions.customerId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); @@ -67,9 +66,10 @@ public Builder customerId(String customerId) { } } + protected DeleteUserDataOptions() {} + protected DeleteUserDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, - "customerId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, "customerId cannot be null"); customerId = builder.customerId; } @@ -85,7 +85,7 @@ public Builder newBuilder() { /** * Gets the customerId. * - * The customer ID for which all data is to be deleted. + *

The customer ID for which all data is to be deleted. * * @return the customerId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java index 19a7ad166ae..66a05516390 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteWord options. - */ +/** The deleteWord options. */ public class DeleteWordOptions extends GenericModel { protected String customizationId; protected String wordName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String wordName; + /** + * Instantiates a new Builder from an existing DeleteWordOptions instance. + * + * @param deleteWordOptions the instance to initialize the Builder with + */ private Builder(DeleteWordOptions deleteWordOptions) { this.customizationId = deleteWordOptions.customizationId; this.wordName = deleteWordOptions.wordName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String wordName) { /** * Builds a DeleteWordOptions. * - * @return the deleteWordOptions + * @return the new DeleteWordOptions instance */ public DeleteWordOptions build() { return new DeleteWordOptions(this); @@ -83,11 +82,12 @@ public Builder wordName(String wordName) { } } + protected DeleteWordOptions() {} + protected DeleteWordOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.wordName, - "wordName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.wordName, "wordName cannot be empty"); customizationId = builder.customizationId; wordName = builder.wordName; } @@ -104,8 +104,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,8 +117,8 @@ public String customizationId() { /** * Gets the wordName. * - * The custom word that is to be deleted from the custom language model. URL-encode the word if it includes non-ASCII - * characters. For more information, see [Character + *

The custom word that is to be deleted from the custom language model. URL-encode the word if + * it includes non-ASCII characters. For more information, see [Character * encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding). * * @return the wordName diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptions.java new file mode 100644 index 00000000000..95e8bf19aea --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptions.java @@ -0,0 +1,167 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The detectLanguage options. */ +public class DetectLanguageOptions extends GenericModel { + + protected Float lidConfidence; + protected InputStream audio; + protected String contentType; + + /** Builder. */ + public static class Builder { + private Float lidConfidence; + private InputStream audio; + private String contentType; + + /** + * Instantiates a new Builder from an existing DetectLanguageOptions instance. + * + * @param detectLanguageOptions the instance to initialize the Builder with + */ + private Builder(DetectLanguageOptions detectLanguageOptions) { + this.lidConfidence = detectLanguageOptions.lidConfidence; + this.audio = detectLanguageOptions.audio; + this.contentType = detectLanguageOptions.contentType; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param lidConfidence the lidConfidence + * @param audio the audio + */ + public Builder(Float lidConfidence, InputStream audio) { + this.lidConfidence = lidConfidence; + this.audio = audio; + } + + /** + * Builds a DetectLanguageOptions. + * + * @return the new DetectLanguageOptions instance + */ + public DetectLanguageOptions build() { + return new DetectLanguageOptions(this); + } + + /** + * Set the lidConfidence. + * + * @param lidConfidence the lidConfidence + * @return the DetectLanguageOptions builder + */ + public Builder lidConfidence(Float lidConfidence) { + this.lidConfidence = lidConfidence; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the DetectLanguageOptions builder + */ + public Builder audio(InputStream audio) { + this.audio = audio; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the DetectLanguageOptions builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the DetectLanguageOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder audio(File audio) throws FileNotFoundException { + this.audio = new FileInputStream(audio); + return this; + } + } + + protected DetectLanguageOptions() {} + + protected DetectLanguageOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.lidConfidence, "lidConfidence cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, "audio cannot be null"); + lidConfidence = builder.lidConfidence; + audio = builder.audio; + contentType = builder.contentType; + } + + /** + * New builder. + * + * @return a DetectLanguageOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the lidConfidence. + * + *

Set a custom confidence threshold for detection. + * + * @return the lidConfidence + */ + public Float lidConfidence() { + return lidConfidence; + } + + /** + * Gets the audio. + * + *

The audio to transcribe. + * + * @return the audio + */ + public InputStream audio() { + return audio; + } + + /** + * Gets the contentType. + * + *

The type of the input. + * + * @return the contentType + */ + public String contentType() { + return contentType; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResults.java new file mode 100644 index 00000000000..b281622f264 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResults.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * If enriched results are requested, transcription with inserted punctuation marks such as periods, + * commas, question marks, and exclamation points. + */ +public class EnrichedResults extends GenericModel { + + protected EnrichedResultsTranscript transcript; + protected String status; + + protected EnrichedResults() {} + + /** + * Gets the transcript. + * + *

If enriched results are requested, transcription with inserted punctuation marks such as + * periods, commas, question marks, and exclamation points. + * + * @return the transcript + */ + public EnrichedResultsTranscript getTranscript() { + return transcript; + } + + /** + * Gets the status. + * + *

The status of the enriched transcription. + * + * @return the status + */ + public String getStatus() { + return status; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscript.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscript.java new file mode 100644 index 00000000000..6f67841a127 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscript.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * If enriched results are requested, transcription with inserted punctuation marks such as periods, + * commas, question marks, and exclamation points. + */ +public class EnrichedResultsTranscript extends GenericModel { + + protected String text; + protected EnrichedResultsTranscriptTimestamp timestamp; + + protected EnrichedResultsTranscript() {} + + /** + * Gets the text. + * + *

The transcript text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the timestamp. + * + *

The speaking time from the beginning of the transcript to the end. + * + * @return the timestamp + */ + public EnrichedResultsTranscriptTimestamp getTimestamp() { + return timestamp; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestamp.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestamp.java new file mode 100644 index 00000000000..0f918fe6d13 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestamp.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The speaking time from the beginning of the transcript to the end. */ +public class EnrichedResultsTranscriptTimestamp extends GenericModel { + + protected Float from; + protected Float to; + + protected EnrichedResultsTranscriptTimestamp() {} + + /** + * Gets the from. + * + *

The start time of a word from the transcript. The value matches the start time of a word + * from the `timestamps` array. + * + * @return the from + */ + public Float getFrom() { + return from; + } + + /** + * Gets the to. + * + *

The end time of a word from the transcript. The value matches the end time of a word from + * the `timestamps` array. + * + * @return the to + */ + public Float getTo() { + return to; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java index 3b5b9f31846..db822dc80db 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getAcousticModel options. - */ +/** The getAcousticModel options. */ public class GetAcousticModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing GetAcousticModelOptions instance. + * + * @param getAcousticModelOptions the instance to initialize the Builder with + */ private Builder(GetAcousticModelOptions getAcousticModelOptions) { this.customizationId = getAcousticModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a GetAcousticModelOptions. * - * @return the getAcousticModelOptions + * @return the new GetAcousticModelOptions instance */ public GetAcousticModelOptions build() { return new GetAcousticModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected GetAcousticModelOptions() {} + protected GetAcousticModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java index 6de7ce70244..a729388fa79 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getAudio options. - */ +/** The getAudio options. */ public class GetAudioOptions extends GenericModel { protected String customizationId; protected String audioName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String audioName; + /** + * Instantiates a new Builder from an existing GetAudioOptions instance. + * + * @param getAudioOptions the instance to initialize the Builder with + */ private Builder(GetAudioOptions getAudioOptions) { this.customizationId = getAudioOptions.customizationId; this.audioName = getAudioOptions.audioName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String audioName) { /** * Builds a GetAudioOptions. * - * @return the getAudioOptions + * @return the new GetAudioOptions instance */ public GetAudioOptions build() { return new GetAudioOptions(this); @@ -83,11 +82,12 @@ public Builder audioName(String audioName) { } } + protected GetAudioOptions() {} + protected GetAudioOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.audioName, - "audioName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.audioName, "audioName cannot be empty"); customizationId = builder.customizationId; audioName = builder.audioName; } @@ -104,8 +104,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,7 +117,7 @@ public String customizationId() { /** * Gets the audioName. * - * The name of the audio resource for the custom acoustic model. + *

The name of the audio resource for the custom acoustic model. * * @return the audioName */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java index 20a61be028c..90c113454a8 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getCorpus options. - */ +/** The getCorpus options. */ public class GetCorpusOptions extends GenericModel { protected String customizationId; protected String corpusName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String corpusName; + /** + * Instantiates a new Builder from an existing GetCorpusOptions instance. + * + * @param getCorpusOptions the instance to initialize the Builder with + */ private Builder(GetCorpusOptions getCorpusOptions) { this.customizationId = getCorpusOptions.customizationId; this.corpusName = getCorpusOptions.corpusName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String corpusName) { /** * Builds a GetCorpusOptions. * - * @return the getCorpusOptions + * @return the new GetCorpusOptions instance */ public GetCorpusOptions build() { return new GetCorpusOptions(this); @@ -83,11 +82,13 @@ public Builder corpusName(String corpusName) { } } + protected GetCorpusOptions() {} + protected GetCorpusOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.corpusName, - "corpusName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.corpusName, "corpusName cannot be empty"); customizationId = builder.customizationId; corpusName = builder.corpusName; } @@ -104,8 +105,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,7 +118,7 @@ public String customizationId() { /** * Gets the corpusName. * - * The name of the corpus for the custom language model. + *

The name of the corpus for the custom language model. * * @return the corpusName */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java index 5012ad997a7..b401ae65612 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getGrammar options. - */ +/** The getGrammar options. */ public class GetGrammarOptions extends GenericModel { protected String customizationId; protected String grammarName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String grammarName; + /** + * Instantiates a new Builder from an existing GetGrammarOptions instance. + * + * @param getGrammarOptions the instance to initialize the Builder with + */ private Builder(GetGrammarOptions getGrammarOptions) { this.customizationId = getGrammarOptions.customizationId; this.grammarName = getGrammarOptions.grammarName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String grammarName) { /** * Builds a GetGrammarOptions. * - * @return the getGrammarOptions + * @return the new GetGrammarOptions instance */ public GetGrammarOptions build() { return new GetGrammarOptions(this); @@ -83,11 +82,13 @@ public Builder grammarName(String grammarName) { } } + protected GetGrammarOptions() {} + protected GetGrammarOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.grammarName, - "grammarName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.grammarName, "grammarName cannot be empty"); customizationId = builder.customizationId; grammarName = builder.grammarName; } @@ -104,8 +105,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,7 +118,7 @@ public String customizationId() { /** * Gets the grammarName. * - * The name of the grammar for the custom language model. + *

The name of the grammar for the custom language model. * * @return the grammarName */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java index 7612966d9bb..900ac96b2eb 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getLanguageModel options. - */ +/** The getLanguageModel options. */ public class GetLanguageModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing GetLanguageModelOptions instance. + * + * @param getLanguageModelOptions the instance to initialize the Builder with + */ private Builder(GetLanguageModelOptions getLanguageModelOptions) { this.customizationId = getLanguageModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a GetLanguageModelOptions. * - * @return the getLanguageModelOptions + * @return the new GetLanguageModelOptions instance */ public GetLanguageModelOptions build() { return new GetLanguageModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected GetLanguageModelOptions() {} + protected GetLanguageModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java index 91bd1c871ca..6c0d50d0cb0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,106 +10,210 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getModel options. - */ +/** The getModel options. */ public class GetModelOptions extends GenericModel { /** - * The identifier of the model in the form of its name from the output of the **Get a model** method. + * The identifier of the model in the form of its name from the output of the [List + * models](#listmodels) method. */ public interface ModelId { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; + /** ar-MS_BroadbandModel. */ + String AR_MS_BROADBANDMODEL = "ar-MS_BroadbandModel"; + /** ar-MS_Telephony. */ + String AR_MS_TELEPHONY = "ar-MS_Telephony"; + /** cs-CZ_Telephony. */ + String CS_CZ_TELEPHONY = "cs-CZ_Telephony"; + /** de-DE. */ + String DE_DE = "de-DE"; /** de-DE_BroadbandModel. */ String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; + /** de-DE_Multimedia. */ + String DE_DE_MULTIMEDIA = "de-DE_Multimedia"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** de-DE_Telephony. */ + String DE_DE_TELEPHONY = "de-DE_Telephony"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_Multimedia. */ + String EN_AU_MULTIMEDIA = "en-AU_Multimedia"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; + /** en-AU_Telephony. */ + String EN_AU_TELEPHONY = "en-AU_Telephony"; + /** en-GB. */ + String EN_GB = "en-GB"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; + /** en-GB_Multimedia. */ + String EN_GB_MULTIMEDIA = "en-GB_Multimedia"; /** en-GB_NarrowbandModel. */ String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; + /** en-GB_Telephony. */ + String EN_GB_TELEPHONY = "en-GB_Telephony"; + /** en-IN. */ + String EN_IN = "en-IN"; + /** en-IN_Telephony. */ + String EN_IN_TELEPHONY = "en-IN_Telephony"; + /** en-US. */ + String EN_US = "en-US"; /** en-US_BroadbandModel. */ String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; + /** en-US_Multimedia. */ + String EN_US_MULTIMEDIA = "en-US_Multimedia"; /** en-US_NarrowbandModel. */ String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; /** en-US_ShortForm_NarrowbandModel. */ String EN_US_SHORTFORM_NARROWBANDMODEL = "en-US_ShortForm_NarrowbandModel"; + /** en-US_Telephony. */ + String EN_US_TELEPHONY = "en-US_Telephony"; + /** en-WW_Medical_Telephony. */ + String EN_WW_MEDICAL_TELEPHONY = "en-WW_Medical_Telephony"; + /** es-AR. */ + String ES_AR = "es-AR"; /** es-AR_BroadbandModel. */ String ES_AR_BROADBANDMODEL = "es-AR_BroadbandModel"; /** es-AR_NarrowbandModel. */ String ES_AR_NARROWBANDMODEL = "es-AR_NarrowbandModel"; + /** es-CL. */ + String ES_CL = "es-CL"; /** es-CL_BroadbandModel. */ String ES_CL_BROADBANDMODEL = "es-CL_BroadbandModel"; /** es-CL_NarrowbandModel. */ String ES_CL_NARROWBANDMODEL = "es-CL_NarrowbandModel"; + /** es-CO. */ + String ES_CO = "es-CO"; /** es-CO_BroadbandModel. */ String ES_CO_BROADBANDMODEL = "es-CO_BroadbandModel"; /** es-CO_NarrowbandModel. */ String ES_CO_NARROWBANDMODEL = "es-CO_NarrowbandModel"; + /** es-ES. */ + String ES_ES = "es-ES"; /** es-ES_BroadbandModel. */ String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; /** es-ES_NarrowbandModel. */ String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; + /** es-ES_Multimedia. */ + String ES_ES_MULTIMEDIA = "es-ES_Multimedia"; + /** es-ES_Telephony. */ + String ES_ES_TELEPHONY = "es-ES_Telephony"; + /** es-LA_Telephony. */ + String ES_LA_TELEPHONY = "es-LA_Telephony"; + /** es-MX. */ + String ES_MX = "es-MX"; /** es-MX_BroadbandModel. */ String ES_MX_BROADBANDMODEL = "es-MX_BroadbandModel"; /** es-MX_NarrowbandModel. */ String ES_MX_NARROWBANDMODEL = "es-MX_NarrowbandModel"; + /** es-PE. */ + String ES_PE = "es-PE"; /** es-PE_BroadbandModel. */ String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_Multimedia. */ + String FR_CA_MULTIMEDIA = "fr-CA_Multimedia"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; + /** fr-CA_Telephony. */ + String FR_CA_TELEPHONY = "fr-CA_Telephony"; + /** fr-FR. */ + String FR_FR = "fr-FR"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; + /** fr-FR_Multimedia. */ + String FR_FR_MULTIMEDIA = "fr-FR_Multimedia"; /** fr-FR_NarrowbandModel. */ String FR_FR_NARROWBANDMODEL = "fr-FR_NarrowbandModel"; + /** fr-FR_Telephony. */ + String FR_FR_TELEPHONY = "fr-FR_Telephony"; + /** hi-IN_Telephony. */ + String HI_IN_TELEPHONY = "hi-IN_Telephony"; /** it-IT_BroadbandModel. */ String IT_IT_BROADBANDMODEL = "it-IT_BroadbandModel"; /** it-IT_NarrowbandModel. */ String IT_IT_NARROWBANDMODEL = "it-IT_NarrowbandModel"; + /** it-IT_Multimedia. */ + String IT_IT_MULTIMEDIA = "it-IT_Multimedia"; + /** it-IT_Telephony. */ + String IT_IT_TELEPHONY = "it-IT_Telephony"; + /** ja-JP. */ + String JA_JP = "ja-JP"; /** ja-JP_BroadbandModel. */ String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; + /** ja-JP_Multimedia. */ + String JA_JP_MULTIMEDIA = "ja-JP_Multimedia"; /** ja-JP_NarrowbandModel. */ String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; + /** ja-JP_Telephony. */ + String JA_JP_TELEPHONY = "ja-JP_Telephony"; /** ko-KR_BroadbandModel. */ String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; + /** ko-KR_Multimedia. */ + String KO_KR_MULTIMEDIA = "ko-KR_Multimedia"; /** ko-KR_NarrowbandModel. */ String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; + /** ko-KR_Telephony. */ + String KO_KR_TELEPHONY = "ko-KR_Telephony"; + /** nl-BE_Telephony. */ + String NL_BE_TELEPHONY = "nl-BE_Telephony"; /** nl-NL_BroadbandModel. */ String NL_NL_BROADBANDMODEL = "nl-NL_BroadbandModel"; + /** nl-NL_Multimedia. */ + String NL_NL_MULTIMEDIA = "nl-NL_Multimedia"; /** nl-NL_NarrowbandModel. */ String NL_NL_NARROWBANDMODEL = "nl-NL_NarrowbandModel"; + /** nl-NL_Telephony. */ + String NL_NL_TELEPHONY = "nl-NL_Telephony"; + /** pt-BR. */ + String PT_BR = "pt-BR"; /** pt-BR_BroadbandModel. */ String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; + /** pt-BR_Multimedia. */ + String PT_BR_MULTIMEDIA = "pt-BR_Multimedia"; /** pt-BR_NarrowbandModel. */ String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; + /** pt-BR_Telephony. */ + String PT_BR_TELEPHONY = "pt-BR_Telephony"; + /** sv-SE_Telephony. */ + String SV_SE_TELEPHONY = "sv-SE_Telephony"; /** zh-CN_BroadbandModel. */ String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; /** zh-CN_NarrowbandModel. */ String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; + /** zh-CN_Telephony. */ + String ZH_CN_TELEPHONY = "zh-CN_Telephony"; } protected String modelId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String modelId; + /** + * Instantiates a new Builder from an existing GetModelOptions instance. + * + * @param getModelOptions the instance to initialize the Builder with + */ private Builder(GetModelOptions getModelOptions) { this.modelId = getModelOptions.modelId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -123,7 +227,7 @@ public Builder(String modelId) { /** * Builds a GetModelOptions. * - * @return the getModelOptions + * @return the new GetModelOptions instance */ public GetModelOptions build() { return new GetModelOptions(this); @@ -141,9 +245,10 @@ public Builder modelId(String modelId) { } } + protected GetModelOptions() {} + protected GetModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, - "modelId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty"); modelId = builder.modelId; } @@ -159,7 +264,8 @@ public Builder newBuilder() { /** * Gets the modelId. * - * The identifier of the model in the form of its name from the output of the **Get a model** method. + *

The identifier of the model in the form of its name from the output of the [List + * models](#listmodels) method. * * @return the modelId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java index ccf5130178f..524cd1a8558 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getWord options. - */ +/** The getWord options. */ public class GetWordOptions extends GenericModel { protected String customizationId; protected String wordName; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String wordName; + /** + * Instantiates a new Builder from an existing GetWordOptions instance. + * + * @param getWordOptions the instance to initialize the Builder with + */ private Builder(GetWordOptions getWordOptions) { this.customizationId = getWordOptions.customizationId; this.wordName = getWordOptions.wordName; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String wordName) { /** * Builds a GetWordOptions. * - * @return the getWordOptions + * @return the new GetWordOptions instance */ public GetWordOptions build() { return new GetWordOptions(this); @@ -83,11 +82,12 @@ public Builder wordName(String wordName) { } } + protected GetWordOptions() {} + protected GetWordOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.wordName, - "wordName cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.wordName, "wordName cannot be empty"); customizationId = builder.customizationId; wordName = builder.wordName; } @@ -104,8 +104,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -116,8 +117,8 @@ public String customizationId() { /** * Gets the wordName. * - * The custom word that is to be read from the custom language model. URL-encode the word if it includes non-ASCII - * characters. For more information, see [Character + *

The custom word that is to be read from the custom language model. URL-encode the word if it + * includes non-ASCII characters. For more information, see [Character * encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding). * * @return the wordName diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java index a0573aaa179..8a25e68554a 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,21 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about a grammar from a custom language model. - */ +/** Information about a grammar from a custom language model. */ public class Grammar extends GenericModel { /** - * The status of the grammar: - * * `analyzed`: The service successfully analyzed the grammar. The custom model can be trained with data from the - * grammar. - * * `being_processed`: The service is still analyzing the grammar. The service cannot accept requests to add new - * resources or to train the custom model. - * * `undetermined`: The service encountered an error while processing the grammar. The `error` field describes the - * failure. + * The status of the grammar: * `analyzed`: The service successfully analyzed the grammar. The + * custom model can be trained with data from the grammar. * `being_processed`: The service is + * still analyzing the grammar. The service cannot accept requests to add new resources or to + * train the custom model. * `undetermined`: The service encountered an error while processing the + * grammar. The `error` field describes the failure. */ public interface Status { /** analyzed. */ @@ -39,15 +36,19 @@ public interface Status { } protected String name; + @SerializedName("out_of_vocabulary_words") protected Long outOfVocabularyWords; + protected String status; protected String error; + protected Grammar() {} + /** * Gets the name. * - * The name of the grammar. + *

The name of the grammar. * * @return the name */ @@ -58,7 +59,11 @@ public String getName() { /** * Gets the outOfVocabularyWords. * - * The number of OOV words in the grammar. The value is `0` while the grammar is being processed. + *

_For custom models that are based on previous-generation models_, the number of OOV words + * extracted from the grammar. The value is `0` while the grammar is being processed. + * + *

_For custom models that are based on next-generation models_, no OOV words are extracted + * from grammars, so the value is always `0`. * * @return the outOfVocabularyWords */ @@ -69,13 +74,11 @@ public Long getOutOfVocabularyWords() { /** * Gets the status. * - * The status of the grammar: - * * `analyzed`: The service successfully analyzed the grammar. The custom model can be trained with data from the - * grammar. - * * `being_processed`: The service is still analyzing the grammar. The service cannot accept requests to add new - * resources or to train the custom model. - * * `undetermined`: The service encountered an error while processing the grammar. The `error` field describes the - * failure. + *

The status of the grammar: * `analyzed`: The service successfully analyzed the grammar. The + * custom model can be trained with data from the grammar. * `being_processed`: The service is + * still analyzing the grammar. The service cannot accept requests to add new resources or to + * train the custom model. * `undetermined`: The service encountered an error while processing the + * grammar. The `error` field describes the failure. * * @return the status */ @@ -86,8 +89,9 @@ public String getStatus() { /** * Gets the error. * - * If the status of the grammar is `undetermined`, the following message: `Analysis of grammar '{grammar_name}' - * failed. Please try fixing the error or adding the grammar again by setting the 'allow_overwrite' flag to 'true'.`. + *

If the status of the grammar is `undetermined`, the following message: `Analysis of grammar + * '{grammar_name}' failed. Please try fixing the error or adding the grammar again by setting the + * 'allow_overwrite' flag to 'true'.`. * * @return the error */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java index 1e6a2cee8bb..7422e9a85e5 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about the grammars from a custom language model. - */ +/** Information about the grammars from a custom language model. */ public class Grammars extends GenericModel { protected List grammars; + protected Grammars() {} + /** * Gets the grammars. * - * An array of `Grammar` objects that provides information about the grammars for the custom model. The array is empty - * if the custom model has no grammars. + *

An array of `Grammar` objects that provides information about the grammars for the custom + * model. The array is empty if the custom model has no grammars. * * @return the grammars */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java index fe5b53b2213..fe90e3cd122 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,28 +10,32 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about a match for a keyword from speech recognition results. - */ +/** Information about a match for a keyword from speech recognition results. */ public class KeywordResult extends GenericModel { @SerializedName("normalized_text") protected String normalizedText; + @SerializedName("start_time") protected Double startTime; + @SerializedName("end_time") protected Double endTime; + protected Double confidence; + protected KeywordResult() {} + /** * Gets the normalizedText. * - * A specified keyword normalized to the spoken phrase that matched in the audio input. + *

A specified keyword normalized to the spoken phrase that matched in the audio input. * * @return the normalizedText */ @@ -42,7 +46,7 @@ public String getNormalizedText() { /** * Gets the startTime. * - * The start time in seconds of the keyword match. + *

The start time in seconds of the keyword match. * * @return the startTime */ @@ -53,7 +57,7 @@ public Double getStartTime() { /** * Gets the endTime. * - * The end time in seconds of the keyword match. + *

The end time in seconds of the keyword match. * * @return the endTime */ @@ -64,7 +68,7 @@ public Double getEndTime() { /** * Gets the confidence. * - * A confidence score for the keyword match in the range of 0.0 to 1.0. + *

A confidence score for the keyword match in the range of 0.0 to 1.0. * * @return the confidence */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResult.java new file mode 100644 index 00000000000..3e9d3e46462 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResult.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Language detection results. */ +public class LanguageDetectionResult extends GenericModel { + + @SerializedName("language_info") + protected List languageInfo; + + protected LanguageDetectionResult() {} + + /** + * Gets the languageInfo. + * + *

An array of `LanguageInfo` objects. + * + * @return the languageInfo + */ + public List getLanguageInfo() { + return languageInfo; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResults.java new file mode 100644 index 00000000000..e51c6757fe5 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResults.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Language detection results. */ +public class LanguageDetectionResults extends GenericModel { + + protected List results; + + @SerializedName("result_index") + protected Long resultIndex; + + protected LanguageDetectionResults() {} + + /** + * Gets the results. + * + *

An array of `LanguageDetectionResult` objects. + * + * @return the results + */ + public List getResults() { + return results; + } + + /** + * Gets the resultIndex. + * + *

An index that indicates a change point in the `results` array. The service increments the + * index for additional results that it sends for new audio for the same request. All results with + * the same index are delivered at the same time. The same index can include multiple final + * results that are delivered with the same response. + * + * @return the resultIndex + */ + public Long getResultIndex() { + return resultIndex; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfo.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfo.java new file mode 100644 index 00000000000..e771e534e95 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfo.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Language detection info such as confidence and language detected. */ +public class LanguageInfo extends GenericModel { + + protected Float confidence; + protected String language; + protected Float timestamp; + + protected LanguageInfo() {} + + /** + * Gets the confidence. + * + *

A score that indicates the service's confidence in its identification of the language in the + * range of 0.0 to 1.0. + * + * @return the confidence + */ + public Float getConfidence() { + return confidence; + } + + /** + * Gets the language. + * + *

The language detected in standard abbreviated ISO 639 format. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the timestamp. + * + *

The timestamp of the detected language. + * + * @return the timestamp + */ + public Float getTimestamp() { + return timestamp; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java index 4973884550c..ab0193e50c0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,28 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about an existing custom language model. - */ +/** Information about an existing custom language model. */ public class LanguageModel extends GenericModel { /** - * The current status of the custom language model: - * * `pending`: The model was created but is waiting either for valid training data to be added or for the service to - * finish analyzing added data. - * * `ready`: The model contains valid data and is ready to be trained. If the model contains a mix of valid and - * invalid resources, you need to set the `strict` parameter to `false` for the training to proceed. - * * `training`: The model is currently being trained. - * * `available`: The model is trained and ready to use. - * * `upgrading`: The model is currently being upgraded. - * * `failed`: Training of the model failed. + * The current status of the custom language model: * `pending`: The model was created but is + * waiting either for valid training data to be added or for the service to finish analyzing added + * data. * `ready`: The model contains valid data and is ready to be trained. If the model + * contains a mix of valid and invalid resources, you need to set the `strict` parameter to + * `false` for the training to proceed. * `training`: The model is currently being trained. * + * `available`: The model is trained and ready to use. * `upgrading`: The model is currently being + * upgraded. * `failed`: Training of the model failed. */ public interface Status { /** pending. */ @@ -50,6 +46,7 @@ public interface Status { @SerializedName("customization_id") protected String customizationId; + protected String created; protected String updated; protected String language; @@ -58,18 +55,23 @@ public interface Status { protected String owner; protected String name; protected String description; + @SerializedName("base_model_name") protected String baseModelName; + protected String status; protected Long progress; protected String error; protected String warnings; + protected LanguageModel() {} + /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model. The **Create a custom language model** method returns - * only this field of the object; it does not return the other fields. + *

The customization ID (GUID) of the custom language model. The [Create a custom language + * model](#createlanguagemodel) method returns only this field of the object; it does not return + * the other fields. * * @return the customizationId */ @@ -80,8 +82,8 @@ public String getCustomizationId() { /** * Gets the created. * - * The date and time in Coordinated Universal Time (UTC) at which the custom language model was created. The value is - * provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + *

The date and time in Coordinated Universal Time (UTC) at which the custom language model was + * created. The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). * * @return the created */ @@ -92,9 +94,10 @@ public String getCreated() { /** * Gets the updated. * - * The date and time in Coordinated Universal Time (UTC) at which the custom language model was last modified. The - * `created` and `updated` fields are equal when a language model is first added but has yet to be updated. The value - * is provided in full ISO 8601 format (YYYY-MM-DDThh:mm:ss.sTZD). + *

The date and time in Coordinated Universal Time (UTC) at which the custom language model was + * last modified. The `created` and `updated` fields are equal when a language model is first + * added but has yet to be updated. The value is provided in full ISO 8601 format + * (YYYY-MM-DDThh:mm:ss.sTZD). * * @return the updated */ @@ -105,7 +108,9 @@ public String getUpdated() { /** * Gets the language. * - * The language identifier of the custom language model (for example, `en-US`). + *

The language identifier of the custom language model (for example, `en-US`). The value + * matches the five-character language identifier from the name of the base model for the custom + * model. This value might be different from the value of the `dialect` field. * * @return the language */ @@ -116,14 +121,16 @@ public String getLanguage() { /** * Gets the dialect. * - * The dialect of the language for the custom language model. For non-Spanish models, the field matches the language - * of the base model; for example, `en-US` for either of the US English language models. For Spanish models, the field - * indicates the dialect for which the model was created: - * * `es-ES` for Castilian Spanish (`es-ES` models) - * * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` models) - * * `es-US` for Mexican (North American) Spanish (`es-MX` models) + *

The dialect of the language for the custom language model. _For custom models that are based + * on non-Spanish previous-generation models and on next-generation models,_ the field matches the + * language of the base model; for example, `en-US` for one of the US English models. _For custom + * models that are based on Spanish previous-generation models,_ the field indicates the dialect + * with which the model was created. The value can match the name of the base model or, if it was + * specified by the user, can be one of the following: * `es-ES` for Castilian Spanish (`es-ES` + * models) * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` models) * + * `es-US` for Mexican (North American) Spanish (`es-MX` models) * - * Dialect values are case-insensitive. + *

Dialect values are case-insensitive. * * @return the dialect */ @@ -134,9 +141,10 @@ public String getDialect() { /** * Gets the versions. * - * A list of the available versions of the custom language model. Each element of the array indicates a version of the - * base model with which the custom model can be used. Multiple versions exist only if the custom model has been - * upgraded; otherwise, only a single version is shown. + *

A list of the available versions of the custom language model. Each element of the array + * indicates a version of the base model with which the custom model can be used. Multiple + * versions exist only if the custom model has been upgraded to a new version of its base model. + * Otherwise, only a single version is shown. * * @return the versions */ @@ -147,7 +155,8 @@ public List getVersions() { /** * Gets the owner. * - * The GUID of the credentials for the instance of the service that owns the custom language model. + *

The GUID of the credentials for the instance of the service that owns the custom language + * model. * * @return the owner */ @@ -158,7 +167,7 @@ public String getOwner() { /** * Gets the name. * - * The name of the custom language model. + *

The name of the custom language model. * * @return the name */ @@ -169,7 +178,7 @@ public String getName() { /** * Gets the description. * - * The description of the custom language model. + *

The description of the custom language model. * * @return the description */ @@ -180,7 +189,7 @@ public String getDescription() { /** * Gets the baseModelName. * - * The name of the language model for which the custom language model was created. + *

The name of the language model for which the custom language model was created. * * @return the baseModelName */ @@ -191,15 +200,13 @@ public String getBaseModelName() { /** * Gets the status. * - * The current status of the custom language model: - * * `pending`: The model was created but is waiting either for valid training data to be added or for the service to - * finish analyzing added data. - * * `ready`: The model contains valid data and is ready to be trained. If the model contains a mix of valid and - * invalid resources, you need to set the `strict` parameter to `false` for the training to proceed. - * * `training`: The model is currently being trained. - * * `available`: The model is trained and ready to use. - * * `upgrading`: The model is currently being upgraded. - * * `failed`: Training of the model failed. + *

The current status of the custom language model: * `pending`: The model was created but is + * waiting either for valid training data to be added or for the service to finish analyzing added + * data. * `ready`: The model contains valid data and is ready to be trained. If the model + * contains a mix of valid and invalid resources, you need to set the `strict` parameter to + * `false` for the training to proceed. * `training`: The model is currently being trained. * + * `available`: The model is trained and ready to use. * `upgrading`: The model is currently being + * upgraded. * `failed`: Training of the model failed. * * @return the status */ @@ -210,9 +217,10 @@ public String getStatus() { /** * Gets the progress. * - * A percentage that indicates the progress of the custom language model's current training. A value of `100` means - * that the model is fully trained. **Note:** The `progress` field does not currently reflect the progress of the - * training. The field changes from `0` to `100` when training is complete. + *

A percentage that indicates the progress of the custom language model's current training. A + * value of `100` means that the model is fully trained. **Note:** The `progress` field does not + * currently reflect the progress of the training. The field changes from `0` to `100` when + * training is complete. * * @return the progress */ @@ -223,9 +231,10 @@ public Long getProgress() { /** * Gets the error. * - * If an error occurred while adding a grammar file to the custom language model, a message that describes an - * `Internal Server Error` and includes the string `Cannot compile grammar`. The status of the custom model is not - * affected by the error, but the grammar cannot be used with the model. + *

If an error occurred while adding a grammar file to the custom language model, a message + * that describes an `Internal Server Error` and includes the string `Cannot compile grammar`. The + * status of the custom model is not affected by the error, but the grammar cannot be used with + * the model. * * @return the error */ @@ -236,8 +245,9 @@ public String getError() { /** * Gets the warnings. * - * If the request included unknown parameters, the following message: `Unexpected query parameter(s) ['parameters'] - * detected`, where `parameters` is a list that includes a quoted string for each unknown parameter. + *

If the request included unknown parameters, the following message: `Unexpected query + * parameter(s) ['parameters'] detected`, where `parameters` is a list that includes a quoted + * string for each unknown parameter. * * @return the warnings */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java index a44cacba0ff..c26a36ca848 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,25 +10,25 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about existing custom language models. - */ +/** Information about existing custom language models. */ public class LanguageModels extends GenericModel { protected List customizations; + protected LanguageModels() {} + /** * Gets the customizations. * - * An array of `LanguageModel` objects that provides information about each available custom language model. The array - * is empty if the requesting credentials own no custom language models (if no language is specified) or own no custom - * language models for the specified language. + *

An array of `LanguageModel` objects that provides information about each available custom + * language model. The array is empty if the requesting credentials own no custom language models + * (if no language is specified) or own no custom language models for the specified language. * * @return the customizations */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java index f1689919226..75b5d54c6fe 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,37 +10,101 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listAcousticModels options. - */ +/** The listAcousticModels options. */ public class ListAcousticModelsOptions extends GenericModel { - protected String language; - /** - * Builder. + * The identifier of the language for which custom language or custom acoustic models are to be + * returned. Specify the five-character language identifier; for example, specify `en-US` to see + * all custom language or custom acoustic models that are based on US English models. Omit the + * parameter to see all custom language or custom acoustic models that are owned by the requesting + * credentials. + * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). */ + public interface Language { + /** ar-MS. */ + String AR_MS = "ar-MS"; + /** cs-CZ. */ + String CS_CZ = "cs-CZ"; + /** de-DE. */ + String DE_DE = "de-DE"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-GB. */ + String EN_GB = "en-GB"; + /** en-IN. */ + String EN_IN = "en-IN"; + /** en-US. */ + String EN_US = "en-US"; + /** en-WW. */ + String EN_WW = "en-WW"; + /** es-AR. */ + String ES_AR = "es-AR"; + /** es-CL. */ + String ES_CL = "es-CL"; + /** es-CO. */ + String ES_CO = "es-CO"; + /** es-ES. */ + String ES_ES = "es-ES"; + /** es-LA. */ + String ES_LA = "es-LA"; + /** es-MX. */ + String ES_MX = "es-MX"; + /** es-PE. */ + String ES_PE = "es-PE"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-FR. */ + String FR_FR = "fr-FR"; + /** hi-IN. */ + String HI_IN = "hi-IN"; + /** it-IT. */ + String IT_IT = "it-IT"; + /** ja-JP. */ + String JA_JP = "ja-JP"; + /** ko-KR. */ + String KO_KR = "ko-KR"; + /** nl-BE. */ + String NL_BE = "nl-BE"; + /** nl-NL. */ + String NL_NL = "nl-NL"; + /** pt-BR. */ + String PT_BR = "pt-BR"; + /** sv-SE. */ + String SV_SE = "sv-SE"; + /** zh-CN. */ + String ZH_CN = "zh-CN"; + } + + protected String language; + + /** Builder. */ public static class Builder { private String language; + /** + * Instantiates a new Builder from an existing ListAcousticModelsOptions instance. + * + * @param listAcousticModelsOptions the instance to initialize the Builder with + */ private Builder(ListAcousticModelsOptions listAcousticModelsOptions) { this.language = listAcousticModelsOptions.language; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a ListAcousticModelsOptions. * - * @return the listAcousticModelsOptions + * @return the new ListAcousticModelsOptions instance */ public ListAcousticModelsOptions build() { return new ListAcousticModelsOptions(this); @@ -58,6 +122,8 @@ public Builder language(String language) { } } + protected ListAcousticModelsOptions() {} + protected ListAcousticModelsOptions(Builder builder) { language = builder.language; } @@ -74,10 +140,15 @@ public Builder newBuilder() { /** * Gets the language. * - * The identifier of the language for which custom language or custom acoustic models are to be returned (for example, - * `en-US`). Omit the parameter to see all custom language or custom acoustic models that are owned by the requesting + *

The identifier of the language for which custom language or custom acoustic models are to be + * returned. Specify the five-character language identifier; for example, specify `en-US` to see + * all custom language or custom acoustic models that are based on US English models. Omit the + * parameter to see all custom language or custom acoustic models that are owned by the requesting * credentials. * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). + * * @return the language */ public String language() { diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java index 7dfefe0e42d..46a7039e15c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listAudio options. - */ +/** The listAudio options. */ public class ListAudioOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing ListAudioOptions instance. + * + * @param listAudioOptions the instance to initialize the Builder with + */ private Builder(ListAudioOptions listAudioOptions) { this.customizationId = listAudioOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a ListAudioOptions. * - * @return the listAudioOptions + * @return the new ListAudioOptions instance */ public ListAudioOptions build() { return new ListAudioOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected ListAudioOptions() {} + protected ListAudioOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java index 27669bb9779..16c14e53d85 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listCorpora options. - */ +/** The listCorpora options. */ public class ListCorporaOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing ListCorporaOptions instance. + * + * @param listCorporaOptions the instance to initialize the Builder with + */ private Builder(ListCorporaOptions listCorporaOptions) { this.customizationId = listCorporaOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a ListCorporaOptions. * - * @return the listCorporaOptions + * @return the new ListCorporaOptions instance */ public ListCorporaOptions build() { return new ListCorporaOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected ListCorporaOptions() {} + protected ListCorporaOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java index 2d31baafd78..e60400e45ba 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listGrammars options. - */ +/** The listGrammars options. */ public class ListGrammarsOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing ListGrammarsOptions instance. + * + * @param listGrammarsOptions the instance to initialize the Builder with + */ private Builder(ListGrammarsOptions listGrammarsOptions) { this.customizationId = listGrammarsOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a ListGrammarsOptions. * - * @return the listGrammarsOptions + * @return the new ListGrammarsOptions instance */ public ListGrammarsOptions build() { return new ListGrammarsOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected ListGrammarsOptions() {} + protected ListGrammarsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java index 7899858b501..0351b5fa6c0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,37 +10,101 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listLanguageModels options. - */ +/** The listLanguageModels options. */ public class ListLanguageModelsOptions extends GenericModel { - protected String language; - /** - * Builder. + * The identifier of the language for which custom language or custom acoustic models are to be + * returned. Specify the five-character language identifier; for example, specify `en-US` to see + * all custom language or custom acoustic models that are based on US English models. Omit the + * parameter to see all custom language or custom acoustic models that are owned by the requesting + * credentials. + * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). */ + public interface Language { + /** ar-MS. */ + String AR_MS = "ar-MS"; + /** cs-CZ. */ + String CS_CZ = "cs-CZ"; + /** de-DE. */ + String DE_DE = "de-DE"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-GB. */ + String EN_GB = "en-GB"; + /** en-IN. */ + String EN_IN = "en-IN"; + /** en-US. */ + String EN_US = "en-US"; + /** en-WW. */ + String EN_WW = "en-WW"; + /** es-AR. */ + String ES_AR = "es-AR"; + /** es-CL. */ + String ES_CL = "es-CL"; + /** es-CO. */ + String ES_CO = "es-CO"; + /** es-ES. */ + String ES_ES = "es-ES"; + /** es-LA. */ + String ES_LA = "es-LA"; + /** es-MX. */ + String ES_MX = "es-MX"; + /** es-PE. */ + String ES_PE = "es-PE"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-FR. */ + String FR_FR = "fr-FR"; + /** hi-IN. */ + String HI_IN = "hi-IN"; + /** it-IT. */ + String IT_IT = "it-IT"; + /** ja-JP. */ + String JA_JP = "ja-JP"; + /** ko-KR. */ + String KO_KR = "ko-KR"; + /** nl-BE. */ + String NL_BE = "nl-BE"; + /** nl-NL. */ + String NL_NL = "nl-NL"; + /** pt-BR. */ + String PT_BR = "pt-BR"; + /** sv-SE. */ + String SV_SE = "sv-SE"; + /** zh-CN. */ + String ZH_CN = "zh-CN"; + } + + protected String language; + + /** Builder. */ public static class Builder { private String language; + /** + * Instantiates a new Builder from an existing ListLanguageModelsOptions instance. + * + * @param listLanguageModelsOptions the instance to initialize the Builder with + */ private Builder(ListLanguageModelsOptions listLanguageModelsOptions) { this.language = listLanguageModelsOptions.language; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Builds a ListLanguageModelsOptions. * - * @return the listLanguageModelsOptions + * @return the new ListLanguageModelsOptions instance */ public ListLanguageModelsOptions build() { return new ListLanguageModelsOptions(this); @@ -58,6 +122,8 @@ public Builder language(String language) { } } + protected ListLanguageModelsOptions() {} + protected ListLanguageModelsOptions(Builder builder) { language = builder.language; } @@ -74,10 +140,15 @@ public Builder newBuilder() { /** * Gets the language. * - * The identifier of the language for which custom language or custom acoustic models are to be returned (for example, - * `en-US`). Omit the parameter to see all custom language or custom acoustic models that are owned by the requesting + *

The identifier of the language for which custom language or custom acoustic models are to be + * returned. Specify the five-character language identifier; for example, specify `en-US` to see + * all custom language or custom acoustic models that are based on US English models. Omit the + * parameter to see all custom language or custom acoustic models that are owned by the requesting * credentials. * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). + * * @return the language */ public String language() { diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java index c4c0d7b989c..e85ed232e1d 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,48 +10,14 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listModels options. - */ +/** The listModels options. */ public class ListModelsOptions extends GenericModel { - /** - * Builder. - */ - public static class Builder { - - private Builder(ListModelsOptions listModelsOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListModelsOptions. - * - * @return the listModelsOptions - */ - public ListModelsOptions build() { - return new ListModelsOptions(this); - } - } - - private ListModelsOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } + /** Construct a new instance of ListModelsOptions. */ + public ListModelsOptions() {} } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java index c919e111562..189430c56c0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,21 +10,23 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listWords options. - */ +/** The listWords options. */ public class ListWordsOptions extends GenericModel { /** - * The type of words to be listed from the custom language model's words resource: - * * `all` (the default) shows all words. - * * `user` shows only custom words that were added or modified by the user directly. - * * `corpora` shows only OOV that were extracted from corpora. - * * `grammars` shows only OOV words that are recognized by grammars. + * The type of words to be listed from the custom language model's words resource: * `all` (the + * default) shows all words. * `user` shows only custom words that were added or modified by the + * user directly. * `corpora` shows only OOV that were extracted from corpora. * `grammars` shows + * only OOV words that are recognized by grammars. + * + *

_For a custom model that is based on a next-generation model_, only `all` and `user` apply. + * Both options return the same results. Words from other sources are not added to custom models + * that are based on next-generation models. */ public interface WordType { /** all. */ @@ -38,11 +40,12 @@ public interface WordType { } /** - * Indicates the order in which the words are to be listed, `alphabetical` or by `count`. You can prepend an optional - * `+` or `-` to an argument to indicate whether the results are to be sorted in ascending or descending order. By - * default, words are sorted in ascending alphabetical order. For alphabetical ordering, the lexicographical - * precedence is numeric values, uppercase letters, and lowercase letters. For count ordering, values with the same - * count are ordered alphabetically. With the `curl` command, URL-encode the `+` symbol as `%2B`. + * Indicates the order in which the words are to be listed, `alphabetical` or by `count`. You can + * prepend an optional `+` or `-` to an argument to indicate whether the results are to be sorted + * in ascending or descending order. By default, words are sorted in ascending alphabetical order. + * For alphabetical ordering, the lexicographical precedence is numeric values, uppercase letters, + * and lowercase letters. For count ordering, values with the same count are ordered + * alphabetically. With the `curl` command, URL-encode the `+` symbol as `%2B`. */ public interface Sort { /** alphabetical. */ @@ -55,25 +58,25 @@ public interface Sort { protected String wordType; protected String sort; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String wordType; private String sort; + /** + * Instantiates a new Builder from an existing ListWordsOptions instance. + * + * @param listWordsOptions the instance to initialize the Builder with + */ private Builder(ListWordsOptions listWordsOptions) { this.customizationId = listWordsOptions.customizationId; this.wordType = listWordsOptions.wordType; this.sort = listWordsOptions.sort; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -87,7 +90,7 @@ public Builder(String customizationId) { /** * Builds a ListWordsOptions. * - * @return the listWordsOptions + * @return the new ListWordsOptions instance */ public ListWordsOptions build() { return new ListWordsOptions(this); @@ -127,9 +130,11 @@ public Builder sort(String sort) { } } + protected ListWordsOptions() {} + protected ListWordsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; wordType = builder.wordType; sort = builder.sort; @@ -147,8 +152,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -159,11 +165,14 @@ public String customizationId() { /** * Gets the wordType. * - * The type of words to be listed from the custom language model's words resource: - * * `all` (the default) shows all words. - * * `user` shows only custom words that were added or modified by the user directly. - * * `corpora` shows only OOV that were extracted from corpora. - * * `grammars` shows only OOV words that are recognized by grammars. + *

The type of words to be listed from the custom language model's words resource: * `all` (the + * default) shows all words. * `user` shows only custom words that were added or modified by the + * user directly. * `corpora` shows only OOV that were extracted from corpora. * `grammars` shows + * only OOV words that are recognized by grammars. + * + *

_For a custom model that is based on a next-generation model_, only `all` and `user` apply. + * Both options return the same results. Words from other sources are not added to custom models + * that are based on next-generation models. * * @return the wordType */ @@ -174,11 +183,12 @@ public String wordType() { /** * Gets the sort. * - * Indicates the order in which the words are to be listed, `alphabetical` or by `count`. You can prepend an optional - * `+` or `-` to an argument to indicate whether the results are to be sorted in ascending or descending order. By - * default, words are sorted in ascending alphabetical order. For alphabetical ordering, the lexicographical - * precedence is numeric values, uppercase letters, and lowercase letters. For count ordering, values with the same - * count are ordered alphabetically. With the `curl` command, URL-encode the `+` symbol as `%2B`. + *

Indicates the order in which the words are to be listed, `alphabetical` or by `count`. You + * can prepend an optional `+` or `-` to an argument to indicate whether the results are to be + * sorted in ascending or descending order. By default, words are sorted in ascending alphabetical + * order. For alphabetical ordering, the lexicographical precedence is numeric values, uppercase + * letters, and lowercase letters. For count ordering, values with the same count are ordered + * alphabetically. With the `curl` command, URL-encode the `+` symbol as `%2B`. * * @return the sort */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java index 5fdec1a7fba..13909777a86 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,30 +10,35 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Detailed timing information about the service's processing of the input audio. - */ +/** Detailed timing information about the service's processing of the input audio. */ public class ProcessedAudio extends GenericModel { protected Float received; + @SerializedName("seen_by_engine") protected Float seenByEngine; + protected Float transcription; + @SerializedName("speaker_labels") protected Float speakerLabels; + protected ProcessedAudio() {} + /** * Gets the received. * - * The seconds of audio that the service has received as of this response. The value of the field is greater than the - * values of the `transcription` and `speaker_labels` fields during speech recognition processing, since the service - * first has to receive the audio before it can begin to process it. The final value can also be greater than the - * value of the `transcription` and `speaker_labels` fields by a fractional number of seconds. + *

The seconds of audio that the service has received as of this response. The value of the + * field is greater than the values of the `transcription` and `speaker_labels` fields during + * speech recognition processing, since the service first has to receive the audio before it can + * begin to process it. The final value can also be greater than the value of the `transcription` + * and `speaker_labels` fields by a fractional number of seconds. * * @return the received */ @@ -44,11 +49,12 @@ public Float getReceived() { /** * Gets the seenByEngine. * - * The seconds of audio that the service has passed to its speech-processing engine as of this response. The value of - * the field is greater than the values of the `transcription` and `speaker_labels` fields during speech recognition - * processing. The `received` and `seen_by_engine` fields have identical values when the service has finished - * processing all audio. This final value can be greater than the value of the `transcription` and `speaker_labels` - * fields by a fractional number of seconds. + *

The seconds of audio that the service has passed to its speech-processing engine as of this + * response. The value of the field is greater than the values of the `transcription` and + * `speaker_labels` fields during speech recognition processing. The `received` and + * `seen_by_engine` fields have identical values when the service has finished processing all + * audio. This final value can be greater than the value of the `transcription` and + * `speaker_labels` fields by a fractional number of seconds. * * @return the seenByEngine */ @@ -59,7 +65,8 @@ public Float getSeenByEngine() { /** * Gets the transcription. * - * The seconds of audio that the service has processed for speech recognition as of this response. + *

The seconds of audio that the service has processed for speech recognition as of this + * response. * * @return the transcription */ @@ -70,10 +77,11 @@ public Float getTranscription() { /** * Gets the speakerLabels. * - * If speaker labels are requested, the seconds of audio that the service has processed to determine speaker labels as - * of this response. This value often trails the value of the `transcription` field during speech recognition - * processing. The `transcription` and `speaker_labels` fields have identical values when the service has finished - * processing all audio. + *

If speaker labels are requested, the seconds of audio that the service has processed to + * determine speaker labels as of this response. This value often trails the value of the + * `transcription` field during speech recognition processing. The `transcription` and + * `speaker_labels` fields have identical values when the service has finished processing all + * audio. * * @return the speakerLabels */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java index d6f7fce626c..f67da215252 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,27 +10,33 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * If processing metrics are requested, information about the service's processing of the input audio. Processing - * metrics are not available with the synchronous **Recognize audio** method. + * If processing metrics are requested, information about the service's processing of the input + * audio. Processing metrics are not available with the synchronous [Recognize audio](#recognize) + * method. */ public class ProcessingMetrics extends GenericModel { @SerializedName("processed_audio") protected ProcessedAudio processedAudio; + @SerializedName("wall_clock_since_first_byte_received") protected Float wallClockSinceFirstByteReceived; + protected Boolean periodic; + protected ProcessingMetrics() {} + /** * Gets the processedAudio. * - * Detailed timing information about the service's processing of the input audio. + *

Detailed timing information about the service's processing of the input audio. * * @return the processedAudio */ @@ -41,12 +47,13 @@ public ProcessedAudio getProcessedAudio() { /** * Gets the wallClockSinceFirstByteReceived. * - * The amount of real time in seconds that has passed since the service received the first byte of input audio. Values - * in this field are generally multiples of the specified metrics interval, with two differences: - * * Values might not reflect exact intervals (for instance, 0.25, 0.5, and so on). Actual values might be 0.27, 0.52, - * and so on, depending on when the service receives and processes audio. - * * The service also returns values for transcription events if you set the `interim_results` parameter to `true`. - * The service returns both processing metrics and transcription results when such events occur. + *

The amount of real time in seconds that has passed since the service received the first byte + * of input audio. Values in this field are generally multiples of the specified metrics interval, + * with two differences: * Values might not reflect exact intervals (for instance, 0.25, 0.5, and + * so on). Actual values might be 0.27, 0.52, and so on, depending on when the service receives + * and processes audio. * The service also returns values for transcription events if you set the + * `interim_results` parameter to `true`. The service returns both processing metrics and + * transcription results when such events occur. * * @return the wallClockSinceFirstByteReceived */ @@ -57,13 +64,14 @@ public Float getWallClockSinceFirstByteReceived() { /** * Gets the periodic. * - * An indication of whether the metrics apply to a periodic interval or a transcription event: - * * `true` means that the response was triggered by a specified processing interval. The information contains - * processing metrics only. - * * `false` means that the response was triggered by a transcription event. The information contains processing - * metrics plus transcription results. + *

An indication of whether the metrics apply to a periodic interval or a transcription event: + * * `true` means that the response was triggered by a specified processing interval. The + * information contains processing metrics only. * `false` means that the response was triggered + * by a transcription event. The information contains processing metrics plus transcription + * results. * - * Use the field to identify why the service generated the response and to filter different results if necessary. + *

Use the field to identify why the service generated the response and to filter different + * results if necessary. * * @return the periodic */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java index 957064f45f4..08ac9875f2e 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,27 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about a current asynchronous speech recognition job. - */ +/** Information about a current asynchronous speech recognition job. */ public class RecognitionJob extends GenericModel { /** - * The current status of the job: - * * `waiting`: The service is preparing the job for processing. The service returns this status when the job is - * initially created or when it is waiting for capacity to process the job. The job remains in this state until the - * service has the capacity to begin processing it. - * * `processing`: The service is actively processing the job. - * * `completed`: The service has finished processing the job. If the job specified a callback URL and the event - * `recognitions.completed_with_results`, the service sent the results with the callback notification. Otherwise, you - * must retrieve the results by checking the individual job. + * The current status of the job: * `waiting`: The service is preparing the job for processing. + * The service returns this status when the job is initially created or when it is waiting for + * capacity to process the job. The job remains in this state until the service has the capacity + * to begin processing it. * `processing`: The service is actively processing the job. * + * `completed`: The service has finished processing the job. If the job specified a callback URL + * and the event `recognitions.completed_with_results`, the service sent the results with the + * callback notification. Otherwise, you must retrieve the results by checking the individual job. * * `failed`: The job failed. */ public interface Status { @@ -49,15 +46,19 @@ public interface Status { protected String created; protected String updated; protected String url; + @SerializedName("user_token") protected String userToken; + protected List results; protected List warnings; + protected RecognitionJob() {} + /** * Gets the id. * - * The ID of the asynchronous job. + *

The ID of the asynchronous job. * * @return the id */ @@ -68,14 +69,13 @@ public String getId() { /** * Gets the status. * - * The current status of the job: - * * `waiting`: The service is preparing the job for processing. The service returns this status when the job is - * initially created or when it is waiting for capacity to process the job. The job remains in this state until the - * service has the capacity to begin processing it. - * * `processing`: The service is actively processing the job. - * * `completed`: The service has finished processing the job. If the job specified a callback URL and the event - * `recognitions.completed_with_results`, the service sent the results with the callback notification. Otherwise, you - * must retrieve the results by checking the individual job. + *

The current status of the job: * `waiting`: The service is preparing the job for processing. + * The service returns this status when the job is initially created or when it is waiting for + * capacity to process the job. The job remains in this state until the service has the capacity + * to begin processing it. * `processing`: The service is actively processing the job. * + * `completed`: The service has finished processing the job. If the job specified a callback URL + * and the event `recognitions.completed_with_results`, the service sent the results with the + * callback notification. Otherwise, you must retrieve the results by checking the individual job. * * `failed`: The job failed. * * @return the status @@ -87,8 +87,8 @@ public String getStatus() { /** * Gets the created. * - * The date and time in Coordinated Universal Time (UTC) at which the job was created. The value is provided in full - * ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + *

The date and time in Coordinated Universal Time (UTC) at which the job was created. The + * value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). * * @return the created */ @@ -99,9 +99,9 @@ public String getCreated() { /** * Gets the updated. * - * The date and time in Coordinated Universal Time (UTC) at which the job was last updated by the service. The value - * is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). This field is returned only by the **Check jobs** - * and **Check a job** methods. + *

The date and time in Coordinated Universal Time (UTC) at which the job was last updated by + * the service. The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). This + * field is returned only by the [Check jobs](#checkjobs) and [Check a job[(#checkjob) methods. * * @return the updated */ @@ -112,8 +112,8 @@ public String getUpdated() { /** * Gets the url. * - * The URL to use to request information about the job with the **Check a job** method. This field is returned only by - * the **Create a job** method. + *

The URL to use to request information about the job with the [Check a job](#checkjob) + * method. This field is returned only by the [Create a job](#createjob) method. * * @return the url */ @@ -124,8 +124,8 @@ public String getUrl() { /** * Gets the userToken. * - * The user token associated with a job that was created with a callback URL and a user token. This field can be - * returned only by the **Check jobs** method. + *

The user token associated with a job that was created with a callback URL and a user token. + * This field can be returned only by the [Check jobs](#checkjobs) method. * * @return the userToken */ @@ -136,8 +136,9 @@ public String getUserToken() { /** * Gets the results. * - * If the status is `completed`, the results of the recognition request as an array that includes a single instance of - * a `SpeechRecognitionResults` object. This field is returned only by the **Check a job** method. + *

If the status is `completed`, the results of the recognition request as an array that + * includes a single instance of a `SpeechRecognitionResults` object. This field is returned only + * by the [Check a job](#checkjob) method. * * @return the results */ @@ -148,10 +149,12 @@ public List getResults() { /** * Gets the warnings. * - * An array of warning messages about invalid parameters included with the request. Each warning includes a - * descriptive message and a list of invalid argument strings, for example, `"unexpected query parameter 'user_token', - * query parameter 'callback_url' was not specified"`. The request succeeds despite the warnings. This field can be - * returned only by the **Create a job** method. + *

An array of warning messages about invalid parameters included with the request. Each + * warning includes a descriptive message and a list of invalid argument strings, for example, + * `"unexpected query parameter 'user_token', query parameter 'callback_url' was not specified"`. + * The request succeeds despite the warnings. This field can be returned only by the [Create a + * job](#createjob) method. (If you use the `character_insertion_bias` parameter with a + * previous-generation model, the warning message refers to the parameter as `lambdaBias`.). * * @return the warnings */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java index 3c7101fe383..89280df2bc1 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about current asynchronous speech recognition jobs. - */ +/** Information about current asynchronous speech recognition jobs. */ public class RecognitionJobs extends GenericModel { protected List recognitions; + protected RecognitionJobs() {} + /** * Gets the recognitions. * - * An array of `RecognitionJob` objects that provides the status for each of the user's current jobs. The array is - * empty if the user has no current jobs. + *

An array of `RecognitionJob` objects that provides the status for each of the user's current + * jobs. The array is empty if the user has no current jobs. * * @return the recognitions */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java index 2fa26a543a7..dce3f99c6fd 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2026. * * 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 @@ -10,8 +10,10 @@ * 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.speech_to_text.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -19,93 +21,202 @@ import java.util.ArrayList; import java.util.List; -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The recognize options. - */ +/** The recognize options. */ public class RecognizeOptions extends GenericModel { /** - * The identifier of the model that is to be used for the recognition request. See [Languages and - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + * The model to use for speech recognition. If you omit the `model` parameter, the service uses + * the US English `en-US_BroadbandModel` by default. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_BroadbandModel`, you must + * either specify a model with the request or specify a new default model for your installation of + * the service. + * + *

**See also:** * [Using a model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use) * + * [Using the default + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use#models-use-default). */ public interface Model { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; + /** ar-MS_BroadbandModel. */ + String AR_MS_BROADBANDMODEL = "ar-MS_BroadbandModel"; + /** ar-MS_Telephony. */ + String AR_MS_TELEPHONY = "ar-MS_Telephony"; + /** cs-CZ_Telephony. */ + String CS_CZ_TELEPHONY = "cs-CZ_Telephony"; + /** de-DE. */ + String DE_DE = "de-DE"; /** de-DE_BroadbandModel. */ String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; + /** de-DE_Multimedia. */ + String DE_DE_MULTIMEDIA = "de-DE_Multimedia"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** de-DE_Telephony. */ + String DE_DE_TELEPHONY = "de-DE_Telephony"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_Multimedia. */ + String EN_AU_MULTIMEDIA = "en-AU_Multimedia"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; + /** en-AU_Telephony. */ + String EN_AU_TELEPHONY = "en-AU_Telephony"; + /** en-IN. */ + String EN_IN = "en-IN"; + /** en-IN_Telephony. */ + String EN_IN_TELEPHONY = "en-IN_Telephony"; + /** en-GB. */ + String EN_GB = "en-GB"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; + /** en-GB_Multimedia. */ + String EN_GB_MULTIMEDIA = "en-GB_Multimedia"; /** en-GB_NarrowbandModel. */ String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; + /** en-GB_Telephony. */ + String EN_GB_TELEPHONY = "en-GB_Telephony"; + /** en-US. */ + String EN_US = "en-US"; /** en-US_BroadbandModel. */ String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; + /** en-US_Multimedia. */ + String EN_US_MULTIMEDIA = "en-US_Multimedia"; /** en-US_NarrowbandModel. */ String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; /** en-US_ShortForm_NarrowbandModel. */ String EN_US_SHORTFORM_NARROWBANDMODEL = "en-US_ShortForm_NarrowbandModel"; + /** en-US_Telephony. */ + String EN_US_TELEPHONY = "en-US_Telephony"; + /** en-WW_Medical_Telephony. */ + String EN_WW_MEDICAL_TELEPHONY = "en-WW_Medical_Telephony"; + /** es-AR. */ + String ES_AR = "es-AR"; /** es-AR_BroadbandModel. */ String ES_AR_BROADBANDMODEL = "es-AR_BroadbandModel"; /** es-AR_NarrowbandModel. */ String ES_AR_NARROWBANDMODEL = "es-AR_NarrowbandModel"; + /** es-CL. */ + String ES_CL = "es-CL"; /** es-CL_BroadbandModel. */ String ES_CL_BROADBANDMODEL = "es-CL_BroadbandModel"; /** es-CL_NarrowbandModel. */ String ES_CL_NARROWBANDMODEL = "es-CL_NarrowbandModel"; + /** es-CO. */ + String ES_CO = "es-CO"; /** es-CO_BroadbandModel. */ String ES_CO_BROADBANDMODEL = "es-CO_BroadbandModel"; /** es-CO_NarrowbandModel. */ String ES_CO_NARROWBANDMODEL = "es-CO_NarrowbandModel"; + /** es-ES. */ + String ES_ES = "es-ES"; /** es-ES_BroadbandModel. */ String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; /** es-ES_NarrowbandModel. */ String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; + /** es-ES_Multimedia. */ + String ES_ES_MULTIMEDIA = "es-ES_Multimedia"; + /** es-ES_Telephony. */ + String ES_ES_TELEPHONY = "es-ES_Telephony"; + /** es-LA_Telephony. */ + String ES_LA_TELEPHONY = "es-LA_Telephony"; + /** es-MX. */ + String ES_MX = "es-MX"; /** es-MX_BroadbandModel. */ String ES_MX_BROADBANDMODEL = "es-MX_BroadbandModel"; /** es-MX_NarrowbandModel. */ String ES_MX_NARROWBANDMODEL = "es-MX_NarrowbandModel"; + /** es-PE. */ + String ES_PE = "es-PE"; /** es-PE_BroadbandModel. */ String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_Multimedia. */ + String FR_CA_MULTIMEDIA = "fr-CA_Multimedia"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; + /** fr-CA_Telephony. */ + String FR_CA_TELEPHONY = "fr-CA_Telephony"; + /** fr-FR. */ + String FR_FR = "fr-FR"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; + /** fr-FR_Multimedia. */ + String FR_FR_MULTIMEDIA = "fr-FR_Multimedia"; /** fr-FR_NarrowbandModel. */ String FR_FR_NARROWBANDMODEL = "fr-FR_NarrowbandModel"; + /** fr-FR_Telephony. */ + String FR_FR_TELEPHONY = "fr-FR_Telephony"; + /** hi-IN_Telephony. */ + String HI_IN_TELEPHONY = "hi-IN_Telephony"; /** it-IT_BroadbandModel. */ String IT_IT_BROADBANDMODEL = "it-IT_BroadbandModel"; /** it-IT_NarrowbandModel. */ String IT_IT_NARROWBANDMODEL = "it-IT_NarrowbandModel"; + /** it-IT_Multimedia. */ + String IT_IT_MULTIMEDIA = "it-IT_Multimedia"; + /** it-IT_Telephony. */ + String IT_IT_TELEPHONY = "it-IT_Telephony"; + /** ja-JP. */ + String JA_JP = "ja-JP"; /** ja-JP_BroadbandModel. */ String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; + /** ja-JP_Multimedia. */ + String JA_JP_MULTIMEDIA = "ja-JP_Multimedia"; /** ja-JP_NarrowbandModel. */ String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; + /** ja-JP_Telephony. */ + String JA_JP_TELEPHONY = "ja-JP_Telephony"; /** ko-KR_BroadbandModel. */ String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; + /** ko-KR_Multimedia. */ + String KO_KR_MULTIMEDIA = "ko-KR_Multimedia"; /** ko-KR_NarrowbandModel. */ String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; + /** ko-KR_Telephony. */ + String KO_KR_TELEPHONY = "ko-KR_Telephony"; + /** nl-BE_Telephony. */ + String NL_BE_TELEPHONY = "nl-BE_Telephony"; /** nl-NL_BroadbandModel. */ String NL_NL_BROADBANDMODEL = "nl-NL_BroadbandModel"; + /** nl-NL_Multimedia. */ + String NL_NL_MULTIMEDIA = "nl-NL_Multimedia"; /** nl-NL_NarrowbandModel. */ String NL_NL_NARROWBANDMODEL = "nl-NL_NarrowbandModel"; + /** nl-NL_Telephony. */ + String NL_NL_TELEPHONY = "nl-NL_Telephony"; + /** pt-BR. */ + String PT_BR = "pt-BR"; /** pt-BR_BroadbandModel. */ String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; + /** pt-BR_Multimedia. */ + String PT_BR_MULTIMEDIA = "pt-BR_Multimedia"; /** pt-BR_NarrowbandModel. */ String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; + /** pt-BR_Telephony. */ + String PT_BR_TELEPHONY = "pt-BR_Telephony"; + /** sv-SE_Telephony. */ + String SV_SE_TELEPHONY = "sv-SE_Telephony"; /** zh-CN_BroadbandModel. */ String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; /** zh-CN_NarrowbandModel. */ String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; + /** zh-CN_Telephony. */ + String ZH_CN_TELEPHONY = "zh-CN_Telephony"; } - protected transient InputStream audio; - @SerializedName("content-type") + protected InputStream audio; protected String contentType; protected String model; + protected Boolean speechBeginEvent; + protected String enrichments; protected String languageCustomizationId; protected String acousticCustomizationId; protected String baseModelVersion; @@ -119,24 +230,26 @@ public interface Model { protected Boolean timestamps; protected Boolean profanityFilter; protected Boolean smartFormatting; + protected Long smartFormattingVersion; protected Boolean speakerLabels; - protected String customizationId; protected String grammarName; protected Boolean redaction; protected Boolean audioMetrics; - private Boolean interimResults; - private Boolean processingMetrics; - private Float processingMetricsInterval; protected Double endOfPhraseSilenceTime; protected Boolean splitTranscriptAtPhraseEnd; + protected Float speechDetectorSensitivity; + protected Long sadModule; + protected Float backgroundAudioSuppression; + protected Boolean lowLatency; + protected Float characterInsertionBias; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private InputStream audio; private String contentType; private String model; + private Boolean speechBeginEvent; + private String enrichments; private String languageCustomizationId; private String acousticCustomizationId; private String baseModelVersion; @@ -150,21 +263,30 @@ public static class Builder { private Boolean timestamps; private Boolean profanityFilter; private Boolean smartFormatting; + private Long smartFormattingVersion; private Boolean speakerLabels; - private String customizationId; private String grammarName; private Boolean redaction; private Boolean audioMetrics; - private Boolean interimResults; - private Boolean processingMetrics; - private Float processingMetricsInterval; private Double endOfPhraseSilenceTime; private Boolean splitTranscriptAtPhraseEnd; + private Float speechDetectorSensitivity; + private Long sadModule; + private Float backgroundAudioSuppression; + private Boolean lowLatency; + private Float characterInsertionBias; + /** + * Instantiates a new Builder from an existing RecognizeOptions instance. + * + * @param recognizeOptions the instance to initialize the Builder with + */ private Builder(RecognizeOptions recognizeOptions) { this.audio = recognizeOptions.audio; this.contentType = recognizeOptions.contentType; this.model = recognizeOptions.model; + this.speechBeginEvent = recognizeOptions.speechBeginEvent; + this.enrichments = recognizeOptions.enrichments; this.languageCustomizationId = recognizeOptions.languageCustomizationId; this.acousticCustomizationId = recognizeOptions.acousticCustomizationId; this.baseModelVersion = recognizeOptions.baseModelVersion; @@ -178,23 +300,22 @@ private Builder(RecognizeOptions recognizeOptions) { this.timestamps = recognizeOptions.timestamps; this.profanityFilter = recognizeOptions.profanityFilter; this.smartFormatting = recognizeOptions.smartFormatting; + this.smartFormattingVersion = recognizeOptions.smartFormattingVersion; this.speakerLabels = recognizeOptions.speakerLabels; - this.customizationId = recognizeOptions.customizationId; this.grammarName = recognizeOptions.grammarName; this.redaction = recognizeOptions.redaction; this.audioMetrics = recognizeOptions.audioMetrics; - this.interimResults = recognizeOptions.interimResults; - this.processingMetrics = recognizeOptions.processingMetrics; - this.processingMetricsInterval = recognizeOptions.processingMetricsInterval; this.endOfPhraseSilenceTime = recognizeOptions.endOfPhraseSilenceTime; this.splitTranscriptAtPhraseEnd = recognizeOptions.splitTranscriptAtPhraseEnd; + this.speechDetectorSensitivity = recognizeOptions.speechDetectorSensitivity; + this.sadModule = recognizeOptions.sadModule; + this.backgroundAudioSuppression = recognizeOptions.backgroundAudioSuppression; + this.lowLatency = recognizeOptions.lowLatency; + this.characterInsertionBias = recognizeOptions.characterInsertionBias; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -208,21 +329,20 @@ public Builder(InputStream audio) { /** * Builds a RecognizeOptions. * - * @return the recognizeOptions + * @return the new RecognizeOptions instance */ public RecognizeOptions build() { return new RecognizeOptions(this); } /** - * Adds an keyword to keywords. + * Adds a new element to keywords. * - * @param keyword the new keyword + * @param keyword the new element to be added * @return the RecognizeOptions builder */ public Builder addKeyword(String keyword) { - com.ibm.cloud.sdk.core.util.Validator.notNull(keyword, - "keyword cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(keyword, "keyword cannot be null"); if (this.keywords == null) { this.keywords = new ArrayList(); } @@ -263,6 +383,28 @@ public Builder model(String model) { return this; } + /** + * Set the speechBeginEvent. + * + * @param speechBeginEvent the speechBeginEvent + * @return the RecognizeOptions builder + */ + public Builder speechBeginEvent(Boolean speechBeginEvent) { + this.speechBeginEvent = speechBeginEvent; + return this; + } + + /** + * Set the enrichments. + * + * @param enrichments the enrichments + * @return the RecognizeOptions builder + */ + public Builder enrichments(String enrichments) { + this.enrichments = enrichments; + return this; + } + /** * Set the languageCustomizationId. * @@ -319,8 +461,7 @@ public Builder inactivityTimeout(long inactivityTimeout) { } /** - * Set the keywords. - * Existing keywords will be replaced. + * Set the keywords. Existing keywords will be replaced. * * @param keywords the keywords * @return the RecognizeOptions builder @@ -408,24 +549,24 @@ public Builder smartFormatting(Boolean smartFormatting) { } /** - * Set the speakerLabels. + * Set the smartFormattingVersion. * - * @param speakerLabels the speakerLabels + * @param smartFormattingVersion the smartFormattingVersion * @return the RecognizeOptions builder */ - public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = speakerLabels; + public Builder smartFormattingVersion(long smartFormattingVersion) { + this.smartFormattingVersion = smartFormattingVersion; return this; } /** - * Set the customizationId. + * Set the speakerLabels. * - * @param customizationId the customizationId + * @param speakerLabels the speakerLabels * @return the RecognizeOptions builder */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; + public Builder speakerLabels(Boolean speakerLabels) { + this.speakerLabels = speakerLabels; return this; } @@ -463,63 +604,79 @@ public Builder audioMetrics(Boolean audioMetrics) { } /** - * Set the interimResults. - * - * NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * Set the endOfPhraseSilenceTime. * - * @param interimResults the interimResults - * @return the interimResults + * @param endOfPhraseSilenceTime the endOfPhraseSilenceTime + * @return the RecognizeOptions builder */ - public Builder interimResults(Boolean interimResults) { - this.interimResults = interimResults; + public Builder endOfPhraseSilenceTime(Double endOfPhraseSilenceTime) { + this.endOfPhraseSilenceTime = endOfPhraseSilenceTime; return this; } /** - * Set the processingMetrics. + * Set the splitTranscriptAtPhraseEnd. * - * NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * @param splitTranscriptAtPhraseEnd the splitTranscriptAtPhraseEnd + * @return the RecognizeOptions builder + */ + public Builder splitTranscriptAtPhraseEnd(Boolean splitTranscriptAtPhraseEnd) { + this.splitTranscriptAtPhraseEnd = splitTranscriptAtPhraseEnd; + return this; + } + + /** + * Set the speechDetectorSensitivity. * - * @param processingMetrics the processingMetrics - * @return the processingMetrics + * @param speechDetectorSensitivity the speechDetectorSensitivity + * @return the RecognizeOptions builder */ - public Builder processingMetrics(Boolean processingMetrics) { - this.processingMetrics = processingMetrics; + public Builder speechDetectorSensitivity(Float speechDetectorSensitivity) { + this.speechDetectorSensitivity = speechDetectorSensitivity; return this; } /** - * Set the processingMetricsInterval. + * Set the sadModule. * - * NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * @param sadModule the sadModule + * @return the RecognizeOptions builder + */ + public Builder sadModule(long sadModule) { + this.sadModule = sadModule; + return this; + } + + /** + * Set the backgroundAudioSuppression. * - * @param processingMetricsInterval the processingMetricsInterval - * @return the processingMetricsInterval + * @param backgroundAudioSuppression the backgroundAudioSuppression + * @return the RecognizeOptions builder */ - public Builder processingMetricsInterval(Float processingMetricsInterval) { - this.processingMetricsInterval = processingMetricsInterval; + public Builder backgroundAudioSuppression(Float backgroundAudioSuppression) { + this.backgroundAudioSuppression = backgroundAudioSuppression; return this; } /** - * Set the endOfPhraseSilenceTime. + * Set the lowLatency. * - * @param endOfPhraseSilenceTime the endOfPhraseSilenceTime + * @param lowLatency the lowLatency * @return the RecognizeOptions builder */ - public Builder endOfPhraseSilenceTime(Double endOfPhraseSilenceTime) { - this.endOfPhraseSilenceTime = endOfPhraseSilenceTime; + public Builder lowLatency(Boolean lowLatency) { + this.lowLatency = lowLatency; return this; } /** - * Set the splitTranscriptAtPhraseEnd. + * Set the characterInsertionBias. * - * @param splitTranscriptAtPhraseEnd the splitTranscriptAtPhraseEnd + * @param characterInsertionBias the characterInsertionBias * @return the RecognizeOptions builder */ - public Builder splitTranscriptAtPhraseEnd(Boolean splitTranscriptAtPhraseEnd) { - this.splitTranscriptAtPhraseEnd = splitTranscriptAtPhraseEnd; + public Builder characterInsertionBias(Float characterInsertionBias) { + this.characterInsertionBias = characterInsertionBias; return this; } @@ -528,7 +685,6 @@ public Builder splitTranscriptAtPhraseEnd(Boolean splitTranscriptAtPhraseEnd) { * * @param audio the audio * @return the RecognizeOptions builder - * * @throws FileNotFoundException if the file could not be found */ public Builder audio(File audio) throws FileNotFoundException { @@ -537,12 +693,15 @@ public Builder audio(File audio) throws FileNotFoundException { } } + protected RecognizeOptions() {} + protected RecognizeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, - "audio cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, "audio cannot be null"); audio = builder.audio; contentType = builder.contentType; model = builder.model; + speechBeginEvent = builder.speechBeginEvent; + enrichments = builder.enrichments; languageCustomizationId = builder.languageCustomizationId; acousticCustomizationId = builder.acousticCustomizationId; baseModelVersion = builder.baseModelVersion; @@ -556,16 +715,18 @@ protected RecognizeOptions(Builder builder) { timestamps = builder.timestamps; profanityFilter = builder.profanityFilter; smartFormatting = builder.smartFormatting; + smartFormattingVersion = builder.smartFormattingVersion; speakerLabels = builder.speakerLabels; - customizationId = builder.customizationId; grammarName = builder.grammarName; redaction = builder.redaction; audioMetrics = builder.audioMetrics; - interimResults = builder.interimResults; - processingMetrics = builder.processingMetrics; - processingMetricsInterval = builder.processingMetricsInterval; endOfPhraseSilenceTime = builder.endOfPhraseSilenceTime; splitTranscriptAtPhraseEnd = builder.splitTranscriptAtPhraseEnd; + speechDetectorSensitivity = builder.speechDetectorSensitivity; + sadModule = builder.sadModule; + backgroundAudioSuppression = builder.backgroundAudioSuppression; + lowLatency = builder.lowLatency; + characterInsertionBias = builder.characterInsertionBias; } /** @@ -580,7 +741,7 @@ public Builder newBuilder() { /** * Gets the audio. * - * The audio to transcribe. + *

The audio to transcribe. * * @return the audio */ @@ -591,8 +752,8 @@ public InputStream audio() { /** * Gets the contentType. * - * The format (MIME type) of the audio. For more information about specifying an audio format, see **Audio formats - * (content types)** in the method description. + *

The format (MIME type) of the audio. For more information about specifying an audio format, + * see **Audio formats (content types)** in the method description. * * @return the contentType */ @@ -603,8 +764,17 @@ public String contentType() { /** * Gets the model. * - * The identifier of the model that is to be used for the recognition request. See [Languages and - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + *

The model to use for speech recognition. If you omit the `model` parameter, the service uses + * the US English `en-US_BroadbandModel` by default. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_BroadbandModel`, you must + * either specify a model with the request or specify a new default model for your installation of + * the service. + * + *

**See also:** * [Using a model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use) * + * [Using the default + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use#models-use-default). * * @return the model */ @@ -612,16 +782,52 @@ public String model() { return model; } + /** + * Gets the speechBeginEvent. + * + *

If `true`, the service returns a response object `SpeechActivity` which contains the time + * when a speech activity is detected in the stream. This can be used both in standard and low + * latency mode. This feature enables client applications to know that some words/speech has been + * detected and the service is in the process of decoding. This can be used in lieu of interim + * results in standard mode. Use `sad_module: 2` to increase accuracy and performance in detecting + * speech boundaries within the audio stream. See [Using speech recognition + * parameters](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-service-features#features-parameters). + * + * @return the speechBeginEvent + */ + public Boolean speechBeginEvent() { + return speechBeginEvent; + } + + /** + * Gets the enrichments. + * + *

Speech transcript enrichment improves readability of raw ASR transcripts by adding + * punctuation (periods, commas, question marks, exclamation points) and intelligent + * capitalization (sentence beginnings, proper nouns, acronyms, brand names). To enable + * enrichment, add the `enrichments=punctuation` parameter to your recognition request. Supported + * languages include English (US, UK, Australia, India), French (France, Canada), German, Italian, + * Portuguese (Brazil, Portugal), Spanish (Spain, Latin America, Argentina, Chile, Colombia, + * Mexico, Peru), and Japanese. See [Speech transcript + * enrichment](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speech-transcript-enrichment). + * + * @return the enrichments + */ + public String enrichments() { + return enrichments; + } + /** * Gets the languageCustomizationId. * - * The customization ID (GUID) of a custom language model that is to be used with the recognition request. The base - * model of the specified custom language model must match the model specified with the `model` parameter. You must - * make the request with credentials for the instance of the service that owns the custom model. By default, no custom - * language model is used. See [Custom - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + *

The customization ID (GUID) of a custom language model that is to be used with the + * recognition request. The base model of the specified custom language model must match the model + * specified with the `model` parameter. You must make the request with credentials for the + * instance of the service that owns the custom model. By default, no custom language model is + * used. See [Using a custom language model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageUse). * - * **Note:** Use this parameter instead of the deprecated `customization_id` parameter. + *

**Note:** Use this parameter instead of the deprecated `customization_id` parameter. * * @return the languageCustomizationId */ @@ -632,11 +838,12 @@ public String languageCustomizationId() { /** * Gets the acousticCustomizationId. * - * The customization ID (GUID) of a custom acoustic model that is to be used with the recognition request. The base - * model of the specified custom acoustic model must match the model specified with the `model` parameter. You must - * make the request with credentials for the instance of the service that owns the custom model. By default, no custom - * acoustic model is used. See [Custom - * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + *

The customization ID (GUID) of a custom acoustic model that is to be used with the + * recognition request. The base model of the specified custom acoustic model must match the model + * specified with the `model` parameter. You must make the request with credentials for the + * instance of the service that owns the custom model. By default, no custom acoustic model is + * used. See [Using a custom acoustic model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acousticUse). * * @return the acousticCustomizationId */ @@ -647,11 +854,12 @@ public String acousticCustomizationId() { /** * Gets the baseModelVersion. * - * The version of the specified base model that is to be used with the recognition request. Multiple versions of a - * base model can exist when a model is updated for internal improvements. The parameter is intended primarily for use - * with custom models that have been upgraded for a new base model. The default value depends on whether the parameter - * is used with or without a custom model. See [Base model - * version](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#version). + *

The version of the specified base model that is to be used with the recognition request. + * Multiple versions of a base model can exist when a model is updated for internal improvements. + * The parameter is intended primarily for use with custom models that have been upgraded for a + * new base model. The default value depends on whether the parameter is used with or without a + * custom model. See [Making speech recognition requests with upgraded custom + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade-use#custom-upgrade-use-recognition). * * @return the baseModelVersion */ @@ -662,19 +870,23 @@ public String baseModelVersion() { /** * Gets the customizationWeight. * - * If you specify the customization ID (GUID) of a custom language model with the recognition request, the - * customization weight tells the service how much weight to give to words from the custom language model compared to - * those from the base model for the current request. + *

If you specify the customization ID (GUID) of a custom language model with the recognition + * request, the customization weight tells the service how much weight to give to words from the + * custom language model compared to those from the base model for the current request. * - * Specify a value between 0.0 and 1.0. Unless a different customization weight was specified for the custom model - * when it was trained, the default value is 0.3. A customization weight that you specify overrides a weight that was - * specified when the custom model was trained. + *

Specify a value between 0.0 and 1.0. Unless a different customization weight was specified + * for the custom model when the model was trained, the default value is: * 0.5 for large speech + * models * 0.3 for previous-generation models * 0.2 for most next-generation models * 0.1 for + * next-generation English and Japanese models * - * The default value yields the best performance in general. Assign a higher value if your audio makes frequent use of - * OOV words from the custom model. Use caution when setting the weight: a higher value can improve the accuracy of - * phrases from the custom model's domain, but it can negatively affect performance on non-domain phrases. + *

A customization weight that you specify overrides a weight that was specified when the + * custom model was trained. The default value yields the best performance in general. Assign a + * higher value if your audio makes frequent use of OOV words from the custom model. Use caution + * when setting the weight: a higher value can improve the accuracy of phrases from the custom + * model's domain, but it can negatively affect performance on non-domain phrases. * - * See [Custom models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + *

See [Using customization + * weight](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageUse#weight). * * @return the customizationWeight */ @@ -685,9 +897,10 @@ public Double customizationWeight() { /** * Gets the inactivityTimeout. * - * The time in seconds after which, if only silence (no speech) is detected in streaming audio, the connection is - * closed with a 400 error. The parameter is useful for stopping audio submission from a live microphone when a user - * simply walks away. Use `-1` for infinity. See [Inactivity + *

The time in seconds after which, if only silence (no speech) is detected in streaming audio, + * the connection is closed with a 400 error. The parameter is useful for stopping audio + * submission from a live microphone when a user simply walks away. Use `-1` for infinity. See + * [Inactivity * timeout](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#timeouts-inactivity). * * @return the inactivityTimeout @@ -699,11 +912,17 @@ public Long inactivityTimeout() { /** * Gets the keywords. * - * An array of keyword strings to spot in the audio. Each keyword string can include one or more string tokens. - * Keywords are spotted only in the final results, not in interim hypotheses. If you specify any keywords, you must - * also specify a keywords threshold. You can spot a maximum of 1000 keywords. Omit the parameter or specify an empty - * array if you do not need to spot keywords. See [Keyword - * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). + *

An array of keyword strings to spot in the audio. Each keyword string can include one or + * more string tokens. Keywords are spotted only in the final results, not in interim hypotheses. + * If you specify any keywords, you must also specify a keywords threshold. Omit the parameter or + * specify an empty array if you do not need to spot keywords. + * + *

You can spot a maximum of 1000 keywords with a single request. A single keyword can have a + * maximum length of 1024 characters, though the maximum effective length for double-byte + * languages might be shorter. Keywords are case-insensitive. + * + *

See [Keyword + * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-spotting#keyword-spotting). * * @return the keywords */ @@ -714,11 +933,11 @@ public List keywords() { /** * Gets the keywordsThreshold. * - * A confidence value that is the lower bound for spotting a keyword. A word is considered to match a keyword if its - * confidence is greater than or equal to the threshold. Specify a probability between 0.0 and 1.0. If you specify a - * threshold, you must also specify one or more keywords. The service performs no keyword spotting if you omit either - * parameter. See [Keyword - * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). + *

A confidence value that is the lower bound for spotting a keyword. A word is considered to + * match a keyword if its confidence is greater than or equal to the threshold. Specify a + * probability between 0.0 and 1.0. If you specify a threshold, you must also specify one or more + * keywords. The service performs no keyword spotting if you omit either parameter. See [Keyword + * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-spotting#keyword-spotting). * * @return the keywordsThreshold */ @@ -729,9 +948,10 @@ public Float keywordsThreshold() { /** * Gets the maxAlternatives. * - * The maximum number of alternative transcripts that the service is to return. By default, the service returns a - * single transcript. If you specify a value of `0`, the service uses the default value, `1`. See [Maximum - * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#max_alternatives). + *

The maximum number of alternative transcripts that the service is to return. By default, the + * service returns a single transcript. If you specify a value of `0`, the service uses the + * default value, `1`. See [Maximum + * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metadata#max-alternatives). * * @return the maxAlternatives */ @@ -742,11 +962,11 @@ public Long maxAlternatives() { /** * Gets the wordAlternativesThreshold. * - * A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative (also known - * as "Confusion Networks"). An alternative word is considered if its confidence is greater than or equal to the - * threshold. Specify a probability between 0.0 and 1.0. By default, the service computes no alternative words. See - * [Word - * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_alternatives). + *

A confidence value that is the lower bound for identifying a hypothesis as a possible word + * alternative (also known as "Confusion Networks"). An alternative word is considered if its + * confidence is greater than or equal to the threshold. Specify a probability between 0.0 and + * 1.0. By default, the service computes no alternative words. See [Word + * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-spotting#word-alternatives). * * @return the wordAlternativesThreshold */ @@ -757,9 +977,9 @@ public Float wordAlternativesThreshold() { /** * Gets the wordConfidence. * - * If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for each word. By default, the - * service returns no word confidence scores. See [Word - * confidence](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_confidence). + *

If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for each + * word. By default, the service returns no word confidence scores. See [Word + * confidence](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metadata#word-confidence). * * @return the wordConfidence */ @@ -770,8 +990,9 @@ public Boolean wordConfidence() { /** * Gets the timestamps. * - * If `true`, the service returns time alignment for each word. By default, no timestamps are returned. See [Word - * timestamps](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_timestamps). + *

If `true`, the service returns time alignment for each word. By default, no timestamps are + * returned. See [Word + * timestamps](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metadata#word-timestamps). * * @return the timestamps */ @@ -782,10 +1003,13 @@ public Boolean timestamps() { /** * Gets the profanityFilter. * - * If `true`, the service filters profanity from all output except for keyword results by replacing inappropriate - * words with a series of asterisks. Set the parameter to `false` to return results with no censoring. Applies to US - * English transcription only. See [Profanity - * filtering](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#profanity_filter). + *

If `true`, the service filters profanity from all output except for keyword results by + * replacing inappropriate words with a series of asterisks. Set the parameter to `false` to + * return results with no censoring. + * + *

**Note:** The parameter can be used with US English and Japanese transcription only. See + * [Profanity + * filtering](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#profanity-filtering). * * @return the profanityFilter */ @@ -796,15 +1020,16 @@ public Boolean profanityFilter() { /** * Gets the smartFormatting. * - * If `true`, the service converts dates, times, series of digits and numbers, phone numbers, currency values, and - * internet addresses into more readable, conventional representations in the final transcript of a recognition - * request. For US English, the service also converts certain keyword strings to punctuation symbols. By default, the - * service performs no smart formatting. + *

If `true`, the service converts dates, times, series of digits and numbers, phone numbers, + * currency values, and internet addresses into more readable, conventional representations in the + * final transcript of a recognition request. For US English, the service also converts certain + * keyword strings to punctuation symbols. By default, the service performs no smart formatting. * - * **Note:** Applies to US English, Japanese, and Spanish transcription only. + *

**Note:** The parameter can be used with US English, Japanese, and Spanish (all dialects) + * transcription only. * - * See [Smart - * formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#smart_formatting). + *

See [Smart + * formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). * * @return the smartFormatting */ @@ -813,45 +1038,49 @@ public Boolean smartFormatting() { } /** - * Gets the speakerLabels. - * - * If `true`, the response includes labels that identify which words were spoken by which participants in a - * multi-person exchange. By default, the service returns no speaker labels. Setting `speaker_labels` to `true` forces - * the `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. - * - * **Note:** Applies to US English, Japanese, and Spanish (both broadband and narrowband models) and UK English - * (narrowband model) transcription only. To determine whether a language model supports speaker labels, you can also - * use the **Get a model** method and check that the attribute `speaker_labels` is set to `true`. + * Gets the smartFormattingVersion. * - * See [Speaker - * labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#speaker_labels). + *

Smart formatting version for large speech models and next-generation models is supported in + * US English, Brazilian Portuguese, French, German, Spanish and French Canadian languages. * - * @return the speakerLabels + * @return the smartFormattingVersion */ - public Boolean speakerLabels() { - return speakerLabels; + public Long smartFormattingVersion() { + return smartFormattingVersion; } /** - * Gets the customizationId. + * Gets the speakerLabels. * - * **Deprecated.** Use the `language_customization_id` parameter to specify the customization ID (GUID) of a custom - * language model that is to be used with the recognition request. Do not specify both parameters with a request. + *

If `true`, the response includes labels that identify which words were spoken by which + * participants in a multi-person exchange. By default, the service returns no speaker labels. + * Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless + * of whether you specify `false` for the parameter. * _For previous-generation models,_ the + * parameter can be used with Australian English, US English, German, Japanese, Korean, and + * Spanish (both broadband and narrowband models) and UK English (narrowband model) transcription + * only. * _For large speech models and next-generation models,_ the parameter can be used with + * all available languages. * - * @return the customizationId + *

See [Speaker + * labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speaker-labels). + * + * @return the speakerLabels */ - public String customizationId() { - return customizationId; + public Boolean speakerLabels() { + return speakerLabels; } /** * Gets the grammarName. * - * The name of a grammar that is to be used with the recognition request. If you specify a grammar, you must also use - * the `language_customization_id` parameter to specify the name of the custom language model for which the grammar is - * defined. The service recognizes only strings that are recognized by the specified grammar; it does not recognize - * other custom words from the model's words resource. See - * [Grammars](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#grammars-input). + *

The name of a grammar that is to be used with the recognition request. If you specify a + * grammar, you must also use the `language_customization_id` parameter to specify the name of the + * custom language model for which the grammar is defined. The service recognizes only strings + * that are recognized by the specified grammar; it does not recognize other custom words from the + * model's words resource. + * + *

See [Using a grammar for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarUse). * * @return the grammarName */ @@ -862,18 +1091,21 @@ public String grammarName() { /** * Gets the redaction. * - * If `true`, the service redacts, or masks, numeric data from final transcripts. The feature redacts any number that - * has three or more consecutive digits by replacing each digit with an `X` character. It is intended to redact - * sensitive numeric data, such as credit card numbers. By default, the service performs no redaction. + *

If `true`, the service redacts, or masks, numeric data from final transcripts. The feature + * redacts any number that has three or more consecutive digits by replacing each digit with an + * `X` character. It is intended to redact sensitive numeric data, such as credit card numbers. By + * default, the service performs no redaction. * - * When you enable redaction, the service automatically enables smart formatting, regardless of whether you explicitly - * disable that feature. To ensure maximum security, the service also disables keyword spotting (ignores the - * `keywords` and `keywords_threshold` parameters) and returns only a single final transcript (forces the - * `max_alternatives` parameter to be `1`). + *

When you enable redaction, the service automatically enables smart formatting, regardless of + * whether you explicitly disable that feature. To ensure maximum security, the service also + * disables keyword spotting (ignores the `keywords` and `keywords_threshold` parameters) and + * returns only a single final transcript (forces the `max_alternatives` parameter to be `1`). * - * **Note:** Applies to US English, Japanese, and Korean transcription only. + *

**Note:** The parameter can be used with US English, Japanese, and Korean transcription + * only. * - * See [Numeric redaction](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#redaction). + *

See [Numeric + * redaction](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#numeric-redaction). * * @return the redaction */ @@ -884,10 +1116,12 @@ public Boolean redaction() { /** * Gets the audioMetrics. * - * If `true`, requests detailed information about the signal characteristics of the input audio. The service returns - * audio metrics with the final transcription results. By default, the service returns no audio metrics. + *

If `true`, requests detailed information about the signal characteristics of the input + * audio. The service returns audio metrics with the final transcription results. By default, the + * service returns no audio metrics. * - * See [Audio metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#audio_metrics). + *

See [Audio + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#audio-metrics). * * @return the audioMetrics */ @@ -896,95 +1130,170 @@ public Boolean audioMetrics() { } /** - * Gets the interimResults. + * Gets the endOfPhraseSilenceTime. * - * If `true`, the service returns interim results as a stream of `SpeechRecognitionResults` objects. By default, - * the service returns a single `SpeechRecognitionResults` object with final results only. + *

Specifies the duration of the pause interval at which the service splits a transcript into + * multiple final results. If the service detects pauses or extended silence before it reaches the + * end of the audio stream, its response can include multiple final results. Silence indicates a + * point at which the speaker pauses between spoken words or phrases. + * + *

Specify a value for the pause interval in the range of 0.0 to 120.0. * A value greater than + * 0 specifies the interval that the service is to use for speech recognition. * A value of 0 + * indicates that the service is to use the default interval. It is equivalent to omitting the + * parameter. * - * NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + *

The default pause interval for most languages is 0.8 seconds; the default for Chinese is 0.6 + * seconds. * - * @return the interimResults + *

See [End of phrase silence + * time](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#silence-time). + * + * @return the endOfPhraseSilenceTime */ - public Boolean interimResults() { - return interimResults; + public Double endOfPhraseSilenceTime() { + return endOfPhraseSilenceTime; } /** - * Gets the processingMetrics. + * Gets the splitTranscriptAtPhraseEnd. * - * If `true`, requests processing metrics about the service's transcription of the input audio. The service returns - * processing metrics at the interval specified by the `processing_metrics_interval` parameter. It also returns - * processing metrics for transcription events, for example, for final and interim results. By default, the service - * returns no processing metrics. + *

If `true`, directs the service to split the transcript into multiple final results based on + * semantic features of the input, for example, at the conclusion of meaningful phrases such as + * sentences. The service bases its understanding of semantic features on the base language model + * that you use with a request. Custom language models and grammars can also influence how and + * where the service splits a transcript. * - * NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + *

By default, the service splits transcripts based solely on the pause interval. If the + * parameters are used together on the same request, `end_of_phrase_silence_time` has precedence + * over `split_transcript_at_phrase_end`. * - * @return the processingMetrics + *

See [Split transcript at phrase + * end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#split-transcript). + * + * @return the splitTranscriptAtPhraseEnd */ - public Boolean processingMetrics() { - return processingMetrics; + public Boolean splitTranscriptAtPhraseEnd() { + return splitTranscriptAtPhraseEnd; } /** - * Gets the processingMetricsInterval. + * Gets the speechDetectorSensitivity. * - * Specifies the interval in real wall-clock seconds at which the service is to return processing metrics. The - * parameter is ignored unless the `processing_metrics` parameter is set to `true`. + *

The sensitivity of speech activity detection that the service is to perform. Use the + * parameter to suppress word insertions from music, coughing, and other non-speech events. The + * service biases the audio it passes for speech recognition by evaluating the input audio against + * prior models of speech and non-speech activity. * - * The parameter accepts a minimum value of 0.1 seconds. The level of precision is not restricted, so you can - * specify values such as 0.25 and 0.125. + *

Specify a value between 0.0 and 1.0: * 0.0 suppresses all audio (no speech is transcribed). + * * 0.5 (the default) provides a reasonable compromise for the level of sensitivity. * 1.0 + * suppresses no audio (speech detection sensitivity is disabled). * - * The service does not impose a maximum value. If you want to receive processing metrics only for transcription - * events instead of at periodic intervals, set the value to a large number. If the value is larger than the - * duration of the audio, the service returns processing metrics only for transcription events. + *

The values increase on a monotonic curve. Specifying one or two decimal places of precision + * (for example, `0.55`) is typically more than sufficient. * - * NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + *

The parameter is supported with all large speech models, next-generation models and with + * most previous-generation models. See [Speech detector + * sensitivity](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-sensitivity) + * and [Language model + * support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). * - * @return the processingMetricsInterval + * @return the speechDetectorSensitivity */ - public Float processingMetricsInterval() { - return processingMetricsInterval; + public Float speechDetectorSensitivity() { + return speechDetectorSensitivity; } /** - * Gets the endOfPhraseSilenceTime. + * Gets the sadModule. * - * If `true`, specifies the duration of the pause interval at which the service splits a transcript into multiple - * final results. If the service detects pauses or extended silence before it reaches the end of the audio stream, its - * response can include multiple final results. Silence indicates a point at which the speaker pauses between spoken - * words or phrases. + *

Detects speech boundaries within the audio stream with better performance, improved noise + * suppression, faster responsiveness, and increased accuracy. * - * Specify a value for the pause interval in the range of 0.0 to 120.0. - * * A value greater than 0 specifies the interval that the service is to use for speech recognition. - * * A value of 0 indicates that the service is to use the default interval. It is equivalent to omitting the - * parameter. + *

Specify `sad_module: 2` * - * The default pause interval for most languages is 0.8 seconds; the default for Chinese is 0.6 seconds. + *

See [Speech Activity Detection + * (SAD)](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#sad). + * + * @return the sadModule + */ + public Long sadModule() { + return sadModule; + } + + /** + * Gets the backgroundAudioSuppression. * - * See [End of phrase silence - * time](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#silence_time). + *

The level to which the service is to suppress background audio based on its volume to + * prevent it from being transcribed as speech. Use the parameter to suppress side conversations + * or background noise. * - * @return the endOfPhraseSilenceTime + *

Specify a value in the range of 0.0 to 1.0: * 0.0 (the default) provides no suppression + * (background audio suppression is disabled). * 0.5 provides a reasonable level of audio + * suppression for general usage. * 1.0 suppresses all audio (no audio is transcribed). + * + *

The values increase on a monotonic curve. Specifying one or two decimal places of precision + * (for example, `0.55`) is typically more than sufficient. + * + *

The parameter is supported with all large speech models, next-generation models and with + * most previous-generation models. See [Background audio + * suppression](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-suppression) + * and [Language model + * support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). + * + * @return the backgroundAudioSuppression */ - public Double endOfPhraseSilenceTime() { - return endOfPhraseSilenceTime; + public Float backgroundAudioSuppression() { + return backgroundAudioSuppression; } /** - * Gets the splitTranscriptAtPhraseEnd. + * Gets the lowLatency. + * + *

If `true` for next-generation `Multimedia` and `Telephony` models that support low latency, + * directs the service to produce results even more quickly than it usually does. Next-generation + * models produce transcription results faster than previous-generation models. The `low_latency` + * parameter causes the models to produce results even more quickly, though the results might be + * less accurate when the parameter is used. + * + *

The parameter is not available for large speech models and previous-generation `Broadband` + * and `Narrowband` models. It is available for most next-generation models. * For a list of + * next-generation models that support low latency, see [Supported next-generation language + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported). + * * For more information about the `low_latency` parameter, see [Low + * latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency). + * + * @return the lowLatency + */ + public Boolean lowLatency() { + return lowLatency; + } + + /** + * Gets the characterInsertionBias. * - * If `true`, directs the service to split the transcript into multiple final results based on semantic features of - * the input, for example, at the conclusion of meaningful phrases such as sentences. The service bases its - * understanding of semantic features on the base language model that you use with a request. Custom language models - * and grammars can also influence how and where the service splits a transcript. By default, the service splits - * transcripts based solely on the pause interval. + *

For large speech models and next-generation models, an indication of whether the service is + * biased to recognize shorter or longer strings of characters when developing transcription + * hypotheses. By default, the service is optimized to produce the best balance of strings of + * different lengths. * - * See [Split transcript at phrase - * end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#split_transcript). + *

The default bias is 0.0. The allowable range of values is -1.0 to 1.0. * Negative values + * bias the service to favor hypotheses with shorter strings of characters. * Positive values bias + * the service to favor hypotheses with longer strings of characters. * - * @return the splitTranscriptAtPhraseEnd + *

As the value approaches -1.0 or 1.0, the impact of the parameter becomes more pronounced. To + * determine the most effective value for your scenario, start by setting the value of the + * parameter to a small increment, such as -0.1, -0.05, 0.05, or 0.1, and assess how the value + * impacts the transcription results. Then experiment with different values as necessary, + * adjusting the value by small increments. + * + *

The parameter is not available for previous-generation models. + * + *

See [Character insertion + * bias](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#insertion-bias). + * + * @return the characterInsertionBias */ - public Boolean splitTranscriptAtPhraseEnd() { - return splitTranscriptAtPhraseEnd; + public Float characterInsertionBias() { + return characterInsertionBias; } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeWithWebsocketsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeWithWebsocketsOptions.java new file mode 100644 index 00000000000..fa404c61eef --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeWithWebsocketsOptions.java @@ -0,0 +1,1265 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** The recognize options. */ +public class RecognizeWithWebsocketsOptions extends GenericModel { + + /** + * The identifier of the model that is to be used for the recognition request. See [Languages and + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + */ + public interface Model { + /** ar-MS_BroadbandModel. */ + String AR_MS_BROADBANDMODEL = "ar-MS_BroadbandModel"; + /** ar-MS_Telephony. */ + String AR_MS_TELEPHONY = "ar-MS_Telephony"; + /** cs-CZ_Telephony. */ + String CS_CZ_TELEPHONY = "cs-CZ_Telephony"; + /** de-DE_BroadbandModel. */ + String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; + /** de-DE_Multimedia. */ + String DE_DE_MULTIMEDIA = "de-DE_Multimedia"; + /** de-DE_NarrowbandModel. */ + String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** de-DE_Telephony. */ + String DE_DE_TELEPHONY = "de-DE_Telephony"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_Multimedia. */ + String EN_AU_MULTIMEDIA = "en-AU_Multimedia"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; + /** en-AU_Telephony. */ + String EN_AU_TELEPHONY = "en-AU_Telephony"; + /** en-IN_Telephony. */ + String EN_IN_TELEPHONY = "en-IN_Telephony"; + /** en-GB_BroadbandModel. */ + String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; + /** en-GB_Multimedia. */ + String EN_GB_MULTIMEDIA = "en-GB_Multimedia"; + /** en-GB_NarrowbandModel. */ + String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; + /** en-GB_Telephony. */ + String EN_GB_TELEPHONY = "en-GB_Telephony"; + /** en-US_BroadbandModel. */ + String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; + /** en-US_Multimedia. */ + String EN_US_MULTIMEDIA = "en-US_Multimedia"; + /** en-US_NarrowbandModel. */ + String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; + /** en-US_ShortForm_NarrowbandModel. */ + String EN_US_SHORTFORM_NARROWBANDMODEL = "en-US_ShortForm_NarrowbandModel"; + /** en-US_Telephony. */ + String EN_US_TELEPHONY = "en-US_Telephony"; + /** en-WW_Medical_Telephony. */ + String EN_WW_MEDICAL_TELEPHONY = "en-WW_Medical_Telephony"; + /** es-AR_BroadbandModel. */ + String ES_AR_BROADBANDMODEL = "es-AR_BroadbandModel"; + /** es-AR_NarrowbandModel. */ + String ES_AR_NARROWBANDMODEL = "es-AR_NarrowbandModel"; + /** es-CL_BroadbandModel. */ + String ES_CL_BROADBANDMODEL = "es-CL_BroadbandModel"; + /** es-CL_NarrowbandModel. */ + String ES_CL_NARROWBANDMODEL = "es-CL_NarrowbandModel"; + /** es-CO_BroadbandModel. */ + String ES_CO_BROADBANDMODEL = "es-CO_BroadbandModel"; + /** es-CO_NarrowbandModel. */ + String ES_CO_NARROWBANDMODEL = "es-CO_NarrowbandModel"; + /** es-ES_BroadbandModel. */ + String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; + /** es-ES_NarrowbandModel. */ + String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; + /** es-ES_Multimedia. */ + String ES_ES_MULTIMEDIA = "es-ES_Multimedia"; + /** es-ES_Telephony. */ + String ES_ES_TELEPHONY = "es-ES_Telephony"; + /** es-LA_Telephony. */ + String ES_LA_TELEPHONY = "es-LA_Telephony"; + /** es-MX_BroadbandModel. */ + String ES_MX_BROADBANDMODEL = "es-MX_BroadbandModel"; + /** es-MX_NarrowbandModel. */ + String ES_MX_NARROWBANDMODEL = "es-MX_NarrowbandModel"; + /** es-PE_BroadbandModel. */ + String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; + /** es-PE_NarrowbandModel. */ + String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_Multimedia. */ + String FR_CA_MULTIMEDIA = "fr-CA_Multimedia"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; + /** fr-CA_Telephony. */ + String FR_CA_TELEPHONY = "fr-CA_Telephony"; + /** fr-FR_BroadbandModel. */ + String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; + /** fr-FR_Multimedia. */ + String FR_FR_MULTIMEDIA = "fr-FR_Multimedia"; + /** fr-FR_NarrowbandModel. */ + String FR_FR_NARROWBANDMODEL = "fr-FR_NarrowbandModel"; + /** fr-FR_Telephony. */ + String FR_FR_TELEPHONY = "fr-FR_Telephony"; + /** hi-IN_Telephony. */ + String HI_IN_TELEPHONY = "hi-IN_Telephony"; + /** it-IT_BroadbandModel. */ + String IT_IT_BROADBANDMODEL = "it-IT_BroadbandModel"; + /** it-IT_NarrowbandModel. */ + String IT_IT_NARROWBANDMODEL = "it-IT_NarrowbandModel"; + /** it-IT_Multimedia. */ + String IT_IT_MULTIMEDIA = "it-IT_Multimedia"; + /** it-IT_Telephony. */ + String IT_IT_TELEPHONY = "it-IT_Telephony"; + /** ja-JP_BroadbandModel. */ + String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; + /** ja-JP_Multimedia. */ + String JA_JP_MULTIMEDIA = "ja-JP_Multimedia"; + /** ja-JP_NarrowbandModel. */ + String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; + /** ja-JP_Telephony. */ + String JA_JP_TELEPHONY = "ja-JP_Telephony"; + /** ko-KR_BroadbandModel. */ + String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; + /** ko-KR_Multimedia. */ + String KO_KR_MULTIMEDIA = "ko-KR_Multimedia"; + /** ko-KR_NarrowbandModel. */ + String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; + /** ko-KR_Telephony. */ + String KO_KR_TELEPHONY = "ko-KR_Telephony"; + /** nl-BE_Telephony. */ + String NL_BE_TELEPHONY = "nl-BE_Telephony"; + /** nl-NL_BroadbandModel. */ + String NL_NL_BROADBANDMODEL = "nl-NL_BroadbandModel"; + /** nl-NL_Multimedia. */ + String NL_NL_MULTIMEDIA = "nl-NL_Multimedia"; + /** nl-NL_NarrowbandModel. */ + String NL_NL_NARROWBANDMODEL = "nl-NL_NarrowbandModel"; + /** nl-NL_Telephony. */ + String NL_NL_TELEPHONY = "nl-NL_Telephony"; + /** pt-BR_BroadbandModel. */ + String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; + /** pt-BR_Multimedia. */ + String PT_BR_MULTIMEDIA = "pt-BR_Multimedia"; + /** pt-BR_NarrowbandModel. */ + String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; + /** pt-BR_Telephony. */ + String PT_BR_TELEPHONY = "pt-BR_Telephony"; + /** sv-SE_Telephony. */ + String SV_SE_TELEPHONY = "sv-SE_Telephony"; + /** zh-CN_BroadbandModel. */ + String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; + /** zh-CN_NarrowbandModel. */ + String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; + /** zh-CN_Telephony. */ + String ZH_CN_TELEPHONY = "zh-CN_Telephony"; + } + + protected transient InputStream audio; + + @SerializedName("content-type") + protected String contentType; + + protected String model; + protected String languageCustomizationId; + protected String acousticCustomizationId; + protected String baseModelVersion; + protected Double customizationWeight; + protected Long inactivityTimeout; + protected List keywords; + protected Float keywordsThreshold; + protected Long maxAlternatives; + protected Float wordAlternativesThreshold; + protected Boolean wordConfidence; + protected Boolean timestamps; + protected Boolean profanityFilter; + protected Boolean smartFormatting; + protected Long smartFormattingVersion; + protected Boolean speakerLabels; + protected String grammarName; + protected Boolean redaction; + protected Boolean audioMetrics; + protected Double endOfPhraseSilenceTime; + protected Boolean splitTranscriptAtPhraseEnd; + protected Float speechDetectorSensitivity; + protected Float backgroundAudioSuppression; + protected Boolean lowLatency; + protected Float characterInsertionBias; + protected Long sadModule; + private Boolean interimResults; + private Boolean processingMetrics; + private Float processingMetricsInterval; + + /** Builder. */ + public static class Builder { + private InputStream audio; + private String contentType; + private String model; + private String languageCustomizationId; + private String acousticCustomizationId; + private String baseModelVersion; + private Double customizationWeight; + private Long inactivityTimeout; + private List keywords; + private Float keywordsThreshold; + private Long maxAlternatives; + private Float wordAlternativesThreshold; + private Boolean wordConfidence; + private Boolean timestamps; + private Boolean profanityFilter; + private Boolean smartFormatting; + private Long smartFormattingVersion; + private Boolean speakerLabels; + private String grammarName; + private Boolean redaction; + private Boolean audioMetrics; + private Double endOfPhraseSilenceTime; + private Boolean splitTranscriptAtPhraseEnd; + private Float speechDetectorSensitivity; + private Float backgroundAudioSuppression; + private Boolean lowLatency; + private Float characterInsertionBias; + private Long sadModule; + private Boolean interimResults; + private Boolean processingMetrics; + private Float processingMetricsInterval; + + private Builder(RecognizeWithWebsocketsOptions recognizeWithWebsocketsOptions) { + this.audio = recognizeWithWebsocketsOptions.audio; + this.contentType = recognizeWithWebsocketsOptions.contentType; + this.model = recognizeWithWebsocketsOptions.model; + this.languageCustomizationId = recognizeWithWebsocketsOptions.languageCustomizationId; + this.acousticCustomizationId = recognizeWithWebsocketsOptions.acousticCustomizationId; + this.baseModelVersion = recognizeWithWebsocketsOptions.baseModelVersion; + this.customizationWeight = recognizeWithWebsocketsOptions.customizationWeight; + this.inactivityTimeout = recognizeWithWebsocketsOptions.inactivityTimeout; + this.keywords = recognizeWithWebsocketsOptions.keywords; + this.keywordsThreshold = recognizeWithWebsocketsOptions.keywordsThreshold; + this.maxAlternatives = recognizeWithWebsocketsOptions.maxAlternatives; + this.wordAlternativesThreshold = recognizeWithWebsocketsOptions.wordAlternativesThreshold; + this.wordConfidence = recognizeWithWebsocketsOptions.wordConfidence; + this.timestamps = recognizeWithWebsocketsOptions.timestamps; + this.profanityFilter = recognizeWithWebsocketsOptions.profanityFilter; + this.smartFormatting = recognizeWithWebsocketsOptions.smartFormatting; + this.smartFormattingVersion = recognizeWithWebsocketsOptions.smartFormattingVersion; + this.speakerLabels = recognizeWithWebsocketsOptions.speakerLabels; + this.grammarName = recognizeWithWebsocketsOptions.grammarName; + this.redaction = recognizeWithWebsocketsOptions.redaction; + this.audioMetrics = recognizeWithWebsocketsOptions.audioMetrics; + this.endOfPhraseSilenceTime = recognizeWithWebsocketsOptions.endOfPhraseSilenceTime; + this.splitTranscriptAtPhraseEnd = recognizeWithWebsocketsOptions.splitTranscriptAtPhraseEnd; + this.speechDetectorSensitivity = recognizeWithWebsocketsOptions.speechDetectorSensitivity; + this.backgroundAudioSuppression = recognizeWithWebsocketsOptions.backgroundAudioSuppression; + this.lowLatency = recognizeWithWebsocketsOptions.lowLatency; + this.characterInsertionBias = recognizeWithWebsocketsOptions.characterInsertionBias; + this.sadModule = recognizeWithWebsocketsOptions.sadModule; + this.interimResults = recognizeWithWebsocketsOptions.interimResults; + this.processingMetrics = recognizeWithWebsocketsOptions.processingMetrics; + this.processingMetricsInterval = recognizeWithWebsocketsOptions.processingMetricsInterval; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param audio the audio + */ + public Builder(InputStream audio) { + this.audio = audio; + } + + /** + * Builds a RecognizeOptions. + * + * @return the new RecognizeOptions instance + */ + public RecognizeWithWebsocketsOptions build() { + return new RecognizeWithWebsocketsOptions(this); + } + + /** + * Adds an keyword to keywords. + * + * @param keyword the new keyword + * @return the RecognizeOptions builder + */ + public Builder addKeyword(String keyword) { + com.ibm.cloud.sdk.core.util.Validator.notNull(keyword, "keyword cannot be null"); + if (this.keywords == null) { + this.keywords = new ArrayList(); + } + this.keywords.add(keyword); + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the RecognizeOptions builder + */ + public Builder audio(InputStream audio) { + this.audio = audio; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the RecognizeOptions builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the model. + * + * @param model the model + * @return the RecognizeOptions builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + + /** + * Set the languageCustomizationId. + * + * @param languageCustomizationId the languageCustomizationId + * @return the RecognizeOptions builder + */ + public Builder languageCustomizationId(String languageCustomizationId) { + this.languageCustomizationId = languageCustomizationId; + return this; + } + + /** + * Set the acousticCustomizationId. + * + * @param acousticCustomizationId the acousticCustomizationId + * @return the RecognizeOptions builder + */ + public Builder acousticCustomizationId(String acousticCustomizationId) { + this.acousticCustomizationId = acousticCustomizationId; + return this; + } + + /** + * Set the baseModelVersion. + * + * @param baseModelVersion the baseModelVersion + * @return the RecognizeOptions builder + */ + public Builder baseModelVersion(String baseModelVersion) { + this.baseModelVersion = baseModelVersion; + return this; + } + + /** + * Set the customizationWeight. + * + * @param customizationWeight the customizationWeight + * @return the RecognizeOptions builder + */ + public Builder customizationWeight(Double customizationWeight) { + this.customizationWeight = customizationWeight; + return this; + } + + /** + * Set the inactivityTimeout. + * + * @param inactivityTimeout the inactivityTimeout + * @return the RecognizeOptions builder + */ + public Builder inactivityTimeout(long inactivityTimeout) { + this.inactivityTimeout = inactivityTimeout; + return this; + } + + /** + * Set the keywords. Existing keywords will be replaced. + * + * @param keywords the keywords + * @return the RecognizeOptions builder + */ + public Builder keywords(List keywords) { + this.keywords = keywords; + return this; + } + + /** + * Set the keywordsThreshold. + * + * @param keywordsThreshold the keywordsThreshold + * @return the RecognizeOptions builder + */ + public Builder keywordsThreshold(Float keywordsThreshold) { + this.keywordsThreshold = keywordsThreshold; + return this; + } + + /** + * Set the maxAlternatives. + * + * @param maxAlternatives the maxAlternatives + * @return the RecognizeOptions builder + */ + public Builder maxAlternatives(long maxAlternatives) { + this.maxAlternatives = maxAlternatives; + return this; + } + + /** + * Set the wordAlternativesThreshold. + * + * @param wordAlternativesThreshold the wordAlternativesThreshold + * @return the RecognizeOptions builder + */ + public Builder wordAlternativesThreshold(Float wordAlternativesThreshold) { + this.wordAlternativesThreshold = wordAlternativesThreshold; + return this; + } + + /** + * Set the wordConfidence. + * + * @param wordConfidence the wordConfidence + * @return the RecognizeOptions builder + */ + public Builder wordConfidence(Boolean wordConfidence) { + this.wordConfidence = wordConfidence; + return this; + } + + /** + * Set the timestamps. + * + * @param timestamps the timestamps + * @return the RecognizeOptions builder + */ + public Builder timestamps(Boolean timestamps) { + this.timestamps = timestamps; + return this; + } + + /** + * Set the profanityFilter. + * + * @param profanityFilter the profanityFilter + * @return the RecognizeOptions builder + */ + public Builder profanityFilter(Boolean profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + /** + * Set the smartFormatting. + * + * @param smartFormatting the smartFormatting + * @return the RecognizeOptions builder + */ + public Builder smartFormatting(Boolean smartFormatting) { + this.smartFormatting = smartFormatting; + return this; + } + + /** + * Set the smartFormattingVersion. + * + * @param smartFormattingVersion the smartFormattingVersion + * @return the RecognizeOptions builder + */ + public Builder smartFormattingVersion(long smartFormattingVersion) { + this.smartFormattingVersion = smartFormattingVersion; + return this; + } + + /** + * Set the speakerLabels. + * + * @param speakerLabels the speakerLabels + * @return the RecognizeOptions builder + */ + public Builder speakerLabels(Boolean speakerLabels) { + this.speakerLabels = speakerLabels; + return this; + } + + /** + * Set the grammarName. + * + * @param grammarName the grammarName + * @return the RecognizeOptions builder + */ + public Builder grammarName(String grammarName) { + this.grammarName = grammarName; + return this; + } + + /** + * Set the redaction. + * + * @param redaction the redaction + * @return the RecognizeOptions builder + */ + public Builder redaction(Boolean redaction) { + this.redaction = redaction; + return this; + } + + /** + * Set the audioMetrics. + * + * @param audioMetrics the audioMetrics + * @return the RecognizeOptions builder + */ + public Builder audioMetrics(Boolean audioMetrics) { + this.audioMetrics = audioMetrics; + return this; + } + + /** + * Set the endOfPhraseSilenceTime. + * + * @param endOfPhraseSilenceTime the endOfPhraseSilenceTime + * @return the RecognizeOptions builder + */ + public Builder endOfPhraseSilenceTime(Double endOfPhraseSilenceTime) { + this.endOfPhraseSilenceTime = endOfPhraseSilenceTime; + return this; + } + + /** + * Set the splitTranscriptAtPhraseEnd. + * + * @param splitTranscriptAtPhraseEnd the splitTranscriptAtPhraseEnd + * @return the RecognizeOptions builder + */ + public Builder splitTranscriptAtPhraseEnd(Boolean splitTranscriptAtPhraseEnd) { + this.splitTranscriptAtPhraseEnd = splitTranscriptAtPhraseEnd; + return this; + } + + /** + * Set the speechDetectorSensitivity. + * + * @param speechDetectorSensitivity the speechDetectorSensitivity + * @return the RecognizeOptions builder + */ + public Builder speechDetectorSensitivity(Float speechDetectorSensitivity) { + this.speechDetectorSensitivity = speechDetectorSensitivity; + return this; + } + + /** + * Set the backgroundAudioSuppression. + * + * @param backgroundAudioSuppression the backgroundAudioSuppression + * @return the RecognizeOptions builder + */ + public Builder backgroundAudioSuppression(Float backgroundAudioSuppression) { + this.backgroundAudioSuppression = backgroundAudioSuppression; + return this; + } + + /** + * Set the lowLatency. + * + * @param lowLatency the lowLatency + * @return the RecognizeOptions builder + */ + public Builder lowLatency(Boolean lowLatency) { + this.lowLatency = lowLatency; + return this; + } + + /** + * Set the characterInsertionBias. + * + * @param characterInsertionBias the characterInsertionBias + * @return the RecognizeOptions builder + */ + public Builder characterInsertionBias(Float characterInsertionBias) { + this.characterInsertionBias = characterInsertionBias; + return this; + } + + /** + * Set the sadModule. + * + * @param sadModule the sadModule + * @return the RecognizeOptions builder + */ + public Builder sadModule(Long sadModule) { + this.sadModule = sadModule; + return this; + } + + /** + * Set the interimResults. + * + *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * + * @param interimResults the interimResults + * @return the interimResults + */ + public Builder interimResults(Boolean interimResults) { + this.interimResults = interimResults; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the RecognizeOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder audio(File audio) throws FileNotFoundException { + this.audio = new FileInputStream(audio); + return this; + } + + /** + * Set the processingMetrics. + * + *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * + * @param processingMetrics the processingMetrics + * @return the processingMetrics + */ + public Builder processingMetrics(Boolean processingMetrics) { + this.processingMetrics = processingMetrics; + return this; + } + + /** + * Set the processingMetricsInterval. + * + *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * + * @param processingMetricsInterval the processingMetricsInterval + * @return the processingMetricsInterval + */ + public Builder processingMetricsInterval(Float processingMetricsInterval) { + this.processingMetricsInterval = processingMetricsInterval; + return this; + } + } + + protected RecognizeWithWebsocketsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, "audio cannot be null"); + audio = builder.audio; + contentType = builder.contentType; + model = builder.model; + languageCustomizationId = builder.languageCustomizationId; + acousticCustomizationId = builder.acousticCustomizationId; + baseModelVersion = builder.baseModelVersion; + customizationWeight = builder.customizationWeight; + inactivityTimeout = builder.inactivityTimeout; + keywords = builder.keywords; + keywordsThreshold = builder.keywordsThreshold; + maxAlternatives = builder.maxAlternatives; + wordAlternativesThreshold = builder.wordAlternativesThreshold; + wordConfidence = builder.wordConfidence; + timestamps = builder.timestamps; + profanityFilter = builder.profanityFilter; + smartFormatting = builder.smartFormatting; + smartFormattingVersion = builder.smartFormattingVersion; + speakerLabels = builder.speakerLabels; + grammarName = builder.grammarName; + redaction = builder.redaction; + audioMetrics = builder.audioMetrics; + endOfPhraseSilenceTime = builder.endOfPhraseSilenceTime; + splitTranscriptAtPhraseEnd = builder.splitTranscriptAtPhraseEnd; + speechDetectorSensitivity = builder.speechDetectorSensitivity; + backgroundAudioSuppression = builder.backgroundAudioSuppression; + lowLatency = builder.lowLatency; + characterInsertionBias = builder.characterInsertionBias; + sadModule = builder.sadModule; + interimResults = builder.interimResults; + processingMetrics = builder.processingMetrics; + processingMetricsInterval = builder.processingMetricsInterval; + } + + /** + * New builder. + * + * @return a RecognizeOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the audio. + * + *

The audio to transcribe. + * + * @return the audio + */ + public InputStream audio() { + return audio; + } + + /** + * Gets the contentType. + * + *

The format (MIME type) of the audio. For more information about specifying an audio format, + * see **Audio formats (content types)** in the method description. + * + * @return the contentType + */ + public String contentType() { + return contentType; + } + + /** + * Gets the model. + * + *

The identifier of the model that is to be used for the recognition request. See [Languages + * and models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). + * + * @return the model + */ + public String model() { + return model; + } + + /** + * Gets the languageCustomizationId. + * + *

The customization ID (GUID) of a custom language model that is to be used with the + * recognition request. The base model of the specified custom language model must match the model + * specified with the `model` parameter. You must make the request with credentials for the + * instance of the service that owns the custom model. By default, no custom language model is + * used. See [Custom + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + * + *

**Note:** Use this parameter instead of the deprecated `customization_id` parameter. + * + * @return the languageCustomizationId + */ + public String languageCustomizationId() { + return languageCustomizationId; + } + + /** + * Gets the acousticCustomizationId. + * + *

The customization ID (GUID) of a custom acoustic model that is to be used with the + * recognition request. The base model of the specified custom acoustic model must match the model + * specified with the `model` parameter. You must make the request with credentials for the + * instance of the service that owns the custom model. By default, no custom acoustic model is + * used. See [Custom + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + * + * @return the acousticCustomizationId + */ + public String acousticCustomizationId() { + return acousticCustomizationId; + } + + /** + * Gets the baseModelVersion. + * + *

The version of the specified base model that is to be used with the recognition request. + * Multiple versions of a base model can exist when a model is updated for internal improvements. + * The parameter is intended primarily for use with custom models that have been upgraded for a + * new base model. The default value depends on whether the parameter is used with or without a + * custom model. See [Base model + * version](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#version). + * + * @return the baseModelVersion + */ + public String baseModelVersion() { + return baseModelVersion; + } + + /** + * Gets the customizationWeight. + * + *

If you specify the customization ID (GUID) of a custom language model with the recognition + * request, the customization weight tells the service how much weight to give to words from the + * custom language model compared to those from the base model for the current request. + * + *

Specify a value between 0.0 and 1.0. Unless a different customization weight was specified + * for the custom model when it was trained, the default value is 0.3. A customization weight that + * you specify overrides a weight that was specified when the custom model was trained. + * + *

The default value yields the best performance in general. Assign a higher value if your + * audio makes frequent use of OOV words from the custom model. Use caution when setting the + * weight: a higher value can improve the accuracy of phrases from the custom model's domain, but + * it can negatively affect performance on non-domain phrases. + * + *

See [Custom + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom-input). + * + * @return the customizationWeight + */ + public Double customizationWeight() { + return customizationWeight; + } + + /** + * Gets the inactivityTimeout. + * + *

The time in seconds after which, if only silence (no speech) is detected in streaming audio, + * the connection is closed with a 400 error. The parameter is useful for stopping audio + * submission from a live microphone when a user simply walks away. Use `-1` for infinity. See + * [Inactivity + * timeout](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#timeouts-inactivity). + * + * @return the inactivityTimeout + */ + public Long inactivityTimeout() { + return inactivityTimeout; + } + + /** + * Gets the keywords. + * + *

An array of keyword strings to spot in the audio. Each keyword string can include one or + * more string tokens. Keywords are spotted only in the final results, not in interim hypotheses. + * If you specify any keywords, you must also specify a keywords threshold. Omit the parameter or + * specify an empty array if you do not need to spot keywords. + * + *

You can spot a maximum of 1000 keywords with a single request. A single keyword can have a + * maximum length of 1024 characters, though the maximum effective length for double-byte + * languages might be shorter. Keywords are case-insensitive. + * + *

See [Keyword + * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). + * + * @return the keywords + */ + public List keywords() { + return keywords; + } + + /** + * Gets the keywordsThreshold. + * + *

A confidence value that is the lower bound for spotting a keyword. A word is considered to + * match a keyword if its confidence is greater than or equal to the threshold. Specify a + * probability between 0.0 and 1.0. If you specify a threshold, you must also specify one or more + * keywords. The service performs no keyword spotting if you omit either parameter. See [Keyword + * spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). + * + * @return the keywordsThreshold + */ + public Float keywordsThreshold() { + return keywordsThreshold; + } + + /** + * Gets the maxAlternatives. + * + *

The maximum number of alternative transcripts that the service is to return. By default, the + * service returns a single transcript. If you specify a value of `0`, the service uses the + * default value, `1`. See [Maximum + * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#max_alternatives). + * + * @return the maxAlternatives + */ + public Long maxAlternatives() { + return maxAlternatives; + } + + /** + * Gets the wordAlternativesThreshold. + * + *

A confidence value that is the lower bound for identifying a hypothesis as a possible word + * alternative (also known as "Confusion Networks"). An alternative word is considered if its + * confidence is greater than or equal to the threshold. Specify a probability between 0.0 and + * 1.0. By default, the service computes no alternative words. See [Word + * alternatives](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_alternatives). + * + * @return the wordAlternativesThreshold + */ + public Float wordAlternativesThreshold() { + return wordAlternativesThreshold; + } + + /** + * Gets the wordConfidence. + * + *

If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for each + * word. By default, the service returns no word confidence scores. See [Word + * confidence](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_confidence). + * + * @return the wordConfidence + */ + public Boolean wordConfidence() { + return wordConfidence; + } + + /** + * Gets the timestamps. + * + *

If `true`, the service returns time alignment for each word. By default, no timestamps are + * returned. See [Word + * timestamps](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#word_timestamps). + * + * @return the timestamps + */ + public Boolean timestamps() { + return timestamps; + } + + /** + * Gets the profanityFilter. + * + *

If `true`, the service filters profanity from all output except for keyword results by + * replacing inappropriate words with a series of asterisks. Set the parameter to `false` to + * return results with no censoring. Applies to US English transcription only. See [Profanity + * filtering](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#profanity_filter). + * + * @return the profanityFilter + */ + public Boolean profanityFilter() { + return profanityFilter; + } + + /** + * Gets the smartFormatting. + * + *

If `true`, the service converts dates, times, series of digits and numbers, phone numbers, + * currency values, and internet addresses into more readable, conventional representations in the + * final transcript of a recognition request. For US English, the service also converts certain + * keyword strings to punctuation symbols. By default, the service performs no smart formatting. + * + *

**Note:** Applies to US English, Japanese, and Spanish transcription only. + * + *

See [Smart + * formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#smart_formatting). + * + * @return the smartFormatting + */ + public Boolean smartFormatting() { + return smartFormatting; + } + + /** + * Gets the smartFormattingVersion. + * + *

Smart formatting version is for next-generation models and that is supported in US English, + * Brazilian Portuguese, French and German languages. + * + * @return the smartFormattingVersion + */ + public Long smartFormattingVersion() { + return smartFormattingVersion; + } + + /** + * Gets the speakerLabels. + * + *

If `true`, the response includes labels that identify which words were spoken by which + * participants in a multi-person exchange. By default, the service returns no speaker labels. + * Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless + * of whether you specify `false` for the parameter. + * + *

**Note:** Applies to US English, Australian English, German, Japanese, Korean, and Spanish + * (both broadband and narrowband models) and UK English (narrowband model) transcription only. + * + *

See [Speaker + * labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#speaker_labels). + * + * @return the speakerLabels + */ + public Boolean speakerLabels() { + return speakerLabels; + } + + /** + * Gets the grammarName. + * + *

The name of a grammar that is to be used with the recognition request. If you specify a + * grammar, you must also use the `language_customization_id` parameter to specify the name of the + * custom language model for which the grammar is defined. The service recognizes only strings + * that are recognized by the specified grammar; it does not recognize other custom words from the + * model's words resource. See + * [Grammars](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#grammars-input). + * + * @return the grammarName + */ + public String grammarName() { + return grammarName; + } + + /** + * Gets the redaction. + * + *

If `true`, the service redacts, or masks, numeric data from final transcripts. The feature + * redacts any number that has three or more consecutive digits by replacing each digit with an + * `X` character. It is intended to redact sensitive numeric data, such as credit card numbers. By + * default, the service performs no redaction. + * + *

When you enable redaction, the service automatically enables smart formatting, regardless of + * whether you explicitly disable that feature. To ensure maximum security, the service also + * disables keyword spotting (ignores the `keywords` and `keywords_threshold` parameters) and + * returns only a single final transcript (forces the `max_alternatives` parameter to be `1`). + * + *

**Note:** Applies to US English, Japanese, and Korean transcription only. + * + *

See [Numeric + * redaction](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#redaction). + * + * @return the redaction + */ + public Boolean redaction() { + return redaction; + } + + /** + * Gets the audioMetrics. + * + *

If `true`, requests detailed information about the signal characteristics of the input + * audio. The service returns audio metrics with the final transcription results. By default, the + * service returns no audio metrics. + * + *

See [Audio + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#audio_metrics). + * + * @return the audioMetrics + */ + public Boolean audioMetrics() { + return audioMetrics; + } + + /** + * Gets the endOfPhraseSilenceTime. + * + *

If `true`, specifies the duration of the pause interval at which the service splits a + * transcript into multiple final results. If the service detects pauses or extended silence + * before it reaches the end of the audio stream, its response can include multiple final results. + * Silence indicates a point at which the speaker pauses between spoken words or phrases. + * + *

Specify a value for the pause interval in the range of 0.0 to 120.0. * A value greater than + * 0 specifies the interval that the service is to use for speech recognition. * A value of 0 + * indicates that the service is to use the default interval. It is equivalent to omitting the + * parameter. + * + *

The default pause interval for most languages is 0.8 seconds; the default for Chinese is 0.6 + * seconds. + * + *

See [End of phrase silence + * time](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#silence_time). + * + * @return the endOfPhraseSilenceTime + */ + public Double endOfPhraseSilenceTime() { + return endOfPhraseSilenceTime; + } + + /** + * Gets the splitTranscriptAtPhraseEnd. + * + *

If `true`, directs the service to split the transcript into multiple final results based on + * semantic features of the input, for example, at the conclusion of meaningful phrases such as + * sentences. The service bases its understanding of semantic features on the base language model + * that you use with a request. Custom language models and grammars can also influence how and + * where the service splits a transcript. By default, the service splits transcripts based solely + * on the pause interval. + * + *

See [Split transcript at phrase + * end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#split_transcript). + * + * @return the splitTranscriptAtPhraseEnd + */ + public Boolean splitTranscriptAtPhraseEnd() { + return splitTranscriptAtPhraseEnd; + } + + /** + * Gets the speechDetectorSensitivity. + * + *

The sensitivity of speech activity detection that the service is to perform. Use the + * parameter to suppress word insertions from music, coughing, and other non-speech events. The + * service biases the audio it passes for speech recognition by evaluating the input audio against + * prior models of speech and non-speech activity. + * + *

Specify a value between 0.0 and 1.0: * 0.0 suppresses all audio (no speech is transcribed). + * * 0.5 (the default) provides a reasonable compromise for the level of sensitivity. * 1.0 + * suppresses no audio (speech detection sensitivity is disabled). + * + *

The values increase on a monotonic curve. See [Speech Activity + * Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). + * + * @return the speechDetectorSensitivity + */ + public Float speechDetectorSensitivity() { + return speechDetectorSensitivity; + } + + /** + * Gets the backgroundAudioSuppression. + * + *

The level to which the service is to suppress background audio based on its volume to + * prevent it from being transcribed as speech. Use the parameter to suppress side conversations + * or background noise. + * + *

Specify a value in the range of 0.0 to 1.0: * 0.0 (the default) provides no suppression + * (background audio suppression is disabled). * 0.5 provides a reasonable level of audio + * suppression for general usage. * 1.0 suppresses all audio (no audio is transcribed). + * + *

The values increase on a monotonic curve. See [Speech Activity + * Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). + * + * @return the backgroundAudioSuppression + */ + public Float backgroundAudioSuppression() { + return backgroundAudioSuppression; + } + + /** + * Gets the lowLatency. + * + *

If `true` for next-generation `Multimedia` and `Telephony` models that support low latency, + * directs the service to produce results even more quickly than it usually does. Next-generation + * models produce transcription results faster than previous-generation models. The `low_latency` + * parameter causes the models to produce results even more quickly, though the results might be + * less accurate when the parameter is used. + * + *

The parameter is not available for previous-generation `Broadband` and `Narrowband` models. + * It is available for most next-generation models. * For a list of next-generation models that + * support low latency, see [Supported next-generation language + * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported). + * * For more information about the `low_latency` parameter, see [Low + * latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency). + * + * @return the lowLatency + */ + public Boolean lowLatency() { + return lowLatency; + } + + /** + * Gets the characterInsertionBias. + * + *

For next-generation `Multimedia` and `Telephony` models, an indication of whether the + * service is biased to recognize shorter or longer strings of characters when developing + * transcription hypotheses. By default, the service is optimized for each individual model to + * balance its recognition of strings of different lengths. The model-specific bias is equivalent + * to 0.0. + * + *

The value that you specify represents a change from a model's default bias. The allowable + * range of values is -1.0 to 1.0. * Negative values bias the service to favor hypotheses with + * shorter strings of characters. * Positive values bias the service to favor hypotheses with + * longer strings of characters. + * + *

As the value approaches -1.0 or 1.0, the impact of the parameter becomes more pronounced. To + * determine the most effective value for your scenario, start by setting the value of the + * parameter to a small increment, such as -0.1, -0.05, 0.05, or 0.1, and assess how the value + * impacts the transcription results. Then experiment with different values as necessary, + * adjusting the value by small increments. + * + *

The parameter is not available for previous-generation `Broadband` and `Narrowband` models. + * + *

See [Character insertion + * bias](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-parsing#insertion-bias). + * + * @return the characterInsertionBias + */ + public Float characterInsertionBias() { + return characterInsertionBias; + } + + /** + * Gets the sadModule. + * + *

Detects speech boundaries within the audio stream with better performance, improved noise + * suppression, faster responsiveness, and increased accuracy. + * + *

Specify `sad_module: 2` + * + *

See [Speech Activity Detection + * (SAD)](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#sad). + * + * @return the sadModule + */ + public Long sadModule() { + return sadModule; + } + + /** + * Gets the interimResults. + * + *

If `true`, the service returns interim results as a stream of `SpeechRecognitionResults` + * objects. By default, the service returns a single `SpeechRecognitionResults` object with final + * results only. + * + *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * + * @return the interimResults + */ + public Boolean interimResults() { + return interimResults; + } + + /** + * Gets the processingMetrics. + * + *

If `true`, requests processing metrics about the service's transcription of the input audio. + * The service returns processing metrics at the interval specified by the + * `processing_metrics_interval` parameter. It also returns processing metrics for transcription + * events, for example, for final and interim results. By default, the service returns no + * processing metrics. + * + *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * + * @return the processingMetrics + */ + public Boolean processingMetrics() { + return processingMetrics; + } + + /** + * Gets the processingMetricsInterval. + * + *

Specifies the interval in real wall-clock seconds at which the service is to return + * processing metrics. The parameter is ignored unless the `processing_metrics` parameter is set + * to `true`. + * + *

The parameter accepts a minimum value of 0.1 seconds. The level of precision is not + * restricted, so you can specify values such as 0.25 and 0.125. + * + *

The service does not impose a maximum value. If you want to receive processing metrics only + * for transcription events instead of at periodic intervals, set the value to a large number. If + * the value is larger than the duration of the audio, the service returns processing metrics only + * for transcription events. + * + *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. + * + * @return the processingMetricsInterval + */ + public Float processingMetricsInterval() { + return processingMetricsInterval; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java index 0814f4373a7..ed05bba31c9 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The registerCallback options. - */ +/** The registerCallback options. */ public class RegisterCallbackOptions extends GenericModel { protected String callbackUrl; protected String userSecret; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String callbackUrl; private String userSecret; + /** + * Instantiates a new Builder from an existing RegisterCallbackOptions instance. + * + * @param registerCallbackOptions the instance to initialize the Builder with + */ private Builder(RegisterCallbackOptions registerCallbackOptions) { this.callbackUrl = registerCallbackOptions.callbackUrl; this.userSecret = registerCallbackOptions.userSecret; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -52,7 +51,7 @@ public Builder(String callbackUrl) { /** * Builds a RegisterCallbackOptions. * - * @return the registerCallbackOptions + * @return the new RegisterCallbackOptions instance */ public RegisterCallbackOptions build() { return new RegisterCallbackOptions(this); @@ -81,9 +80,11 @@ public Builder userSecret(String userSecret) { } } + protected RegisterCallbackOptions() {} + protected RegisterCallbackOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.callbackUrl, - "callbackUrl cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.callbackUrl, "callbackUrl cannot be null"); callbackUrl = builder.callbackUrl; userSecret = builder.userSecret; } @@ -100,9 +101,10 @@ public Builder newBuilder() { /** * Gets the callbackUrl. * - * An HTTP or HTTPS URL to which callback notifications are to be sent. To be white-listed, the URL must successfully - * echo the challenge string during URL verification. During verification, the client can also check the signature - * that the service sends in the `X-Callback-Signature` header to verify the origin of the request. + *

An HTTP or HTTPS URL to which callback notifications are to be sent. To be allowlisted, the + * URL must successfully echo the challenge string during URL verification. During verification, + * the client can also check the signature that the service sends in the `X-Callback-Signature` + * header to verify the origin of the request. * * @return the callbackUrl */ @@ -113,10 +115,11 @@ public String callbackUrl() { /** * Gets the userSecret. * - * A user-specified string that the service uses to generate the HMAC-SHA1 signature that it sends via the - * `X-Callback-Signature` header. The service includes the header during URL verification and with every notification - * sent to the callback URL. It calculates the signature over the payload of the notification. If you omit the - * parameter, the service does not send the header. + *

A user-specified string that the service uses to generate the HMAC-SHA1 signature that it + * sends via the `X-Callback-Signature` header. The service includes the header during URL + * verification and with every notification sent to the callback URL. It calculates the signature + * over the payload of the notification. If you omit the parameter, the service does not send the + * header. * * @return the userSecret */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java index 11c63273fd7..c9fe53a67a5 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,19 +10,17 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about a request to register a callback for asynchronous speech recognition. - */ +/** Information about a request to register a callback for asynchronous speech recognition. */ public class RegisterStatus extends GenericModel { /** - * The current status of the job: - * * `created`: The service successfully white-listed the callback URL as a result of the call. - * * `already created`: The URL was already white-listed. + * The current status of the job: * `created`: The service successfully allowlisted the callback + * URL as a result of the call. * `already created`: The URL was already allowlisted. */ public interface Status { /** created. */ @@ -34,12 +32,13 @@ public interface Status { protected String status; protected String url; + protected RegisterStatus() {} + /** * Gets the status. * - * The current status of the job: - * * `created`: The service successfully white-listed the callback URL as a result of the call. - * * `already created`: The URL was already white-listed. + *

The current status of the job: * `created`: The service successfully allowlisted the + * callback URL as a result of the call. * `already created`: The URL was already allowlisted. * * @return the status */ @@ -50,7 +49,7 @@ public String getStatus() { /** * Gets the url. * - * The callback URL that is successfully registered. + *

The callback URL that is successfully registered. * * @return the url */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java index 994620425f6..041a3d36884 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The resetAcousticModel options. - */ +/** The resetAcousticModel options. */ public class ResetAcousticModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing ResetAcousticModelOptions instance. + * + * @param resetAcousticModelOptions the instance to initialize the Builder with + */ private Builder(ResetAcousticModelOptions resetAcousticModelOptions) { this.customizationId = resetAcousticModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a ResetAcousticModelOptions. * - * @return the resetAcousticModelOptions + * @return the new ResetAcousticModelOptions instance */ public ResetAcousticModelOptions build() { return new ResetAcousticModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected ResetAcousticModelOptions() {} + protected ResetAcousticModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java index 606caa6d748..99459ac4926 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The resetLanguageModel options. - */ +/** The resetLanguageModel options. */ public class ResetLanguageModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing ResetLanguageModelOptions instance. + * + * @param resetLanguageModelOptions the instance to initialize the Builder with + */ private Builder(ResetLanguageModelOptions resetLanguageModelOptions) { this.customizationId = resetLanguageModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a ResetLanguageModelOptions. * - * @return the resetLanguageModelOptions + * @return the new ResetLanguageModelOptions instance */ public ResetLanguageModelOptions build() { return new ResetLanguageModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected ResetLanguageModelOptions() {} + protected ResetLanguageModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java index a622c8ab60f..e362991b47c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,28 +10,30 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about the speakers from speech recognition results. - */ +/** Information about the speakers from speech recognition results. */ public class SpeakerLabelsResult extends GenericModel { protected Float from; protected Float to; protected Long speaker; protected Float confidence; + @SerializedName("final") protected Boolean xFinal; + protected SpeakerLabelsResult() {} + /** * Gets the from. * - * The start time of a word from the transcript. The value matches the start time of a word from the `timestamps` - * array. + *

The start time of a word from the transcript. The value matches the start time of a word + * from the `timestamps` array. * * @return the from */ @@ -42,7 +44,8 @@ public Float getFrom() { /** * Gets the to. * - * The end time of a word from the transcript. The value matches the end time of a word from the `timestamps` array. + *

The end time of a word from the transcript. The value matches the end time of a word from + * the `timestamps` array. * * @return the to */ @@ -53,9 +56,10 @@ public Float getTo() { /** * Gets the speaker. * - * The numeric identifier that the service assigns to a speaker from the audio. Speaker IDs begin at `0` initially but - * can evolve and change across interim results (if supported by the method) and between interim and final results as - * the service processes the audio. They are not guaranteed to be sequential, contiguous, or ordered. + *

The numeric identifier that the service assigns to a speaker from the audio. Speaker IDs + * begin at `0` initially but can evolve and change across interim results (if supported by the + * method) and between interim and final results as the service processes the audio. They are not + * guaranteed to be sequential, contiguous, or ordered. * * @return the speaker */ @@ -66,7 +70,8 @@ public Long getSpeaker() { /** * Gets the confidence. * - * A score that indicates the service's confidence in its identification of the speaker in the range of 0.0 to 1.0. + *

A score that indicates the service's confidence in its identification of the speaker in the + * range of 0.0 to 1.0. * * @return the confidence */ @@ -77,9 +82,10 @@ public Float getConfidence() { /** * Gets the xFinal. * - * An indication of whether the service might further change word and speaker-label results. A value of `true` means - * that the service guarantees not to send any further updates for the current or any preceding results; `false` means - * that the service might send further updates to the results. + *

An indication of whether the service might further change word and speaker-label results. A + * value of `true` means that the service guarantees not to send any further updates for the + * current or any preceding results; `false` means that the service might send further updates to + * the results. * * @return the xFinal */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java index 92671c4c363..9224f2242af 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,28 +10,32 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about an available language model. - */ +/** Information about an available language model. */ public class SpeechModel extends GenericModel { protected String name; protected String language; protected Long rate; protected String url; + @SerializedName("supported_features") protected SupportedFeatures supportedFeatures; + protected String description; + protected SpeechModel() {} + /** * Gets the name. * - * The name of the model for use as an identifier in calls to the service (for example, `en-US_BroadbandModel`). + *

The name of the model for use as an identifier in calls to the service (for example, + * `en-US_BroadbandModel`). * * @return the name */ @@ -42,7 +46,7 @@ public String getName() { /** * Gets the language. * - * The language identifier of the model (for example, `en-US`). + *

The language identifier of the model (for example, `en-US`). * * @return the language */ @@ -53,7 +57,7 @@ public String getLanguage() { /** * Gets the rate. * - * The sampling rate (minimum acceptable rate for audio) used by the model in Hertz. + *

The sampling rate (minimum acceptable rate for audio) used by the model in Hertz. * * @return the rate */ @@ -64,7 +68,7 @@ public Long getRate() { /** * Gets the url. * - * The URI for the model. + *

The URI for the model. * * @return the url */ @@ -75,7 +79,7 @@ public String getUrl() { /** * Gets the supportedFeatures. * - * Additional service features that are supported with the model. + *

Indicates whether select service features are supported with the model. * * @return the supportedFeatures */ @@ -86,7 +90,7 @@ public SupportedFeatures getSupportedFeatures() { /** * Gets the description. * - * A brief description of the model. + *

A brief description of the model. * * @return the description */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java index e733c72d23e..67892178f44 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,23 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about the available language models. - */ +/** Information about the available language models. */ public class SpeechModels extends GenericModel { protected List models; + protected SpeechModels() {} + /** * Gets the models. * - * An array of `SpeechModel` objects that provides information about each available model. + *

An array of `SpeechModel` objects that provides information about each available model. * * @return the models */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java index 48a83d31d1d..419433566aa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,28 +10,29 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * An alternative transcript from speech recognition results. - */ +/** An alternative transcript from speech recognition results. */ public class SpeechRecognitionAlternative extends GenericModel { protected String transcript; protected Double confidence; protected List timestamps; + @SerializedName("word_confidence") protected List wordConfidence; + protected SpeechRecognitionAlternative() {} + /** * Gets the transcript. * - * A transcription of the audio. + *

A transcription of the audio. * * @return the transcript */ @@ -42,8 +43,9 @@ public String getTranscript() { /** * Gets the confidence. * - * A score that indicates the service's confidence in the transcript in the range of 0.0 to 1.0. A confidence score is - * returned only for the best alternative and only with results marked as final. + *

A score that indicates the service's confidence in the transcript in the range of 0.0 to + * 1.0. The service returns a confidence score only for the best alternative and only with results + * marked as final. * * @return the confidence */ @@ -54,9 +56,10 @@ public Double getConfidence() { /** * Gets the timestamps. * - * Time alignments for each word from the transcript as a list of lists. Each inner list consists of three elements: - * the word followed by its start and end time in seconds, for example: `[["hello",0.0,1.2],["world",1.2,2.5]]`. - * Timestamps are returned only for the best alternative. + *

Time alignments for each word from the transcript as a list of lists. Each inner list + * consists of three elements: the word followed by its start and end time in seconds, for + * example: `[["hello",0.0,1.2],["world",1.2,2.5]]`. Timestamps are returned only for the best + * alternative. * * @return the timestamps */ @@ -67,9 +70,10 @@ public List getTimestamps() { /** * Gets the wordConfidence. * - * A confidence score for each word of the transcript as a list of lists. Each inner list consists of two elements: - * the word and its confidence score in the range of 0.0 to 1.0, for example: `[["hello",0.95],["world",0.866]]`. - * Confidence scores are returned only for the best alternative and only with results marked as final. + *

A confidence score for each word of the transcript as a list of lists. Each inner list + * consists of two elements: the word and its confidence score in the range of 0.0 to 1.0, for + * example: `[["hello",0.95],["world",0.86]]`. Confidence scores are returned only for the best + * alternative and only with results marked as final. * * @return the wordConfidence */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java index b5132b36dca..0eb5b0563ee 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2026. * * 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 @@ -10,27 +10,25 @@ * 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.speech_to_text.v1.model; -import java.util.List; -import java.util.Map; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; -/** - * Component results for a speech recognition request. - */ +/** Component results for a speech recognition request. */ public class SpeechRecognitionResult extends GenericModel { /** - * If the `split_transcript_at_phrase_end` parameter is `true`, describes the reason for the split: - * * `end_of_data` - The end of the input audio stream. - * * `full_stop` - A full semantic stop, such as for the conclusion of a grammatical sentence. The insertion of splits - * is influenced by the base language model and biased by custom language models and grammars. - * * `reset` - The amount of audio that is currently being processed exceeds the two-minute maximum. The service - * splits the transcript to avoid excessive memory use. - * * `silence` - A pause or silence that is at least as long as the pause interval. + * If the `split_transcript_at_phrase_end` parameter is `true`, describes the reason for the + * split: * `end_of_data` - The end of the input audio stream. * `full_stop` - A full semantic + * stop, such as for the conclusion of a grammatical sentence. The insertion of splits is + * influenced by the base language model and biased by custom language models and grammars. * + * `reset` - The amount of audio that is currently being processed exceeds the two-minute maximum. + * The service splits the transcript to avoid excessive memory use. * `silence` - A pause or + * silence that is at least as long as the pause interval. */ public interface EndOfUtterance { /** end_of_data. */ @@ -45,19 +43,29 @@ public interface EndOfUtterance { @SerializedName("final") protected Boolean xFinal; + protected List alternatives; + @SerializedName("keywords_result") protected Map> keywordsResult; + @SerializedName("word_alternatives") protected List wordAlternatives; + @SerializedName("end_of_utterance") protected String endOfUtterance; + protected SpeechRecognitionResult() {} + /** * Gets the xFinal. * - * An indication of whether the transcription results are final. If `true`, the results for this utterance are not - * updated further; no additional results are sent for a `result_index` once its results are indicated as final. + *

An indication of whether the transcription results are final: * If `true`, the results for + * this utterance are final. They are guaranteed not to be updated further. * If `false`, the + * results are interim. They can be updated with further interim results until final results are + * eventually sent. + * + *

**Note:** Because `final` is a reserved word in Java, the field is renamed `xFinal` in Java. * * @return the xFinal */ @@ -68,8 +76,8 @@ public Boolean isXFinal() { /** * Gets the alternatives. * - * An array of alternative transcripts. The `alternatives` array can include additional requested output such as word - * confidence or timestamps. + *

An array of alternative transcripts. The `alternatives` array can include additional + * requested output such as word confidence or timestamps. * * @return the alternatives */ @@ -80,10 +88,11 @@ public List getAlternatives() { /** * Gets the keywordsResult. * - * A dictionary (or associative array) whose keys are the strings specified for `keywords` if both that parameter and - * `keywords_threshold` are specified. The value for each key is an array of matches spotted in the audio for that - * keyword. Each match is described by a `KeywordResult` object. A keyword for which no matches are found is omitted - * from the dictionary. The dictionary is omitted entirely if no matches are found for any keywords. + *

A dictionary (or associative array) whose keys are the strings specified for `keywords` if + * both that parameter and `keywords_threshold` are specified. The value for each key is an array + * of matches spotted in the audio for that keyword. Each match is described by a `KeywordResult` + * object. A keyword for which no matches are found is omitted from the dictionary. The dictionary + * is omitted entirely if no matches are found for any keywords. * * @return the keywordsResult */ @@ -94,8 +103,8 @@ public Map> getKeywordsResult() { /** * Gets the wordAlternatives. * - * An array of alternative hypotheses found for words of the input audio if a `word_alternatives_threshold` is - * specified. + *

An array of alternative hypotheses found for words of the input audio if a + * `word_alternatives_threshold` is specified. * * @return the wordAlternatives */ @@ -106,13 +115,13 @@ public List getWordAlternatives() { /** * Gets the endOfUtterance. * - * If the `split_transcript_at_phrase_end` parameter is `true`, describes the reason for the split: - * * `end_of_data` - The end of the input audio stream. - * * `full_stop` - A full semantic stop, such as for the conclusion of a grammatical sentence. The insertion of splits - * is influenced by the base language model and biased by custom language models and grammars. - * * `reset` - The amount of audio that is currently being processed exceeds the two-minute maximum. The service - * splits the transcript to avoid excessive memory use. - * * `silence` - A pause or silence that is at least as long as the pause interval. + *

If the `split_transcript_at_phrase_end` parameter is `true`, describes the reason for the + * split: * `end_of_data` - The end of the input audio stream. * `full_stop` - A full semantic + * stop, such as for the conclusion of a grammatical sentence. The insertion of splits is + * influenced by the base language model and biased by custom language models and grammars. * + * `reset` - The amount of audio that is currently being processed exceeds the two-minute maximum. + * The service splits the transcript to avoid excessive memory use. * `silence` - A pause or + * silence that is at least as long as the pause interval. * * @return the endOfUtterance */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java index 9cca9857623..c8b6e89d399 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2026. * * 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 @@ -10,36 +10,52 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * The complete results for a speech recognition request. - */ +/** The complete results for a speech recognition request. */ public class SpeechRecognitionResults extends GenericModel { protected List results; + @SerializedName("result_index") protected Long resultIndex; + @SerializedName("speaker_labels") protected List speakerLabels; + @SerializedName("processing_metrics") protected ProcessingMetrics processingMetrics; + @SerializedName("audio_metrics") protected AudioMetrics audioMetrics; + protected List warnings; + @SerializedName("enriched_results") + protected EnrichedResults enrichedResults; + + protected SpeechRecognitionResults() {} + /** * Gets the results. * - * An array of `SpeechRecognitionResult` objects that can include interim and final results (interim results are - * returned only if supported by the method). Final results are guaranteed not to change; interim results might be - * replaced by further interim results and final results. The service periodically sends updates to the results list; - * the `result_index` is set to the lowest index in the array that has changed; it is incremented for new results. + *

An array of `SpeechRecognitionResult` objects that can include interim and final results + * (interim results are returned only if supported by the method). Final results are guaranteed + * not to change; interim results might be replaced by further interim results and eventually + * final results. + * + *

For the HTTP interfaces, all results arrive at the same time. For the WebSocket interface, + * results can be sent as multiple separate responses. The service periodically sends updates to + * the results list. The `result_index` is incremented to the lowest index in the array that has + * changed for new results. + * + *

For more information, see [Understanding speech recognition + * results](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-basic-response). * * @return the results */ @@ -50,8 +66,10 @@ public List getResults() { /** * Gets the resultIndex. * - * An index that indicates a change point in the `results` array. The service increments the index only for additional - * results that it sends for new audio for the same request. + *

An index that indicates a change point in the `results` array. The service increments the + * index for additional results that it sends for new audio for the same request. All results with + * the same index are delivered at the same time. The same index can include multiple final + * results that are delivered with the same response. * * @return the resultIndex */ @@ -62,10 +80,10 @@ public Long getResultIndex() { /** * Gets the speakerLabels. * - * An array of `SpeakerLabelsResult` objects that identifies which words were spoken by which speakers in a - * multi-person exchange. The array is returned only if the `speaker_labels` parameter is `true`. When interim results - * are also requested for methods that support them, it is possible for a `SpeechRecognitionResults` object to include - * only the `speaker_labels` field. + *

An array of `SpeakerLabelsResult` objects that identifies which words were spoken by which + * speakers in a multi-person exchange. The array is returned only if the `speaker_labels` + * parameter is `true`. When interim results are also requested for methods that support them, it + * is possible for a `SpeechRecognitionResults` object to include only the `speaker_labels` field. * * @return the speakerLabels */ @@ -76,8 +94,9 @@ public List getSpeakerLabels() { /** * Gets the processingMetrics. * - * If processing metrics are requested, information about the service's processing of the input audio. Processing - * metrics are not available with the synchronous **Recognize audio** method. + *

If processing metrics are requested, information about the service's processing of the input + * audio. Processing metrics are not available with the synchronous [Recognize audio](#recognize) + * method. * * @return the processingMetrics */ @@ -88,7 +107,8 @@ public ProcessingMetrics getProcessingMetrics() { /** * Gets the audioMetrics. * - * If audio metrics are requested, information about the signal characteristics of the input audio. + *

If audio metrics are requested, information about the signal characteristics of the input + * audio. * * @return the audioMetrics */ @@ -99,21 +119,35 @@ public AudioMetrics getAudioMetrics() { /** * Gets the warnings. * - * An array of warning messages associated with the request: - * * Warnings for invalid parameters or fields can include a descriptive message and a list of invalid argument - * strings, for example, `"Unknown arguments:"` or `"Unknown url query arguments:"` followed by a list of the form - * `"{invalid_arg_1}, {invalid_arg_2}."` - * * The following warning is returned if the request passes a custom model that is based on an older version of a - * base model for which an updated version is available: `"Using previous version of base model, because your custom - * model has been built with it. Please note that this version will be supported only for a limited time. Consider - * updating your custom model to the new base model. If you do not do that you will be automatically switched to base - * model when you used the non-updated custom model."` + *

An array of warning messages associated with the request: * Warnings for invalid parameters + * or fields can include a descriptive message and a list of invalid argument strings, for + * example, `"Unknown arguments:"` or `"Unknown url query arguments:"` followed by a list of the + * form `"{invalid_arg_1}, {invalid_arg_2}."` (If you use the `character_insertion_bias` parameter + * with a previous-generation model, the warning message refers to the parameter as `lambdaBias`.) + * * The following warning is returned if the request passes a custom model that is based on an + * older version of a base model for which an updated version is available: `"Using previous + * version of base model, because your custom model has been built with it. Please note that this + * version will be supported only for a limited time. Consider updating your custom model to the + * new base model. If you do not do that you will be automatically switched to base model when you + * used the non-updated custom model."` * - * In both cases, the request succeeds despite the warnings. + *

In both cases, the request succeeds despite the warnings. * * @return the warnings */ public List getWarnings() { return warnings; } + + /** + * Gets the enrichedResults. + * + *

If enriched results are requested, transcription with inserted punctuation marks such as + * periods, commas, question marks, and exclamation points. + * + * @return the enrichedResults + */ + public EnrichedResults getEnrichedResults() { + return enrichedResults; + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java index 549824bc1a4..903e78d5f30 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -16,9 +16,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; import com.ibm.watson.speech_to_text.v1.util.SpeechTimestampTypeAdapter; -/** - * Transcription timestamp. - */ +/** Transcription timestamp. */ @JsonAdapter(SpeechTimestampTypeAdapter.class) public class SpeechTimestamp extends GenericModel { private Double endTime; diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java index 9a80423d0ac..67fdd84838b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -16,9 +16,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; import com.ibm.watson.speech_to_text.v1.util.SpeechWordConfidenceTypeAdapter; -/** - * Transcription word confidence. - */ +/** Transcription word confidence. */ @JsonAdapter(SpeechWordConfidenceTypeAdapter.class) public class SpeechWordConfidence extends GenericModel { private Double confidence; diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java index b4ca89ad2d7..61225ffbbd4 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,26 +10,34 @@ * 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.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Additional service features that are supported with the model. - */ +/** Indicates whether select service features are supported with the model. */ public class SupportedFeatures extends GenericModel { @SerializedName("custom_language_model") protected Boolean customLanguageModel; + + @SerializedName("custom_acoustic_model") + protected Boolean customAcousticModel; + @SerializedName("speaker_labels") protected Boolean speakerLabels; + @SerializedName("low_latency") + protected Boolean lowLatency; + + protected SupportedFeatures() {} + /** * Gets the customLanguageModel. * - * Indicates whether the customization interface can be used to create a custom language model based on the language - * model. + *

Indicates whether the customization interface can be used to create a custom language model + * based on the language model. * * @return the customLanguageModel */ @@ -37,14 +45,48 @@ public Boolean isCustomLanguageModel() { return customLanguageModel; } + /** + * Gets the customAcousticModel. + * + *

Indicates whether the customization interface can be used to create a custom acoustic model + * based on the language model. + * + * @return the customAcousticModel + */ + public Boolean isCustomAcousticModel() { + return customAcousticModel; + } + /** * Gets the speakerLabels. * - * Indicates whether the `speaker_labels` parameter can be used with the language model. + *

Indicates whether the `speaker_labels` parameter can be used with the language model. + * + *

**Note:** The field returns `true` for all models. However, speaker labels are supported for + * use only with the following languages and models: * _For previous-generation models,_ the + * parameter can be used with Australian English, US English, German, Japanese, Korean, and + * Spanish (both broadband and narrowband models) and UK English (narrowband model) transcription + * only. * _For next-generation models,_ the parameter can be used with Czech, English + * (Australian, Indian, UK, and US), German, Japanese, Korean, and Spanish transcription only. + * + *

Speaker labels are not supported for use with any other languages or models. * * @return the speakerLabels */ public Boolean isSpeakerLabels() { return speakerLabels; } + + /** + * Gets the lowLatency. + * + *

Indicates whether the `low_latency` parameter can be used with a next-generation language + * model. The field is returned only for next-generation models. Previous-generation models do not + * support the `low_latency` parameter. + * + * @return the lowLatency + */ + public Boolean isLowLatency() { + return lowLatency; + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java index 2c1c195b339..00d5dce54fa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,37 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The trainAcousticModel options. - */ +/** The trainAcousticModel options. */ public class TrainAcousticModelOptions extends GenericModel { protected String customizationId; protected String customLanguageModelId; + protected Boolean strict; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String customLanguageModelId; + private Boolean strict; + /** + * Instantiates a new Builder from an existing TrainAcousticModelOptions instance. + * + * @param trainAcousticModelOptions the instance to initialize the Builder with + */ private Builder(TrainAcousticModelOptions trainAcousticModelOptions) { this.customizationId = trainAcousticModelOptions.customizationId; this.customLanguageModelId = trainAcousticModelOptions.customLanguageModelId; + this.strict = trainAcousticModelOptions.strict; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -52,7 +54,7 @@ public Builder(String customizationId) { /** * Builds a TrainAcousticModelOptions. * - * @return the trainAcousticModelOptions + * @return the new TrainAcousticModelOptions instance */ public TrainAcousticModelOptions build() { return new TrainAcousticModelOptions(this); @@ -79,13 +81,27 @@ public Builder customLanguageModelId(String customLanguageModelId) { this.customLanguageModelId = customLanguageModelId; return this; } + + /** + * Set the strict. + * + * @param strict the strict + * @return the TrainAcousticModelOptions builder + */ + public Builder strict(Boolean strict) { + this.strict = strict; + return this; + } } + protected TrainAcousticModelOptions() {} + protected TrainAcousticModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; customLanguageModelId = builder.customLanguageModelId; + strict = builder.strict; } /** @@ -100,8 +116,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -112,15 +129,30 @@ public String customizationId() { /** * Gets the customLanguageModelId. * - * The customization ID (GUID) of a custom language model that is to be used during training of the custom acoustic - * model. Specify a custom language model that has been trained with verbatim transcriptions of the audio resources or - * that contains words that are relevant to the contents of the audio resources. The custom language model must be - * based on the same version of the same base model as the custom acoustic model. The credentials specified with the - * request must own both custom models. + *

The customization ID (GUID) of a custom language model that is to be used during training of + * the custom acoustic model. Specify a custom language model that has been trained with verbatim + * transcriptions of the audio resources or that contains words that are relevant to the contents + * of the audio resources. The custom language model must be based on the same version of the same + * base model as the custom acoustic model, and the custom language model must be fully trained + * and available. The credentials specified with the request must own both custom models. * * @return the customLanguageModelId */ public String customLanguageModelId() { return customLanguageModelId; } + + /** + * Gets the strict. + * + *

If `false`, allows training of the custom acoustic model to proceed as long as the model + * contains at least one valid audio resource. The method returns an array of `TrainingWarning` + * objects that lists any invalid resources. By default (`true`), training of a custom acoustic + * model fails (status code 400) if the model contains one or more invalid audio resources. + * + * @return the strict + */ + public Boolean strict() { + return strict; + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java index f5eecfd4490..2aaaf3f2c1a 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,21 +10,25 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The trainLanguageModel options. - */ +/** The trainLanguageModel options. */ public class TrainLanguageModelOptions extends GenericModel { /** - * The type of words from the custom language model's words resource on which to train the model: - * * `all` (the default) trains the model on all new words, regardless of whether they were extracted from corpora or - * grammars or were added or modified by the user. - * * `user` trains the model only on new words that were added or modified by the user directly. The model is not - * trained on new words extracted from corpora or grammars. + * _For custom models that are based on previous-generation models_, the type of words from the + * custom language model's words resource on which to train the model: * `all` (the default) + * trains the model on all new words, regardless of whether they were extracted from corpora or + * grammars or were added or modified by the user. * `user` trains the model only on custom words + * that were added or modified by the user directly. The model is not trained on new words + * extracted from corpora or grammars. + * + *

_For custom models that are based on large speech models and next-generation models_, the + * service ignores the `word_type_to_add` parameter. The words resource contains only custom words + * that the user adds or modifies directly, so the parameter is unnecessary. */ public interface WordTypeToAdd { /** all. */ @@ -36,26 +40,32 @@ public interface WordTypeToAdd { protected String customizationId; protected String wordTypeToAdd; protected Double customizationWeight; + protected Boolean strict; + protected Boolean force; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String wordTypeToAdd; private Double customizationWeight; + private Boolean strict; + private Boolean force; + /** + * Instantiates a new Builder from an existing TrainLanguageModelOptions instance. + * + * @param trainLanguageModelOptions the instance to initialize the Builder with + */ private Builder(TrainLanguageModelOptions trainLanguageModelOptions) { this.customizationId = trainLanguageModelOptions.customizationId; this.wordTypeToAdd = trainLanguageModelOptions.wordTypeToAdd; this.customizationWeight = trainLanguageModelOptions.customizationWeight; + this.strict = trainLanguageModelOptions.strict; + this.force = trainLanguageModelOptions.force; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -69,7 +79,7 @@ public Builder(String customizationId) { /** * Builds a TrainLanguageModelOptions. * - * @return the trainLanguageModelOptions + * @return the new TrainLanguageModelOptions instance */ public TrainLanguageModelOptions build() { return new TrainLanguageModelOptions(this); @@ -107,14 +117,40 @@ public Builder customizationWeight(Double customizationWeight) { this.customizationWeight = customizationWeight; return this; } + + /** + * Set the strict. + * + * @param strict the strict + * @return the TrainLanguageModelOptions builder + */ + public Builder strict(Boolean strict) { + this.strict = strict; + return this; + } + + /** + * Set the force. + * + * @param force the force + * @return the TrainLanguageModelOptions builder + */ + public Builder force(Boolean force) { + this.force = force; + return this; + } } + protected TrainLanguageModelOptions() {} + protected TrainLanguageModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; wordTypeToAdd = builder.wordTypeToAdd; customizationWeight = builder.customizationWeight; + strict = builder.strict; + force = builder.force; } /** @@ -129,8 +165,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -141,11 +178,16 @@ public String customizationId() { /** * Gets the wordTypeToAdd. * - * The type of words from the custom language model's words resource on which to train the model: - * * `all` (the default) trains the model on all new words, regardless of whether they were extracted from corpora or - * grammars or were added or modified by the user. - * * `user` trains the model only on new words that were added or modified by the user directly. The model is not - * trained on new words extracted from corpora or grammars. + *

_For custom models that are based on previous-generation models_, the type of words from the + * custom language model's words resource on which to train the model: * `all` (the default) + * trains the model on all new words, regardless of whether they were extracted from corpora or + * grammars or were added or modified by the user. * `user` trains the model only on custom words + * that were added or modified by the user directly. The model is not trained on new words + * extracted from corpora or grammars. + * + *

_For custom models that are based on large speech models and next-generation models_, the + * service ignores the `word_type_to_add` parameter. The words resource contains only custom words + * that the user adds or modifies directly, so the parameter is unnecessary. * * @return the wordTypeToAdd */ @@ -156,20 +198,59 @@ public String wordTypeToAdd() { /** * Gets the customizationWeight. * - * Specifies a customization weight for the custom language model. The customization weight tells the service how much - * weight to give to words from the custom language model compared to those from the base model for speech - * recognition. Specify a value between 0.0 and 1.0; the default is 0.3. + *

Specifies a customization weight for the custom language model. The customization weight + * tells the service how much weight to give to words from the custom language model compared to + * those from the base model for speech recognition. Specify a value between 0.0 and 1.0. The + * default value is: * 0.5 for large speech models * 0.3 for previous-generation models * 0.2 for + * most next-generation models * 0.1 for next-generation English and Japanese models + * + *

The default value yields the best performance in general. Assign a higher value if your + * audio makes frequent use of OOV words from the custom model. Use caution when setting the + * weight: a higher value can improve the accuracy of phrases from the custom model's domain, but + * it can negatively affect performance on non-domain phrases. * - * The default value yields the best performance in general. Assign a higher value if your audio makes frequent use of - * OOV words from the custom model. Use caution when setting the weight: a higher value can improve the accuracy of - * phrases from the custom model's domain, but it can negatively affect performance on non-domain phrases. + *

The value that you assign is used for all recognition requests that use the model. You can + * override it for any recognition request by specifying a customization weight for that request. * - * The value that you assign is used for all recognition requests that use the model. You can override it for any - * recognition request by specifying a customization weight for that request. + *

See [Using customization + * weight](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageUse#weight). * * @return the customizationWeight */ public Double customizationWeight() { return customizationWeight; } + + /** + * Gets the strict. + * + *

If `false`, allows training of the custom language model to proceed as long as the model + * contains at least one valid resource. The method returns an array of `TrainingWarning` objects + * that lists any invalid resources. By default (`true`), training of a custom language model + * fails (status code 400) if the model contains one or more invalid resources (corpus files, + * grammar files, or custom words). + * + * @return the strict + */ + public Boolean strict() { + return strict; + } + + /** + * Gets the force. + * + *

If `true`, forces the training of the custom language model regardless of whether it + * contains any changes (is in the `ready` or `available` state). By default (`false`), the model + * must be in the `ready` state to be trained. You can use the parameter to train and thus upgrade + * a custom model that is based on an improved next-generation model. *The parameter is available + * only for IBM Cloud, not for IBM Cloud Pak for Data.* + * + *

See [Upgrading a custom language model based on an improved next-generation + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language-ng). + * + * @return the force + */ + public Boolean force() { + return force; + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java index 7d65bf6796c..20696e168cb 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,25 +10,25 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * The response from training of a custom language or custom acoustic model. - */ +/** The response from training of a custom language or custom acoustic model. */ public class TrainingResponse extends GenericModel { protected List warnings; + protected TrainingResponse() {} + /** * Gets the warnings. * - * An array of `TrainingWarning` objects that lists any invalid resources contained in the custom model. For custom - * language models, invalid resources are grouped and identified by type of resource. The method can return warnings - * only if the `strict` parameter is set to `false`. + *

An array of `TrainingWarning` objects that lists any invalid resources contained in the + * custom model. For custom language models, invalid resources are grouped and identified by type + * of resource. The method can return warnings only if the `strict` parameter is set to `false`. * * @return the warnings */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java index 77c3741bf23..3eea674224f 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,18 +10,15 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * A warning from training of a custom language or custom acoustic model. - */ +/** A warning from training of a custom language or custom acoustic model. */ public class TrainingWarning extends GenericModel { - /** - * An identifier for the type of invalid resources listed in the `description` field. - */ + /** An identifier for the type of invalid resources listed in the `description` field. */ public interface Code { /** invalid_audio_files. */ String INVALID_AUDIO_FILES = "invalid_audio_files"; @@ -36,10 +33,12 @@ public interface Code { protected String code; protected String message; + protected TrainingWarning() {} + /** * Gets the code. * - * An identifier for the type of invalid resources listed in the `description` field. + *

An identifier for the type of invalid resources listed in the `description` field. * * @return the code */ @@ -50,9 +49,10 @@ public String getCode() { /** * Gets the message. * - * A warning message that lists the invalid resources that are excluded from the custom model's training. The message - * has the following format: `Analysis of the following {resource_type} has not completed successfully: - * [{resource_names}]. They will be excluded from custom {model_type} model training.`. + *

A warning message that lists the invalid resources that are excluded from the custom model's + * training. The message has the following format: `Analysis of the following {resource_type} has + * not completed successfully: [{resource_names}]. They will be excluded from custom {model_type} + * model training.`. * * @return the message */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java index f05f83e5736..b4f454b1126 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The unregisterCallback options. - */ +/** The unregisterCallback options. */ public class UnregisterCallbackOptions extends GenericModel { protected String callbackUrl; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String callbackUrl; + /** + * Instantiates a new Builder from an existing UnregisterCallbackOptions instance. + * + * @param unregisterCallbackOptions the instance to initialize the Builder with + */ private Builder(UnregisterCallbackOptions unregisterCallbackOptions) { this.callbackUrl = unregisterCallbackOptions.callbackUrl; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String callbackUrl) { /** * Builds a UnregisterCallbackOptions. * - * @return the unregisterCallbackOptions + * @return the new UnregisterCallbackOptions instance */ public UnregisterCallbackOptions build() { return new UnregisterCallbackOptions(this); @@ -67,9 +66,11 @@ public Builder callbackUrl(String callbackUrl) { } } + protected UnregisterCallbackOptions() {} + protected UnregisterCallbackOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.callbackUrl, - "callbackUrl cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.callbackUrl, "callbackUrl cannot be null"); callbackUrl = builder.callbackUrl; } @@ -85,7 +86,7 @@ public Builder newBuilder() { /** * Gets the callbackUrl. * - * The callback URL that is to be unregistered. + *

The callback URL that is to be unregistered. * * @return the callbackUrl */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java index d3b3baa3946..3ccf0004db7 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,37 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The upgradeAcousticModel options. - */ +/** The upgradeAcousticModel options. */ public class UpgradeAcousticModelOptions extends GenericModel { protected String customizationId; protected String customLanguageModelId; protected Boolean force; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String customLanguageModelId; private Boolean force; + /** + * Instantiates a new Builder from an existing UpgradeAcousticModelOptions instance. + * + * @param upgradeAcousticModelOptions the instance to initialize the Builder with + */ private Builder(UpgradeAcousticModelOptions upgradeAcousticModelOptions) { this.customizationId = upgradeAcousticModelOptions.customizationId; this.customLanguageModelId = upgradeAcousticModelOptions.customLanguageModelId; this.force = upgradeAcousticModelOptions.force; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -55,7 +54,7 @@ public Builder(String customizationId) { /** * Builds a UpgradeAcousticModelOptions. * - * @return the upgradeAcousticModelOptions + * @return the new UpgradeAcousticModelOptions instance */ public UpgradeAcousticModelOptions build() { return new UpgradeAcousticModelOptions(this); @@ -95,9 +94,11 @@ public Builder force(Boolean force) { } } + protected UpgradeAcousticModelOptions() {} + protected UpgradeAcousticModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; customLanguageModelId = builder.customLanguageModelId; force = builder.force; @@ -115,8 +116,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom acoustic model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom acoustic model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ @@ -127,9 +129,10 @@ public String customizationId() { /** * Gets the customLanguageModelId. * - * If the custom acoustic model was trained with a custom language model, the customization ID (GUID) of that custom - * language model. The custom language model must be upgraded before the custom acoustic model can be upgraded. The - * credentials specified with the request must own both custom models. + *

If the custom acoustic model was trained with a custom language model, the customization ID + * (GUID) of that custom language model. The custom language model must be upgraded before the + * custom acoustic model can be upgraded. The custom language model must be fully trained and + * available. The credentials specified with the request must own both custom models. * * @return the customLanguageModelId */ @@ -140,11 +143,12 @@ public String customLanguageModelId() { /** * Gets the force. * - * If `true`, forces the upgrade of a custom acoustic model for which no input data has been modified since it was - * last trained. Use this parameter only to force the upgrade of a custom acoustic model that is trained with a custom - * language model, and only if you receive a 400 response code and the message `No input data modified since last - * training`. See [Upgrading a custom acoustic - * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customUpgrade#upgradeAcoustic). + *

If `true`, forces the upgrade of a custom acoustic model for which no input data has been + * modified since it was last trained. Use this parameter only to force the upgrade of a custom + * acoustic model that is trained with a custom language model, and only if you receive a 400 + * response code and the message `No input data modified since last training`. See [Upgrading a + * custom acoustic + * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-acoustic). * * @return the force */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java index ffcddec8fd8..290c36e1aaa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The upgradeLanguageModel options. - */ +/** The upgradeLanguageModel options. */ public class UpgradeLanguageModelOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing UpgradeLanguageModelOptions instance. + * + * @param upgradeLanguageModelOptions the instance to initialize the Builder with + */ private Builder(UpgradeLanguageModelOptions upgradeLanguageModelOptions) { this.customizationId = upgradeLanguageModelOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a UpgradeLanguageModelOptions. * - * @return the upgradeLanguageModelOptions + * @return the new UpgradeLanguageModelOptions instance */ public UpgradeLanguageModelOptions build() { return new UpgradeLanguageModelOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected UpgradeLanguageModelOptions() {} + protected UpgradeLanguageModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,9 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom language model that is to be used for the request. You must make the - * request with credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom language model that is to be used for the request. + * You must make the request with credentials for the instance of the service that owns the custom + * model. * * @return the customizationId */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java index be393fb4ee3..64caa9b77c2 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,31 +10,38 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about a word from a custom language model. - */ +/** Information about a word from a custom language model. */ public class Word extends GenericModel { protected String word; + + @SerializedName("mapping_only") + protected List mappingOnly; + @SerializedName("sounds_like") protected List soundsLike; + @SerializedName("display_as") protected String displayAs; + protected Long count; protected List source; protected List error; + protected Word() {} + /** * Gets the word. * - * A word from the custom model's words resource. The spelling of the word is used to train the model. + *

A word from the custom model's words resource. The spelling of the word is used to train the + * model. * * @return the word */ @@ -42,12 +49,30 @@ public String getWord() { return word; } + /** + * Gets the mappingOnly. + * + *

(Optional) Parameter for custom words. You can use the 'mapping_only' key in custom words as + * a form of post processing. A boolean value that indicates whether the added word should be used + * to fine-tune the mode for selected next-gen models. This field appears in the response body + * only when it's 'For a custom model that is based on a previous-generation model', the + * mapping_only field is populated with the value set by the user, but would not be used. + * + * @return the mappingOnly + */ + public List getMappingOnly() { + return mappingOnly; + } + /** * Gets the soundsLike. * - * An array of pronunciations for the word. The array can include the sounds-like pronunciation automatically - * generated by the service if none is provided for the word; the service adds this pronunciation when it finishes - * processing the word. + *

An array of as many as five pronunciations for the word. * _For a custom model that is based + * on a previous-generation model_, in addition to sounds-like pronunciations that were added by a + * user, the array can include a sounds-like pronunciation that is automatically generated by the + * service if none is provided when the word is added to the custom model. * _For a custom model + * that is based on a next-generation model_, the array can include only sounds-like + * pronunciations that were added by a user. * * @return the soundsLike */ @@ -58,8 +83,12 @@ public List getSoundsLike() { /** * Gets the displayAs. * - * The spelling of the word that the service uses to display the word in a transcript. The field contains an empty - * string if no display-as value is provided for the word, in which case the word is displayed as it is spelled. + *

The spelling of the word that the service uses to display the word in a transcript. * _For a + * custom model that is based on a previous-generation model_, the field can contain an empty + * string if no display-as value is provided for a word that exists in the service's base + * vocabulary. In this case, the word is displayed as it is spelled. * _For a custom model that is + * based on a next-generation model_, the service uses the spelling of the word as the value of + * the display-as field when the word is added to the model. * * @return the displayAs */ @@ -70,10 +99,15 @@ public String getDisplayAs() { /** * Gets the count. * - * A sum of the number of times the word is found across all corpora. For example, if the word occurs five times in - * one corpus and seven times in another, its count is `12`. If you add a custom word to a model before it is added by - * any corpora, the count begins at `1`; if the word is added from a corpus first and later modified, the count - * reflects only the number of times it is found in corpora. + *

_For a custom model that is based on a previous-generation model_, a sum of the number of + * times the word is found across all corpora and grammars. For example, if the word occurs five + * times in one corpus and seven times in another, its count is `12`. If you add a custom word to + * a model before it is added by any corpora or grammars, the count begins at `1`; if the word is + * added from a corpus or grammar first and later modified, the count reflects only the number of + * times it is found in corpora and grammars. + * + *

_For a custom model that is based on a next-generation model_, the `count` field for any + * word is always `1`. * * @return the count */ @@ -84,9 +118,14 @@ public Long getCount() { /** * Gets the source. * - * An array of sources that describes how the word was added to the custom model's words resource. For OOV words added - * from a corpus, includes the name of the corpus; if the word was added by multiple corpora, the names of all corpora - * are listed. If the word was modified or added by the user directly, the field includes the string `user`. + *

An array of sources that describes how the word was added to the custom model's words + * resource. * _For a custom model that is based on previous-generation model,_ the field includes + * the name of each corpus and grammar from which the service extracted the word. For OOV that are + * added by multiple corpora or grammars, the names of all corpora and grammars are listed. If you + * modified or added the word directly, the field includes the string `user`. * _For a custom + * model that is based on a next-generation model,_ this field shows only `user` for custom words + * that were added directly to the custom model. Words from corpora and grammars are not added to + * the words resource for custom models that are based on next-generation models. * * @return the source */ @@ -97,8 +136,8 @@ public List getSource() { /** * Gets the error. * - * If the service discovered one or more problems that you need to correct for the word's definition, an array that - * describes each of the errors. + *

If the service discovered one or more problems that you need to correct for the word's + * definition, an array that describes each of the errors. * * @return the error */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java index d04262985f4..038ebde53d1 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,22 +10,23 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An alternative hypothesis for a word from speech recognition results. - */ +/** An alternative hypothesis for a word from speech recognition results. */ public class WordAlternativeResult extends GenericModel { protected Double confidence; protected String word; + protected WordAlternativeResult() {} + /** * Gets the confidence. * - * A confidence score for the word alternative hypothesis in the range of 0.0 to 1.0. + *

A confidence score for the word alternative hypothesis in the range of 0.0 to 1.0. * * @return the confidence */ @@ -36,7 +37,7 @@ public Double getConfidence() { /** * Gets the word. * - * An alternative hypothesis for a word from the input audio. + *

An alternative hypothesis for a word from the input audio. * * @return the word */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java index 692074ca69e..6654d4ffd5b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,28 +10,31 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about alternative hypotheses for words from speech recognition results. - */ +/** Information about alternative hypotheses for words from speech recognition results. */ public class WordAlternativeResults extends GenericModel { @SerializedName("start_time") protected Double startTime; + @SerializedName("end_time") protected Double endTime; + protected List alternatives; + protected WordAlternativeResults() {} + /** * Gets the startTime. * - * The start time in seconds of the word from the input audio that corresponds to the word alternatives. + *

The start time in seconds of the word from the input audio that corresponds to the word + * alternatives. * * @return the startTime */ @@ -42,7 +45,8 @@ public Double getStartTime() { /** * Gets the endTime. * - * The end time in seconds of the word from the input audio that corresponds to the word alternatives. + *

The end time in seconds of the word from the input audio that corresponds to the word + * alternatives. * * @return the endTime */ @@ -53,7 +57,7 @@ public Double getEndTime() { /** * Gets the alternatives. * - * An array of alternative hypotheses for a word from the input audio. + *

An array of alternative hypotheses for a word from the input audio. * * @return the alternatives */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java index 0ba4928b753..2bcc38ad3f9 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,24 +10,26 @@ * 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.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * An error associated with a word from a custom language model. - */ +/** An error associated with a word from a custom language model. */ public class WordError extends GenericModel { protected String element; + protected WordError() {} + /** * Gets the element. * - * A key-value pair that describes an error associated with the definition of a word in the words resource. The pair - * has the format `"element": "message"`, where `element` is the aspect of the definition that caused the problem and - * `message` describes the problem. The following example describes a problem with one of the word's sounds-like - * definitions: `"{sounds_like_string}": "Numbers are not allowed in sounds-like. You can try for example + *

A key-value pair that describes an error associated with the definition of a word in the + * words resource. The pair has the format `"element": "message"`, where `element` is the aspect + * of the definition that caused the problem and `message` describes the problem. The following + * example describes a problem with one of the word's sounds-like definitions: + * `"{sounds_like_string}": "Numbers are not allowed in sounds-like. You can try for example * '{suggested_string}'."`. * * @return the element diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java index e5332e0d563..faa1e435f05 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,24 +10,24 @@ * 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.speech_to_text.v1.model; -import java.util.List; +package com.ibm.watson.speech_to_text.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about the words from a custom language model. - */ +/** Information about the words from a custom language model. */ public class Words extends GenericModel { protected List words; + protected Words() {} + /** * Gets the words. * - * An array of `Word` objects that provides information about each word in the custom model's words resource. The - * array is empty if the custom model has no words. + *

An array of `Word` objects that provides information about each word in the custom model's + * words resource. The array is empty if the custom model has no words. * * @return the words */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java index 895036e15b6..5d4cd287ed1 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,7 +10,6 @@ * 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. */ -/** - * Speech to Text v1. - */ + +/** Speech to Text v1. */ package com.ibm.watson.speech_to_text.v1; diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java index f81d093a5eb..793f555d055 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -12,13 +12,12 @@ */ package com.ibm.watson.speech_to_text.v1.util; +import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.watson.speech_to_text.v1.SpeechToText; import java.io.File; import java.util.HashMap; import java.util.Map; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.watson.speech_to_text.v1.SpeechToText; - /** * The utilities required for processing audio files using the {@link SpeechToText} service. * @@ -75,5 +74,4 @@ public static String getMediaTypeFromFile(final File file) { public static boolean isValidMediaType(final String mediaType) { return (mediaType != null) && MEDIA_TYPES.values().contains(mediaType.toLowerCase()); } - } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java index 5309b1867aa..3b216e10d54 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -12,17 +12,14 @@ */ package com.ibm.watson.speech_to_text.v1.util; -import java.io.IOException; - import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.ibm.watson.speech_to_text.v1.model.SpeechTimestamp; +import java.io.IOException; -/** - * Type adapter to transform timestamp from json into objects and viseversa. - */ +/** Type adapter to transform timestamp from json into objects and viseversa. */ public class SpeechTimestampTypeAdapter extends TypeAdapter { /* diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java index 21153f12628..2564ab692a8 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -12,17 +12,14 @@ */ package com.ibm.watson.speech_to_text.v1.util; -import java.io.IOException; - import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.ibm.watson.speech_to_text.v1.model.SpeechWordConfidence; +import java.io.IOException; -/** - * Type adapter to transform word confidence from json into objects and viseversa.. - */ +/** Type adapter to transform word confidence from json into objects and viseversa.. */ public class SpeechWordConfidenceTypeAdapter extends TypeAdapter { /* @@ -55,7 +52,8 @@ public SpeechWordConfidence read(JsonReader reader) throws IOException { * @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object) */ @Override - public void write(JsonWriter writer, SpeechWordConfidence speechWordConfidence) throws IOException { + public void write(JsonWriter writer, SpeechWordConfidence speechWordConfidence) + throws IOException { writer.beginArray(); writer.value(speechWordConfidence.getWord()); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/BaseRecognizeCallback.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/BaseRecognizeCallback.java index 82fee198ac4..7c6f1da1fc4 100755 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/BaseRecognizeCallback.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/BaseRecognizeCallback.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -13,13 +13,10 @@ package com.ibm.watson.speech_to_text.v1.websocket; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; - import java.util.logging.Level; import java.util.logging.Logger; -/** - * An empty implementation of {@link RecognizeCallback} interface. - */ +/** An empty implementation of {@link RecognizeCallback} interface. */ public class BaseRecognizeCallback implements RecognizeCallback { private static final Logger LOG = Logger.getLogger(BaseRecognizeCallback.class.getName()); @@ -28,17 +25,15 @@ public class BaseRecognizeCallback implements RecognizeCallback { * (non-Javadoc) * @see * RecognizeCallback#onTranscription(com. - * ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults) + * ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults) */ - public void onTranscription(SpeechRecognitionResults speechResults) { - }; + public void onTranscription(SpeechRecognitionResults speechResults) {}; /* * (non-Javadoc) * @see RecognizeCallback#onConnected() */ - public void onConnected() { - }; + public void onConnected() {}; /* * (non-Javadoc) @@ -55,32 +50,27 @@ public void onError(Exception e) { * @see * RecognizeCallback#onDisconnected() */ - public void onDisconnected() { - }; + public void onDisconnected() {}; /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.speech_to_text.v1.websocket + * @see com.ibm.watson.speech_to_text.v1.websocket * .RecognizeCallback#onInactivityTimeout(java.lang.RuntimeException) */ @Override - public void onInactivityTimeout(RuntimeException runtimeException) { - }; + public void onInactivityTimeout(RuntimeException runtimeException) {}; /* * (non-Javadoc) * @see RecognizeCallback#onListening() */ @Override - public void onListening() { - }; + public void onListening() {}; /* * (non-Javadoc) * @see RecognizeCallback#onTranscriptionComplete() */ @Override - public void onTranscriptionComplete() { - }; - + public void onTranscriptionComplete() {}; } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/RecognizeCallback.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/RecognizeCallback.java index 74408859273..b23e4e26ef8 100755 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/RecognizeCallback.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/RecognizeCallback.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -14,11 +14,11 @@ import com.ibm.watson.speech_to_text.v1.SpeechToText; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; - import okhttp3.WebSocket; /** - * The recognize callback used during a {@link WebSocket} recognition by the {@link SpeechToText} service. + * The recognize callback used during a {@link WebSocket} recognition by the {@link SpeechToText} + * service. */ public interface RecognizeCallback { @@ -29,9 +29,7 @@ public interface RecognizeCallback { */ void onTranscription(SpeechRecognitionResults speechResults); - /** - * Called when a WebSocket connection was made. - */ + /** Called when a WebSocket connection was made. */ void onConnected(); /** @@ -41,9 +39,7 @@ public interface RecognizeCallback { */ void onError(Exception e); - /** - * Called when a WebSocket connection was closed. - */ + /** Called when a WebSocket connection was closed. */ void onDisconnected(); /** @@ -53,13 +49,9 @@ public interface RecognizeCallback { */ void onInactivityTimeout(RuntimeException runtimeException); - /** - * Called when the service is listening for audio. - */ + /** Called when the service is listening for audio. */ void onListening(); - /** - * Called after the service returns the final result for the transcription. - */ + /** Called after the service returns the final result for the transcription. */ void onTranscriptionComplete(); } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java index a0798cc9df5..5a609ca7d80 100755 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2019. + * (C) Copyright IBM Corp. 2017, 2022. * * 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 @@ -19,23 +19,22 @@ import com.google.gson.JsonParser; import com.ibm.cloud.sdk.core.util.GsonSingleton; import com.ibm.watson.speech_to_text.v1.SpeechToText; -import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; +import com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; -import okhttp3.Response; -import okhttp3.WebSocket; -import okhttp3.WebSocketListener; -import okio.ByteString; - import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; +import okhttp3.Response; +import okhttp3.WebSocket; +import okhttp3.WebSocketListener; +import okio.ByteString; /** * The listener interface for receiving {@link WebSocket} events.
- * The class that is interested in processing a event implements this interface. When the event occurs, that object's - * appropriate method is invoked. + * The class that is interested in processing a event implements this interface. When the event + * occurs, that object's appropriate method is invoked. * * @see SpeechToText */ @@ -55,7 +54,6 @@ public final class SpeechToTextWebSocketListener extends WebSocketListener { private static final String RESULTS = "results"; private static final String SPEAKER_LABELS = "speaker_labels"; private static final String AUDIO_METRICS = "audio_metrics"; - private static final String CUSTOMIZATION_ID = "customization_id"; private static final String LANGUAGE_CUSTOMIZATION_ID = "language_customization_id"; private static final String ACOUSTIC_CUSTOMIZATION_ID = "acoustic_customization_id"; private static final String VERSION = "base_model_version"; @@ -67,7 +65,7 @@ public final class SpeechToTextWebSocketListener extends WebSocketListener { private static final long QUEUE_WAIT_MILLIS = 500; private final InputStream stream; - private final RecognizeOptions options; + private final RecognizeWithWebsocketsOptions options; private final RecognizeCallback callback; private WebSocket socket; private boolean socketOpen = true; @@ -81,7 +79,8 @@ public final class SpeechToTextWebSocketListener extends WebSocketListener { * @param options the recognize options * @param callback the callback */ - public SpeechToTextWebSocketListener(final RecognizeOptions options, final RecognizeCallback callback) { + public SpeechToTextWebSocketListener( + final RecognizeWithWebsocketsOptions options, final RecognizeCallback callback) { this.stream = options.audio(); this.options = options; this.callback = callback; @@ -162,19 +161,22 @@ public void onOpen(final WebSocket socket, Response response) { // Send the InputStream on a different Thread. Elsewise, interim results cannot be // received, // because the Thread that called SpeechToText.recognizeUsingWebSocket is blocked. - audioThread = new Thread(AUDIO_TO_WEB_SOCKET) { - @Override - public void run() { - sendInputStream(stream); - // Do not send the stop message if the socket has been closed already, for example because of the - // inactivity timeout. - // If the socket is still open after the sending finishes, for example because the user closed the - // microphone AudioInputStream, send a stop message. - if (socketOpen && !socket.send(buildStopMessage())) { - LOG.log(Level.SEVERE, "Stop message discarded because WebSocket is unavailable"); - } - } - }; + audioThread = + new Thread(AUDIO_TO_WEB_SOCKET) { + @Override + public void run() { + sendInputStream(stream); + // Do not send the stop message if the socket has been closed already, for example + // because of the + // inactivity timeout. + // If the socket is still open after the sending finishes, for example because the + // user closed the + // microphone AudioInputStream, send a stop message. + if (socketOpen && !socket.send(buildStopMessage())) { + LOG.log(Level.SEVERE, "Stop message discarded because WebSocket is unavailable"); + } + } + }; audioThread.start(); } @@ -189,13 +191,16 @@ private void sendInputStream(InputStream inputStream) { byte[] buffer = new byte[ONE_KB]; int read; try { - // This method uses a blocking while loop to receive all contents of the underlying input stream. - // AudioInputStreams, typically used for streaming microphone inputs return 0 only when the stream has been + // This method uses a blocking while loop to receive all contents of the underlying input + // stream. + // AudioInputStreams, typically used for streaming microphone inputs return 0 only when the + // stream has been // closed. Elsewise AudioInputStream.read() blocks until enough audio frames are read. while (((read = inputStream.read(buffer)) > 0) && socketOpen) { // If OkHttp's WebSocket queue gets overwhelmed, it'll abruptly close the connection - // (see: https://github.com/square/okhttp/issues/3317). This will ensure we wait until the coast is clear. + // (see: https://github.com/square/okhttp/issues/3317). This will ensure we wait until the + // coast is clear. while (socket.queueSize() > QUEUE_SIZE_LIMIT) { Thread.sleep(QUEUE_WAIT_MILLIS); } @@ -223,13 +228,13 @@ private void sendInputStream(InputStream inputStream) { * @param options the options * @return the request */ - private String buildStartMessage(RecognizeOptions options) { - Gson gson = new GsonBuilder() - .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) - .create(); + private String buildStartMessage(RecognizeWithWebsocketsOptions options) { + Gson gson = + new GsonBuilder() + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) + .create(); JsonObject startMessage = new JsonParser().parse(gson.toJson(options)).getAsJsonObject(); startMessage.remove(MODEL); - startMessage.remove(CUSTOMIZATION_ID); startMessage.remove(LANGUAGE_CUSTOMIZATION_ID); startMessage.remove(ACOUSTIC_CUSTOMIZATION_ID); startMessage.remove(VERSION); diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java index d49c1558195..5c622dcf991 100755 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2022. * * 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 @@ -12,67 +12,19 @@ */ package com.ibm.watson.speech_to_text.v1; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.cloud.sdk.core.service.exception.NotFoundException; import com.ibm.watson.common.RetryRunner; import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.speech_to_text.v1.model.AcousticModel; -import com.ibm.watson.speech_to_text.v1.model.AcousticModels; -import com.ibm.watson.speech_to_text.v1.model.AddAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.AddCorpusOptions; -import com.ibm.watson.speech_to_text.v1.model.AddGrammarOptions; -import com.ibm.watson.speech_to_text.v1.model.AddWordOptions; -import com.ibm.watson.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.speech_to_text.v1.model.AudioResources; -import com.ibm.watson.speech_to_text.v1.model.CheckJobOptions; -import com.ibm.watson.speech_to_text.v1.model.Corpora; -import com.ibm.watson.speech_to_text.v1.model.Corpus; -import com.ibm.watson.speech_to_text.v1.model.CreateAcousticModelOptions; -import com.ibm.watson.speech_to_text.v1.model.CreateJobOptions; -import com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteAcousticModelOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteGrammarOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteJobOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteUserDataOptions; -import com.ibm.watson.speech_to_text.v1.model.GetAcousticModelOptions; -import com.ibm.watson.speech_to_text.v1.model.GetAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; -import com.ibm.watson.speech_to_text.v1.model.GetGrammarOptions; -import com.ibm.watson.speech_to_text.v1.model.GetLanguageModelOptions; -import com.ibm.watson.speech_to_text.v1.model.GetModelOptions; -import com.ibm.watson.speech_to_text.v1.model.GetWordOptions; -import com.ibm.watson.speech_to_text.v1.model.Grammar; -import com.ibm.watson.speech_to_text.v1.model.Grammars; -import com.ibm.watson.speech_to_text.v1.model.KeywordResult; -import com.ibm.watson.speech_to_text.v1.model.LanguageModel; -import com.ibm.watson.speech_to_text.v1.model.LanguageModels; -import com.ibm.watson.speech_to_text.v1.model.ListAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.ListCorporaOptions; -import com.ibm.watson.speech_to_text.v1.model.ListGrammarsOptions; -import com.ibm.watson.speech_to_text.v1.model.ListWordsOptions; -import com.ibm.watson.speech_to_text.v1.model.RecognitionJob; -import com.ibm.watson.speech_to_text.v1.model.RecognitionJobs; -import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.speech_to_text.v1.model.SpeechModel; -import com.ibm.watson.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResult; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.speech_to_text.v1.model.Word; -import com.ibm.watson.speech_to_text.v1.model.WordAlternativeResults; -import com.ibm.watson.speech_to_text.v1.model.Words; +import com.ibm.watson.speech_to_text.v1.model.*; import com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -82,15 +34,14 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Speech to text Integration tests. - */ +/** Speech to text Integration tests. */ @RunWith(RetryRunner.class) public class SpeechToTextIT extends WatsonServiceTest { @@ -98,8 +49,10 @@ public class SpeechToTextIT extends WatsonServiceTest { private static final String SPEECH_RESOURCE = "src/test/resources/speech_to_text/%s"; private static final String SAMPLE_WAV = String.format(SPEECH_RESOURCE, "sample1.wav"); private static final String TWO_SPEAKERS_WAV = String.format(SPEECH_RESOURCE, "twospeakers.wav"); - private static final String SAMPLE_WAV_WITH_PAUSE = String.format(SPEECH_RESOURCE, "sound-with-pause.wav"); - private static final String WAV_ARCHIVE = String.format(SPEECH_RESOURCE, "sample-wav-archive.zip"); + private static final String SAMPLE_WAV_WITH_PAUSE = + String.format(SPEECH_RESOURCE, "sound-with-pause.wav"); + private static final String WAV_ARCHIVE = + String.format(SPEECH_RESOURCE, "sample-wav-archive.zip"); private static final String SAMPLE_GRAMMAR = String.format(SPEECH_RESOURCE, "confirm.abnf"); private static final Logger LOG = Logger.getLogger(SpeechToTextIT.class.getName()); @@ -112,39 +65,50 @@ public class SpeechToTextIT extends WatsonServiceTest { private String acousticCustomizationId; /** The expected exception. */ - @Rule - public final ExpectedException expectedException = ExpectedException.none(); + @Rule public final ExpectedException expectedException = ExpectedException.none(); + /** + * Sets up the tests. + * + * @throws Exception the exception + */ /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - this.customizationId = getProperty("speech_to_text.customization_id"); - this.acousticCustomizationId = getProperty("speech_to_text.acoustic_customization_id"); + this.customizationId = System.getenv("SPEECH_TO_TEXT_CUSTOM_ID"); + this.acousticCustomizationId = System.getenv("SPEECH_TO_TEXT_ACOUSTIC_CUSTOM_ID"); + + String apiKey = System.getenv("SPEECH_TO_TEXT_APIKEY"); + String serviceUrl = System.getenv("SPEECH_TO_TEXT_URL"); - String apiKey = getProperty("speech_to_text.apikey"); + if (apiKey == null) { + apiKey = getProperty("speech_to_text.apikey"); + this.customizationId = getProperty("speech_to_text.customization_id"); + this.acousticCustomizationId = getProperty("speech_to_text.acoustic_customization_id"); + serviceUrl = getProperty("speech_to_text.url"); + } - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); + assertNotNull( + "SPEECH_TO_TEXT_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey); Authenticator authenticator = new IamAuthenticator(apiKey); service = new SpeechToText(authenticator); - service.setServiceUrl(getProperty("speech_to_text.url")); + service.setServiceUrl(serviceUrl); service.setDefaultHeaders(getDefaultHeaders()); } - /** - * Test get model. - */ + /** Test get model. */ @Test public void testGetModel() { - GetModelOptions getOptions = new GetModelOptions.Builder() - .modelId(EN_BROADBAND16K) - .build(); + GetModelOptions getOptions = new GetModelOptions.Builder().modelId(EN_BROADBAND16K).build(); SpeechModel model = service.getModel(getOptions).execute().getResult(); assertNotNull(model); assertNotNull(model.getName()); @@ -156,9 +120,7 @@ public void testGetModel() { assertNotNull(model.getSupportedFeatures().isSpeakerLabels()); } - /** - * Test list models. - */ + /** Test list models. */ @Test public void testListModels() { SpeechModels models = service.listModels().execute().getResult(); @@ -168,67 +130,105 @@ public void testListModels() { /** * Test recognize audio file. + * + * @throws FileNotFoundException the file not found exception */ @Test public void testRecognizeFileString() throws FileNotFoundException { Long maxAlternatives = 3L; Float wordAlternativesThreshold = 0.8f; File audio = new File(SAMPLE_WAV); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .maxAlternatives(maxAlternatives) - .wordAlternativesThreshold(wordAlternativesThreshold) - .smartFormatting(true) - .build(); + RecognizeOptions options = + new RecognizeOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .maxAlternatives(maxAlternatives) + .wordAlternativesThreshold(wordAlternativesThreshold) + .smartFormatting(true) + .build(); SpeechRecognitionResults results = service.recognize(options).execute().getResult(); assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTranscript()); assertTrue(results.getResults().get(0).getAlternatives().size() <= maxAlternatives); - List wordAlternatives = results.getResults().get(0).getWordAlternatives(); + List wordAlternatives = + results.getResults().get(0).getWordAlternatives(); for (WordAlternativeResults alternativeResults : wordAlternatives) { - assertTrue(alternativeResults.getAlternatives().get(0).getConfidence() >= wordAlternativesThreshold); + assertTrue( + alternativeResults.getAlternatives().get(0).getConfidence() >= wordAlternativesThreshold); } } + /** + * Test recognize audio file. + * + * @throws FileNotFoundException the file not found exception + */ + @Test + public void testRecognizeEnrichments() throws FileNotFoundException { + File audio = new File(SAMPLE_WAV); + RecognizeOptions options = + new RecognizeOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .enrichments("punctuation") + .build(); + SpeechRecognitionResults results = service.recognize(options).execute().getResult(); + + assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTranscript()); + } + + /** + * Test recognize with silence. + * + * @throws FileNotFoundException the file not found exception + */ @Test public void testRecognizeWithSilence() throws FileNotFoundException { File audio = new File(SAMPLE_WAV_WITH_PAUSE); // Make call with a long end-of-phrase silence time. - RecognizeOptions firstOptions = new RecognizeOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .endOfPhraseSilenceTime(100.0) - .splitTranscriptAtPhraseEnd(true) - .build(); + RecognizeOptions firstOptions = + new RecognizeOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .endOfPhraseSilenceTime(100.0) + .splitTranscriptAtPhraseEnd(true) + .build(); SpeechRecognitionResults results = service.recognize(firstOptions).execute().getResult(); assertEquals(1, results.getResults().size()); - // Make call again with a short end-of-phrase silence time, which should return multiple results. - RecognizeOptions secondOptions = new RecognizeOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .endOfPhraseSilenceTime(0.1) - .splitTranscriptAtPhraseEnd(true) - .build(); + // Make call again with a short end-of-phrase silence time, which should return + // multiple + // results. + RecognizeOptions secondOptions = + new RecognizeOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .endOfPhraseSilenceTime(0.1) + .splitTranscriptAtPhraseEnd(true) + .build(); results = service.recognize(secondOptions).execute().getResult(); assertTrue(results.getResults().size() > 1); - assertEquals(SpeechRecognitionResult.EndOfUtterance.SILENCE, results.getResults().get(0).getEndOfUtterance()); + assertEquals( + SpeechRecognitionResult.EndOfUtterance.SILENCE, + results.getResults().get(0).getEndOfUtterance()); } /** * Test recognize multiple speakers. + * + * @throws FileNotFoundException the file not found exception */ @Test public void testRecognizeMultipleSpeakers() throws FileNotFoundException { File audio = new File(TWO_SPEAKERS_WAV); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .speakerLabels(true) - .model(RecognizeOptions.Model.EN_US_NARROWBANDMODEL) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); + RecognizeOptions options = + new RecognizeOptions.Builder() + .audio(audio) + .speakerLabels(true) + .model(RecognizeOptions.Model.EN_US_NARROWBANDMODEL) + .contentType(HttpMediaType.AUDIO_WAV) + .build(); SpeechRecognitionResults results = service.recognize(options).execute().getResult(); assertNotNull(results.getSpeakerLabels()); @@ -237,20 +237,23 @@ public void testRecognizeMultipleSpeakers() throws FileNotFoundException { /** * Test recognize file string recognize options. + * + * @throws FileNotFoundException the file not found exception */ @Test public void testRecognizeFileStringRecognizeOptions() throws FileNotFoundException { File audio = new File(SAMPLE_WAV); String contentType = HttpMediaType.AUDIO_WAV; - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .timestamps(true) - .wordConfidence(true) - .model(EN_BROADBAND16K) - .contentType(contentType) - .profanityFilter(false) - .audioMetrics(true) - .build(); + RecognizeOptions options = + new RecognizeOptions.Builder() + .audio(audio) + .timestamps(true) + .wordConfidence(true) + .model(EN_BROADBAND16K) + .contentType(contentType) + .profanityFilter(false) + .audioMetrics(true) + .build(); SpeechRecognitionResults results = service.recognize(options).execute().getResult(); assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTranscript()); assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTimestamps()); @@ -260,6 +263,8 @@ public void testRecognizeFileStringRecognizeOptions() throws FileNotFoundExcepti /** * Test keyword recognition. + * + * @throws FileNotFoundException the file not found exception */ @Test public void testRecognizeKeywords() throws FileNotFoundException { @@ -267,14 +272,15 @@ public void testRecognizeKeywords() throws FileNotFoundException { final String keyword2 = "tornadoes"; final File audio = new File(SAMPLE_WAV); - final RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .model(RecognizeOptions.Model.EN_US_NARROWBANDMODEL) - .inactivityTimeout(500) - .keywords(Arrays.asList(keyword1, keyword2)) - .keywordsThreshold(0.5f) - .build(); + final RecognizeOptions options = + new RecognizeOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .model(RecognizeOptions.Model.EN_US_NARROWBANDMODEL) + .inactivityTimeout(500) + .keywords(Arrays.asList(keyword1, keyword2)) + .keywordsThreshold(0.5f) + .build(); final SpeechRecognitionResults results = service.recognize(options).execute().getResult(); final SpeechRecognitionResult transcript = results.getResults().get(0); @@ -305,68 +311,73 @@ public void testRecognizeKeywords() throws FileNotFoundException { @Test public void testRecognizeWebSocket() throws FileNotFoundException, InterruptedException { FileInputStream audio = new FileInputStream(SAMPLE_WAV); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .inactivityTimeout(40) - .timestamps(true) - .maxAlternatives(2) - .wordAlternativesThreshold(0.5f) - .model(EN_BROADBAND16K) - .contentType(HttpMediaType.AUDIO_WAV) - .interimResults(true) - .processingMetrics(true) - .processingMetricsInterval(0.2f) - .audioMetrics(true) - .build(); - - service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { - - @Override - public void onConnected() { - LOG.info("onConnected()"); - } - - @Override - public void onDisconnected() { - LOG.info("onDisconnected()"); - } - - @Override - public void onTranscriptionComplete() { - LOG.info("onTranscriptionComplete()"); - lock.countDown(); - } + RecognizeWithWebsocketsOptions options = + new RecognizeWithWebsocketsOptions.Builder() + .audio(audio) + .inactivityTimeout(40) + .timestamps(true) + .maxAlternatives(2) + .wordAlternativesThreshold(0.5f) + .model(EN_BROADBAND16K) + .contentType(HttpMediaType.AUDIO_WAV) + .interimResults(true) + .processingMetrics(true) + .processingMetricsInterval(0.2f) + .audioMetrics(true) + .build(); + + service.recognizeUsingWebSocket( + options, + new BaseRecognizeCallback() { + + @Override + public void onConnected() { + LOG.info("onConnected()"); + } - @Override - public void onError(Exception e) { - e.printStackTrace(); - lock.countDown(); - } + @Override + public void onDisconnected() { + LOG.info("onDisconnected()"); + } - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - if (speechResults != null) { - if (speechResults.getResults() != null && speechResults.getResults().get(0).isXFinal()) { - asyncTranscriptionResults = speechResults; + @Override + public void onTranscriptionComplete() { + LOG.info("onTranscriptionComplete()"); + lock.countDown(); } - if (speechResults.getAudioMetrics() != null) { - asyncAudioMetricsResults = speechResults; + + @Override + public void onError(Exception e) { + // e.printStackTrace(); + lock.countDown(); } - System.out.println(speechResults); - } - } - }); + @Override + public void onTranscription(SpeechRecognitionResults speechResults) { + if (speechResults != null) { + if (speechResults.getResults() != null + && speechResults.getResults().get(0).isXFinal()) { + asyncTranscriptionResults = speechResults; + } + if (speechResults.getAudioMetrics() != null) { + asyncAudioMetricsResults = speechResults; + } + // System.out.println(speechResults); + } + } + }); - lock.await(2, TimeUnit.MINUTES); + lock.await(3, TimeUnit.MINUTES); assertNotNull(asyncTranscriptionResults); assertNotNull(asyncAudioMetricsResults); - List wordAlternatives = asyncTranscriptionResults.getResults() - .get(asyncTranscriptionResults.getResultIndex().intValue()).getWordAlternatives(); + List wordAlternatives = + asyncTranscriptionResults + .getResults() + .get(asyncTranscriptionResults.getResultIndex().intValue()) + .getWordAlternatives(); assertTrue(wordAlternatives != null && !wordAlternatives.isEmpty()); assertNotNull(wordAlternatives.get(0).getAlternatives()); - assertNotNull(asyncTranscriptionResults.getProcessingMetrics()); assertNotNull(asyncAudioMetricsResults.getAudioMetrics()); // Clear for later tests. @@ -381,80 +392,94 @@ public void onTranscription(SpeechRecognitionResults speechResults) { * @throws InterruptedException the interrupted exception */ @Test - public void testInactivityTimeoutWithWebSocket() throws FileNotFoundException, InterruptedException { + public void testInactivityTimeoutWithWebSocket() + throws FileNotFoundException, InterruptedException { FileInputStream audio = new FileInputStream(SAMPLE_WAV_WITH_PAUSE); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .inactivityTimeout(3) - .timestamps(true) - .maxAlternatives(2) - .wordAlternativesThreshold(0.5f) - .model(EN_BROADBAND16K) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); - - service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { - - @Override - public void onDisconnected() { - lock.countDown(); - } + RecognizeWithWebsocketsOptions options = + new RecognizeWithWebsocketsOptions.Builder() + .audio(audio) + .inactivityTimeout(3) + .timestamps(true) + .maxAlternatives(2) + .wordAlternativesThreshold(0.5f) + .model(EN_BROADBAND16K) + .contentType(HttpMediaType.AUDIO_WAV) + .build(); + + service.recognizeUsingWebSocket( + options, + new BaseRecognizeCallback() { + + @Override + public void onDisconnected() { + lock.countDown(); + } - @Override - public void onError(Exception e) { - e.printStackTrace(); - lock.countDown(); - } + @Override + public void onError(Exception e) { + // e.printStackTrace(); + lock.countDown(); + } - @Override - public void onInactivityTimeout(RuntimeException runtimeException) { - inactivityTimeoutOccurred = true; - } - }); + @Override + public void onInactivityTimeout(RuntimeException runtimeException) { + inactivityTimeoutOccurred = true; + } + }); lock.await(2, TimeUnit.MINUTES); assertTrue(inactivityTimeoutOccurred); } + /** + * Test end of phrase silence time web socket. + * + * @throws FileNotFoundException the file not found exception + * @throws InterruptedException the interrupted exception + */ @Test - public void testEndOfPhraseSilenceTimeWebSocket() throws FileNotFoundException, InterruptedException { + public void testEndOfPhraseSilenceTimeWebSocket() + throws FileNotFoundException, InterruptedException { FileInputStream audio = new FileInputStream(SAMPLE_WAV_WITH_PAUSE); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .endOfPhraseSilenceTime(0.2) - .build(); - - service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { - @Override - public void onConnected() { - LOG.info("onConnected()"); - } + RecognizeWithWebsocketsOptions options = + new RecognizeWithWebsocketsOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .endOfPhraseSilenceTime(0.2) + .build(); + + service.recognizeUsingWebSocket( + options, + new BaseRecognizeCallback() { + @Override + public void onConnected() { + LOG.info("onConnected()"); + } - @Override - public void onDisconnected() { - LOG.info("onDisconnected()"); - } + @Override + public void onDisconnected() { + LOG.info("onDisconnected()"); + } - @Override - public void onTranscriptionComplete() { - LOG.info("onTranscriptionComplete()"); - lock.countDown(); - } + @Override + public void onTranscriptionComplete() { + LOG.info("onTranscriptionComplete()"); + lock.countDown(); + } - @Override - public void onError(Exception e) { - e.printStackTrace(); - lock.countDown(); - } + @Override + public void onError(Exception e) { + // e.printStackTrace(); + lock.countDown(); + } - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - if (speechResults != null && speechResults.getResults() != null) { - asyncTranscriptionResults = speechResults; - } - } - }); + @Override + public void onTranscription(SpeechRecognitionResults speechResults) { + if (speechResults != null && speechResults.getResults() != null) { + asyncTranscriptionResults = speechResults; + } + } + }); lock.await(1, TimeUnit.MINUTES); @@ -476,18 +501,17 @@ public void testCreateJob() throws InterruptedException, FileNotFoundException { File audio = new File(SAMPLE_WAV); Long maxAlternatives = 3L; Float wordAlternativesThreshold = 0.5f; - CreateJobOptions createOptions = new CreateJobOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .maxAlternatives(maxAlternatives) - .wordAlternativesThreshold(wordAlternativesThreshold) - .build(); + CreateJobOptions createOptions = + new CreateJobOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .maxAlternatives(maxAlternatives) + .wordAlternativesThreshold(wordAlternativesThreshold) + .build(); RecognitionJob job = service.createJob(createOptions).execute().getResult(); try { assertNotNull(job.getId()); - CheckJobOptions checkOptions = new CheckJobOptions.Builder() - .id(job.getId()) - .build(); + CheckJobOptions checkOptions = new CheckJobOptions.Builder().id(job.getId()).build(); for (int x = 0; x < 30 && !job.getStatus().equals(RecognitionJob.Status.COMPLETED); x++) { Thread.sleep(3000); job = service.checkJob(checkOptions).execute().getResult(); @@ -496,16 +520,18 @@ public void testCreateJob() throws InterruptedException, FileNotFoundException { assertEquals(RecognitionJob.Status.COMPLETED, job.getStatus()); assertNotNull(job.getResults()); - assertTrue(job.getResults().get(0).getResults().get(0).getAlternatives().size() <= maxAlternatives); - List wordAlternatives = job.getResults().get(0).getResults().get(0).getWordAlternatives(); + assertTrue( + job.getResults().get(0).getResults().get(0).getAlternatives().size() <= maxAlternatives); + List wordAlternatives = + job.getResults().get(0).getResults().get(0).getWordAlternatives(); for (WordAlternativeResults alternativeResults : wordAlternatives) { - assertTrue(alternativeResults.getAlternatives().get(0).getConfidence() >= wordAlternativesThreshold); + assertTrue( + alternativeResults.getAlternatives().get(0).getConfidence() + >= wordAlternativesThreshold); } } finally { - DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder() - .id(job.getId()) - .build(); + DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder().id(job.getId()).build(); service.deleteJob(deleteOptions).execute(); } } @@ -513,8 +539,8 @@ public void testCreateJob() throws InterruptedException, FileNotFoundException { /** * Test create job with a warning message. * - * This test is currently being ignored as it has a very long runtime and causes Travis to timeout. - * The ignore annotation can be removed to test this locally. + *

This test is currently being ignored as it has a very long runtime and causes Travis to + * timeout. The ignore annotation can be removed to test this locally. * * @throws InterruptedException the interrupted exception * @throws FileNotFoundException the file not found exception @@ -523,19 +549,20 @@ public void testCreateJob() throws InterruptedException, FileNotFoundException { @Test public void testCreateJobWarning() throws InterruptedException, FileNotFoundException { File audio = new File(SAMPLE_WAV); - CreateJobOptions createOptions = new CreateJobOptions.Builder() - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .userToken("job") - .build(); + CreateJobOptions createOptions = + new CreateJobOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .userToken("job") + .build(); RecognitionJob job = service.createJob(createOptions).execute().getResult(); try { assertNotNull(job.getId()); assertNotNull(job.getWarnings()); - CheckJobOptions checkOptions = new CheckJobOptions.Builder() - .id(job.getId()) - .build(); - for (int x = 0; x < 30 && !Objects.equals(job.getStatus(), RecognitionJob.Status.COMPLETED); x++) { + CheckJobOptions checkOptions = new CheckJobOptions.Builder().id(job.getId()).build(); + for (int x = 0; + x < 30 && !Objects.equals(job.getStatus(), RecognitionJob.Status.COMPLETED); + x++) { Thread.sleep(3000); job = service.checkJob(checkOptions).execute().getResult(); } @@ -543,31 +570,24 @@ public void testCreateJobWarning() throws InterruptedException, FileNotFoundExce assertEquals(RecognitionJob.Status.COMPLETED, job.getStatus()); assertNotNull(job.getResults()); } finally { - DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder() - .id(job.getId()) - .build(); + DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder().id(job.getId()).build(); service.deleteJob(deleteOptions).execute(); } } - /** - * Test check job with wrong id. - * - */ + /** Test check job with wrong id. */ @Test public void testCheckJobWithWrongId() { expectedException.expect(NotFoundException.class); expectedException.expectMessage("job not found"); - CheckJobOptions checkOptions = new CheckJobOptions.Builder() - .id("foo") - .build(); + CheckJobOptions checkOptions = new CheckJobOptions.Builder().id("foo").build(); service.checkJob(checkOptions).execute().getResult(); } /** * Test check jobs. * - * Ignoring while the endpoint is broken. + *

Ignoring while the endpoint is broken. */ @Ignore @Test @@ -576,9 +596,7 @@ public void testCheckJobs() { assertNotNull(jobs); } - /** - * Test list language models. - */ + /** Test list language models. */ @Test public void testListLanguageModels() { LanguageModels models = service.listLanguageModels().execute().getResult(); @@ -586,131 +604,106 @@ public void testListLanguageModels() { assertTrue(!models.getCustomizations().isEmpty()); } - /** - * Test list corpora. - * - */ + /** Test list corpora. */ @Test @Ignore public void testListCorpora() { - ListCorporaOptions listOptions = new ListCorporaOptions.Builder() - .customizationId(customizationId) - .build(); + ListCorporaOptions listOptions = + new ListCorporaOptions.Builder().customizationId(customizationId).build(); Corpora result = service.listCorpora(listOptions).execute().getResult(); assertNotNull(result); } - /** - * Test get corpus. - * - */ + /** Test get corpus. */ @Test @Ignore public void testGetCorpus() { - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .corpusName("foo3") - .customizationId(customizationId) - .build(); + GetCorpusOptions getOptions = + new GetCorpusOptions.Builder().corpusName("foo3").customizationId(customizationId).build(); Corpus result = service.getCorpus(getOptions).execute().getResult(); assertNotNull(result); } - /** - * Test add corpus with expected failure. - * - */ + /** Test add corpus with expected failure. */ @Test(expected = IllegalArgumentException.class) public void testAddCorpusFail() { - AddCorpusOptions addOptions = new AddCorpusOptions.Builder() - .corpusName("foo3") - .customizationId(customizationId) - .build(); + AddCorpusOptions addOptions = + new AddCorpusOptions.Builder().corpusName("foo3").customizationId(customizationId).build(); service.addCorpus(addOptions).execute().getResult(); } - /** - * Test list words with just a customization ID. - */ + /** Test list words with just a customization ID. */ @Test @Ignore public void testListWordsCustomizationId() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(customizationId).build(); Words result = service.listWords(listOptions).execute().getResult(); assertNotNull(result); assertTrue(!result.getWords().isEmpty()); } - /** - * Test list words with a customization ID and word type. - */ + /** Test list words with a customization ID and word type. */ @Test @Ignore public void testListWordsIdAndType() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .wordType(ListWordsOptions.WordType.CORPORA) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder() + .customizationId(customizationId) + .wordType(ListWordsOptions.WordType.CORPORA) + .build(); Words result = service.listWords(listOptions).execute().getResult(); assertNotNull(result); assertTrue(!result.getWords().isEmpty()); } - /** - * Test list words with type all. - */ + /** Test list words with type all. */ @Test @Ignore public void testListWordsTypeAll() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .wordType(ListWordsOptions.WordType.ALL) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder() + .customizationId(customizationId) + .wordType(ListWordsOptions.WordType.ALL) + .build(); Words result = service.listWords(listOptions).execute().getResult(); assertNotNull(result); assertTrue(!result.getWords().isEmpty()); } - /** - * Test list words with alphabetical sort. - */ + /** Test list words with alphabetical sort. */ @Test @Ignore public void testGetWordsThreeSort() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .sort(ListWordsOptions.Sort.ALPHABETICAL) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder() + .customizationId(customizationId) + .sort(ListWordsOptions.Sort.ALPHABETICAL) + .build(); Words result = service.listWords(listOptions).execute().getResult(); assertNotNull(result); assertTrue(!result.getWords().isEmpty()); } - /** - * Test list words with type all and count sort. - */ + /** Test list words with type all and count sort. */ @Test @Ignore public void testGetWordsThreeTypeSort() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .wordType(ListWordsOptions.WordType.ALL) - .sort(ListWordsOptions.Sort.COUNT) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder() + .customizationId(customizationId) + .wordType(ListWordsOptions.WordType.ALL) + .sort(ListWordsOptions.Sort.COUNT) + .build(); Words result = service.listWords(listOptions).execute().getResult(); assertNotNull(result); assertTrue(!result.getWords().isEmpty()); } - /** - * Test get word. - */ + /** Test get word. */ public void testGetWord() { - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(customizationId) - .wordName("string") - .build(); + GetWordOptions getOptions = + new GetWordOptions.Builder().customizationId(customizationId).wordName("string").build(); Word result = service.getWord(getOptions).execute().getResult(); assertNotNull(result); } @@ -718,152 +711,199 @@ public void testGetWord() { /** * Test create language model. * - * Takes a long time to the point of timing out on Travis sometimes, so we'll just run locally. + *

Takes a long time to the point of timing out on Travis sometimes, so we'll just run locally. * * @throws InterruptedException the interrupted exception + * @throws FileNotFoundException the file not found exception */ @Test @Ignore public void testCreateLanguageModel() throws InterruptedException, FileNotFoundException { - CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder() - .name("java-sdk-temporary") - .baseModelName(EN_BROADBAND16K) - .description("Temporary custom model for testing the Java SDK") - .build(); + CreateLanguageModelOptions createOptions = + new CreateLanguageModelOptions.Builder() + .name("java-sdk-temporary") + .baseModelName(EN_BROADBAND16K) + .description("Temporary custom model for testing the Java SDK") + .build(); LanguageModel myModel = service.createLanguageModel(createOptions).execute().getResult(); String id = myModel.getCustomizationId(); try { // Add a corpus file to the model - AddCorpusOptions addOptions = new AddCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .corpusFile(new File(String.format(SPEECH_RESOURCE, "corpus1.txt"))) - .allowOverwrite(false) - .build(); + AddCorpusOptions addOptions = + new AddCorpusOptions.Builder() + .customizationId(id) + .corpusName("corpus-1") + .corpusFile(new File(String.format(SPEECH_RESOURCE, "corpus1.txt"))) + .allowOverwrite(false) + .build(); service.addCorpus(addOptions).execute().getResult(); // Get corpus status - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .build(); - for (int x = 0; x < 30 && !service.getCorpus(getOptions).execute().getResult().getStatus().equals( - Corpus.Status.ANALYZED); x++) { + GetCorpusOptions getOptions = + new GetCorpusOptions.Builder().customizationId(id).corpusName("corpus-1").build(); + for (int x = 0; + x < 30 + && !service + .getCorpus(getOptions) + .execute() + .getResult() + .getStatus() + .equals(Corpus.Status.ANALYZED); + x++) { Thread.sleep(5000); } - assertTrue(service.getCorpus(getOptions).execute().getResult().getStatus().equals(Corpus.Status.ANALYZED)); + assertTrue( + service + .getCorpus(getOptions) + .execute() + .getResult() + .getStatus() + .equals(Corpus.Status.ANALYZED)); // Add the corpus file to the model again and allow overwrite - AddCorpusOptions addOptionsWithOverwrite = new AddCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .corpusFile(new File(String.format(SPEECH_RESOURCE, "corpus1.txt"))) - .allowOverwrite(true) - .build(); + AddCorpusOptions addOptionsWithOverwrite = + new AddCorpusOptions.Builder() + .customizationId(id) + .corpusName("corpus-1") + .corpusFile(new File(String.format(SPEECH_RESOURCE, "corpus1.txt"))) + .allowOverwrite(true) + .build(); service.addCorpus(addOptionsWithOverwrite).execute().getResult(); // Get corpus status - for (int x = 0; x < 30 && !service.getCorpus(getOptions).execute().getResult().getStatus().equals( - Corpus.Status.ANALYZED); x++) { + for (int x = 0; + x < 30 + && !service + .getCorpus(getOptions) + .execute() + .getResult() + .getStatus() + .equals(Corpus.Status.ANALYZED); + x++) { Thread.sleep(5000); } - assertTrue(service.getCorpus(getOptions).execute().getResult().getStatus().equals(Corpus.Status.ANALYZED)); + assertTrue( + service + .getCorpus(getOptions) + .execute() + .getResult() + .getStatus() + .equals(Corpus.Status.ANALYZED)); // Get corpora - ListCorporaOptions listCorporaOptions = new ListCorporaOptions.Builder() - .customizationId(id) - .build(); + ListCorporaOptions listCorporaOptions = + new ListCorporaOptions.Builder().customizationId(id).build(); Corpora corpora = service.listCorpora(listCorporaOptions).execute().getResult(); assertNotNull(corpora); assertTrue(corpora.getCorpora().size() == 1); // Now add some user words to the custom model - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("IEEE") - .word("IEEE") - .displayAs("IEEE") - .addSoundsLike("I. triple E.") - .build()).execute().getResult(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("hhonors") - .word("hhonors") - .displayAs("IEEE") - .addSoundsLike("H. honors") - .addSoundsLike("Hilton honors") - .build()).execute().getResult(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("aaa") - .word("aaa") - .displayAs("aaa") - .addSoundsLike("aaa") - .addSoundsLike("bbb") - .build()).execute().getResult(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("bbb") - .word("bbb") - .addSoundsLike("aaa") - .addSoundsLike("bbb") - .build()).execute().getResult(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("ccc") - .word("ccc") - .displayAs("ccc") - .build()).execute().getResult(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("ddd") - .word("ddd") - .build()).execute().getResult(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("eee") - .word("eee") - .build()).execute().getResult(); - - // Display all words in the words resource (coming from OOVs from the corpus add and the new words just added) - ListWordsOptions listWordsOptions = new ListWordsOptions.Builder() - .customizationId(id) - .wordType(ListWordsOptions.WordType.ALL) - .build(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("IEEE") + .word("IEEE") + .displayAs("IEEE") + .addSoundsLike("I. triple E.") + .build()) + .execute() + .getResult(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("hhonors") + .word("hhonors") + .displayAs("IEEE") + .addSoundsLike("H. honors") + .addSoundsLike("Hilton honors") + .build()) + .execute() + .getResult(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("aaa") + .word("aaa") + .displayAs("aaa") + .addSoundsLike("aaa") + .addSoundsLike("bbb") + .build()) + .execute() + .getResult(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("bbb") + .word("bbb") + .addSoundsLike("aaa") + .addSoundsLike("bbb") + .build()) + .execute() + .getResult(); + service + .addWord( + new AddWordOptions.Builder() + .customizationId(id) + .wordName("ccc") + .word("ccc") + .displayAs("ccc") + .build()) + .execute() + .getResult(); + service + .addWord( + new AddWordOptions.Builder().customizationId(id).wordName("ddd").word("ddd").build()) + .execute() + .getResult(); + service + .addWord( + new AddWordOptions.Builder().customizationId(id).wordName("eee").word("eee").build()) + .execute() + .getResult(); + + // Display all words in the words resource (coming from OOVs from the corpus add + // and the new + // words just added) + ListWordsOptions listWordsOptions = + new ListWordsOptions.Builder() + .customizationId(id) + .wordType(ListWordsOptions.WordType.ALL) + .build(); Words words = service.listWords(listWordsOptions).execute().getResult(); assertNotNull(words); } finally { - DeleteLanguageModelOptions deleteOptions = new DeleteLanguageModelOptions.Builder() - .customizationId(id) - .build(); + DeleteLanguageModelOptions deleteOptions = + new DeleteLanguageModelOptions.Builder().customizationId(id).build(); service.deleteLanguageModel(deleteOptions).execute(); } } - /** - * Test create acoustic model. - */ + /** Test create acoustic model. */ @Test public void testCreateAcousticModel() { String name = "java-sdk-temporary"; String description = "Temporary custom model for testing the Java SDK"; - CreateAcousticModelOptions createOptions = new CreateAcousticModelOptions.Builder() - .name(name) - .baseModelName(EN_BROADBAND16K) - .description(description) - .build(); + CreateAcousticModelOptions createOptions = + new CreateAcousticModelOptions.Builder() + .name(name) + .baseModelName(EN_BROADBAND16K) + .description(description) + .build(); AcousticModel myModel = service.createAcousticModel(createOptions).execute().getResult(); String id = myModel.getCustomizationId(); try { - GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder() - .customizationId(id) - .build(); + GetAcousticModelOptions getOptions = + new GetAcousticModelOptions.Builder().customizationId(id).build(); AcousticModel model = service.getAcousticModel(getOptions).execute().getResult(); assertNotNull(model); @@ -871,16 +911,13 @@ public void testCreateAcousticModel() { assertEquals(EN_BROADBAND16K, model.getBaseModelName()); assertEquals(description, model.getDescription()); } finally { - DeleteAcousticModelOptions deleteOptions = new DeleteAcousticModelOptions.Builder() - .customizationId(id) - .build(); + DeleteAcousticModelOptions deleteOptions = + new DeleteAcousticModelOptions.Builder().customizationId(id).build(); service.deleteAcousticModel(deleteOptions).execute(); } } - /** - * Test list acoustic models. - */ + /** Test list acoustic models. */ @Test public void testListAcousticModels() { AcousticModels models = service.listAcousticModels().execute().getResult(); @@ -890,50 +927,51 @@ public void testListAcousticModels() { /** * Test get audio. * - * This test is currently being ignored as it has a very long runtime and causes Travis to timeout. - * The ignore annotation can be removed to test this locally. + *

This test is currently being ignored as it has a very long runtime and causes Travis to + * timeout. The ignore annotation can be removed to test this locally. * * @throws InterruptedException the interrupted exception + * @throws FileNotFoundException the file not found exception */ @Ignore @Test public void testGetAudio() throws InterruptedException, FileNotFoundException { String audioName = "sample"; - AddAudioOptions addOptions = new AddAudioOptions.Builder() - .audioResource(new File(SAMPLE_WAV)) - .contentType(HttpMediaType.AUDIO_WAV) - .audioName(audioName) - .customizationId(acousticCustomizationId) - .allowOverwrite(true) - .build(); + AddAudioOptions addOptions = + new AddAudioOptions.Builder() + .audioResource(new File(SAMPLE_WAV)) + .contentType(HttpMediaType.AUDIO_WAV) + .audioName(audioName) + .customizationId(acousticCustomizationId) + .allowOverwrite(true) + .build(); service.addAudio(addOptions).execute().getResult(); try { - GetAudioOptions getOptions = new GetAudioOptions.Builder() - .customizationId(acousticCustomizationId) - .audioName(audioName) - .build(); + GetAudioOptions getOptions = + new GetAudioOptions.Builder() + .customizationId(acousticCustomizationId) + .audioName(audioName) + .build(); AudioListing audio = service.getAudio(getOptions).execute().getResult(); assertNotNull(audio); assertEquals(audioName, audio.getName()); } finally { - DeleteAudioOptions deleteAudioOptions = new DeleteAudioOptions.Builder() - .customizationId(acousticCustomizationId) - .audioName(audioName) - .build(); + DeleteAudioOptions deleteAudioOptions = + new DeleteAudioOptions.Builder() + .customizationId(acousticCustomizationId) + .audioName(audioName) + .build(); service.deleteAudio(deleteAudioOptions).execute(); } } - /** - * Test list audio. - */ + /** Test list audio. */ @Test public void testListAudio() { - ListAudioOptions listOptions = new ListAudioOptions.Builder() - .customizationId(acousticCustomizationId) - .build(); + ListAudioOptions listOptions = + new ListAudioOptions.Builder().customizationId(acousticCustomizationId).build(); AudioResources resources = service.listAudio(listOptions).execute().getResult(); assertNotNull(resources); @@ -943,54 +981,64 @@ public void testListAudio() { * Test add audio with an archive file. * * @throws FileNotFoundException the file not found exception + * @throws InterruptedException the interrupted exception */ @Test public void testAddAudioArchive() throws FileNotFoundException, InterruptedException { String audioName = "test-archive"; File audio = new File(WAV_ARCHIVE); Thread.sleep(5000); - AddAudioOptions addOptions = new AddAudioOptions.Builder() - .customizationId(acousticCustomizationId) - .audioName(audioName) - .contentType(HttpMediaType.APPLICATION_ZIP) - .containedContentType(AddAudioOptions.ContainedContentType.AUDIO_WAV) - .audioResource(audio) - .allowOverwrite(true) - .build(); + AddAudioOptions addOptions = + new AddAudioOptions.Builder() + .customizationId(acousticCustomizationId) + .audioName(audioName) + .contentType(HttpMediaType.APPLICATION_ZIP) + .containedContentType(AddAudioOptions.ContainedContentType.AUDIO_WAV) + .audioResource(audio) + .allowOverwrite(true) + .build(); service.addAudio(addOptions).execute().getResult(); try { - GetAudioOptions getOptions = new GetAudioOptions.Builder() - .customizationId(acousticCustomizationId) - .audioName(audioName) - .build(); + GetAudioOptions getOptions = + new GetAudioOptions.Builder() + .customizationId(acousticCustomizationId) + .audioName(audioName) + .build(); AudioListing listing = service.getAudio(getOptions).execute().getResult(); assertNotNull(listing); assertEquals(audioName, listing.getContainer().getName()); } finally { - DeleteAudioOptions deleteAudioOptions = new DeleteAudioOptions.Builder() - .customizationId(acousticCustomizationId) - .audioName(audioName) - .build(); + DeleteAudioOptions deleteAudioOptions = + new DeleteAudioOptions.Builder() + .customizationId(acousticCustomizationId) + .audioName(audioName) + .build(); service.deleteAudio(deleteAudioOptions).execute(); } } + /** Test delete user data. */ @Test public void testDeleteUserData() { String customerId = "java_sdk_test_id"; try { - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); + DeleteUserDataOptions deleteOptions = + new DeleteUserDataOptions.Builder().customerId(customerId).build(); service.deleteUserData(deleteOptions); } catch (Exception ex) { fail(ex.getMessage()); } } + /** + * Test grammar operations. + * + * @throws FileNotFoundException the file not found exception + * @throws InterruptedException the interrupted exception + */ // Avoid running in CI due to possible timeouts. @Ignore @Test @@ -1001,18 +1049,18 @@ public void testGrammarOperations() throws FileNotFoundException, InterruptedExc String grammarName = "java-sdk-test-grammar"; - AddGrammarOptions addGrammarOptions = new AddGrammarOptions.Builder() - .customizationId(customizationId) - .grammarFile(new FileInputStream(SAMPLE_GRAMMAR)) - .grammarName(grammarName) - .contentType("application/srgs") - .allowOverwrite(true) - .build(); + AddGrammarOptions addGrammarOptions = + new AddGrammarOptions.Builder() + .customizationId(customizationId) + .grammarFile(new FileInputStream(SAMPLE_GRAMMAR)) + .grammarName(grammarName) + .contentType("application/srgs") + .allowOverwrite(true) + .build(); service.addGrammar(addGrammarOptions).execute().getResult(); - ListGrammarsOptions listGrammarsOptions = new ListGrammarsOptions.Builder() - .customizationId(customizationId) - .build(); + ListGrammarsOptions listGrammarsOptions = + new ListGrammarsOptions.Builder().customizationId(customizationId).build(); Grammars listGrammarsResponse = service.listGrammars(listGrammarsOptions).execute().getResult(); assertNotNull(listGrammarsResponse); boolean found = false; @@ -1024,10 +1072,11 @@ public void testGrammarOperations() throws FileNotFoundException, InterruptedExc } assertTrue(found); - GetGrammarOptions getGrammarOptions = new GetGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); + GetGrammarOptions getGrammarOptions = + new GetGrammarOptions.Builder() + .customizationId(customizationId) + .grammarName(grammarName) + .build(); Grammar getGrammarResponse = service.getGrammar(getGrammarOptions).execute().getResult(); assertNotNull(getGrammarResponse); assertEquals(grammarName, getGrammarResponse.getName()); @@ -1036,17 +1085,36 @@ public void testGrammarOperations() throws FileNotFoundException, InterruptedExc Thread.sleep(5000); } - DeleteGrammarOptions deleteGrammarOptions = new DeleteGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); + DeleteGrammarOptions deleteGrammarOptions = + new DeleteGrammarOptions.Builder() + .customizationId(customizationId) + .grammarName(grammarName) + .build(); service.deleteGrammar(deleteGrammarOptions).execute(); } + /** + * Test detect language. + * + * @throws FileNotFoundException the file not found exception + */ + @Test + public void testdetectLanguage() throws FileNotFoundException { + File audio = new File(SAMPLE_WAV); + DetectLanguageOptions options = + new DetectLanguageOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .lidConfidence(0.9f) + .build(); + LanguageDetectionResults results = service.detectLanguage(options).execute().getResult(); + + assertNotNull(results.getResults().get(0)); + } + private boolean isCustomizationReady(String customizationId) { - GetLanguageModelOptions getLanguageModelOptions = new GetLanguageModelOptions.Builder() - .customizationId(customizationId) - .build(); + GetLanguageModelOptions getLanguageModelOptions = + new GetLanguageModelOptions.Builder().customizationId(customizationId).build(); LanguageModel model = service.getLanguageModel(getLanguageModelOptions).execute().getResult(); return model.getStatus().equals(LanguageModel.Status.READY) || model.getStatus().equals(LanguageModel.Status.AVAILABLE); diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java index f6199db4ab8..70ba77e10dc 100755 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2026. * * 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 @@ -10,17 +10,16 @@ * 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.speech_to_text.v1; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.util.GsonSingleton; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.watson.common.TestUtils; -import com.ibm.watson.common.WatsonServiceUnitTest; import com.ibm.watson.speech_to_text.v1.model.AcousticModel; import com.ibm.watson.speech_to_text.v1.model.AcousticModels; import com.ibm.watson.speech_to_text.v1.model.AddAudioOptions; @@ -29,10 +28,11 @@ import com.ibm.watson.speech_to_text.v1.model.AddWordOptions; import com.ibm.watson.speech_to_text.v1.model.AddWordsOptions; import com.ibm.watson.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.speech_to_text.v1.model.AudioResource; import com.ibm.watson.speech_to_text.v1.model.AudioResources; import com.ibm.watson.speech_to_text.v1.model.CheckJobOptions; +import com.ibm.watson.speech_to_text.v1.model.CheckJobsOptions; import com.ibm.watson.speech_to_text.v1.model.Corpora; +import com.ibm.watson.speech_to_text.v1.model.Corpus; import com.ibm.watson.speech_to_text.v1.model.CreateAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.CreateJobOptions; import com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions; @@ -45,6 +45,7 @@ import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteUserDataOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteWordOptions; +import com.ibm.watson.speech_to_text.v1.model.DetectLanguageOptions; import com.ibm.watson.speech_to_text.v1.model.GetAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.GetAudioOptions; import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; @@ -54,6 +55,7 @@ import com.ibm.watson.speech_to_text.v1.model.GetWordOptions; import com.ibm.watson.speech_to_text.v1.model.Grammar; import com.ibm.watson.speech_to_text.v1.model.Grammars; +import com.ibm.watson.speech_to_text.v1.model.LanguageDetectionResults; import com.ibm.watson.speech_to_text.v1.model.LanguageModel; import com.ibm.watson.speech_to_text.v1.model.LanguageModels; import com.ibm.watson.speech_to_text.v1.model.ListAcousticModelsOptions; @@ -61,6 +63,7 @@ import com.ibm.watson.speech_to_text.v1.model.ListCorporaOptions; import com.ibm.watson.speech_to_text.v1.model.ListGrammarsOptions; import com.ibm.watson.speech_to_text.v1.model.ListLanguageModelsOptions; +import com.ibm.watson.speech_to_text.v1.model.ListModelsOptions; import com.ibm.watson.speech_to_text.v1.model.ListWordsOptions; import com.ibm.watson.speech_to_text.v1.model.RecognitionJob; import com.ibm.watson.speech_to_text.v1.model.RecognitionJobs; @@ -71,1608 +74,2407 @@ import com.ibm.watson.speech_to_text.v1.model.ResetLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.SpeechModel; import com.ibm.watson.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResult; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; import com.ibm.watson.speech_to_text.v1.model.TrainAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.TrainLanguageModelOptions; +import com.ibm.watson.speech_to_text.v1.model.TrainingResponse; import com.ibm.watson.speech_to_text.v1.model.UnregisterCallbackOptions; import com.ibm.watson.speech_to_text.v1.model.UpgradeAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.UpgradeLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.Word; import com.ibm.watson.speech_to_text.v1.model.Words; -import com.ibm.watson.speech_to_text.v1.util.MediaTypeUtils; -import com.ibm.watson.speech_to_text.v1.websocket.RecognizeCallback; -import okhttp3.WebSocket; -import okhttp3.internal.ws.WebSocketRecorder; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okio.ByteString; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * The Class SpeechToTextTest. - */ -@FixMethodOrder(MethodSorters.JVM) -public class SpeechToTextTest extends WatsonServiceUnitTest { +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); +/** Unit test class for the SpeechToText service. */ +public class SpeechToTextTest { - private static final String PATH_CORPORA = "/v1/customizations/%s/corpora"; - private static final String PATH_CORPUS = "/v1/customizations/%s/corpora/%s"; - private static final String PATH_CUSTOMIZATION = "/v1/customizations/%s"; - private static final String PATH_CUSTOMIZATIONS = "/v1/customizations"; - private static final String PATH_ACOUSTIC_CUSTOMIZATION = "/v1/acoustic_customizations/%s"; - private static final String PATH_ACOUSTIC_CUSTOMIZATIONS = "/v1/acoustic_customizations"; - private static final String PATH_MODELS = "/v1/models"; - private static final String PATH_RECOGNITION = "/v1/recognitions/%s"; - private static final String PATH_RECOGNITIONS = "/v1/recognitions"; - private static final String PATH_RECOGNIZE = "/v1/recognize"; - private static final String PATH_ACOUSTIC_RESET = "/v1/acoustic_customizations/%s/reset"; - private static final String PATH_RESET = "/v1/customizations/%s/reset"; - private static final String PATH_ACOUSTIC_TRAIN = "/v1/acoustic_customizations/%s/train"; - private static final String PATH_TRAIN = "/v1/customizations/%s/train"; - private static final String PATH_WORDS = "/v1/customizations/%s/words"; - private static final String PATH_WORD = "/v1/customizations/%s/words/%s"; - private static final String PATH_ACOUSTIC_UPGRADE = "/v1/acoustic_customizations/%s/upgrade_model"; - private static final String PATH_UPGRADE = "/v1/customizations/%s/upgrade_model"; - private static final String PATH_ALL_AUDIO = "/v1/acoustic_customizations/%s/audio"; - private static final String PATH_SPECIFIC_AUDIO = "/v1/acoustic_customizations/%s/audio/%s"; - private static final String REGISTER_CALLBACK = "/v1/register_callback?callback_url=%s&user_secret=%s"; - private static final String UNREGISTER_CALLBACK = "/v1/unregister_callback?callback_url=%s"; + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); - private static final File SAMPLE_WAV = new File("src/test/resources/speech_to_text/sample1.wav"); - private static final File SAMPLE_WEBM = new File("src/test/resources/speech_to_text/sample1.webm"); + protected MockWebServer server; + protected SpeechToText speechToTextService; - private static final String UPDATED = "2019-10-11T19:16:58.547Z"; + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + new SpeechToText(serviceName, null); + } - private SpeechModel speechModel; - private SpeechModels speechModels; - private SpeechRecognitionResults recognitionResults; - private Grammars grammars; - private Grammar grammar; + // Test the listModels operation with a valid options model parameter + @Test + public void testListModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"models\": [{\"name\": \"name\", \"language\": \"language\", \"rate\": 4, \"url\": \"url\", \"supported_features\": {\"custom_language_model\": false, \"custom_acoustic_model\": false, \"speaker_labels\": false, \"low_latency\": true}, \"description\": \"description\"}]}"; + String listModelsPath = "/v1/models"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListModelsOptions model + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + + // Invoke listModels() with a valid options model and verify the result + Response response = + speechToTextService.listModels(listModelsOptionsModel).execute(); + assertNotNull(response); + SpeechModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listModelsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - private SpeechToText service; + // Test the listModels operation with and without retries enabled + @Test + public void testListModelsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListModelsWOptions(); + + speechToTextService.disableRetries(); + testListModelsWOptions(); + } + + // Test the getModel operation with a valid options model parameter + @Test + public void testGetModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"language\": \"language\", \"rate\": 4, \"url\": \"url\", \"supported_features\": {\"custom_language_model\": false, \"custom_acoustic_model\": false, \"speaker_labels\": false, \"low_latency\": true}, \"description\": \"description\"}"; + String getModelPath = "/v1/models/ar-MS_BroadbandModel"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetModelOptions model + GetModelOptions getModelOptionsModel = + new GetModelOptions.Builder().modelId("ar-MS_BroadbandModel").build(); + + // Invoke getModel() with a valid options model and verify the result + Response response = speechToTextService.getModel(getModelOptionsModel).execute(); + assertNotNull(response); + SpeechModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); + // Test the getModel operation with and without retries enabled + @Test + public void testGetModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetModelWOptions(); - service = new SpeechToText(new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); + speechToTextService.disableRetries(); + testGetModelWOptions(); + } - speechModel = loadFixture("src/test/resources/speech_to_text/speech-model.json", SpeechModel.class); - speechModels = loadFixture("src/test/resources/speech_to_text/speech-models.json", SpeechModels.class); - recognitionResults = loadFixture("src/test/resources/speech_to_text/recognition-results.json", - SpeechRecognitionResults.class); - grammars = loadFixture("src/test/resources/speech_to_text/grammar_list.json", Grammars.class); - grammar = loadFixture("src/test/resources/speech_to_text/grammar.json", Grammar.class); + // Test the getModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getModel(null).execute(); } - // --- MODELS --- + // Test the recognize operation with a valid options model parameter + @Test + public void testRecognizeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}"; + String recognizePath = "/v1/recognize"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RecognizeOptions model + RecognizeOptions recognizeOptionsModel = + new RecognizeOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("en-US_BroadbandModel") + .speechBeginEvent(false) + .enrichments("testString") + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("30")) + .keywords(java.util.Arrays.asList("testString")) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("1")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(false) + .timestamps(false) + .profanityFilter(true) + .smartFormatting(false) + .smartFormattingVersion(Long.valueOf("0")) + .speakerLabels(false) + .grammarName("testString") + .redaction(false) + .audioMetrics(false) + .endOfPhraseSilenceTime(Double.valueOf("0.8")) + .splitTranscriptAtPhraseEnd(false) + .speechDetectorSensitivity(Float.valueOf("0.5")) + .sadModule(Long.valueOf("1")) + .backgroundAudioSuppression(Float.valueOf("0.0")) + .lowLatency(false) + .characterInsertionBias(Float.valueOf("0.0")) + .build(); + + // Invoke recognize() with a valid options model and verify the result + Response response = + speechToTextService.recognize(recognizeOptionsModel).execute(); + assertNotNull(response); + SpeechRecognitionResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, recognizePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("model"), "en-US_BroadbandModel"); + assertEquals(Boolean.valueOf(query.get("speech_begin_event")), Boolean.valueOf(false)); + assertEquals(query.get("enrichments"), "testString"); + assertEquals(query.get("language_customization_id"), "testString"); + assertEquals(query.get("acoustic_customization_id"), "testString"); + assertEquals(query.get("base_model_version"), "testString"); + assertEquals(Double.valueOf(query.get("customization_weight")), Double.valueOf("72.5")); + assertEquals(Long.valueOf(query.get("inactivity_timeout")), Long.valueOf("30")); + assertEquals( + query.get("keywords"), RequestUtils.join(java.util.Arrays.asList("testString"), ",")); + assertEquals(Float.valueOf(query.get("keywords_threshold")), Float.valueOf("36.0")); + assertEquals(Long.valueOf(query.get("max_alternatives")), Long.valueOf("1")); + assertEquals(Float.valueOf(query.get("word_alternatives_threshold")), Float.valueOf("36.0")); + assertEquals(Boolean.valueOf(query.get("word_confidence")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("timestamps")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("profanity_filter")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("smart_formatting")), Boolean.valueOf(false)); + assertEquals(Long.valueOf(query.get("smart_formatting_version")), Long.valueOf("0")); + assertEquals(Boolean.valueOf(query.get("speaker_labels")), Boolean.valueOf(false)); + assertEquals(query.get("grammar_name"), "testString"); + assertEquals(Boolean.valueOf(query.get("redaction")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("audio_metrics")), Boolean.valueOf(false)); + assertEquals(Double.valueOf(query.get("end_of_phrase_silence_time")), Double.valueOf("0.8")); + assertEquals( + Boolean.valueOf(query.get("split_transcript_at_phrase_end")), Boolean.valueOf(false)); + assertEquals(Float.valueOf(query.get("speech_detector_sensitivity")), Float.valueOf("0.5")); + assertEquals(Long.valueOf(query.get("sad_module")), Long.valueOf("1")); + assertEquals(Float.valueOf(query.get("background_audio_suppression")), Float.valueOf("0.0")); + assertEquals(Boolean.valueOf(query.get("low_latency")), Boolean.valueOf(false)); + assertEquals(Float.valueOf(query.get("character_insertion_bias")), Float.valueOf("0.0")); + } + // Test the recognize operation with and without retries enabled @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "customerId"; + public void testRecognizeWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testRecognizeWOptions(); - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); + speechToTextService.disableRetries(); + testRecognizeWOptions(); + } - assertEquals(deleteOptions.customerId(), customerId); + // Test the recognize operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRecognizeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.recognize(null).execute(); } + // Test the registerCallback operation with a valid options model parameter @Test - public void testAddGrammarOptions() throws FileNotFoundException { - String customizationId = "id"; - String grammarName = "grammar_name"; - InputStream grammarFile = new FileInputStream(SAMPLE_WAV); + public void testRegisterCallbackWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"status\": \"created\", \"url\": \"url\"}"; + String registerCallbackPath = "/v1/register_callback"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RegisterCallbackOptions model + RegisterCallbackOptions registerCallbackOptionsModel = + new RegisterCallbackOptions.Builder() + .callbackUrl("testString") + .userSecret("testString") + .build(); + + // Invoke registerCallback() with a valid options model and verify the result + Response response = + speechToTextService.registerCallback(registerCallbackOptionsModel).execute(); + assertNotNull(response); + RegisterStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, registerCallbackPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("callback_url"), "testString"); + assertEquals(query.get("user_secret"), "testString"); + } - AddGrammarOptions addGrammarOptions = new AddGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .grammarFile(grammarFile) - .contentType("application/srgs") - .allowOverwrite(true) - .build(); + // Test the registerCallback operation with and without retries enabled + @Test + public void testRegisterCallbackWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testRegisterCallbackWOptions(); - assertEquals(customizationId, addGrammarOptions.customizationId()); - assertEquals(grammarName, addGrammarOptions.grammarName()); - assertEquals(grammarFile, addGrammarOptions.grammarFile()); - assertEquals("application/srgs", addGrammarOptions.contentType()); - assertTrue(addGrammarOptions.allowOverwrite()); + speechToTextService.disableRetries(); + testRegisterCallbackWOptions(); } + // Test the registerCallback operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRegisterCallbackNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.registerCallback(null).execute(); + } + + // Test the unregisterCallback operation with a valid options model parameter @Test - public void testListGrammarsOptions() { - String customizationId = "id"; + public void testUnregisterCallbackWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String unregisterCallbackPath = "/v1/unregister_callback"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the UnregisterCallbackOptions model + UnregisterCallbackOptions unregisterCallbackOptionsModel = + new UnregisterCallbackOptions.Builder().callbackUrl("testString").build(); + + // Invoke unregisterCallback() with a valid options model and verify the result + Response response = + speechToTextService.unregisterCallback(unregisterCallbackOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, unregisterCallbackPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("callback_url"), "testString"); + } + + // Test the unregisterCallback operation with and without retries enabled + @Test + public void testUnregisterCallbackWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testUnregisterCallbackWOptions(); + + speechToTextService.disableRetries(); + testUnregisterCallbackWOptions(); + } - ListGrammarsOptions listGrammarsOptions = new ListGrammarsOptions.Builder() - .customizationId(customizationId) - .build(); + // Test the unregisterCallback operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUnregisterCallbackNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.unregisterCallback(null).execute(); + } - assertEquals(customizationId, listGrammarsOptions.customizationId()); + // Test the createJob operation with a valid options model parameter + @Test + public void testCreateJobWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}], \"warnings\": [\"warnings\"]}"; + String createJobPath = "/v1/recognitions"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateJobOptions model + CreateJobOptions createJobOptionsModel = + new CreateJobOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("en-US_BroadbandModel") + .callbackUrl("testString") + .events("recognitions.started") + .userToken("testString") + .resultsTtl(Long.valueOf("26")) + .speechBeginEvent(false) + .enrichments("testString") + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("30")) + .keywords(java.util.Arrays.asList("testString")) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("1")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(false) + .timestamps(false) + .profanityFilter(true) + .smartFormatting(false) + .smartFormattingVersion(Long.valueOf("0")) + .speakerLabels(false) + .grammarName("testString") + .redaction(false) + .processingMetrics(false) + .processingMetricsInterval(Float.valueOf("1.0")) + .audioMetrics(false) + .endOfPhraseSilenceTime(Double.valueOf("0.8")) + .splitTranscriptAtPhraseEnd(false) + .speechDetectorSensitivity(Float.valueOf("0.5")) + .sadModule(Long.valueOf("1")) + .backgroundAudioSuppression(Float.valueOf("0.0")) + .lowLatency(false) + .characterInsertionBias(Float.valueOf("0.0")) + .build(); + + // Invoke createJob() with a valid options model and verify the result + Response response = + speechToTextService.createJob(createJobOptionsModel).execute(); + assertNotNull(response); + RecognitionJob responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createJobPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("model"), "en-US_BroadbandModel"); + assertEquals(query.get("callback_url"), "testString"); + assertEquals(query.get("events"), "recognitions.started"); + assertEquals(query.get("user_token"), "testString"); + assertEquals(Long.valueOf(query.get("results_ttl")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("speech_begin_event")), Boolean.valueOf(false)); + assertEquals(query.get("enrichments"), "testString"); + assertEquals(query.get("language_customization_id"), "testString"); + assertEquals(query.get("acoustic_customization_id"), "testString"); + assertEquals(query.get("base_model_version"), "testString"); + assertEquals(Double.valueOf(query.get("customization_weight")), Double.valueOf("72.5")); + assertEquals(Long.valueOf(query.get("inactivity_timeout")), Long.valueOf("30")); + assertEquals( + query.get("keywords"), RequestUtils.join(java.util.Arrays.asList("testString"), ",")); + assertEquals(Float.valueOf(query.get("keywords_threshold")), Float.valueOf("36.0")); + assertEquals(Long.valueOf(query.get("max_alternatives")), Long.valueOf("1")); + assertEquals(Float.valueOf(query.get("word_alternatives_threshold")), Float.valueOf("36.0")); + assertEquals(Boolean.valueOf(query.get("word_confidence")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("timestamps")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("profanity_filter")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("smart_formatting")), Boolean.valueOf(false)); + assertEquals(Long.valueOf(query.get("smart_formatting_version")), Long.valueOf("0")); + assertEquals(Boolean.valueOf(query.get("speaker_labels")), Boolean.valueOf(false)); + assertEquals(query.get("grammar_name"), "testString"); + assertEquals(Boolean.valueOf(query.get("redaction")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("processing_metrics")), Boolean.valueOf(false)); + assertEquals(Float.valueOf(query.get("processing_metrics_interval")), Float.valueOf("1.0")); + assertEquals(Boolean.valueOf(query.get("audio_metrics")), Boolean.valueOf(false)); + assertEquals(Double.valueOf(query.get("end_of_phrase_silence_time")), Double.valueOf("0.8")); + assertEquals( + Boolean.valueOf(query.get("split_transcript_at_phrase_end")), Boolean.valueOf(false)); + assertEquals(Float.valueOf(query.get("speech_detector_sensitivity")), Float.valueOf("0.5")); + assertEquals(Long.valueOf(query.get("sad_module")), Long.valueOf("1")); + assertEquals(Float.valueOf(query.get("background_audio_suppression")), Float.valueOf("0.0")); + assertEquals(Boolean.valueOf(query.get("low_latency")), Boolean.valueOf(false)); + assertEquals(Float.valueOf(query.get("character_insertion_bias")), Float.valueOf("0.0")); } + // Test the createJob operation with and without retries enabled @Test - public void testGetGrammarOptions() { - String customizationId = "id"; - String grammarName = "grammar_name"; + public void testCreateJobWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCreateJobWOptions(); - GetGrammarOptions getGrammarOptions = new GetGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); + speechToTextService.disableRetries(); + testCreateJobWOptions(); + } - assertEquals(customizationId, getGrammarOptions.customizationId()); - assertEquals(grammarName, getGrammarOptions.grammarName()); + // Test the createJob operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateJobNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.createJob(null).execute(); } + // Test the checkJobs operation with a valid options model parameter @Test - public void testDeleteGrammarOptions() { - String customizationId = "id"; - String grammarName = "grammar_name"; + public void testCheckJobsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"recognitions\": [{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}], \"warnings\": [\"warnings\"]}]}"; + String checkJobsPath = "/v1/recognitions"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CheckJobsOptions model + CheckJobsOptions checkJobsOptionsModel = new CheckJobsOptions(); + + // Invoke checkJobs() with a valid options model and verify the result + Response response = + speechToTextService.checkJobs(checkJobsOptionsModel).execute(); + assertNotNull(response); + RecognitionJobs responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, checkJobsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - DeleteGrammarOptions deleteGrammarOptions = new DeleteGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); + // Test the checkJobs operation with and without retries enabled + @Test + public void testCheckJobsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCheckJobsWOptions(); - assertEquals(customizationId, deleteGrammarOptions.customizationId()); - assertEquals(grammarName, deleteGrammarOptions.grammarName()); + speechToTextService.disableRetries(); + testCheckJobsWOptions(); } - // --- METHODS --- + // Test the checkJob operation with a valid options model parameter + @Test + public void testCheckJobWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}], \"warnings\": [\"warnings\"]}"; + String checkJobPath = "/v1/recognitions/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CheckJobOptions model + CheckJobOptions checkJobOptionsModel = new CheckJobOptions.Builder().id("testString").build(); + + // Invoke checkJob() with a valid options model and verify the result + Response response = + speechToTextService.checkJob(checkJobOptionsModel).execute(); + assertNotNull(response); + RecognitionJob responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, checkJobPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - /** - * Test get model. - * - * @throws Exception the exception - */ + // Test the checkJob operation with and without retries enabled @Test - public void testGetModel() throws Exception { - final MockResponse mockResponse = new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(speechModel)); + public void testCheckJobWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCheckJobWOptions(); - server.enqueue(mockResponse); - GetModelOptions getOptionsString = new GetModelOptions.Builder() - .modelId("not-a-real-Model") - .build(); - SpeechModel model = service.getModel(getOptionsString).execute().getResult(); + speechToTextService.disableRetries(); + testCheckJobWOptions(); + } + + // Test the checkJob operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCheckJobNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.checkJob(null).execute(); + } + + // Test the deleteJob operation with a valid options model parameter + @Test + public void testDeleteJobWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteJobPath = "/v1/recognitions/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteJobOptions model + DeleteJobOptions deleteJobOptionsModel = + new DeleteJobOptions.Builder().id("testString").build(); + + // Invoke deleteJob() with a valid options model and verify the result + Response response = speechToTextService.deleteJob(deleteJobOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteJobPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - assertNotNull(model); - assertEquals(model, speechModel); - assertEquals(GET, request.getMethod()); + // Test the deleteJob operation with and without retries enabled + @Test + public void testDeleteJobWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteJobWOptions(); - server.enqueue(mockResponse); - GetModelOptions getOptionsGetter = new GetModelOptions.Builder() - .modelId("not-a-real-Model") - .build(); - model = service.getModel(getOptionsGetter).execute().getResult(); - request = server.takeRequest(); + speechToTextService.disableRetries(); + testDeleteJobWOptions(); + } - assertNotNull(model); - assertEquals(model, speechModel); - assertEquals(GET, request.getMethod()); + // Test the deleteJob operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteJobNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteJob(null).execute(); + } - TestUtils.assertNoExceptionsOnGetters(model); + // Test the createLanguageModel operation with a valid options model parameter + @Test + public void testCreateLanguageModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}"; + String createLanguageModelPath = "/v1/customizations"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateLanguageModelOptions model + CreateLanguageModelOptions createLanguageModelOptionsModel = + new CreateLanguageModelOptions.Builder() + .name("testString") + .baseModelName("ar-MS_Telephony") + .dialect("testString") + .description("testString") + .build(); + + // Invoke createLanguageModel() with a valid options model and verify the result + Response response = + speechToTextService.createLanguageModel(createLanguageModelOptionsModel).execute(); + assertNotNull(response); + LanguageModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createLanguageModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); } - /** - * Test get models. - * - * @throws InterruptedException the interrupted exception - */ + // Test the createLanguageModel operation with and without retries enabled @Test - public void testGetModels() throws InterruptedException { + public void testCreateLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCreateLanguageModelWOptions(); + + speechToTextService.disableRetries(); + testCreateLanguageModelWOptions(); + } + + // Test the createLanguageModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateLanguageModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.createLanguageModel(null).execute(); + } + + // Test the listLanguageModels operation with a valid options model parameter + @Test + public void testListLanguageModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}]}"; + String listLanguageModelsPath = "/v1/customizations"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(speechModels))); - - final SpeechModels models = service.listModels().execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertNotNull(models); - assertFalse(models.getModels().isEmpty()); - assertEquals(models.getModels(), speechModels.getModels()); - assertEquals(PATH_MODELS, request.getPath()); - } - - /** - * Test get model with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testGetModelWithNull() { - service.getModel(null).execute().getResult(); - } - - /** - * Test recognize. - * - * @throws URISyntaxException the URI syntax exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRecognize() throws URISyntaxException, InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(recognitionResults))); - - RecognizeOptions recognizeOptions = new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .audioMetrics(true) - .endOfPhraseSilenceTime(2.0) - .splitTranscriptAtPhraseEnd(true) - .build(); - - assertEquals((Double) 2.0, recognizeOptions.endOfPhraseSilenceTime()); - assertTrue(recognizeOptions.splitTranscriptAtPhraseEnd()); - - final SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertNotNull(result); - assertEquals(result, recognitionResults); - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE - + "?audio_metrics=true&end_of_phrase_silence_time=2.0&split_transcript_at_phrase_end=true", request.getPath()); - assertEquals(HttpMediaType.AUDIO_WAV, request.getHeader(CONTENT_TYPE)); - assertEquals(recognitionResults.getAudioMetrics().getSamplingInterval(), - result.getAudioMetrics().getSamplingInterval()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().isXFinal(), - result.getAudioMetrics().getAccumulated().isXFinal()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getEndTime(), - result.getAudioMetrics().getAccumulated().getEndTime()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getSpeechRatio(), - result.getAudioMetrics().getAccumulated().getSpeechRatio()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getHighFrequencyLoss(), - result.getAudioMetrics().getAccumulated().getHighFrequencyLoss()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getSignalToNoiseRatio(), - result.getAudioMetrics().getAccumulated().getSignalToNoiseRatio()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getBegin()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getEnd()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getCount()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getClippingRate().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getClippingRate().get(0).getBegin()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getClippingRate().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getClippingRate().get(0).getEnd()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getClippingRate().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getClippingRate().get(0).getCount()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getBegin()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getEnd()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getCount()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getBegin()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getEnd()); - assertEquals(recognitionResults.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getCount()); - assertEquals(SpeechRecognitionResult.EndOfUtterance.END_OF_DATA, - recognitionResults.getResults().get(0).getEndOfUtterance()); - } - - /** - * Test recognize WebM for WebM audio format. - * - * @throws URISyntaxException the URI syntax exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRecognizeWebM() throws URISyntaxException, InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(recognitionResults))); - - RecognizeOptions recognizeOptions = new RecognizeOptions.Builder() - .audio(SAMPLE_WEBM) - .contentType(HttpMediaType.AUDIO_WEBM) - .build(); - final SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertNotNull(result); - assertEquals(result, recognitionResults); - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE, request.getPath()); - assertEquals(HttpMediaType.AUDIO_WEBM, request.getHeader(CONTENT_TYPE)); - } - - /** - * Test diarization. - * - * @throws URISyntaxException the URI syntax exception - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testRecognizeWithSpeakerLabels() throws URISyntaxException, InterruptedException, FileNotFoundException { - FileInputStream jsonFile = new FileInputStream("src/test/resources/speech_to_text/diarization.json"); - String diarizationStr = getStringFromInputStream(jsonFile); - JsonObject diarization = new JsonParser().parse(diarizationStr).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(diarizationStr)); - - RecognizeOptions recognizeOptions = new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .speakerLabels(true) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE + "?speaker_labels=true", request.getPath()); - assertEquals(diarization.toString(), GSON.toJsonTree(result).toString()); - } - - /** - * Test recognize with customization. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRecognizeWithCustomization() throws FileNotFoundException, InterruptedException { - String id = "foo"; - String version = "version"; - String recString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/recognition.json")); - JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(recString)); - - RecognizeOptions recognizeOptions = new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .languageCustomizationId(id) - .baseModelVersion(version) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE + "?language_customization_id=" + id + "&base_model_version=" + version, request - .getPath()); - assertEquals(recognition, GSON.toJsonTree(result)); - } - - /** - * Test recognize with acoustic customization. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRecognizeWithAcousticCustomization() throws FileNotFoundException, InterruptedException { - String id = "foo"; - String version = "version"; - String recString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/recognition.json")); - JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(recString)); - - RecognizeOptions recognizeOptions = new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .acousticCustomizationId(id) - .baseModelVersion(version) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE + "?acoustic_customization_id=" + id + "&base_model_version=" + version, - request.getPath()); - assertEquals(recognition, GSON.toJsonTree(result)); - } - - /** - * Test recognize with customization weight. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRecognizeWithCustomizationWeight() throws FileNotFoundException, InterruptedException { - String id = "foo"; - String recString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/recognition.json")); - JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(recString)); - - RecognizeOptions recognizeOptions = new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .languageCustomizationId(id) - .customizationWeight(0.5) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PATH_RECOGNIZE + "?language_customization_id=" + id + "&customization_weight=0.5", request.getPath()); - assertEquals(recognition, GSON.toJsonTree(result)); - } - - /** - * Test MediaTypeUtils class. - */ - @Test - public void testMediaTypeUtils() { - assertEquals(HttpMediaType.AUDIO_WAV, MediaTypeUtils.getMediaTypeFromFile(new File("test.wav"))); - assertEquals(HttpMediaType.AUDIO_OGG, MediaTypeUtils.getMediaTypeFromFile(new File("test.OGG"))); - assertNull(MediaTypeUtils.getMediaTypeFromFile(new File("invalid.png"))); - assertNull(MediaTypeUtils.getMediaTypeFromFile(new File("invalidwav"))); - assertNull(MediaTypeUtils.getMediaTypeFromFile(null)); - - assertTrue(MediaTypeUtils.isValidMediaType("audio/wav")); - assertFalse(MediaTypeUtils.isValidMediaType("image/png")); - assertFalse(MediaTypeUtils.isValidMediaType(null)); - } - - @Test - public void testCreateJob() throws InterruptedException, FileNotFoundException { - String callbackUrl = "callback"; - String events = CreateJobOptions.Events.RECOGNITIONS_STARTED; - String userToken = "token"; - Long resultsTtl = 5L; - File audio = SAMPLE_WAV; - String contentType = HttpMediaType.AUDIO_WAV; - String model = CreateJobOptions.Model.EN_US_BROADBANDMODEL; - String customizationId = "customizationId"; - Double customizationWeight = 5d; - String version = "version"; - Long inactivityTimeout = 20L; - List keywords = Arrays.asList("keyword1", "keyword2"); - Float keywordsThreshold = 5f; - Boolean wordConfidence = true; - Boolean timestamps = true; - Boolean profanityFilter = true; - Boolean smartFormatting = true; - Boolean speakerLabels = true; - Double endOfPhraseSilenceTime = 2.0; - Boolean splitTranscriptAtPhraseEnd = true; - - RecognitionJob job = loadFixture("src/test/resources/speech_to_text/job.json", RecognitionJob.class); - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(job))); - - CreateJobOptions createOptions = new CreateJobOptions.Builder() - .callbackUrl(callbackUrl) - .events(events) - .userToken(userToken) - .resultsTtl(resultsTtl) - .audio(audio) - .contentType(contentType) - .model(model) - .languageCustomizationId(customizationId) - .customizationWeight(customizationWeight) - .baseModelVersion(version) - .inactivityTimeout(inactivityTimeout) - .keywords(keywords) - .keywordsThreshold(keywordsThreshold) - .wordConfidence(wordConfidence) - .timestamps(timestamps) - .profanityFilter(profanityFilter) - .smartFormatting(smartFormatting) - .speakerLabels(speakerLabels) - .endOfPhraseSilenceTime(endOfPhraseSilenceTime) - .splitTranscriptAtPhraseEnd(splitTranscriptAtPhraseEnd) - .build(); - - assertEquals((Double) 2.0, createOptions.endOfPhraseSilenceTime()); - assertTrue(createOptions.splitTranscriptAtPhraseEnd()); - - service.createJob(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNITIONS - + "?model=" + model - + "&callback_url=" + callbackUrl - + "&events=" + events - + "&user_token=" + userToken - + "&results_ttl=" + resultsTtl - + "&language_customization_id=" + customizationId - + "&base_model_version=" + version - + "&customization_weight=" + customizationWeight - + "&inactivity_timeout=" + inactivityTimeout - + "&keywords=" + RequestUtils.encode(StringUtils.join(keywords, ',')) - + "&keywords_threshold=" + keywordsThreshold - + "&word_confidence=" + wordConfidence - + "×tamps=" + timestamps - + "&profanity_filter=" + profanityFilter - + "&smart_formatting=" + smartFormatting - + "&speaker_labels=" + speakerLabels - + "&end_of_phrase_silence_time=" + endOfPhraseSilenceTime - + "&split_transcript_at_phrase_end=" + splitTranscriptAtPhraseEnd, - request.getPath()); - } - - /** - * Test delete job. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteJob() throws InterruptedException { - String id = "foo"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder() - .id(id) - .build(); - service.deleteJob(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_RECOGNITION, id), request.getPath()); - } - - /** - * Test check job. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testCheckJob() throws InterruptedException, FileNotFoundException { - String id = "foo"; - RecognitionJob job = loadFixture("src/test/resources/speech_to_text/job.json", RecognitionJob.class); - - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(job))); - - CheckJobOptions checkOptions = new CheckJobOptions.Builder() - .id(id) - .build(); - RecognitionJob result = service.checkJob(checkOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_RECOGNITION, id), request.getPath()); - assertEquals(result.toString(), job.toString()); - } - - /** - * Test check jobs. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testCheckJobs() throws InterruptedException, FileNotFoundException { - String jobsAsString = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/jobs.json")); - JsonObject jobsAsJson = new JsonParser().parse(jobsAsString).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(jobsAsString)); - - RecognitionJobs result = service.checkJobs().execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(PATH_RECOGNITIONS, request.getPath()); - assertEquals(jobsAsJson.get("recognitions"), GSON.toJsonTree(result.getRecognitions())); - } - - /** - * Test list language models. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListLanguageModels() throws InterruptedException, FileNotFoundException { - String customizationsAsString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/customizations.json")); - JsonObject customizations = new JsonParser().parse(customizationsAsString).getAsJsonObject(); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListLanguageModelsOptions model + ListLanguageModelsOptions listLanguageModelsOptionsModel = + new ListLanguageModelsOptions.Builder().language("ar-MS").build(); + + // Invoke listLanguageModels() with a valid options model and verify the result + Response response = + speechToTextService.listLanguageModels(listLanguageModelsOptionsModel).execute(); + assertNotNull(response); + LanguageModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLanguageModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("language"), "ar-MS"); + } + + // Test the listLanguageModels operation with and without retries enabled + @Test + public void testListLanguageModelsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListLanguageModelsWOptions(); + + speechToTextService.disableRetries(); + testListLanguageModelsWOptions(); + } + // Test the getLanguageModel operation with a valid options model parameter + @Test + public void testGetLanguageModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}"; + String getLanguageModelPath = "/v1/customizations/testString"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(customizationsAsString)); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetLanguageModelOptions model + GetLanguageModelOptions getLanguageModelOptionsModel = + new GetLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke getLanguageModel() with a valid options model and verify the result + Response response = + speechToTextService.getLanguageModel(getLanguageModelOptionsModel).execute(); + assertNotNull(response); + LanguageModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getLanguageModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getLanguageModel operation with and without retries enabled + @Test + public void testGetLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetLanguageModelWOptions(); - ListLanguageModelsOptions listOptions = new ListLanguageModelsOptions.Builder() - .language("en-us") - .build(); - LanguageModels result = service.listLanguageModels(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + speechToTextService.disableRetries(); + testGetLanguageModelWOptions(); + } + + // Test the getLanguageModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetLanguageModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getLanguageModel(null).execute(); + } - assertEquals("GET", request.getMethod()); - assertEquals(PATH_CUSTOMIZATIONS + "?language=en-us", request.getPath()); - assertEquals(customizations.get("customizations").getAsJsonArray().size(), result.getCustomizations().size()); - assertEquals(customizations.get("customizations"), GSON.toJsonTree(result.getCustomizations())); + // Test the deleteLanguageModel operation with a valid options model parameter + @Test + public void testDeleteLanguageModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteLanguageModelPath = "/v1/customizations/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteLanguageModelOptions model + DeleteLanguageModelOptions deleteLanguageModelOptionsModel = + new DeleteLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke deleteLanguageModel() with a valid options model and verify the result + Response response = + speechToTextService.deleteLanguageModel(deleteLanguageModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteLanguageModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); } - /** - * Test get language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + // Test the deleteLanguageModel operation with and without retries enabled @Test - public void testGetLanguageModel() throws InterruptedException, FileNotFoundException { - String id = "foo"; - LanguageModel model = loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class); + public void testDeleteLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteLanguageModelWOptions(); + speechToTextService.disableRetries(); + testDeleteLanguageModelWOptions(); + } + + // Test the deleteLanguageModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteLanguageModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteLanguageModel(null).execute(); + } + + // Test the trainLanguageModel operation with a valid options model parameter + @Test + public void testTrainLanguageModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"warnings\": [{\"code\": \"invalid_audio_files\", \"message\": \"message\"}]}"; + String trainLanguageModelPath = "/v1/customizations/testString/train"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the TrainLanguageModelOptions model + TrainLanguageModelOptions trainLanguageModelOptionsModel = + new TrainLanguageModelOptions.Builder() + .customizationId("testString") + .wordTypeToAdd("all") + .customizationWeight(Double.valueOf("72.5")) + .strict(true) + .force(false) + .build(); + + // Invoke trainLanguageModel() with a valid options model and verify the result + Response response = + speechToTextService.trainLanguageModel(trainLanguageModelOptionsModel).execute(); + assertNotNull(response); + TrainingResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, trainLanguageModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("word_type_to_add"), "all"); + assertEquals(Double.valueOf(query.get("customization_weight")), Double.valueOf("72.5")); + assertEquals(Boolean.valueOf(query.get("strict")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("force")), Boolean.valueOf(false)); + } + + // Test the trainLanguageModel operation with and without retries enabled + @Test + public void testTrainLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testTrainLanguageModelWOptions(); - GetLanguageModelOptions getOptions = new GetLanguageModelOptions.Builder() - .customizationId(id) - .build(); - LanguageModel result = service.getLanguageModel(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + speechToTextService.disableRetries(); + testTrainLanguageModelWOptions(); + } - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CUSTOMIZATION, id), request.getPath()); - assertEquals(result.toString(), model.toString()); - assertEquals(UPDATED, result.getUpdated()); + // Test the trainLanguageModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainLanguageModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.trainLanguageModel(null).execute(); } - /** - * Test create language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + // Test the resetLanguageModel operation with a valid options model parameter @Test - public void testCreateLanguageModel() throws InterruptedException, FileNotFoundException { - LanguageModel model = loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class); + public void testResetLanguageModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String resetLanguageModelPath = "/v1/customizations/testString/reset"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the ResetLanguageModelOptions model + ResetLanguageModelOptions resetLanguageModelOptionsModel = + new ResetLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke resetLanguageModel() with a valid options model and verify the result + Response response = + speechToTextService.resetLanguageModel(resetLanguageModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, resetLanguageModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); + // Test the resetLanguageModel operation with and without retries enabled + @Test + public void testResetLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testResetLanguageModelWOptions(); - CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder() - .name(model.getName()) - .baseModelName("en-GB_BroadbandModel") - .description(model.getDescription()) - .build(); - LanguageModel result = service.createLanguageModel(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_CUSTOMIZATIONS, request.getPath()); - assertEquals(result.toString(), model.toString()); - } - - /** - * Test delete language model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteLanguageModel() throws InterruptedException { - String id = "foo"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - DeleteLanguageModelOptions deleteOptions = new DeleteLanguageModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteLanguageModel(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_CUSTOMIZATION, id), request.getPath()); - } - - /** - * Test train language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testTrainLanguageModel() throws InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - - TrainLanguageModelOptions trainOptions = new TrainLanguageModelOptions.Builder() - .customizationId(id) - .wordTypeToAdd(TrainLanguageModelOptions.WordTypeToAdd.ALL) - .customizationWeight(0.5) - .build(); - service.trainLanguageModel(trainOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_TRAIN, id) + "?word_type_to_add=all&customization_weight=" + 0.5, - request.getPath()); - } - - /** - * Test reset language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testResetLanguageModel() throws InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - - ResetLanguageModelOptions resetOptions = new ResetLanguageModelOptions.Builder() - .customizationId(id) - .build(); - service.resetLanguageModel(resetOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_RESET, id), request.getPath()); - } - - /** - * Test upgrade language model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testUpgradeLanguageModel() throws InterruptedException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - - UpgradeLanguageModelOptions upgradeOptions = new UpgradeLanguageModelOptions.Builder() - .customizationId(id) - .build(); - service.upgradeLanguageModel(upgradeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_UPGRADE, id), request.getPath()); - } - - /** - * Test list corpora. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListCorpora() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String corporaAsString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/corpora.json")); - JsonObject corpora = new JsonParser().parse(corporaAsString).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(corporaAsString)); - - ListCorporaOptions listOptions = new ListCorporaOptions.Builder() - .customizationId(id) - .build(); - Corpora result = service.listCorpora(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CORPORA, id), request.getPath()); - assertEquals(corpora.get("corpora"), GSON.toJsonTree(result.getCorpora())); - } - - /** - * Test get corpus. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testGetCorpus() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String corpus = "cName"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .customizationId(id) - .corpusName(corpus) - .build(); - service.getCorpus(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath()); - } - - /** - * Test delete corpus. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testDeleteCorpus() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String corpus = "cName"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - DeleteCorpusOptions deleteOptions = new DeleteCorpusOptions.Builder() - .customizationId(id) - .corpusName(corpus) - .build(); - service.deleteCorpus(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath()); - } - - /** - * Test add corpus. - * - * @throws InterruptedException the interrupted exception - * @throws IOException the IO exception - */ - @Test - public void testAddCorpus() throws InterruptedException, IOException { - String id = "foo"; - String corpusName = "cName"; - File corpusFile = new File("src/test/resources/speech_to_text/corpus-text.txt"); - String corpusFileText = new String(Files.readAllBytes(Paths.get(corpusFile.toURI()))); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - AddCorpusOptions addOptions = new AddCorpusOptions.Builder() - .customizationId(id) - .corpusName(corpusName) - .corpusFile(corpusFile) - .allowOverwrite(true) - .build(); - service.addCorpus(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_CORPUS, id, corpusName) + "?allow_overwrite=true", request.getPath()); - assertTrue(request.getBody().readUtf8().contains(corpusFileText)); - } - - /** - * Test list words. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListWords() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordsAsStr)); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(id) - .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id), request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); - } - - /** - * Test list words with word type all. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListWordsType() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordsAsStr)); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(id) - .wordType(ListWordsOptions.WordType.ALL) - .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id) + "?word_type=all", request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); - } - - /** - * Test list words with sort order alphabetical. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListWordsSort() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordsAsStr)); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(id) - .sort(ListWordsOptions.Sort.ALPHABETICAL) - .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id) + "?sort=alphabetical", request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); - } - - /** - * Test list words with word type all and sort order alphabetical. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListWordsTypeSort() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordsAsStr)); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(id) - .sort(ListWordsOptions.Sort.ALPHABETICAL) - .wordType(ListWordsOptions.WordType.ALL) - .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id) + "?word_type=all&sort=alphabetical", request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); - } - - /** - * Test get word. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testGetWord() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordName = "bar"; - - String wordAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/word.json")); - JsonObject word = new JsonParser().parse(wordAsStr).getAsJsonObject(); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordAsStr)); - - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(id) - .wordName(wordName) - .build(); - Word result = service.getWord(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, wordName), request.getPath()); - assertEquals(word, GSON.toJsonTree(result)); - } - - /** - * Test delete word. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteWord() throws InterruptedException { - String id = "foo"; - String wordName = "bar"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder() - .customizationId(id) - .wordName(wordName) - .build(); - service.deleteWord(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, wordName), request.getPath()); - } - - /** - * Test add words. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testAddWords() throws InterruptedException, FileNotFoundException { - String id = "foo"; - Word newWord = loadFixture("src/test/resources/speech_to_text/word.json", Word.class); - Map wordsAsMap = new HashMap(); - wordsAsMap.put("words", new Word[] { newWord }); - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - CustomWord word = new CustomWord.Builder() - .word(newWord.getWord()) - .displayAs(newWord.getDisplayAs()) - .soundsLike(newWord.getSoundsLike()) - .build(); - - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(id) - .addWords(word) - .build(); - service.addWords(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id), request.getPath()); - Gson testGsonNoNulls = new Gson(); - assertEquals(testGsonNoNulls.toJson(wordsAsMap), request.getBody().readUtf8()); - } - - /** - * Test add word. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testAddWord() throws InterruptedException, FileNotFoundException { - String id = "foo"; - Word newWord = loadFixture("src/test/resources/speech_to_text/word.json", Word.class); - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - AddWordOptions addOptions = new AddWordOptions.Builder() - .wordName(newWord.getWord()) - .customizationId(id) - .word(newWord.getWord()) - .displayAs(newWord.getDisplayAs()) - .soundsLike(newWord.getSoundsLike()) - .build(); - service.addWord(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("PUT", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, newWord.getWord()), request.getPath()); - Gson testGsonNoNulls = new Gson(); - assertEquals(testGsonNoNulls.toJson(newWord), request.getBody().readUtf8()); - } - - /** - * Test create acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testCreateAcousticModel() throws InterruptedException, FileNotFoundException { - AcousticModel model = loadFixture("src/test/resources/speech_to_text/acoustic-model.json", AcousticModel.class); + speechToTextService.disableRetries(); + testResetLanguageModelWOptions(); + } + + // Test the resetLanguageModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetLanguageModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.resetLanguageModel(null).execute(); + } + // Test the upgradeLanguageModel operation with a valid options model parameter + @Test + public void testUpgradeLanguageModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String upgradeLanguageModelPath = "/v1/customizations/testString/upgrade_model"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the UpgradeLanguageModelOptions model + UpgradeLanguageModelOptions upgradeLanguageModelOptionsModel = + new UpgradeLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke upgradeLanguageModel() with a valid options model and verify the result + Response response = + speechToTextService.upgradeLanguageModel(upgradeLanguageModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, upgradeLanguageModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the upgradeLanguageModel operation with and without retries enabled + @Test + public void testUpgradeLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testUpgradeLanguageModelWOptions(); + + speechToTextService.disableRetries(); + testUpgradeLanguageModelWOptions(); + } + + // Test the upgradeLanguageModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeLanguageModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.upgradeLanguageModel(null).execute(); + } + + // Test the listCorpora operation with a valid options model parameter + @Test + public void testListCorporaWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"corpora\": [{\"name\": \"name\", \"total_words\": 10, \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}]}"; + String listCorporaPath = "/v1/customizations/testString/corpora"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListCorporaOptions model + ListCorporaOptions listCorporaOptionsModel = + new ListCorporaOptions.Builder().customizationId("testString").build(); + + // Invoke listCorpora() with a valid options model and verify the result + Response response = speechToTextService.listCorpora(listCorporaOptionsModel).execute(); + assertNotNull(response); + Corpora responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCorporaPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listCorpora operation with and without retries enabled + @Test + public void testListCorporaWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListCorporaWOptions(); + + speechToTextService.disableRetries(); + testListCorporaWOptions(); + } - CreateAcousticModelOptions createOptions = new CreateAcousticModelOptions.Builder() - .name(model.getName()) - .baseModelName(model.getBaseModelName()) - .description(model.getDescription()) - .build(); - AcousticModel result = service.createAcousticModel(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Test the listCorpora operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCorporaNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.listCorpora(null).execute(); + } - assertEquals("POST", request.getMethod()); - assertEquals(PATH_ACOUSTIC_CUSTOMIZATIONS, request.getPath()); - assertEquals(result.toString(), model.toString()); + // Test the addCorpus operation with a valid options model parameter + @Test + public void testAddCorpusWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addCorpusPath = "/v1/customizations/testString/corpora/testString"; + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + // Construct an instance of the AddCorpusOptions model + AddCorpusOptions addCorpusOptionsModel = + new AddCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .corpusFile(TestUtilities.createMockStream("This is a mock file.")) + .allowOverwrite(false) + .build(); + + // Invoke addCorpus() with a valid options model and verify the result + Response response = speechToTextService.addCorpus(addCorpusOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addCorpusPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(false)); } - /** - * Test list acoustic models. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + // Test the addCorpus operation with and without retries enabled @Test - public void testListAcousticModels() throws InterruptedException, FileNotFoundException { - String acousticModelsAsString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/acoustic-models.json")); - JsonObject acousticModels = new JsonParser().parse(acousticModelsAsString).getAsJsonObject(); + public void testAddCorpusWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddCorpusWOptions(); + speechToTextService.disableRetries(); + testAddCorpusWOptions(); + } + + // Test the addCorpus operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddCorpusNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.addCorpus(null).execute(); + } + + // Test the getCorpus operation with a valid options model parameter + @Test + public void testGetCorpusWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"total_words\": 10, \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}"; + String getCorpusPath = "/v1/customizations/testString/corpora/testString"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(acousticModelsAsString)); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCorpusOptions model + GetCorpusOptions getCorpusOptionsModel = + new GetCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .build(); + + // Invoke getCorpus() with a valid options model and verify the result + Response response = speechToTextService.getCorpus(getCorpusOptionsModel).execute(); + assertNotNull(response); + Corpus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCorpusPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getCorpus operation with and without retries enabled + @Test + public void testGetCorpusWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetCorpusWOptions(); - ListAcousticModelsOptions listOptions = new ListAcousticModelsOptions.Builder() - .language("en-us") - .build(); - AcousticModels result = service.listAcousticModels(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + speechToTextService.disableRetries(); + testGetCorpusWOptions(); + } - assertEquals("GET", request.getMethod()); - assertEquals(PATH_ACOUSTIC_CUSTOMIZATIONS + "?language=en-us", request.getPath()); - assertEquals(acousticModels.get("customizations").getAsJsonArray().size(), result.getCustomizations().size()); - assertEquals(acousticModels.get("customizations"), GSON.toJsonTree(result.getCustomizations())); + // Test the getCorpus operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCorpusNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getCorpus(null).execute(); } - /** - * Test get acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + // Test the deleteCorpus operation with a valid options model parameter @Test - public void testGetAcousticModel() throws InterruptedException, FileNotFoundException { - String id = "foo"; - AcousticModel model = loadFixture("src/test/resources/speech_to_text/acoustic-model.json", AcousticModel.class); + public void testDeleteCorpusWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteCorpusPath = "/v1/customizations/testString/corpora/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteCorpusOptions model + DeleteCorpusOptions deleteCorpusOptionsModel = + new DeleteCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .build(); + + // Invoke deleteCorpus() with a valid options model and verify the result + Response response = speechToTextService.deleteCorpus(deleteCorpusOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCorpusPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); - - GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder() - .customizationId(id) - .build(); - AcousticModel result = service.getAcousticModel(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_CUSTOMIZATION, id), request.getPath()); - assertEquals(result.toString(), model.toString()); - assertEquals(UPDATED, result.getUpdated()); - } - - /** - * Test delete acoustic model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteAcousticModel() throws InterruptedException { - String id = "foo"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - DeleteAcousticModelOptions deleteOptions = new DeleteAcousticModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteAcousticModel(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_CUSTOMIZATION, id), request.getPath()); - } - - /** - * Test train acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testTrainAcousticModel() throws InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - String languageModelId = "bar"; - - TrainAcousticModelOptions trainOptions = new TrainAcousticModelOptions.Builder() - .customizationId(id) - .customLanguageModelId(languageModelId) - .build(); - service.trainAcousticModel(trainOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_TRAIN, id) + "?custom_language_model_id=bar", - request.getPath()); - } - - /** - * Test reset acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testResetAcousticModel() throws InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - - ResetAcousticModelOptions resetOptions = new ResetAcousticModelOptions.Builder() - .customizationId(id) - .build(); - service.resetAcousticModel(resetOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_RESET, id), request.getPath()); - } - - /** - * Test upgrade acoustic model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testUpgradeAcousticModel() throws InterruptedException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - String languageModelId = "modelId"; - - UpgradeAcousticModelOptions upgradeOptions = new UpgradeAcousticModelOptions.Builder() - .customizationId(id) - .customLanguageModelId(languageModelId) - .force(true) - .build(); - upgradeOptions = upgradeOptions.newBuilder().build(); - service.upgradeAcousticModel(upgradeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_UPGRADE, id) - + "?custom_language_model_id=" - + languageModelId - + "&force=true", - request.getPath()); - } - - @Test - public void testAddAudio() throws InterruptedException, FileNotFoundException { - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - String audioName = "test_file"; - - AddAudioOptions addOptions = new AddAudioOptions.Builder() - .customizationId(id) - .audioResource(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .audioName(audioName) - .allowOverwrite(true) - .build(); - service.addAudio(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName) + "?allow_overwrite=true", - request.getPath()); - } - - @Test - public void testListAudio() throws FileNotFoundException, InterruptedException { - String resourcesAsString = getStringFromInputStream(new FileInputStream( - "src/test/resources/speech_to_text/audio-resources.json")); - JsonObject audioResources = new JsonParser().parse(resourcesAsString).getAsJsonObject(); - String id = "foo"; + // Test the deleteCorpus operation with and without retries enabled + @Test + public void testDeleteCorpusWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteCorpusWOptions(); + speechToTextService.disableRetries(); + testDeleteCorpusWOptions(); + } + + // Test the deleteCorpus operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCorpusNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteCorpus(null).execute(); + } + + // Test the listWords operation with a valid options model parameter + @Test + public void testListWordsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"words\": [{\"word\": \"word\", \"mapping_only\": [\"mappingOnly\"], \"sounds_like\": [\"soundsLike\"], \"display_as\": \"displayAs\", \"count\": 5, \"source\": [\"source\"], \"error\": [{\"element\": \"element\"}]}]}"; + String listWordsPath = "/v1/customizations/testString/words"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(resourcesAsString)); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListWordsOptions model + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder() + .customizationId("testString") + .wordType("all") + .sort("alphabetical") + .build(); + + // Invoke listWords() with a valid options model and verify the result + Response response = speechToTextService.listWords(listWordsOptionsModel).execute(); + assertNotNull(response); + Words responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listWordsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("word_type"), "all"); + assertEquals(query.get("sort"), "alphabetical"); + } - ListAudioOptions listOptions = new ListAudioOptions.Builder() - .customizationId(id) - .build(); - AudioResources result = service.listAudio(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Test the listWords operation with and without retries enabled + @Test + public void testListWordsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListWordsWOptions(); + + speechToTextService.disableRetries(); + testListWordsWOptions(); + } - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_ALL_AUDIO, id), request.getPath()); - assertEquals(audioResources.get("audio").getAsJsonArray().size(), result.getAudio().size()); - assertEquals(audioResources.get("audio"), GSON.toJsonTree(result.getAudio())); + // Test the listWords operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.listWords(null).execute(); + } + + // Test the addWords operation with a valid options model parameter + @Test + public void testAddWordsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addWordsPath = "/v1/customizations/testString/words"; + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + // Construct an instance of the CustomWord model + CustomWord customWordModel = + new CustomWord.Builder() + .word("testString") + .mappingOnly(java.util.Arrays.asList("testString")) + .soundsLike(java.util.Arrays.asList("testString")) + .displayAs("testString") + .build(); + + // Construct an instance of the AddWordsOptions model + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(java.util.Arrays.asList(customWordModel)) + .build(); + + // Invoke addWords() with a valid options model and verify the result + Response response = speechToTextService.addWords(addWordsOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); } + // Test the addWords operation with and without retries enabled @Test - public void testGetAudio() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String audioName = "audio1"; - AudioResource audio = loadFixture("src/test/resources/speech_to_text/audio-resource.json", AudioResource.class); + public void testAddWordsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddWordsWOptions(); + speechToTextService.disableRetries(); + testAddWordsWOptions(); + } + + // Test the addWords operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.addWords(null).execute(); + } + + // Test the addWord operation with a valid options model parameter + @Test + public void testAddWordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addWordPath = "/v1/customizations/testString/words/testString"; + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + // Construct an instance of the AddWordOptions model + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .word("testString") + .mappingOnly(java.util.Arrays.asList("testString")) + .soundsLike(java.util.Arrays.asList("testString")) + .displayAs("testString") + .build(); + + // Invoke addWord() with a valid options model and verify the result + Response response = speechToTextService.addWord(addWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the addWord operation with and without retries enabled + @Test + public void testAddWordWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddWordWOptions(); + + speechToTextService.disableRetries(); + testAddWordWOptions(); + } + + // Test the addWord operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.addWord(null).execute(); + } + + // Test the getWord operation with a valid options model parameter + @Test + public void testGetWordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"word\": \"word\", \"mapping_only\": [\"mappingOnly\"], \"sounds_like\": [\"soundsLike\"], \"display_as\": \"displayAs\", \"count\": 5, \"source\": [\"source\"], \"error\": [{\"element\": \"element\"}]}"; + String getWordPath = "/v1/customizations/testString/words/testString"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(audio))); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetWordOptions model + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").wordName("testString").build(); + + // Invoke getWord() with a valid options model and verify the result + Response response = speechToTextService.getWord(getWordOptionsModel).execute(); + assertNotNull(response); + Word responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getWordPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getWord operation with and without retries enabled + @Test + public void testGetWordWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetWordWOptions(); - GetAudioOptions getOptions = new GetAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - AudioListing result = service.getAudio(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + speechToTextService.disableRetries(); + testGetWordWOptions(); + } - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName), request.getPath()); - assertEquals(audio.getDetails(), result.getDetails()); - assertEquals(audio.getDuration(), result.getDuration()); - assertEquals(audio.getName(), result.getName()); - assertEquals(audio.getStatus(), result.getStatus()); + // Test the getWord operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getWord(null).execute(); } + // Test the deleteWord operation with a valid options model parameter @Test - public void testDeleteAudio() throws InterruptedException { - String id = "foo"; - String audioName = "audio1"; + public void testDeleteWordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteWordPath = "/v1/customizations/testString/words/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteWordOptions model + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .build(); + + // Invoke deleteWord() with a valid options model and verify the result + Response response = speechToTextService.deleteWord(deleteWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteWordPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Test the deleteWord operation with and without retries enabled + @Test + public void testDeleteWordWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteWordWOptions(); - DeleteAudioOptions deleteOptions = new DeleteAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - service.deleteAudio(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + speechToTextService.disableRetries(); + testDeleteWordWOptions(); + } - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName), request.getPath()); + // Test the deleteWord operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteWord(null).execute(); } + // Test the listGrammars operation with a valid options model parameter @Test - public void testRegisterCallback() throws FileNotFoundException, InterruptedException { - String callbackUrl = "http://testurl.com"; - String secret = "secret"; - RegisterStatus registerStatus = loadFixture("src/test/resources/speech_to_text/register-status.json", - RegisterStatus.class); + public void testListGrammarsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"grammars\": [{\"name\": \"name\", \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}]}"; + String listGrammarsPath = "/v1/customizations/testString/grammars"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListGrammarsOptions model + ListGrammarsOptions listGrammarsOptionsModel = + new ListGrammarsOptions.Builder().customizationId("testString").build(); + + // Invoke listGrammars() with a valid options model and verify the result + Response response = + speechToTextService.listGrammars(listGrammarsOptionsModel).execute(); + assertNotNull(response); + Grammars responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listGrammarsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(registerStatus))); + // Test the listGrammars operation with and without retries enabled + @Test + public void testListGrammarsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListGrammarsWOptions(); - RegisterCallbackOptions registerOptions = new RegisterCallbackOptions.Builder() - .callbackUrl(callbackUrl) - .userSecret(secret) - .build(); - RegisterStatus result = service.registerCallback(registerOptions).execute().getResult(); - final RecordedRequest registerRequest = server.takeRequest(); + speechToTextService.disableRetries(); + testListGrammarsWOptions(); + } - assertEquals("POST", registerRequest.getMethod()); - assertEquals(String.format(REGISTER_CALLBACK, RequestUtils.encode(callbackUrl), RequestUtils.encode(secret)), - registerRequest.getPath()); - assertEquals(RegisterStatus.Status.CREATED, result.getStatus()); - assertEquals(callbackUrl, result.getUrl()); + // Test the listGrammars operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListGrammarsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.listGrammars(null).execute(); } + // Test the addGrammar operation with a valid options model parameter @Test - public void testUnregisterCallback() throws InterruptedException { - String callbackUrl = "http://testurl.com"; - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + public void testAddGrammarWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addGrammarPath = "/v1/customizations/testString/grammars/testString"; + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + // Construct an instance of the AddGrammarOptions model + AddGrammarOptions addGrammarOptionsModel = + new AddGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .grammarFile(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/srgs") + .allowOverwrite(false) + .build(); + + // Invoke addGrammar() with a valid options model and verify the result + Response response = speechToTextService.addGrammar(addGrammarOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addGrammarPath); + // Verify header parameters + assertEquals(request.getHeader("Content-Type"), "application/srgs"); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(false)); + } - UnregisterCallbackOptions unregisterOptions = new UnregisterCallbackOptions.Builder() - .callbackUrl(callbackUrl) - .build(); - service.unregisterCallback(unregisterOptions).execute().getResult(); - final RecordedRequest unregisterRequest = server.takeRequest(); + // Test the addGrammar operation with and without retries enabled + @Test + public void testAddGrammarWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddGrammarWOptions(); + + speechToTextService.disableRetries(); + testAddGrammarWOptions(); + } - assertEquals("POST", unregisterRequest.getMethod()); - assertEquals(String.format(UNREGISTER_CALLBACK, RequestUtils.encode(callbackUrl)), unregisterRequest.getPath()); + // Test the addGrammar operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddGrammarNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.addGrammar(null).execute(); } + // Test the getGrammar operation with a valid options model parameter @Test - public void testClosingInputStreamClosesWebSocket() throws Exception { - TestRecognizeCallback callback = new TestRecognizeCallback(); - WebSocketRecorder webSocketRecorder = new WebSocketRecorder("server"); - PipedOutputStream outputStream = new PipedOutputStream(); - InputStream inputStream = new PipedInputStream(outputStream); + public void testGetGrammarWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"name\": \"name\", \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}"; + String getGrammarPath = "/v1/customizations/testString/grammars/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetGrammarOptions model + GetGrammarOptions getGrammarOptionsModel = + new GetGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .build(); + + // Invoke getGrammar() with a valid options model and verify the result + Response response = speechToTextService.getGrammar(getGrammarOptionsModel).execute(); + assertNotNull(response); + Grammar responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getGrammarPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - server.enqueue(new MockResponse().withWebSocketUpgrade(webSocketRecorder)); + // Test the getGrammar operation with and without retries enabled + @Test + public void testGetGrammarWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetGrammarWOptions(); - String customizationId = "id"; - String version = "version"; - Double customizationWeight = 0.1; - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(inputStream) - .contentType(HttpMediaType.createAudioRaw(44000)) - .customizationId(customizationId) - .baseModelVersion(version) - .customizationWeight(customizationWeight) - .build(); - service.recognizeUsingWebSocket(options, callback); + speechToTextService.disableRetries(); + testGetGrammarWOptions(); + } - WebSocket serverSocket = webSocketRecorder.assertOpen(); - serverSocket.send("{\"state\": {}}"); + // Test the getGrammar operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetGrammarNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getGrammar(null).execute(); + } - outputStream.write(ByteString.encodeUtf8("test").toByteArray()); - outputStream.close(); + // Test the deleteGrammar operation with a valid options model parameter + @Test + public void testDeleteGrammarWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteGrammarPath = "/v1/customizations/testString/grammars/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteGrammarOptions model + DeleteGrammarOptions deleteGrammarOptionsModel = + new DeleteGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .build(); + + // Invoke deleteGrammar() with a valid options model and verify the result + Response response = + speechToTextService.deleteGrammar(deleteGrammarOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteGrammarPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - webSocketRecorder.assertTextMessage("{\"content-type\":\"audio/l16; rate=44000\"," - + "\"customization_weight\":0.1,\"action\":\"start\"}"); - webSocketRecorder.assertBinaryMessage(ByteString.encodeUtf8("test")); - webSocketRecorder.assertTextMessage("{\"action\":\"stop\"}"); - webSocketRecorder.assertExhausted(); + // Test the deleteGrammar operation with and without retries enabled + @Test + public void testDeleteGrammarWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteGrammarWOptions(); - serverSocket.close(1000, null); + speechToTextService.disableRetries(); + testDeleteGrammarWOptions(); + } - callback.assertConnected(); - callback.assertDisconnected(); - callback.assertNoErrors(); - callback.assertOnTranscriptionComplete(); + // Test the deleteGrammar operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteGrammarNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteGrammar(null).execute(); } + // Test the createAcousticModel operation with a valid options model parameter @Test - public void testAddGrammar() throws FileNotFoundException, InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); + public void testCreateAcousticModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"warnings\": \"warnings\"}"; + String createAcousticModelPath = "/v1/acoustic_customizations"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateAcousticModelOptions model + CreateAcousticModelOptions createAcousticModelOptionsModel = + new CreateAcousticModelOptions.Builder() + .name("testString") + .baseModelName("ar-MS_BroadbandModel") + .description("testString") + .build(); + + // Invoke createAcousticModel() with a valid options model and verify the result + Response response = + speechToTextService.createAcousticModel(createAcousticModelOptionsModel).execute(); + assertNotNull(response); + AcousticModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createAcousticModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - String customizationId = "id"; - String grammarName = "grammar_name"; - InputStream grammarFile = new FileInputStream(SAMPLE_WAV); + // Test the createAcousticModel operation with and without retries enabled + @Test + public void testCreateAcousticModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCreateAcousticModelWOptions(); + + speechToTextService.disableRetries(); + testCreateAcousticModelWOptions(); + } + + // Test the createAcousticModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateAcousticModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.createAcousticModel(null).execute(); + } - AddGrammarOptions addGrammarOptions = new AddGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .grammarFile(grammarFile) - .contentType("application/srgs") - .build(); - service.addGrammar(addGrammarOptions).execute().getResult(); + // Test the listAcousticModels operation with a valid options model parameter + @Test + public void testListAcousticModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"warnings\": \"warnings\"}]}"; + String listAcousticModelsPath = "/v1/acoustic_customizations"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListAcousticModelsOptions model + ListAcousticModelsOptions listAcousticModelsOptionsModel = + new ListAcousticModelsOptions.Builder().language("ar-MS").build(); + + // Invoke listAcousticModels() with a valid options model and verify the result + Response response = + speechToTextService.listAcousticModels(listAcousticModelsOptionsModel).execute(); + assertNotNull(response); + AcousticModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAcousticModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("language"), "ar-MS"); + } - assertEquals(POST, request.getMethod()); + // Test the listAcousticModels operation with and without retries enabled + @Test + public void testListAcousticModelsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListAcousticModelsWOptions(); + + speechToTextService.disableRetries(); + testListAcousticModelsWOptions(); + } + + // Test the getAcousticModel operation with a valid options model parameter + @Test + public void testGetAcousticModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"warnings\": \"warnings\"}"; + String getAcousticModelPath = "/v1/acoustic_customizations/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetAcousticModelOptions model + GetAcousticModelOptions getAcousticModelOptionsModel = + new GetAcousticModelOptions.Builder().customizationId("testString").build(); + + // Invoke getAcousticModel() with a valid options model and verify the result + Response response = + speechToTextService.getAcousticModel(getAcousticModelOptionsModel).execute(); + assertNotNull(response); + AcousticModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAcousticModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getAcousticModel operation with and without retries enabled + @Test + public void testGetAcousticModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetAcousticModelWOptions(); + + speechToTextService.disableRetries(); + testGetAcousticModelWOptions(); + } + + // Test the getAcousticModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAcousticModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getAcousticModel(null).execute(); } + // Test the deleteAcousticModel operation with a valid options model parameter @Test - public void testListGrammars() throws InterruptedException { - server.enqueue(jsonResponse(grammars)); + public void testDeleteAcousticModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteAcousticModelPath = "/v1/acoustic_customizations/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteAcousticModelOptions model + DeleteAcousticModelOptions deleteAcousticModelOptionsModel = + new DeleteAcousticModelOptions.Builder().customizationId("testString").build(); + + // Invoke deleteAcousticModel() with a valid options model and verify the result + Response response = + speechToTextService.deleteAcousticModel(deleteAcousticModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteAcousticModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteAcousticModel operation with and without retries enabled + @Test + public void testDeleteAcousticModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteAcousticModelWOptions(); + + speechToTextService.disableRetries(); + testDeleteAcousticModelWOptions(); + } - String customizationId = "id"; + // Test the deleteAcousticModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAcousticModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteAcousticModel(null).execute(); + } - ListGrammarsOptions listGrammarsOptions = new ListGrammarsOptions.Builder() - .customizationId(customizationId) - .build(); - Grammars response = service.listGrammars(listGrammarsOptions).execute().getResult(); + // Test the trainAcousticModel operation with a valid options model parameter + @Test + public void testTrainAcousticModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"warnings\": [{\"code\": \"invalid_audio_files\", \"message\": \"message\"}]}"; + String trainAcousticModelPath = "/v1/acoustic_customizations/testString/train"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the TrainAcousticModelOptions model + TrainAcousticModelOptions trainAcousticModelOptionsModel = + new TrainAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .strict(true) + .build(); + + // Invoke trainAcousticModel() with a valid options model and verify the result + Response response = + speechToTextService.trainAcousticModel(trainAcousticModelOptionsModel).execute(); + assertNotNull(response); + TrainingResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, trainAcousticModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("custom_language_model_id"), "testString"); + assertEquals(Boolean.valueOf(query.get("strict")), Boolean.valueOf(true)); + } + + // Test the trainAcousticModel operation with and without retries enabled + @Test + public void testTrainAcousticModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testTrainAcousticModelWOptions(); + + speechToTextService.disableRetries(); + testTrainAcousticModelWOptions(); + } - assertEquals(GET, request.getMethod()); - assertEquals(grammars, response); + // Test the trainAcousticModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainAcousticModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.trainAcousticModel(null).execute(); } + // Test the resetAcousticModel operation with a valid options model parameter @Test - public void testGetGrammar() throws InterruptedException { - server.enqueue(jsonResponse(grammar)); + public void testResetAcousticModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String resetAcousticModelPath = "/v1/acoustic_customizations/testString/reset"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the ResetAcousticModelOptions model + ResetAcousticModelOptions resetAcousticModelOptionsModel = + new ResetAcousticModelOptions.Builder().customizationId("testString").build(); + + // Invoke resetAcousticModel() with a valid options model and verify the result + Response response = + speechToTextService.resetAcousticModel(resetAcousticModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, resetAcousticModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - String customizationId = "id"; - String grammarName = "grammar_name"; + // Test the resetAcousticModel operation with and without retries enabled + @Test + public void testResetAcousticModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testResetAcousticModelWOptions(); + + speechToTextService.disableRetries(); + testResetAcousticModelWOptions(); + } + + // Test the resetAcousticModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetAcousticModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.resetAcousticModel(null).execute(); + } - GetGrammarOptions getGrammarOptions = new GetGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); - Grammar response = service.getGrammar(getGrammarOptions).execute().getResult(); + // Test the upgradeAcousticModel operation with a valid options model parameter + @Test + public void testUpgradeAcousticModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String upgradeAcousticModelPath = "/v1/acoustic_customizations/testString/upgrade_model"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the UpgradeAcousticModelOptions model + UpgradeAcousticModelOptions upgradeAcousticModelOptionsModel = + new UpgradeAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .force(false) + .build(); + + // Invoke upgradeAcousticModel() with a valid options model and verify the result + Response response = + speechToTextService.upgradeAcousticModel(upgradeAcousticModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, upgradeAcousticModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("custom_language_model_id"), "testString"); + assertEquals(Boolean.valueOf(query.get("force")), Boolean.valueOf(false)); + } + + // Test the upgradeAcousticModel operation with and without retries enabled + @Test + public void testUpgradeAcousticModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testUpgradeAcousticModelWOptions(); - assertEquals(GET, request.getMethod()); - assertEquals(grammar, response); + speechToTextService.disableRetries(); + testUpgradeAcousticModelWOptions(); } + // Test the upgradeAcousticModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeAcousticModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.upgradeAcousticModel(null).execute(); + } + + // Test the listAudio operation with a valid options model parameter + @Test + public void testListAudioWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"total_minutes_of_audio\": 19, \"audio\": [{\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\"}]}"; + String listAudioPath = "/v1/acoustic_customizations/testString/audio"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListAudioOptions model + ListAudioOptions listAudioOptionsModel = + new ListAudioOptions.Builder().customizationId("testString").build(); + + // Invoke listAudio() with a valid options model and verify the result + Response response = + speechToTextService.listAudio(listAudioOptionsModel).execute(); + assertNotNull(response); + AudioResources responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAudioPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listAudio operation with and without retries enabled @Test - public void testDeleteGrammar() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); + public void testListAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListAudioWOptions(); - String customizationId = "id"; - String grammarName = "grammar_name"; + speechToTextService.disableRetries(); + testListAudioWOptions(); + } + + // Test the listAudio operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAudioNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.listAudio(null).execute(); + } - DeleteGrammarOptions deleteGrammarOptions = new DeleteGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); - service.deleteGrammar(deleteGrammarOptions).execute(); + // Test the addAudio operation with a valid options model parameter + @Test + public void testAddAudioWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addAudioPath = "/v1/acoustic_customizations/testString/audio/testString"; + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + // Construct an instance of the AddAudioOptions model + AddAudioOptions addAudioOptionsModel = + new AddAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .audioResource(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/zip") + .containedContentType("audio/alaw") + .allowOverwrite(false) + .build(); + + // Invoke addAudio() with a valid options model and verify the result + Response response = speechToTextService.addAudio(addAudioOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addAudioPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(false)); + } - assertEquals(DELETE, request.getMethod()); + // Test the addAudio operation with and without retries enabled + @Test + public void testAddAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddAudioWOptions(); + + speechToTextService.disableRetries(); + testAddAudioWOptions(); } - // --- HELPERS --- + // Test the addAudio operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddAudioNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.addAudio(null).execute(); + } - private static class TestRecognizeCallback implements RecognizeCallback { + // Test the getAudio operation with a valid options model parameter + @Test + public void testGetAudioWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\", \"container\": {\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\"}, \"audio\": [{\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\"}]}"; + String getAudioPath = "/v1/acoustic_customizations/testString/audio/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetAudioOptions model + GetAudioOptions getAudioOptionsModel = + new GetAudioOptions.Builder().customizationId("testString").audioName("testString").build(); + + // Invoke getAudio() with a valid options model and verify the result + Response response = speechToTextService.getAudio(getAudioOptionsModel).execute(); + assertNotNull(response); + AudioListing responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAudioPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - private final BlockingQueue speechResults = new LinkedBlockingQueue<>(); + // Test the getAudio operation with and without retries enabled + @Test + public void testGetAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetAudioWOptions(); - private final BlockingQueue errors = new LinkedBlockingQueue<>(); + speechToTextService.disableRetries(); + testGetAudioWOptions(); + } - private final BlockingQueue onDisconnectedCalls = new LinkedBlockingQueue<>(); + // Test the getAudio operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAudioNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.getAudio(null).execute(); + } - private final BlockingQueue onConnectedCalls = new LinkedBlockingQueue<>(); + // Test the deleteAudio operation with a valid options model parameter + @Test + public void testDeleteAudioWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteAudioPath = "/v1/acoustic_customizations/testString/audio/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteAudioOptions model + DeleteAudioOptions deleteAudioOptionsModel = + new DeleteAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .build(); + + // Invoke deleteAudio() with a valid options model and verify the result + Response response = speechToTextService.deleteAudio(deleteAudioOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteAudioPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - private final BlockingQueue onTranscriptionCompleteCalls = new LinkedBlockingQueue<>(); + // Test the deleteAudio operation with and without retries enabled + @Test + public void testDeleteAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteAudioWOptions(); - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - this.speechResults.add(speechResults); - } + speechToTextService.disableRetries(); + testDeleteAudioWOptions(); + } - @Override - public void onConnected() { - this.onConnectedCalls.add(new Object()); - } + // Test the deleteAudio operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAudioNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteAudio(null).execute(); + } - @Override - public void onError(Exception e) { - this.errors.add(e); - } + // Test the deleteUserData operation with a valid options model parameter + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke deleteUserData() with a valid options model and verify the result + Response response = + speechToTextService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("customer_id"), "testString"); + } - @Override - public void onDisconnected() { - this.onDisconnectedCalls.add(new Object()); - } + // Test the deleteUserData operation with and without retries enabled + @Test + public void testDeleteUserDataWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteUserDataWOptions(); - private void assertOnTranscriptionComplete() { - if (this.onTranscriptionCompleteCalls.size() == 1) { - throw new AssertionError("There were " + this.errors.size() + " calls to onTranscriptionComplete"); - } - } + speechToTextService.disableRetries(); + testDeleteUserDataWOptions(); + } - private void assertConnected() { - try { - Object connectedEvent = this.onConnectedCalls.poll(10, TimeUnit.SECONDS); - if (connectedEvent == null) { - throw new AssertionError("Timed out waiting for connect."); - } - } catch (InterruptedException e) { - throw new AssertionError(e); - } - } + // Test the deleteUserData operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.deleteUserData(null).execute(); + } - private void assertDisconnected() { - try { - Object disconnectedEvent = this.onDisconnectedCalls.poll(10, TimeUnit.SECONDS); - if (disconnectedEvent == null) { - throw new AssertionError("Timed out waiting for disconnect."); - } - } catch (InterruptedException e) { - throw new AssertionError(e); - } - } + // Test the detectLanguage operation with a valid options model parameter + @Test + public void testDetectLanguageWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"results\": [{\"language_info\": [{\"confidence\": 10, \"language\": \"language\", \"timestamp\": 9}]}], \"result_index\": 11}"; + String detectLanguagePath = "/v1/detect_language"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DetectLanguageOptions model + DetectLanguageOptions detectLanguageOptionsModel = + new DetectLanguageOptions.Builder() + .lidConfidence(Float.valueOf("36.0")) + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .build(); + + // Invoke detectLanguage() with a valid options model and verify the result + Response response = + speechToTextService.detectLanguage(detectLanguageOptionsModel).execute(); + assertNotNull(response); + LanguageDetectionResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, detectLanguagePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(Float.valueOf(query.get("lid_confidence")), Float.valueOf("36.0")); + } - private void assertNoErrors() { - if (this.errors.size() > 0) { - throw new AssertionError("There were " + this.errors.size() + " errors"); - } - } + // Test the detectLanguage operation with and without retries enabled + @Test + public void testDetectLanguageWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDetectLanguageWOptions(); - @Override - public void onInactivityTimeout(RuntimeException runtimeException) { - } + speechToTextService.disableRetries(); + testDetectLanguageWOptions(); + } - @Override - public void onListening() { + // Test the detectLanguage operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDetectLanguageNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.detectLanguage(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); } - @Override - public void onTranscriptionComplete() { - this.onTranscriptionCompleteCalls.add(new Object()); + // Construct an instance of the service + constructClientService(); + } - } + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + speechToTextService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + speechToTextService = new SpeechToText(serviceName, authenticator); + String url = server.url("/").toString(); + speechToTextService.setServiceUrl(url); } } diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/TypeAdaptersTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/TypeAdaptersTest.java index 1086ffe5156..ae4ec1d9bf6 100644 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/TypeAdaptersTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/TypeAdaptersTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2020. * * 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 @@ -12,6 +12,8 @@ */ package com.ibm.watson.speech_to_text.v1; +import static org.junit.Assert.assertEquals; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; @@ -20,42 +22,35 @@ import com.ibm.watson.speech_to_text.v1.model.SpeechWordConfidence; import com.ibm.watson.speech_to_text.v1.util.SpeechTimestampTypeAdapter; import com.ibm.watson.speech_to_text.v1.util.SpeechWordConfidenceTypeAdapter; -import org.junit.Test; - import java.lang.reflect.Type; import java.util.Collections; import java.util.Date; import java.util.List; +import org.junit.Test; -import static org.junit.Assert.assertEquals; - -/** - * Tests for several TypeAdapters. - */ +/** Tests for several TypeAdapters. */ public class TypeAdaptersTest { - /** - * Tests null (de)serialization of LongToDateTypeAdapter. - */ + /** Tests null (de)serialization of LongToDateTypeAdapter. */ @Test public void testLongToDateNull() { - final Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new LongToDateTypeAdapter()).create(); + final Gson gson = + new GsonBuilder().registerTypeAdapter(Date.class, new LongToDateTypeAdapter()).create(); final List values = Collections.singletonList(null); - final Type type = new TypeToken>() { - }.getType(); + final Type type = new TypeToken>() {}.getType(); final String json = "[null]"; assertEquals("[null]", gson.toJson(values)); assertEquals(values, gson.fromJson(json, type)); } - /** - * Tests serialization of {@link SpeechTimestampTypeAdapter}. - */ + /** Tests serialization of {@link SpeechTimestampTypeAdapter}. */ @Test public void testSpeechTimestampTypeAdapter() { - final Gson gson = new GsonBuilder().registerTypeAdapter(SpeechTimestamp.class, new SpeechTimestampTypeAdapter()) - .create(); + final Gson gson = + new GsonBuilder() + .registerTypeAdapter(SpeechTimestamp.class, new SpeechTimestampTypeAdapter()) + .create(); final String json = "[\"test\",1.1,2.3]"; final SpeechTimestamp value = new SpeechTimestamp(); value.setWord("test"); @@ -65,13 +60,13 @@ public void testSpeechTimestampTypeAdapter() { assertEquals(json, gson.toJson(value)); } - /** - * Tests serialization of {@link SpeechWordConfidenceTypeAdapter}. - */ + /** Tests serialization of {@link SpeechWordConfidenceTypeAdapter}. */ @Test public void testSpeechWordConfidenceTypeAdapter() { - final Gson gson = new GsonBuilder() - .registerTypeAdapter(SpeechWordConfidence.class, new SpeechWordConfidenceTypeAdapter()).create(); + final Gson gson = + new GsonBuilder() + .registerTypeAdapter(SpeechWordConfidence.class, new SpeechWordConfidenceTypeAdapter()) + .create(); final String json = "[\"test\",0.6]"; final SpeechWordConfidence value = new SpeechWordConfidence(); value.setWord("test"); @@ -79,5 +74,4 @@ public void testSpeechWordConfidenceTypeAdapter() { assertEquals(json, gson.toJson(value)); } - } diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelTest.java new file mode 100644 index 00000000000..9180df7ad58 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AcousticModel model. */ +public class AcousticModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAcousticModel() throws Throwable { + AcousticModel acousticModelModel = new AcousticModel(); + assertNull(acousticModelModel.getCustomizationId()); + assertNull(acousticModelModel.getCreated()); + assertNull(acousticModelModel.getUpdated()); + assertNull(acousticModelModel.getLanguage()); + assertNull(acousticModelModel.getVersions()); + assertNull(acousticModelModel.getOwner()); + assertNull(acousticModelModel.getName()); + assertNull(acousticModelModel.getDescription()); + assertNull(acousticModelModel.getBaseModelName()); + assertNull(acousticModelModel.getStatus()); + assertNull(acousticModelModel.getProgress()); + assertNull(acousticModelModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelsTest.java new file mode 100644 index 00000000000..1fc1e642ecb --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AcousticModels model. */ +public class AcousticModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAcousticModels() throws Throwable { + AcousticModels acousticModelsModel = new AcousticModels(); + assertNull(acousticModelsModel.getCustomizations()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptionsTest.java new file mode 100644 index 00000000000..c8f3473d07c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddAudioOptions model. */ +public class AddAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddAudioOptions() throws Throwable { + AddAudioOptions addAudioOptionsModel = + new AddAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .audioResource(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/zip") + .containedContentType("audio/alaw") + .allowOverwrite(false) + .build(); + assertEquals(addAudioOptionsModel.customizationId(), "testString"); + assertEquals(addAudioOptionsModel.audioName(), "testString"); + assertEquals( + IOUtils.toString(addAudioOptionsModel.audioResource()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addAudioOptionsModel.contentType(), "application/zip"); + assertEquals(addAudioOptionsModel.containedContentType(), "audio/alaw"); + assertEquals(addAudioOptionsModel.allowOverwrite(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddAudioOptionsError() throws Throwable { + new AddAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptionsTest.java new file mode 100644 index 00000000000..34e9f07b5a8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddCorpusOptions model. */ +public class AddCorpusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddCorpusOptions() throws Throwable { + AddCorpusOptions addCorpusOptionsModel = + new AddCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .corpusFile(TestUtilities.createMockStream("This is a mock file.")) + .allowOverwrite(false) + .build(); + assertEquals(addCorpusOptionsModel.customizationId(), "testString"); + assertEquals(addCorpusOptionsModel.corpusName(), "testString"); + assertEquals( + IOUtils.toString(addCorpusOptionsModel.corpusFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addCorpusOptionsModel.allowOverwrite(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddCorpusOptionsError() throws Throwable { + new AddCorpusOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptionsTest.java new file mode 100644 index 00000000000..3df1e7cb231 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddGrammarOptions model. */ +public class AddGrammarOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddGrammarOptions() throws Throwable { + AddGrammarOptions addGrammarOptionsModel = + new AddGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .grammarFile(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/srgs") + .allowOverwrite(false) + .build(); + assertEquals(addGrammarOptionsModel.customizationId(), "testString"); + assertEquals(addGrammarOptionsModel.grammarName(), "testString"); + assertEquals( + IOUtils.toString(addGrammarOptionsModel.grammarFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addGrammarOptionsModel.contentType(), "application/srgs"); + assertEquals(addGrammarOptionsModel.allowOverwrite(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddGrammarOptionsError() throws Throwable { + new AddGrammarOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptionsTest.java new file mode 100644 index 00000000000..ffc56019610 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordOptions model. */ +public class AddWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordOptions() throws Throwable { + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .word("testString") + .mappingOnly(java.util.Arrays.asList("testString")) + .soundsLike(java.util.Arrays.asList("testString")) + .displayAs("testString") + .build(); + assertEquals(addWordOptionsModel.customizationId(), "testString"); + assertEquals(addWordOptionsModel.wordName(), "testString"); + assertEquals(addWordOptionsModel.word(), "testString"); + assertEquals(addWordOptionsModel.mappingOnly(), java.util.Arrays.asList("testString")); + assertEquals(addWordOptionsModel.soundsLike(), java.util.Arrays.asList("testString")); + assertEquals(addWordOptionsModel.displayAs(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordOptionsError() throws Throwable { + new AddWordOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptionsTest.java new file mode 100644 index 00000000000..365da40bb9c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordsOptions model. */ +public class AddWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordsOptions() throws Throwable { + CustomWord customWordModel = + new CustomWord.Builder() + .word("testString") + .mappingOnly(java.util.Arrays.asList("testString")) + .soundsLike(java.util.Arrays.asList("testString")) + .displayAs("testString") + .build(); + assertEquals(customWordModel.word(), "testString"); + assertEquals(customWordModel.mappingOnly(), java.util.Arrays.asList("testString")); + assertEquals(customWordModel.soundsLike(), java.util.Arrays.asList("testString")); + assertEquals(customWordModel.displayAs(), "testString"); + + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(java.util.Arrays.asList(customWordModel)) + .build(); + assertEquals(addWordsOptionsModel.customizationId(), "testString"); + assertEquals(addWordsOptionsModel.words(), java.util.Arrays.asList(customWordModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsOptionsError() throws Throwable { + new AddWordsOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioDetailsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioDetailsTest.java new file mode 100644 index 00000000000..38728466449 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioDetailsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioDetails model. */ +public class AudioDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioDetails() throws Throwable { + AudioDetails audioDetailsModel = new AudioDetails(); + assertNull(audioDetailsModel.getType()); + assertNull(audioDetailsModel.getCodec()); + assertNull(audioDetailsModel.getFrequency()); + assertNull(audioDetailsModel.getCompression()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioListingTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioListingTest.java new file mode 100644 index 00000000000..7e1aa576348 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioListingTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioListing model. */ +public class AudioListingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioListing() throws Throwable { + AudioListing audioListingModel = new AudioListing(); + assertNull(audioListingModel.getDuration()); + assertNull(audioListingModel.getName()); + assertNull(audioListingModel.getDetails()); + assertNull(audioListingModel.getStatus()); + assertNull(audioListingModel.getContainer()); + assertNull(audioListingModel.getAudio()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetailsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetailsTest.java new file mode 100644 index 00000000000..7cb5329561f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetailsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioMetricsDetails model. */ +public class AudioMetricsDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioMetricsDetails() throws Throwable { + AudioMetricsDetails audioMetricsDetailsModel = new AudioMetricsDetails(); + assertNull(audioMetricsDetailsModel.isXFinal()); + assertNull(audioMetricsDetailsModel.getEndTime()); + assertNull(audioMetricsDetailsModel.getSignalToNoiseRatio()); + assertNull(audioMetricsDetailsModel.getSpeechRatio()); + assertNull(audioMetricsDetailsModel.getHighFrequencyLoss()); + assertNull(audioMetricsDetailsModel.getDirectCurrentOffset()); + assertNull(audioMetricsDetailsModel.getClippingRate()); + assertNull(audioMetricsDetailsModel.getSpeechLevel()); + assertNull(audioMetricsDetailsModel.getNonSpeechLevel()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBinTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBinTest.java new file mode 100644 index 00000000000..08fd0da60d0 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBinTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioMetricsHistogramBin model. */ +public class AudioMetricsHistogramBinTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioMetricsHistogramBin() throws Throwable { + AudioMetricsHistogramBin audioMetricsHistogramBinModel = new AudioMetricsHistogramBin(); + assertNull(audioMetricsHistogramBinModel.getBegin()); + assertNull(audioMetricsHistogramBinModel.getEnd()); + assertNull(audioMetricsHistogramBinModel.getCount()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsTest.java new file mode 100644 index 00000000000..424bbf06d45 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioMetrics model. */ +public class AudioMetricsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioMetrics() throws Throwable { + AudioMetrics audioMetricsModel = new AudioMetrics(); + assertNull(audioMetricsModel.getSamplingInterval()); + assertNull(audioMetricsModel.getAccumulated()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourceTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourceTest.java new file mode 100644 index 00000000000..12834c7260b --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourceTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioResource model. */ +public class AudioResourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioResource() throws Throwable { + AudioResource audioResourceModel = new AudioResource(); + assertNull(audioResourceModel.getDuration()); + assertNull(audioResourceModel.getName()); + assertNull(audioResourceModel.getDetails()); + assertNull(audioResourceModel.getStatus()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourcesTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourcesTest.java new file mode 100644 index 00000000000..d24afe32521 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourcesTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioResources model. */ +public class AudioResourcesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioResources() throws Throwable { + AudioResources audioResourcesModel = new AudioResources(); + assertNull(audioResourcesModel.getTotalMinutesOfAudio()); + assertNull(audioResourcesModel.getAudio()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptionsTest.java new file mode 100644 index 00000000000..e19a826742d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptionsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CheckJobOptions model. */ +public class CheckJobOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCheckJobOptions() throws Throwable { + CheckJobOptions checkJobOptionsModel = new CheckJobOptions.Builder().id("testString").build(); + assertEquals(checkJobOptionsModel.id(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCheckJobOptionsError() throws Throwable { + new CheckJobOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptionsTest.java new file mode 100644 index 00000000000..36063074f5c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CheckJobsOptions model. */ +public class CheckJobsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCheckJobsOptions() throws Throwable { + CheckJobsOptions checkJobsOptionsModel = new CheckJobsOptions(); + assertNotNull(checkJobsOptionsModel); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorporaTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorporaTest.java new file mode 100644 index 00000000000..1ca388222a5 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorporaTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Corpora model. */ +public class CorporaTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCorpora() throws Throwable { + Corpora corporaModel = new Corpora(); + assertNull(corporaModel.getCorpora()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorpusTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorpusTest.java new file mode 100644 index 00000000000..5ad24853e7d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorpusTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Corpus model. */ +public class CorpusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCorpus() throws Throwable { + Corpus corpusModel = new Corpus(); + assertNull(corpusModel.getName()); + assertNull(corpusModel.getTotalWords()); + assertNull(corpusModel.getOutOfVocabularyWords()); + assertNull(corpusModel.getStatus()); + assertNull(corpusModel.getError()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptionsTest.java new file mode 100644 index 00000000000..d1161ea55ea --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateAcousticModelOptions model. */ +public class CreateAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateAcousticModelOptions() throws Throwable { + CreateAcousticModelOptions createAcousticModelOptionsModel = + new CreateAcousticModelOptions.Builder() + .name("testString") + .baseModelName("ar-MS_BroadbandModel") + .description("testString") + .build(); + assertEquals(createAcousticModelOptionsModel.name(), "testString"); + assertEquals(createAcousticModelOptionsModel.baseModelName(), "ar-MS_BroadbandModel"); + assertEquals(createAcousticModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateAcousticModelOptionsError() throws Throwable { + new CreateAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java new file mode 100644 index 00000000000..e4e3c55c2bb --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java @@ -0,0 +1,117 @@ +/* + * (C) Copyright IBM Corp. 2020, 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateJobOptions model. */ +public class CreateJobOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateJobOptions() throws Throwable { + CreateJobOptions createJobOptionsModel = + new CreateJobOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("en-US_BroadbandModel") + .callbackUrl("testString") + .events("recognitions.started") + .userToken("testString") + .resultsTtl(Long.valueOf("26")) + .speechBeginEvent(false) + .enrichments("testString") + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("30")) + .keywords(java.util.Arrays.asList("testString")) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("1")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(false) + .timestamps(false) + .profanityFilter(true) + .smartFormatting(false) + .smartFormattingVersion(Long.valueOf("0")) + .speakerLabels(false) + .grammarName("testString") + .redaction(false) + .processingMetrics(false) + .processingMetricsInterval(Float.valueOf("1.0")) + .audioMetrics(false) + .endOfPhraseSilenceTime(Double.valueOf("0.8")) + .splitTranscriptAtPhraseEnd(false) + .speechDetectorSensitivity(Float.valueOf("0.5")) + .sadModule(Long.valueOf("1")) + .backgroundAudioSuppression(Float.valueOf("0.0")) + .lowLatency(false) + .characterInsertionBias(Float.valueOf("0.0")) + .build(); + assertEquals( + IOUtils.toString(createJobOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createJobOptionsModel.contentType(), "application/octet-stream"); + assertEquals(createJobOptionsModel.model(), "en-US_BroadbandModel"); + assertEquals(createJobOptionsModel.callbackUrl(), "testString"); + assertEquals(createJobOptionsModel.events(), "recognitions.started"); + assertEquals(createJobOptionsModel.userToken(), "testString"); + assertEquals(createJobOptionsModel.resultsTtl(), Long.valueOf("26")); + assertEquals(createJobOptionsModel.speechBeginEvent(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.enrichments(), "testString"); + assertEquals(createJobOptionsModel.languageCustomizationId(), "testString"); + assertEquals(createJobOptionsModel.acousticCustomizationId(), "testString"); + assertEquals(createJobOptionsModel.baseModelVersion(), "testString"); + assertEquals(createJobOptionsModel.customizationWeight(), Double.valueOf("72.5")); + assertEquals(createJobOptionsModel.inactivityTimeout(), Long.valueOf("30")); + assertEquals(createJobOptionsModel.keywords(), java.util.Arrays.asList("testString")); + assertEquals(createJobOptionsModel.keywordsThreshold(), Float.valueOf("36.0")); + assertEquals(createJobOptionsModel.maxAlternatives(), Long.valueOf("1")); + assertEquals(createJobOptionsModel.wordAlternativesThreshold(), Float.valueOf("36.0")); + assertEquals(createJobOptionsModel.wordConfidence(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.timestamps(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.profanityFilter(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.smartFormatting(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.smartFormattingVersion(), Long.valueOf("0")); + assertEquals(createJobOptionsModel.speakerLabels(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.grammarName(), "testString"); + assertEquals(createJobOptionsModel.redaction(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.processingMetrics(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.processingMetricsInterval(), Float.valueOf("1.0")); + assertEquals(createJobOptionsModel.audioMetrics(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.endOfPhraseSilenceTime(), Double.valueOf("0.8")); + assertEquals(createJobOptionsModel.splitTranscriptAtPhraseEnd(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.speechDetectorSensitivity(), Float.valueOf("0.5")); + assertEquals(createJobOptionsModel.sadModule(), Long.valueOf("1")); + assertEquals(createJobOptionsModel.backgroundAudioSuppression(), Float.valueOf("0.0")); + assertEquals(createJobOptionsModel.lowLatency(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.characterInsertionBias(), Float.valueOf("0.0")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateJobOptionsError() throws Throwable { + new CreateJobOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptionsTest.java new file mode 100644 index 00000000000..db56874cec3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateLanguageModelOptions model. */ +public class CreateLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateLanguageModelOptions() throws Throwable { + CreateLanguageModelOptions createLanguageModelOptionsModel = + new CreateLanguageModelOptions.Builder() + .name("testString") + .baseModelName("ar-MS_Telephony") + .dialect("testString") + .description("testString") + .build(); + assertEquals(createLanguageModelOptionsModel.name(), "testString"); + assertEquals(createLanguageModelOptionsModel.baseModelName(), "ar-MS_Telephony"); + assertEquals(createLanguageModelOptionsModel.dialect(), "testString"); + assertEquals(createLanguageModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateLanguageModelOptionsError() throws Throwable { + new CreateLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CustomWordTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CustomWordTest.java new file mode 100644 index 00000000000..b6eae467108 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CustomWordTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CustomWord model. */ +public class CustomWordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCustomWord() throws Throwable { + CustomWord customWordModel = + new CustomWord.Builder() + .word("testString") + .mappingOnly(java.util.Arrays.asList("testString")) + .soundsLike(java.util.Arrays.asList("testString")) + .displayAs("testString") + .build(); + assertEquals(customWordModel.word(), "testString"); + assertEquals(customWordModel.mappingOnly(), java.util.Arrays.asList("testString")); + assertEquals(customWordModel.soundsLike(), java.util.Arrays.asList("testString")); + assertEquals(customWordModel.displayAs(), "testString"); + + String json = TestUtilities.serialize(customWordModel); + + CustomWord customWordModelNew = TestUtilities.deserialize(json, CustomWord.class); + assertTrue(customWordModelNew instanceof CustomWord); + assertEquals(customWordModelNew.word(), "testString"); + assertEquals(customWordModelNew.displayAs(), "testString"); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptionsTest.java new file mode 100644 index 00000000000..da37e0aff2c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteAcousticModelOptions model. */ +public class DeleteAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteAcousticModelOptions() throws Throwable { + DeleteAcousticModelOptions deleteAcousticModelOptionsModel = + new DeleteAcousticModelOptions.Builder().customizationId("testString").build(); + assertEquals(deleteAcousticModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAcousticModelOptionsError() throws Throwable { + new DeleteAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptionsTest.java new file mode 100644 index 00000000000..1f819c3cac1 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteAudioOptions model. */ +public class DeleteAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteAudioOptions() throws Throwable { + DeleteAudioOptions deleteAudioOptionsModel = + new DeleteAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .build(); + assertEquals(deleteAudioOptionsModel.customizationId(), "testString"); + assertEquals(deleteAudioOptionsModel.audioName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAudioOptionsError() throws Throwable { + new DeleteAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptionsTest.java new file mode 100644 index 00000000000..fac8f8acf39 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCorpusOptions model. */ +public class DeleteCorpusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCorpusOptions() throws Throwable { + DeleteCorpusOptions deleteCorpusOptionsModel = + new DeleteCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .build(); + assertEquals(deleteCorpusOptionsModel.customizationId(), "testString"); + assertEquals(deleteCorpusOptionsModel.corpusName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCorpusOptionsError() throws Throwable { + new DeleteCorpusOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptionsTest.java new file mode 100644 index 00000000000..ec4c32d20f8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteGrammarOptions model. */ +public class DeleteGrammarOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteGrammarOptions() throws Throwable { + DeleteGrammarOptions deleteGrammarOptionsModel = + new DeleteGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .build(); + assertEquals(deleteGrammarOptionsModel.customizationId(), "testString"); + assertEquals(deleteGrammarOptionsModel.grammarName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteGrammarOptionsError() throws Throwable { + new DeleteGrammarOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptionsTest.java new file mode 100644 index 00000000000..6e60a6c131e --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteJobOptions model. */ +public class DeleteJobOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteJobOptions() throws Throwable { + DeleteJobOptions deleteJobOptionsModel = + new DeleteJobOptions.Builder().id("testString").build(); + assertEquals(deleteJobOptionsModel.id(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteJobOptionsError() throws Throwable { + new DeleteJobOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptionsTest.java new file mode 100644 index 00000000000..3d6196b5c09 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteLanguageModelOptions model. */ +public class DeleteLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteLanguageModelOptions() throws Throwable { + DeleteLanguageModelOptions deleteLanguageModelOptionsModel = + new DeleteLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(deleteLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteLanguageModelOptionsError() throws Throwable { + new DeleteLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..0ceb8f6b6ec --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptionsTest.java new file mode 100644 index 00000000000..236c8409cef --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteWordOptions model. */ +public class DeleteWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteWordOptions() throws Throwable { + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .build(); + assertEquals(deleteWordOptionsModel.customizationId(), "testString"); + assertEquals(deleteWordOptionsModel.wordName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordOptionsError() throws Throwable { + new DeleteWordOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptionsTest.java new file mode 100644 index 00000000000..7a2cc9851d4 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the DetectLanguageOptions model. */ +public class DetectLanguageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDetectLanguageOptions() throws Throwable { + DetectLanguageOptions detectLanguageOptionsModel = + new DetectLanguageOptions.Builder() + .lidConfidence(Float.valueOf("36.0")) + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .build(); + assertEquals(detectLanguageOptionsModel.lidConfidence(), Float.valueOf("36.0")); + assertEquals( + IOUtils.toString(detectLanguageOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(detectLanguageOptionsModel.contentType(), "application/octet-stream"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDetectLanguageOptionsError() throws Throwable { + new DetectLanguageOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTest.java new file mode 100644 index 00000000000..6f0e7c76369 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichedResults model. */ +public class EnrichedResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichedResults() throws Throwable { + EnrichedResults enrichedResultsModel = new EnrichedResults(); + assertNull(enrichedResultsModel.getTranscript()); + assertNull(enrichedResultsModel.getStatus()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTest.java new file mode 100644 index 00000000000..cb0abc6c64e --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichedResultsTranscript model. */ +public class EnrichedResultsTranscriptTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichedResultsTranscript() throws Throwable { + EnrichedResultsTranscript enrichedResultsTranscriptModel = new EnrichedResultsTranscript(); + assertNull(enrichedResultsTranscriptModel.getText()); + assertNull(enrichedResultsTranscriptModel.getTimestamp()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestampTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestampTest.java new file mode 100644 index 00000000000..3ef738df8a9 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestampTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichedResultsTranscriptTimestamp model. */ +public class EnrichedResultsTranscriptTimestampTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichedResultsTranscriptTimestamp() throws Throwable { + EnrichedResultsTranscriptTimestamp enrichedResultsTranscriptTimestampModel = + new EnrichedResultsTranscriptTimestamp(); + assertNull(enrichedResultsTranscriptTimestampModel.getFrom()); + assertNull(enrichedResultsTranscriptTimestampModel.getTo()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptionsTest.java new file mode 100644 index 00000000000..5418cf925af --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAcousticModelOptions model. */ +public class GetAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAcousticModelOptions() throws Throwable { + GetAcousticModelOptions getAcousticModelOptionsModel = + new GetAcousticModelOptions.Builder().customizationId("testString").build(); + assertEquals(getAcousticModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAcousticModelOptionsError() throws Throwable { + new GetAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptionsTest.java new file mode 100644 index 00000000000..87e2f57865b --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAudioOptions model. */ +public class GetAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAudioOptions() throws Throwable { + GetAudioOptions getAudioOptionsModel = + new GetAudioOptions.Builder().customizationId("testString").audioName("testString").build(); + assertEquals(getAudioOptionsModel.customizationId(), "testString"); + assertEquals(getAudioOptionsModel.audioName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAudioOptionsError() throws Throwable { + new GetAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptionsTest.java new file mode 100644 index 00000000000..9a1898b75f0 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCorpusOptions model. */ +public class GetCorpusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCorpusOptions() throws Throwable { + GetCorpusOptions getCorpusOptionsModel = + new GetCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .build(); + assertEquals(getCorpusOptionsModel.customizationId(), "testString"); + assertEquals(getCorpusOptionsModel.corpusName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCorpusOptionsError() throws Throwable { + new GetCorpusOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptionsTest.java new file mode 100644 index 00000000000..26ed1a93bba --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetGrammarOptions model. */ +public class GetGrammarOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetGrammarOptions() throws Throwable { + GetGrammarOptions getGrammarOptionsModel = + new GetGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .build(); + assertEquals(getGrammarOptionsModel.customizationId(), "testString"); + assertEquals(getGrammarOptionsModel.grammarName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetGrammarOptionsError() throws Throwable { + new GetGrammarOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptionsTest.java new file mode 100644 index 00000000000..6b70ac6b27f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetLanguageModelOptions model. */ +public class GetLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetLanguageModelOptions() throws Throwable { + GetLanguageModelOptions getLanguageModelOptionsModel = + new GetLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(getLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetLanguageModelOptionsError() throws Throwable { + new GetLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptionsTest.java new file mode 100644 index 00000000000..66cd261f34d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetModelOptions model. */ +public class GetModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetModelOptions() throws Throwable { + GetModelOptions getModelOptionsModel = + new GetModelOptions.Builder().modelId("ar-MS_BroadbandModel").build(); + assertEquals(getModelOptionsModel.modelId(), "ar-MS_BroadbandModel"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelOptionsError() throws Throwable { + new GetModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptionsTest.java new file mode 100644 index 00000000000..db9392665a8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetWordOptions model. */ +public class GetWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetWordOptions() throws Throwable { + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").wordName("testString").build(); + assertEquals(getWordOptionsModel.customizationId(), "testString"); + assertEquals(getWordOptionsModel.wordName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordOptionsError() throws Throwable { + new GetWordOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarTest.java new file mode 100644 index 00000000000..1d084a76ded --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Grammar model. */ +public class GrammarTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGrammar() throws Throwable { + Grammar grammarModel = new Grammar(); + assertNull(grammarModel.getName()); + assertNull(grammarModel.getOutOfVocabularyWords()); + assertNull(grammarModel.getStatus()); + assertNull(grammarModel.getError()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarsTest.java new file mode 100644 index 00000000000..a5238a3321c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Grammars model. */ +public class GrammarsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGrammars() throws Throwable { + Grammars grammarsModel = new Grammars(); + assertNull(grammarsModel.getGrammars()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/KeywordResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/KeywordResultTest.java new file mode 100644 index 00000000000..9053fe5fc20 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/KeywordResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeywordResult model. */ +public class KeywordResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeywordResult() throws Throwable { + KeywordResult keywordResultModel = new KeywordResult(); + assertNull(keywordResultModel.getNormalizedText()); + assertNull(keywordResultModel.getStartTime()); + assertNull(keywordResultModel.getEndTime()); + assertNull(keywordResultModel.getConfidence()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultTest.java new file mode 100644 index 00000000000..05eabfeab6a --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageDetectionResult model. */ +public class LanguageDetectionResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageDetectionResult() throws Throwable { + LanguageDetectionResult languageDetectionResultModel = new LanguageDetectionResult(); + assertNull(languageDetectionResultModel.getLanguageInfo()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultsTest.java new file mode 100644 index 00000000000..8fcb3aa1495 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageDetectionResults model. */ +public class LanguageDetectionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageDetectionResults() throws Throwable { + LanguageDetectionResults languageDetectionResultsModel = new LanguageDetectionResults(); + assertNull(languageDetectionResultsModel.getResults()); + assertNull(languageDetectionResultsModel.getResultIndex()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfoTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfoTest.java new file mode 100644 index 00000000000..9f824bddfc2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfoTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageInfo model. */ +public class LanguageInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageInfo() throws Throwable { + LanguageInfo languageInfoModel = new LanguageInfo(); + assertNull(languageInfoModel.getConfidence()); + assertNull(languageInfoModel.getLanguage()); + assertNull(languageInfoModel.getTimestamp()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelTest.java new file mode 100644 index 00000000000..e2a180806d2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageModel model. */ +public class LanguageModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageModel() throws Throwable { + LanguageModel languageModelModel = new LanguageModel(); + assertNull(languageModelModel.getCustomizationId()); + assertNull(languageModelModel.getCreated()); + assertNull(languageModelModel.getUpdated()); + assertNull(languageModelModel.getLanguage()); + assertNull(languageModelModel.getDialect()); + assertNull(languageModelModel.getVersions()); + assertNull(languageModelModel.getOwner()); + assertNull(languageModelModel.getName()); + assertNull(languageModelModel.getDescription()); + assertNull(languageModelModel.getBaseModelName()); + assertNull(languageModelModel.getStatus()); + assertNull(languageModelModel.getProgress()); + assertNull(languageModelModel.getError()); + assertNull(languageModelModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelsTest.java new file mode 100644 index 00000000000..547701416ac --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageModels model. */ +public class LanguageModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageModels() throws Throwable { + LanguageModels languageModelsModel = new LanguageModels(); + assertNull(languageModelsModel.getCustomizations()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptionsTest.java new file mode 100644 index 00000000000..bf63a16d599 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAcousticModelsOptions model. */ +public class ListAcousticModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAcousticModelsOptions() throws Throwable { + ListAcousticModelsOptions listAcousticModelsOptionsModel = + new ListAcousticModelsOptions.Builder().language("ar-MS").build(); + assertEquals(listAcousticModelsOptionsModel.language(), "ar-MS"); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptionsTest.java new file mode 100644 index 00000000000..c70d1017ab2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAudioOptions model. */ +public class ListAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAudioOptions() throws Throwable { + ListAudioOptions listAudioOptionsModel = + new ListAudioOptions.Builder().customizationId("testString").build(); + assertEquals(listAudioOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAudioOptionsError() throws Throwable { + new ListAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptionsTest.java new file mode 100644 index 00000000000..898b817220f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCorporaOptions model. */ +public class ListCorporaOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCorporaOptions() throws Throwable { + ListCorporaOptions listCorporaOptionsModel = + new ListCorporaOptions.Builder().customizationId("testString").build(); + assertEquals(listCorporaOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCorporaOptionsError() throws Throwable { + new ListCorporaOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptionsTest.java new file mode 100644 index 00000000000..c025a37c687 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListGrammarsOptions model. */ +public class ListGrammarsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListGrammarsOptions() throws Throwable { + ListGrammarsOptions listGrammarsOptionsModel = + new ListGrammarsOptions.Builder().customizationId("testString").build(); + assertEquals(listGrammarsOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListGrammarsOptionsError() throws Throwable { + new ListGrammarsOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptionsTest.java new file mode 100644 index 00000000000..bbc6da3586b --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 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 + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLanguageModelsOptions model. */ +public class ListLanguageModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLanguageModelsOptions() throws Throwable { + ListLanguageModelsOptions listLanguageModelsOptionsModel = + new ListLanguageModelsOptions.Builder().language("ar-MS").build(); + assertEquals(listLanguageModelsOptionsModel.language(), "ar-MS"); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptionsTest.java new file mode 100644 index 00000000000..549435f8771 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsOptions model. */ +public class ListModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsOptions() throws Throwable { + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + assertNotNull(listModelsOptionsModel); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptionsTest.java new file mode 100644 index 00000000000..ff5b2b015f3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListWordsOptions model. */ +public class ListWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListWordsOptions() throws Throwable { + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder() + .customizationId("testString") + .wordType("all") + .sort("alphabetical") + .build(); + assertEquals(listWordsOptionsModel.customizationId(), "testString"); + assertEquals(listWordsOptionsModel.wordType(), "all"); + assertEquals(listWordsOptionsModel.sort(), "alphabetical"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsOptionsError() throws Throwable { + new ListWordsOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudioTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudioTest.java new file mode 100644 index 00000000000..df6eeb7f0a3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudioTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProcessedAudio model. */ +public class ProcessedAudioTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProcessedAudio() throws Throwable { + ProcessedAudio processedAudioModel = new ProcessedAudio(); + assertNull(processedAudioModel.getReceived()); + assertNull(processedAudioModel.getSeenByEngine()); + assertNull(processedAudioModel.getTranscription()); + assertNull(processedAudioModel.getSpeakerLabels()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetricsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetricsTest.java new file mode 100644 index 00000000000..86285ffdc89 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetricsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProcessingMetrics model. */ +public class ProcessingMetricsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProcessingMetrics() throws Throwable { + ProcessingMetrics processingMetricsModel = new ProcessingMetrics(); + assertNull(processingMetricsModel.getProcessedAudio()); + assertNull(processingMetricsModel.getWallClockSinceFirstByteReceived()); + assertNull(processingMetricsModel.isPeriodic()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobTest.java new file mode 100644 index 00000000000..2fda4143572 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RecognitionJob model. */ +public class RecognitionJobTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRecognitionJob() throws Throwable { + RecognitionJob recognitionJobModel = new RecognitionJob(); + assertNull(recognitionJobModel.getId()); + assertNull(recognitionJobModel.getStatus()); + assertNull(recognitionJobModel.getCreated()); + assertNull(recognitionJobModel.getUpdated()); + assertNull(recognitionJobModel.getUrl()); + assertNull(recognitionJobModel.getUserToken()); + assertNull(recognitionJobModel.getResults()); + assertNull(recognitionJobModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobsTest.java new file mode 100644 index 00000000000..24486f3a3c8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RecognitionJobs model. */ +public class RecognitionJobsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRecognitionJobs() throws Throwable { + RecognitionJobs recognitionJobsModel = new RecognitionJobs(); + assertNull(recognitionJobsModel.getRecognitions()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java new file mode 100644 index 00000000000..c6a364d0f54 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java @@ -0,0 +1,105 @@ +/* + * (C) Copyright IBM Corp. 2020, 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the RecognizeOptions model. */ +public class RecognizeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRecognizeOptions() throws Throwable { + RecognizeOptions recognizeOptionsModel = + new RecognizeOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("en-US_BroadbandModel") + .speechBeginEvent(false) + .enrichments("testString") + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("30")) + .keywords(java.util.Arrays.asList("testString")) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("1")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(false) + .timestamps(false) + .profanityFilter(true) + .smartFormatting(false) + .smartFormattingVersion(Long.valueOf("0")) + .speakerLabels(false) + .grammarName("testString") + .redaction(false) + .audioMetrics(false) + .endOfPhraseSilenceTime(Double.valueOf("0.8")) + .splitTranscriptAtPhraseEnd(false) + .speechDetectorSensitivity(Float.valueOf("0.5")) + .sadModule(Long.valueOf("1")) + .backgroundAudioSuppression(Float.valueOf("0.0")) + .lowLatency(false) + .characterInsertionBias(Float.valueOf("0.0")) + .build(); + assertEquals( + IOUtils.toString(recognizeOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(recognizeOptionsModel.contentType(), "application/octet-stream"); + assertEquals(recognizeOptionsModel.model(), "en-US_BroadbandModel"); + assertEquals(recognizeOptionsModel.speechBeginEvent(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.enrichments(), "testString"); + assertEquals(recognizeOptionsModel.languageCustomizationId(), "testString"); + assertEquals(recognizeOptionsModel.acousticCustomizationId(), "testString"); + assertEquals(recognizeOptionsModel.baseModelVersion(), "testString"); + assertEquals(recognizeOptionsModel.customizationWeight(), Double.valueOf("72.5")); + assertEquals(recognizeOptionsModel.inactivityTimeout(), Long.valueOf("30")); + assertEquals(recognizeOptionsModel.keywords(), java.util.Arrays.asList("testString")); + assertEquals(recognizeOptionsModel.keywordsThreshold(), Float.valueOf("36.0")); + assertEquals(recognizeOptionsModel.maxAlternatives(), Long.valueOf("1")); + assertEquals(recognizeOptionsModel.wordAlternativesThreshold(), Float.valueOf("36.0")); + assertEquals(recognizeOptionsModel.wordConfidence(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.timestamps(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.profanityFilter(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.smartFormatting(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.smartFormattingVersion(), Long.valueOf("0")); + assertEquals(recognizeOptionsModel.speakerLabels(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.grammarName(), "testString"); + assertEquals(recognizeOptionsModel.redaction(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.audioMetrics(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.endOfPhraseSilenceTime(), Double.valueOf("0.8")); + assertEquals(recognizeOptionsModel.splitTranscriptAtPhraseEnd(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.speechDetectorSensitivity(), Float.valueOf("0.5")); + assertEquals(recognizeOptionsModel.sadModule(), Long.valueOf("1")); + assertEquals(recognizeOptionsModel.backgroundAudioSuppression(), Float.valueOf("0.0")); + assertEquals(recognizeOptionsModel.lowLatency(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.characterInsertionBias(), Float.valueOf("0.0")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRecognizeOptionsError() throws Throwable { + new RecognizeOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptionsTest.java new file mode 100644 index 00000000000..672abc52443 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RegisterCallbackOptions model. */ +public class RegisterCallbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRegisterCallbackOptions() throws Throwable { + RegisterCallbackOptions registerCallbackOptionsModel = + new RegisterCallbackOptions.Builder() + .callbackUrl("testString") + .userSecret("testString") + .build(); + assertEquals(registerCallbackOptionsModel.callbackUrl(), "testString"); + assertEquals(registerCallbackOptionsModel.userSecret(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRegisterCallbackOptionsError() throws Throwable { + new RegisterCallbackOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatusTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatusTest.java new file mode 100644 index 00000000000..11d6ab141a3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatusTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RegisterStatus model. */ +public class RegisterStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRegisterStatus() throws Throwable { + RegisterStatus registerStatusModel = new RegisterStatus(); + assertNull(registerStatusModel.getStatus()); + assertNull(registerStatusModel.getUrl()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptionsTest.java new file mode 100644 index 00000000000..cde7f724775 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResetAcousticModelOptions model. */ +public class ResetAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResetAcousticModelOptions() throws Throwable { + ResetAcousticModelOptions resetAcousticModelOptionsModel = + new ResetAcousticModelOptions.Builder().customizationId("testString").build(); + assertEquals(resetAcousticModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetAcousticModelOptionsError() throws Throwable { + new ResetAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptionsTest.java new file mode 100644 index 00000000000..4b0598cc1d6 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResetLanguageModelOptions model. */ +public class ResetLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResetLanguageModelOptions() throws Throwable { + ResetLanguageModelOptions resetLanguageModelOptionsModel = + new ResetLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(resetLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetLanguageModelOptionsError() throws Throwable { + new ResetLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResultTest.java new file mode 100644 index 00000000000..5d68864e930 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeakerLabelsResult model. */ +public class SpeakerLabelsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakerLabelsResult() throws Throwable { + SpeakerLabelsResult speakerLabelsResultModel = new SpeakerLabelsResult(); + assertNull(speakerLabelsResultModel.getFrom()); + assertNull(speakerLabelsResultModel.getTo()); + assertNull(speakerLabelsResultModel.getSpeaker()); + assertNull(speakerLabelsResultModel.getConfidence()); + assertNull(speakerLabelsResultModel.isXFinal()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelTest.java new file mode 100644 index 00000000000..6f43e748cc4 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechModel model. */ +public class SpeechModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechModel() throws Throwable { + SpeechModel speechModelModel = new SpeechModel(); + assertNull(speechModelModel.getName()); + assertNull(speechModelModel.getLanguage()); + assertNull(speechModelModel.getRate()); + assertNull(speechModelModel.getUrl()); + assertNull(speechModelModel.getSupportedFeatures()); + assertNull(speechModelModel.getDescription()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelsTest.java new file mode 100644 index 00000000000..2b7e47e653d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechModels model. */ +public class SpeechModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechModels() throws Throwable { + SpeechModels speechModelsModel = new SpeechModels(); + assertNull(speechModelsModel.getModels()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternativeTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternativeTest.java new file mode 100644 index 00000000000..4708977f0ad --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternativeTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechRecognitionAlternative model. */ +public class SpeechRecognitionAlternativeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechRecognitionAlternative() throws Throwable { + SpeechRecognitionAlternative speechRecognitionAlternativeModel = + new SpeechRecognitionAlternative(); + assertNull(speechRecognitionAlternativeModel.getTranscript()); + assertNull(speechRecognitionAlternativeModel.getConfidence()); + assertNull(speechRecognitionAlternativeModel.getTimestamps()); + assertNull(speechRecognitionAlternativeModel.getWordConfidence()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultTest.java new file mode 100644 index 00000000000..863e20ac75c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechRecognitionResult model. */ +public class SpeechRecognitionResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechRecognitionResult() throws Throwable { + SpeechRecognitionResult speechRecognitionResultModel = new SpeechRecognitionResult(); + assertNull(speechRecognitionResultModel.isXFinal()); + assertNull(speechRecognitionResultModel.getAlternatives()); + assertNull(speechRecognitionResultModel.getKeywordsResult()); + assertNull(speechRecognitionResultModel.getWordAlternatives()); + assertNull(speechRecognitionResultModel.getEndOfUtterance()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java new file mode 100644 index 00000000000..420bd51715a --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 2026. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechRecognitionResults model. */ +public class SpeechRecognitionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechRecognitionResults() throws Throwable { + SpeechRecognitionResults speechRecognitionResultsModel = new SpeechRecognitionResults(); + assertNull(speechRecognitionResultsModel.getResults()); + assertNull(speechRecognitionResultsModel.getResultIndex()); + assertNull(speechRecognitionResultsModel.getSpeakerLabels()); + assertNull(speechRecognitionResultsModel.getProcessingMetrics()); + assertNull(speechRecognitionResultsModel.getAudioMetrics()); + assertNull(speechRecognitionResultsModel.getWarnings()); + assertNull(speechRecognitionResultsModel.getEnrichedResults()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeaturesTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeaturesTest.java new file mode 100644 index 00000000000..2d9c8fc1e9c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeaturesTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SupportedFeatures model. */ +public class SupportedFeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSupportedFeatures() throws Throwable { + SupportedFeatures supportedFeaturesModel = new SupportedFeatures(); + assertNull(supportedFeaturesModel.isCustomLanguageModel()); + assertNull(supportedFeaturesModel.isCustomAcousticModel()); + assertNull(supportedFeaturesModel.isSpeakerLabels()); + assertNull(supportedFeaturesModel.isLowLatency()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptionsTest.java new file mode 100644 index 00000000000..aa290a375fb --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainAcousticModelOptions model. */ +public class TrainAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainAcousticModelOptions() throws Throwable { + TrainAcousticModelOptions trainAcousticModelOptionsModel = + new TrainAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .strict(true) + .build(); + assertEquals(trainAcousticModelOptionsModel.customizationId(), "testString"); + assertEquals(trainAcousticModelOptionsModel.customLanguageModelId(), "testString"); + assertEquals(trainAcousticModelOptionsModel.strict(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainAcousticModelOptionsError() throws Throwable { + new TrainAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptionsTest.java new file mode 100644 index 00000000000..39135e6b8aa --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainLanguageModelOptions model. */ +public class TrainLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainLanguageModelOptions() throws Throwable { + TrainLanguageModelOptions trainLanguageModelOptionsModel = + new TrainLanguageModelOptions.Builder() + .customizationId("testString") + .wordTypeToAdd("all") + .customizationWeight(Double.valueOf("72.5")) + .strict(true) + .force(false) + .build(); + assertEquals(trainLanguageModelOptionsModel.customizationId(), "testString"); + assertEquals(trainLanguageModelOptionsModel.wordTypeToAdd(), "all"); + assertEquals(trainLanguageModelOptionsModel.customizationWeight(), Double.valueOf("72.5")); + assertEquals(trainLanguageModelOptionsModel.strict(), Boolean.valueOf(true)); + assertEquals(trainLanguageModelOptionsModel.force(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainLanguageModelOptionsError() throws Throwable { + new TrainLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponseTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponseTest.java new file mode 100644 index 00000000000..cd153c69c19 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingResponse model. */ +public class TrainingResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingResponse() throws Throwable { + TrainingResponse trainingResponseModel = new TrainingResponse(); + assertNull(trainingResponseModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarningTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarningTest.java new file mode 100644 index 00000000000..76f943c68f8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarningTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingWarning model. */ +public class TrainingWarningTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingWarning() throws Throwable { + TrainingWarning trainingWarningModel = new TrainingWarning(); + assertNull(trainingWarningModel.getCode()); + assertNull(trainingWarningModel.getMessage()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptionsTest.java new file mode 100644 index 00000000000..0615a419ee9 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UnregisterCallbackOptions model. */ +public class UnregisterCallbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUnregisterCallbackOptions() throws Throwable { + UnregisterCallbackOptions unregisterCallbackOptionsModel = + new UnregisterCallbackOptions.Builder().callbackUrl("testString").build(); + assertEquals(unregisterCallbackOptionsModel.callbackUrl(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUnregisterCallbackOptionsError() throws Throwable { + new UnregisterCallbackOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptionsTest.java new file mode 100644 index 00000000000..0db9b4ba69c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpgradeAcousticModelOptions model. */ +public class UpgradeAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpgradeAcousticModelOptions() throws Throwable { + UpgradeAcousticModelOptions upgradeAcousticModelOptionsModel = + new UpgradeAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .force(false) + .build(); + assertEquals(upgradeAcousticModelOptionsModel.customizationId(), "testString"); + assertEquals(upgradeAcousticModelOptionsModel.customLanguageModelId(), "testString"); + assertEquals(upgradeAcousticModelOptionsModel.force(), Boolean.valueOf(false)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeAcousticModelOptionsError() throws Throwable { + new UpgradeAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptionsTest.java new file mode 100644 index 00000000000..9dd57cb11af --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpgradeLanguageModelOptions model. */ +public class UpgradeLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpgradeLanguageModelOptions() throws Throwable { + UpgradeLanguageModelOptions upgradeLanguageModelOptionsModel = + new UpgradeLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(upgradeLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeLanguageModelOptionsError() throws Throwable { + new UpgradeLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultTest.java new file mode 100644 index 00000000000..81c03b6a49f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordAlternativeResult model. */ +public class WordAlternativeResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordAlternativeResult() throws Throwable { + WordAlternativeResult wordAlternativeResultModel = new WordAlternativeResult(); + assertNull(wordAlternativeResultModel.getConfidence()); + assertNull(wordAlternativeResultModel.getWord()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultsTest.java new file mode 100644 index 00000000000..f73eee2d049 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordAlternativeResults model. */ +public class WordAlternativeResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordAlternativeResults() throws Throwable { + WordAlternativeResults wordAlternativeResultsModel = new WordAlternativeResults(); + assertNull(wordAlternativeResultsModel.getStartTime()); + assertNull(wordAlternativeResultsModel.getEndTime()); + assertNull(wordAlternativeResultsModel.getAlternatives()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordErrorTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordErrorTest.java new file mode 100644 index 00000000000..c85e3ad150a --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordErrorTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordError model. */ +public class WordErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordError() throws Throwable { + WordError wordErrorModel = new WordError(); + assertNull(wordErrorModel.getElement()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordTest.java new file mode 100644 index 00000000000..ce3f1cdb0e0 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Word model. */ +public class WordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWord() throws Throwable { + Word wordModel = new Word(); + assertNull(wordModel.getWord()); + assertNull(wordModel.getMappingOnly()); + assertNull(wordModel.getSoundsLike()); + assertNull(wordModel.getDisplayAs()); + assertNull(wordModel.getCount()); + assertNull(wordModel.getSource()); + assertNull(wordModel.getError()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordsTest.java new file mode 100644 index 00000000000..535f405d9fd --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Words model. */ +public class WordsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWords() throws Throwable { + Words wordsModel = new Words(); + assertNull(wordsModel.getWords()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/testng.xml b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/testng.xml new file mode 100644 index 00000000000..0de0d8db9fc --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/utils/TestUtilities.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..57695908719 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/utils/TestUtilities.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.speech_to_text.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} diff --git a/speech-to-text/src/test/java/okhttp3/internal/ws/WebSocketRecorder.java b/speech-to-text/src/test/java/okhttp3/internal/ws/WebSocketRecorder.java deleted file mode 100755 index 78a860939d1..00000000000 --- a/speech-to-text/src/test/java/okhttp3/internal/ws/WebSocketRecorder.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2016 Square, Inc. - * - * 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 okhttp3.internal.ws; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -import okhttp3.Response; -import okhttp3.WebSocket; -import okhttp3.WebSocketListener; -import okhttp3.internal.Util; -import okhttp3.internal.platform.Platform; -import okio.ByteString; - -public final class WebSocketRecorder extends WebSocketListener { - private final String name; - private final BlockingQueue events = new LinkedBlockingQueue<>(); - private WebSocketListener delegate; - - public WebSocketRecorder(String name) { - this.name = name; - } - - /** - * Sets a delegate for handling the next callback to this listener. Cleared after invoked. - * - * @param delegate the delegate to be set - */ - public void setNextEventDelegate(WebSocketListener delegate) { - this.delegate = delegate; - } - - @Override - public void onOpen(WebSocket webSocket, Response response) { - Platform.get().log(Platform.INFO, "[WS " + name + "] onOpen", null); - - WebSocketListener delegate = this.delegate; - if (delegate != null) { - this.delegate = null; - delegate.onOpen(webSocket, response); - } else { - events.add(new Open(webSocket, response)); - } - } - - @Override - public void onMessage(WebSocket webSocket, ByteString bytes) { - Platform.get().log(Platform.INFO, "[WS " + name + "] onMessage", null); - - WebSocketListener delegate = this.delegate; - if (delegate != null) { - this.delegate = null; - delegate.onMessage(webSocket, bytes); - } else { - Message event = new Message(bytes); - events.add(event); - } - } - - @Override - public void onMessage(WebSocket webSocket, String text) { - Platform.get().log(Platform.INFO, "[WS " + name + "] onMessage", null); - - WebSocketListener delegate = this.delegate; - if (delegate != null) { - this.delegate = null; - delegate.onMessage(webSocket, text); - } else { - Message event = new Message(text); - events.add(event); - } - } - - @Override - public void onClosing(WebSocket webSocket, int code, String reason) { - Platform.get().log(Platform.INFO, "[WS " + name + "] onClose " + code, null); - - WebSocketListener delegate = this.delegate; - if (delegate != null) { - this.delegate = null; - delegate.onClosing(webSocket, code, reason); - } else { - events.add(new Closing(code, reason)); - } - } - - @Override - public void onClosed(WebSocket webSocket, int code, String reason) { - Platform.get().log(Platform.INFO, "[WS " + name + "] onClose " + code, null); - - WebSocketListener delegate = this.delegate; - if (delegate != null) { - this.delegate = null; - delegate.onClosed(webSocket, code, reason); - } else { - events.add(new Closed(code, reason)); - } - } - - @Override - public void onFailure(WebSocket webSocket, Throwable t, Response response) { - Platform.get().log(Platform.INFO, "[WS " + name + "] onFailure", t); - - WebSocketListener delegate = this.delegate; - if (delegate != null) { - this.delegate = null; - delegate.onFailure(webSocket, t, response); - } else { - events.add(new Failure(t, response)); - } - } - - private Object nextEvent() { - try { - Object event = events.poll(10, TimeUnit.SECONDS); - if (event == null) { - throw new AssertionError("Timed out waiting for event."); - } - return event; - } catch (InterruptedException e) { - throw new AssertionError(e); - } - } - - public void assertTextMessage(String payload) { - Object actual = nextEvent(); - assertEquals(new Message(payload), actual); - } - - public void assertBinaryMessage(ByteString payload) { - Object actual = nextEvent(); - assertEquals(new Message(payload), actual); - } - - public void assertPing(ByteString payload) { - Object actual = nextEvent(); - assertEquals(new Ping(payload), actual); - } - - public void assertPong(ByteString payload) { - Object actual = nextEvent(); - assertEquals(new Pong(payload), actual); - } - - public void assertClosing(int code, String reason) { - Object actual = nextEvent(); - assertEquals(new Closing(code, reason), actual); - } - - public void assertClosed(int code, String reason) { - Object actual = nextEvent(); - assertEquals(new Closed(code, reason), actual); - } - - public void assertExhausted() { - assertTrue("Remaining events: " + events, events.isEmpty()); - } - - public WebSocket assertOpen() { - Object event = nextEvent(); - if (!(event instanceof Open)) { - throw new AssertionError("Expected Open but was " + event); - } - return ((Open) event).webSocket; - } - - public void assertFailure(Throwable t) { - Object event = nextEvent(); - if (!(event instanceof Failure)) { - throw new AssertionError("Expected Failure but was " + event); - } - Failure failure = (Failure) event; - assertNull(failure.response); - assertSame(t, failure.t); - } - - public void assertFailure(Class cls, String message) { - Object event = nextEvent(); - if (!(event instanceof Failure)) { - throw new AssertionError("Expected Failure but was " + event); - } - Failure failure = (Failure) event; - assertNull(failure.response); - assertEquals(cls, failure.t.getClass()); - assertEquals(message, failure.t.getMessage()); - } - - public void assertFailure() { - Object event = nextEvent(); - if (!(event instanceof Failure)) { - throw new AssertionError("Expected Failure but was " + event); - } - } - - public void assertFailure(int code, String body, Class cls, String message) - throws IOException { - Object event = nextEvent(); - if (!(event instanceof Failure)) { - throw new AssertionError("Expected Failure but was " + event); - } - Failure failure = (Failure) event; - assertEquals(code, failure.response.code()); - if (body != null) { - assertEquals(body, failure.responseBody); - } - assertEquals(cls, failure.t.getClass()); - assertEquals(message, failure.t.getMessage()); - } - - /** - * Expose this recorder as a frame callback and shim in "ping" events. - * - * @return the frame callback for the WebSocket reader - */ - public WebSocketReader.FrameCallback asFrameCallback() { - return new WebSocketReader.FrameCallback() { - @Override - public void onReadMessage(String text) throws IOException { - onMessage(null, text); - } - - @Override - public void onReadMessage(ByteString bytes) throws IOException { - onMessage(null, bytes); - } - - @Override - public void onReadPing(ByteString payload) { - events.add(new Ping(payload)); - } - - @Override - public void onReadPong(ByteString payload) { - events.add(new Pong(payload)); - } - - @Override - public void onReadClose(int code, String reason) { - onClosing(null, code, reason); - } - }; - } - - static final class Open { - final WebSocket webSocket; - final Response response; - - Open(WebSocket webSocket, Response response) { - this.webSocket = webSocket; - this.response = response; - } - - @Override - public String toString() { - return "Open[" + response + "]"; - } - } - - static final class Failure { - final Throwable t; - final Response response; - final String responseBody; - - Failure(Throwable t, Response response) { - this.t = t; - this.response = response; - String responseBody = null; - if (response != null) { - try { - responseBody = response.body().string(); - } catch (IOException ignored) { - } - } - this.responseBody = responseBody; - } - - @Override - public String toString() { - if (response == null) { - return "Failure[" + t + "]"; - } - return "Failure[" + response + "]"; - } - } - - static final class Message { - public final ByteString bytes; - public final String string; - - Message(ByteString bytes) { - this.bytes = bytes; - this.string = null; - } - - Message(String string) { - this.bytes = null; - this.string = string; - } - - @Override - public String toString() { - return "Message[" + (bytes != null ? bytes : string) + "]"; - } - - @Override - public int hashCode() { - return (bytes != null ? bytes : string).hashCode(); - } - - @Override - public boolean equals(Object other) { - return other instanceof Message - && Util.equal(((Message) other).bytes, bytes) - && Util.equal(((Message) other).string, string); - } - } - - static final class Ping { - public final ByteString payload; - - Ping(ByteString payload) { - this.payload = payload; - } - - @Override - public String toString() { - return "Ping[" + payload + "]"; - } - - @Override - public int hashCode() { - return payload.hashCode(); - } - - @Override - public boolean equals(Object other) { - return other instanceof Ping - && ((Ping) other).payload.equals(payload); - } - } - - static final class Pong { - public final ByteString payload; - - Pong(ByteString payload) { - this.payload = payload; - } - - @Override - public String toString() { - return "Pong[" + payload + "]"; - } - - @Override - public int hashCode() { - return payload.hashCode(); - } - - @Override - public boolean equals(Object other) { - return other instanceof Pong - && ((Pong) other).payload.equals(payload); - } - } - - static final class Closing { - public final int code; - public final String reason; - - Closing(int code, String reason) { - this.code = code; - this.reason = reason; - } - - @Override - public String toString() { - return "Closing[" + code + " " + reason + "]"; - } - - @Override - public int hashCode() { - return code * 37 + reason.hashCode(); - } - - @Override - public boolean equals(Object other) { - return other instanceof Closing - && ((Closing) other).code == code - && ((Closing) other).reason.equals(reason); - } - } - - static final class Closed { - public final int code; - public final String reason; - - Closed(int code, String reason) { - this.code = code; - this.reason = reason; - } - - @Override - public String toString() { - return "Closed[" + code + " " + reason + "]"; - } - - @Override - public int hashCode() { - return code * 37 + reason.hashCode(); - } - - @Override - public boolean equals(Object other) { - return other instanceof Closed - && ((Closed) other).code == code - && ((Closed) other).reason.equals(reason); - } - } -} diff --git a/speech-to-text/src/test/resources/speech_to_text/jobs.json b/speech-to-text/src/test/resources/speech_to_text/jobs.json index ae23a245c21..91ffc855712 100644 --- a/speech-to-text/src/test/resources/speech_to_text/jobs.json +++ b/speech-to-text/src/test/resources/speech_to_text/jobs.json @@ -8,7 +8,7 @@ "id": "2d0ef860-872e-11e6-90d3-5f28bc58ceb2", "status": "processing", "created": "2016-09-30T16:51:47.558", - "url": "https://stream.watsonplatform.net/speech-to-text/api/v1/recognitions/2d0ef860-872e-11e6-90d3-5f28bc58ceb2" + "url": "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognitions/2d0ef860-872e-11e6-90d3-5f28bc58ceb2" }, { "id": "2d0ef860-872e-11e6-90d3-5f28bc58ceb2", "results": [{ diff --git a/text-to-speech/README.md b/text-to-speech/README.md index 5f594e703e6..9a4f812975a 100755 --- a/text-to-speech/README.md +++ b/text-to-speech/README.md @@ -8,14 +8,14 @@ com.ibm.watson text-to-speech - 8.3.1 + 16.2.0 ``` ##### Gradle ```gradle -'com.ibm.watson:text-to-speech:8.3.1' +'com.ibm.watson:text-to-speech:16.2.0' ``` ## Usage diff --git a/text-to-speech/build.gradle b/text-to-speech/build.gradle deleted file mode 100644 index e63b7d64fa9..00000000000 --- a/text-to-speech/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/text-to-speech/gradle.properties b/text-to-speech/gradle.properties deleted file mode 100644 index 7ec0df7dd34..00000000000 --- a/text-to-speech/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:text-to-speech -ARTIFACT_ID=text-to-speech -NAME=IBM Watson Java SDK - Text to Speech -DESCRIPTION=Java client library to use the IBM Text to Speech API \ No newline at end of file diff --git a/text-to-speech/pom.xml b/text-to-speech/pom.xml new file mode 100644 index 00000000000..47ec9ec1be0 --- /dev/null +++ b/text-to-speech/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + + + ibm-watson-parent + com.ibm.watson + 99-SNAPSHOT + ../pom.xml + + + text-to-speech + jar + IBM Watson Java SDK - Text to Speech + + + + com.ibm.cloud + sdk-core + + + ${project.groupId} + common + compile + + + ${project.groupId} + common + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + + Watson Developer Experience + watdevex@us.ibm.com + https://www.ibm.com/ + + + diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java index a0d4791c328..7697b36132f 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2025. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116 + */ + package com.ibm.watson.text_to_speech.v1; import com.google.gson.JsonObject; @@ -19,99 +24,126 @@ import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; +import com.ibm.cloud.sdk.core.util.RequestUtils; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; import com.ibm.watson.common.SdkCommon; +import com.ibm.watson.text_to_speech.v1.model.AddCustomPromptOptions; import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.CreateVoiceModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CustomModel; +import com.ibm.watson.text_to_speech.v1.model.CustomModels; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteUserDataOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteVoiceModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomPromptOptions; import com.ibm.watson.text_to_speech.v1.model.GetPronunciationOptions; -import com.ibm.watson.text_to_speech.v1.model.GetVoiceModelOptions; +import com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions; import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.text_to_speech.v1.model.ListVoiceModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListSpeakerModelsOptions; import com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions; import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; +import com.ibm.watson.text_to_speech.v1.model.Prompt; +import com.ibm.watson.text_to_speech.v1.model.Prompts; import com.ibm.watson.text_to_speech.v1.model.Pronunciation; +import com.ibm.watson.text_to_speech.v1.model.SpeakerCustomModels; +import com.ibm.watson.text_to_speech.v1.model.SpeakerModel; +import com.ibm.watson.text_to_speech.v1.model.Speakers; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; import com.ibm.watson.text_to_speech.v1.model.Translation; -import com.ibm.watson.text_to_speech.v1.model.UpdateVoiceModelOptions; +import com.ibm.watson.text_to_speech.v1.model.UpdateCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.Voice; -import com.ibm.watson.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.text_to_speech.v1.model.VoiceModels; import com.ibm.watson.text_to_speech.v1.model.Voices; import com.ibm.watson.text_to_speech.v1.model.Words; import com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback; import com.ibm.watson.text_to_speech.v1.websocket.TextToSpeechWebSocketListener; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import okhttp3.HttpUrl; +import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.WebSocket; -import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; - /** - * The IBM® Text to Speech service provides APIs that use IBM's speech-synthesis capabilities to synthesize text - * into natural-sounding speech in a variety of languages, dialects, and voices. The service supports at least one male - * or female voice, sometimes both, for each language. The audio is streamed back to the client with minimal delay. + * The IBM Watson&trade; Text to Speech service provides APIs that use IBM's speech-synthesis + * capabilities to synthesize text into natural-sounding speech in a variety of languages, dialects, + * and voices. The service supports at least one male or female voice, sometimes both, for each + * language. The audio is streamed back to the client with minimal delay. + * + *

For speech synthesis, the service supports a synchronous HTTP Representational State Transfer + * (REST) interface and a WebSocket interface. Both interfaces support plain text and SSML input. + * SSML is an XML-based markup language that provides text annotation for speech-synthesis + * applications. The WebSocket interface also supports the SSML + * <code>&lt;mark&gt;</code> element and word timings. * - * For speech synthesis, the service supports a synchronous HTTP Representational State Transfer (REST) interface. It - * also supports a WebSocket interface that provides both plain text and SSML input, including the SSML <mark> - * element and word timings. SSML is an XML-based markup language that provides text annotation for speech-synthesis - * applications. + *

The service offers a customization interface that you can use to define sounds-like or + * phonetic translations for words. A sounds-like translation consists of one or more words that, + * when combined, sound like the word. A phonetic translation is based on the SSML phoneme format + * for representing a word. You can specify a phonetic translation in standard International + * Phonetic Alphabet (IPA) representation or in the proprietary IBM Symbolic Phonetic Representation + * (SPR). * - * The service also offers a customization interface. You can use the interface to define sounds-like or phonetic - * translations for words. A sounds-like translation consists of one or more words that, when combined, sound like the - * word. A phonetic translation is based on the SSML phoneme format for representing a word. You can specify a phonetic - * translation in standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM Symbolic - * Phonetic Representation (SPR). + *

The service also offers a Tune by Example feature that lets you define custom prompts. You can + * also define speaker models to improve the quality of your custom prompts. The service supports + * custom prompts only for US English custom models and voices. * - * @version v1 - * @see Text to Speech + *

API Version: 1.0.0 See: https://cloud.ibm.com/docs/text-to-speech */ public class TextToSpeech extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "text_to_speech"; + /** Default service name used when configuring the `TextToSpeech` client. */ + public static final String DEFAULT_SERVICE_NAME = "text_to_speech"; - private static final String DEFAULT_SERVICE_URL = "https://stream.watsonplatform.net/text-to-speech/api"; + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.text-to-speech.watson.cloud.ibm.com"; /** - * Constructs a new `TextToSpeech` client using the DEFAULT_SERVICE_NAME. - * + * Constructs an instance of the `TextToSpeech` client. The default service name is used to + * configure the client instance. */ public TextToSpeech() { - this(DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + this( + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `TextToSpeech` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. + * Constructs an instance of the `TextToSpeech` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param authenticator the Authenticator instance to be configured for this service + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public TextToSpeech(Authenticator authenticator) { this(DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `TextToSpeech` client with the specified serviceName. + * Constructs an instance of the `TextToSpeech` client. The specified service name is used to + * configure the client instance. * - * @param serviceName The name of the service to configure. + * @param serviceName the service name to be used when configuring the client instance */ public TextToSpeech(String serviceName) { this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `TextToSpeech` client with the specified Authenticator - * and serviceName. + * Constructs an instance of the `TextToSpeech` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public TextToSpeech(String serviceName, Authenticator authenticator) { super(serviceName, authenticator); @@ -119,45 +151,93 @@ public TextToSpeech(String serviceName, Authenticator authenticator) { this.configureService(serviceName); } + /** + * Synthesize audio. + * + *

Synthesizes text to audio that is spoken in the specified voice. The service bases its + * understanding of the language for the input text on the specified voice. Use a voice that + * matches the language of the input text. + * + *

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for + * the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service + * returns the synthesized audio stream as an array of bytes. + * + *

### Audio formats (accept types) + * + *

For more information about specifying an audio format, including additional details about + * some of the formats, see [Audio + * formats](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-audioFormats#audioFormats). + * + * @param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call + * @param callback the {@link SynthesizeCallback} callback + * @return a {@link WebSocket} instance + */ + public WebSocket synthesizeUsingWebSocket( + SynthesizeOptions synthesizeOptions, SynthesizeCallback callback) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + synthesizeOptions, "synthesizeOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(callback, "callback cannot be null"); + + HttpUrl.Builder urlBuilder = HttpUrl.parse(getServiceUrl() + "/v1/synthesize").newBuilder(); + + if (synthesizeOptions.voice() != null) { + urlBuilder.addQueryParameter("voice", synthesizeOptions.voice()); + } + if (synthesizeOptions.customizationId() != null) { + urlBuilder.addQueryParameter("customization_id", synthesizeOptions.customizationId()); + } + + String url = urlBuilder.toString().replace("https://", "wss://"); + Request.Builder builder = new Request.Builder().url(url); + + setAuthentication(builder); + setDefaultHeaders(builder); + + OkHttpClient client = configureHttpClient(); + return client.newWebSocket( + builder.build(), new TextToSpeechWebSocketListener(synthesizeOptions, callback)); + } + /** * List voices. * - * Lists all voices available for use with the service. The information includes the name, language, gender, and other - * details about the voice. To see information about a specific voice, use the **Get a voice** method. + *

Lists all voices available for use with the service. The information includes the name, + * language, gender, and other details about the voice. The ordering of the list of voices can + * change from call to call; do not rely on an alphabetized or static list of voices. To see + * information about a specific voice, use the [Get a voice](#getvoice). * - * **See also:** [Listing all available - * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices). + *

**See also:** [Listing all + * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-list#list-all-voices). * * @param listVoicesOptions the {@link ListVoicesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Voices} + * @return a {@link ServiceCall} with a result of type {@link Voices} */ public ServiceCall listVoices(ListVoicesOptions listVoicesOptions) { - String[] pathSegments = { "v1/voices" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/voices")); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoices"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listVoicesOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List voices. * - * Lists all voices available for use with the service. The information includes the name, language, gender, and other - * details about the voice. To see information about a specific voice, use the **Get a voice** method. + *

Lists all voices available for use with the service. The information includes the name, + * language, gender, and other details about the voice. The ordering of the list of voices can + * change from call to call; do not rely on an alphabetized or static list of voices. To see + * information about a specific voice, use the [Get a voice](#getvoice). * - * **See also:** [Listing all available - * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices). + *

**See also:** [Listing all + * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-list#list-all-voices). * - * @return a {@link ServiceCall} with a response type of {@link Voices} + * @return a {@link ServiceCall} with a result of type {@link Voices} */ public ServiceCall listVoices() { return listVoices(null); @@ -166,102 +246,113 @@ public ServiceCall listVoices() { /** * Get a voice. * - * Gets information about the specified voice. The information includes the name, language, gender, and other details - * about the voice. Specify a customization ID to obtain information for a custom voice model that is defined for the - * language of the specified voice. To list information about all available voices, use the **List voices** method. + *

Gets information about the specified voice. The information includes the name, language, + * gender, and other details about the voice. Specify a customization ID to obtain information for + * a custom model that is defined for the language of the specified voice. To list information + * about all available voices, use the [List voices](#listvoices) method. * - * **See also:** [Listing a specific - * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoice). + *

**See also:** [Listing a specific + * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-list#list-specific-voice). * * @param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Voice} + * @return a {@link ServiceCall} with a result of type {@link Voice} */ public ServiceCall getVoice(GetVoiceOptions getVoiceOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getVoiceOptions, - "getVoiceOptions cannot be null"); - String[] pathSegments = { "v1/voices" }; - String[] pathParameters = { getVoiceOptions.voice() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + getVoiceOptions, "getVoiceOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("voice", getVoiceOptions.voice()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/voices/{voice}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (getVoiceOptions.customizationId() != null) { - builder.query("customization_id", getVoiceOptions.customizationId()); + builder.query("customization_id", String.valueOf(getVoiceOptions.customizationId())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Synthesize audio. * - * Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the - * language for the input text on the specified voice. Use a voice that matches the language of the input text. + *

Synthesizes text to audio that is spoken in the specified voice. The service bases its + * understanding of the language for the input text on the specified voice. Use a voice that + * matches the language of the input text. * - * The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers. - * The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an - * array of bytes. + *

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for + * the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service + * returns the synthesized audio stream as an array of bytes. * - * **See also:** [The HTTP + *

**See also:** [The HTTP * interface](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingHTTP#usingHTTP). * - * ### Audio formats (accept types) - * - * The service can return audio in the following formats (MIME types). - * * Where indicated, you can optionally specify the sampling rate (`rate`) of the audio. You must specify a sampling - * rate for the `audio/l16` and `audio/mulaw` formats. A specified sampling rate must lie in the range of 8 kHz to 192 - * kHz. Some formats restrict the sampling rate to certain values, as noted. - * * For the `audio/l16` format, you can optionally specify the endianness (`endianness`) of the audio: - * `endianness=big-endian` or `endianness=little-endian`. - * - * Use the `Accept` header or the `accept` parameter to specify the requested format of the response audio. If you - * omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec - * (`audio/ogg;codecs=opus`). The service always returns single-channel audio. - * * `audio/basic` - The service returns audio with a sampling rate of 8000 Hz. - * * `audio/flac` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - * * `audio/l16` - You must specify the `rate` of the audio. You can optionally specify the `endianness` of the audio. - * The default endianness is `little-endian`. - * * `audio/mp3` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - * * `audio/mpeg` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - * * `audio/mulaw` - You must specify the `rate` of the audio. - * * `audio/ogg` - The service returns the audio in the `vorbis` codec. You can optionally specify the `rate` of the - * audio. The default sampling rate is 22,050 Hz. - * * `audio/ogg;codecs=opus` - You can optionally specify the `rate` of the audio. Only the following values are valid - * sampling rates: `48000`, `24000`, `16000`, `12000`, or `8000`. If you specify a value other than one of these, the - * service returns an error. The default sampling rate is 48,000 Hz. - * * `audio/ogg;codecs=vorbis` - You can optionally specify the `rate` of the audio. The default sampling rate is - * 22,050 Hz. - * * `audio/wav` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - * * `audio/webm` - The service returns the audio in the `opus` codec. The service returns audio with a sampling rate - * of 48,000 Hz. - * * `audio/webm;codecs=opus` - The service returns audio with a sampling rate of 48,000 Hz. - * * `audio/webm;codecs=vorbis` - You can optionally specify the `rate` of the audio. The default sampling rate is - * 22,050 Hz. - * - * For more information about specifying an audio format, including additional details about some of the formats, see - * [Audio formats](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-audioFormats#audioFormats). - * - * - * ### Warning messages - * - * If a request includes invalid query parameters, the service returns a `Warnings` response header that provides - * messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument - * strings. For example, a message such as `"Unknown arguments:"` or `"Unknown url query arguments:"` followed by a - * list of the form `"{invalid_arg_1}, {invalid_arg_2}."` The request succeeds despite the warnings. + *

### Audio formats (accept types) + * + *

The service can return audio in the following formats (MIME types). * Where indicated, you + * can optionally specify the sampling rate (`rate`) of the audio. You must specify a sampling + * rate for the `audio/alaw`, `audio/l16`, and `audio/mulaw` formats. A specified sampling rate + * must lie in the range of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain + * values, as noted. * For the `audio/l16` format, you can optionally specify the endianness + * (`endianness`) of the audio: `endianness=big-endian` or `endianness=little-endian`. + * + *

Use the `Accept` header or the `accept` parameter to specify the requested format of the + * response audio. If you omit an audio format altogether, the service returns the audio in Ogg + * format with the Opus codec (`audio/ogg;codecs=opus`). The service always returns single-channel + * audio. * `audio/alaw` - You must specify the `rate` of the audio. * `audio/basic` - The service + * returns audio with a sampling rate of 8000 Hz. * `audio/flac` - You can optionally specify the + * `rate` of the audio. The default sampling rate is 24,000 Hz for Natural voices and 22,050 Hz + * for all other voices. * `audio/l16` - You must specify the `rate` of the audio. You can + * optionally specify the `endianness` of the audio. The default endianness is `little-endian`. * + * `audio/mp3` - You can optionally specify the `rate` of the audio. The default sampling rate is + * 24,000 Hz for Natural voices and 22,050 Hz for for all other voices. * `audio/mpeg` - You can + * optionally specify the `rate` of the audio. The default sampling rate is 24,000 Hz for Natural + * voices and 22,050 Hz for all other voices. * `audio/mulaw` - You must specify the `rate` of the + * audio. * `audio/ogg` - The service returns the audio in the `vorbis` codec. You can optionally + * specify the `rate` of the audio. The default sampling rate is 48,000 Hz. * + * `audio/ogg;codecs=opus` - You can optionally specify the `rate` of the audio. Only the + * following values are valid sampling rates: `48000`, `24000`, `16000`, `12000`, or `8000`. If + * you specify a value other than one of these, the service returns an error. The default sampling + * rate is 48,000 Hz. * `audio/ogg;codecs=vorbis` - You can optionally specify the `rate` of the + * audio. The default sampling rate is 48,000 Hz. * `audio/wav` - You can optionally specify the + * `rate` of the audio. The default sampling rate is 24,000 Hz for Natural voices and 22,050 Hz + * for all other voices. * `audio/webm` - The service returns the audio in the `opus` codec. The + * service returns audio with a sampling rate of 48,000 Hz. * `audio/webm;codecs=opus` - The + * service returns audio with a sampling rate of 48,000 Hz. * `audio/webm;codecs=vorbis` - You can + * optionally specify the `rate` of the audio. The default sampling rate is 48,000 Hz. + * + *

For more information about specifying an audio format, including additional details about + * some of the formats, see [Using audio + * formats](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-audio-formats). + * + *

**Note:** By default, the service returns audio in the Ogg audio format with the Opus codec + * (`audio/ogg;codecs=opus`). However, the Ogg audio format is not supported with the Safari + * browser. If you are using the service with the Safari browser, you must use the `Accept` + * request header or the `accept` query parameter specify a different format in which you want the + * service to return the audio. + * + *

### Warning messages + * + *

If a request includes invalid query parameters, the service returns a `Warnings` response + * header that provides messages about the invalid parameters. The warning includes a descriptive + * message and a list of invalid argument strings. For example, a message such as `"Unknown + * arguments:"` or `"Unknown url query arguments:"` followed by a list of the form + * `"{invalid_arg_1}, {invalid_arg_2}."` The request succeeds despite the warnings. * * @param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(synthesizeOptions, - "synthesizeOptions cannot be null"); - String[] pathSegments = { "v1/synthesize" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + synthesizeOptions, "synthesizeOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/synthesize")); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "synthesize"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -270,10 +361,19 @@ public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) builder.header("Accept", synthesizeOptions.accept()); } if (synthesizeOptions.voice() != null) { - builder.query("voice", synthesizeOptions.voice()); + builder.query("voice", String.valueOf(synthesizeOptions.voice())); } if (synthesizeOptions.customizationId() != null) { - builder.query("customization_id", synthesizeOptions.customizationId()); + builder.query("customization_id", String.valueOf(synthesizeOptions.customizationId())); + } + if (synthesizeOptions.spellOutMode() != null) { + builder.query("spell_out_mode", String.valueOf(synthesizeOptions.spellOutMode())); + } + if (synthesizeOptions.ratePercentage() != null) { + builder.query("rate_percentage", String.valueOf(synthesizeOptions.ratePercentage())); + } + if (synthesizeOptions.pitchPercentage() != null) { + builder.query("pitch_percentage", String.valueOf(synthesizeOptions.pitchPercentage())); } final JsonObject contentJson = new JsonObject(); contentJson.addProperty("text", synthesizeOptions.text()); @@ -282,221 +382,208 @@ public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) return createServiceCall(builder.build(), responseConverter); } - public WebSocket synthesizeUsingWebSocket(SynthesizeOptions synthesizeOptions, SynthesizeCallback callback) { - com.ibm.cloud.sdk.core.util.Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(callback, "callback cannot be null"); - - HttpUrl.Builder urlBuilder = HttpUrl.parse(getServiceUrl() + "/v1/synthesize").newBuilder(); - - if (synthesizeOptions.voice() != null) { - urlBuilder.addQueryParameter("voice", synthesizeOptions.voice()); - } - if (synthesizeOptions.customizationId() != null) { - urlBuilder.addQueryParameter("customization_id", synthesizeOptions.customizationId()); - } - - String url = urlBuilder.toString().replace("https://", "wss://"); - Request.Builder builder = new Request.Builder().url(url); - - setAuthentication(builder); - setDefaultHeaders(builder); - - OkHttpClient client = configureHttpClient(); - return client.newWebSocket(builder.build(), new TextToSpeechWebSocketListener(synthesizeOptions, callback)); - } - /** * Get pronunciation. * - * Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. - * You can also request the pronunciation for a specific voice to see the default translation for the language of that - * voice or for a specific custom voice model to see the translation for that voice model. + *

Gets the phonetic pronunciation for the specified word. You can request the pronunciation + * for a specific format. You can also request the pronunciation for a specific voice to see the + * default translation for the language of that voice or for a specific custom model to see the + * translation for that model. * - * **Note:** This method is currently a beta release. The method does not support the Arabic, Chinese, and Dutch - * languages. + *

**See also:** [Querying a word from a + * language](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage). * - * **See also:** [Querying a word from a - * language] - * (https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage). - * - * @param getPronunciationOptions the {@link GetPronunciationOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Pronunciation} + * @param getPronunciationOptions the {@link GetPronunciationOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Pronunciation} */ - public ServiceCall getPronunciation(GetPronunciationOptions getPronunciationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getPronunciationOptions, - "getPronunciationOptions cannot be null"); - String[] pathSegments = { "v1/pronunciation" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getPronunciation"); + public ServiceCall getPronunciation( + GetPronunciationOptions getPronunciationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getPronunciationOptions, "getPronunciationOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/pronunciation")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "getPronunciation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("text", getPronunciationOptions.text()); + builder.query("text", String.valueOf(getPronunciationOptions.text())); if (getPronunciationOptions.voice() != null) { - builder.query("voice", getPronunciationOptions.voice()); + builder.query("voice", String.valueOf(getPronunciationOptions.voice())); } if (getPronunciationOptions.format() != null) { - builder.query("format", getPronunciationOptions.format()); + builder.query("format", String.valueOf(getPronunciationOptions.format())); } if (getPronunciationOptions.customizationId() != null) { - builder.query("customization_id", getPronunciationOptions.customizationId()); + builder.query("customization_id", String.valueOf(getPronunciationOptions.customizationId())); } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Create a custom model. * - * Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally - * specify the language and a description for the new model. The model is owned by the instance of the service whose - * credentials are used to create it. - * - * **Note:** This method is currently a beta release. The service does not support voice model customization for the - * Arabic, Chinese, and Dutch languages. + *

Creates a new empty custom model. You must specify a name for the new custom model. You can + * optionally specify the language and a description for the new model. The model is owned by the + * instance of the service whose credentials are used to create it. * - * **See also:** [Creating a custom + *

**See also:** [Creating a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate). * - * @param createVoiceModelOptions the {@link CreateVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModel} + * @param createCustomModelOptions the {@link CreateCustomModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CustomModel} */ - public ServiceCall createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createVoiceModelOptions, - "createVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "createVoiceModel"); + public ServiceCall createCustomModel( + CreateCustomModelOptions createCustomModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createCustomModelOptions, "createCustomModelOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "createCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createVoiceModelOptions.name()); - if (createVoiceModelOptions.language() != null) { - contentJson.addProperty("language", createVoiceModelOptions.language()); + contentJson.addProperty("name", createCustomModelOptions.name()); + if (createCustomModelOptions.language() != null) { + contentJson.addProperty("language", createCustomModelOptions.language()); } - if (createVoiceModelOptions.description() != null) { - contentJson.addProperty("description", createVoiceModelOptions.description()); + if (createCustomModelOptions.description() != null) { + contentJson.addProperty("description", createCustomModelOptions.description()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom models. * - * Lists metadata such as the name and description for all custom voice models that are owned by an instance of the - * service. Specify a language to list the voice models for that language only. To see the words in addition to the - * metadata for a specific voice model, use the **List a custom model** method. You must use credentials for the - * instance of the service that owns a model to list information about it. + *

Lists metadata such as the name and description for all custom models that are owned by an + * instance of the service. Specify a language to list the custom models for that language only. + * To see the words and prompts in addition to the metadata for a specific custom model, use the + * [Get a custom model](#getcustommodel) method. You must use credentials for the instance of the + * service that owns a model to list information about it. * - * **Note:** This method is currently a beta release. - * - * **See also:** [Querying all custom + *

**See also:** [Querying all custom * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll). * - * @param listVoiceModelsOptions the {@link ListVoiceModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModels} + * @param listCustomModelsOptions the {@link ListCustomModelsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CustomModels} */ - public ServiceCall listVoiceModels(ListVoiceModelsOptions listVoiceModelsOptions) { - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoiceModels"); + public ServiceCall listCustomModels( + ListCustomModelsOptions listCustomModelsOptions) { + if (listCustomModelsOptions == null) { + listCustomModelsOptions = new ListCustomModelsOptions.Builder().build(); + } + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "listCustomModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listVoiceModelsOptions != null) { - if (listVoiceModelsOptions.language() != null) { - builder.query("language", listVoiceModelsOptions.language()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + if (listCustomModelsOptions.language() != null) { + builder.query("language", String.valueOf(listCustomModelsOptions.language())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom models. * - * Lists metadata such as the name and description for all custom voice models that are owned by an instance of the - * service. Specify a language to list the voice models for that language only. To see the words in addition to the - * metadata for a specific voice model, use the **List a custom model** method. You must use credentials for the - * instance of the service that owns a model to list information about it. + *

Lists metadata such as the name and description for all custom models that are owned by an + * instance of the service. Specify a language to list the custom models for that language only. + * To see the words and prompts in addition to the metadata for a specific custom model, use the + * [Get a custom model](#getcustommodel) method. You must use credentials for the instance of the + * service that owns a model to list information about it. * - * **Note:** This method is currently a beta release. - * - * **See also:** [Querying all custom + *

**See also:** [Querying all custom * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll). * - * @return a {@link ServiceCall} with a response type of {@link VoiceModels} + * @return a {@link ServiceCall} with a result of type {@link CustomModels} */ - public ServiceCall listVoiceModels() { - return listVoiceModels(null); + public ServiceCall listCustomModels() { + return listCustomModels(null); } /** * Update a custom model. * - * Updates information for the specified custom voice model. You can update metadata such as the name and description - * of the voice model. You can also update the words in the model and their translations. Adding a new translation for - * a word that already exists in a custom model overwrites the word's existing translation. A custom model can contain - * no more than 20,000 entries. You must use credentials for the instance of the service that owns a model to update + *

Updates information for the specified custom model. You can update metadata such as the name + * and description of the model. You can also update the words in the model and their + * translations. Adding a new translation for a word that already exists in a custom model + * overwrites the word's existing translation. A custom model can contain no more than 20,000 + * entries. You must use credentials for the instance of the service that owns a model to update * it. * - * You can define sounds-like or phonetic translations for words. A sounds-like translation consists of one or more - * words that, when combined, sound like the word. Phonetic translations are based on the SSML phoneme format for - * representing a word. You can specify them in standard International Phonetic Alphabet (IPA) representation - * - * <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme> + *

You can define sounds-like or phonetic translations for words. A sounds-like translation + * consists of one or more words that, when combined, sound like the word. Phonetic translations + * are based on the SSML phoneme format for representing a word. You can specify them in standard + * International Phonetic Alphabet (IPA) representation * - * or in the proprietary IBM Symbolic Phonetic Representation (SPR) + *

<code>&lt;phoneme alphabet="ipa" + * ph="t&#601;m&#712;&#593;to"&gt;&lt;/phoneme&gt;</code> * - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> + *

or in the proprietary IBM Symbolic Phonetic Representation (SPR) * - * **Note:** This method is currently a beta release. + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> * - * **See also:** - * * [Updating a custom + *

**See also:** * [Updating a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate) * * [Adding words to a Japanese custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd) * * [Understanding * customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). * - * @param updateVoiceModelOptions the {@link UpdateVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param updateCustomModelOptions the {@link UpdateCustomModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall updateVoiceModel(UpdateVoiceModelOptions updateVoiceModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateVoiceModelOptions, - "updateVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { updateVoiceModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "updateVoiceModel"); + public ServiceCall updateCustomModel(UpdateCustomModelOptions updateCustomModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + updateCustomModelOptions, "updateCustomModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", updateCustomModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "updateCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - if (updateVoiceModelOptions.name() != null) { - contentJson.addProperty("name", updateVoiceModelOptions.name()); + if (updateCustomModelOptions.name() != null) { + contentJson.addProperty("name", updateCustomModelOptions.name()); } - if (updateVoiceModelOptions.description() != null) { - contentJson.addProperty("description", updateVoiceModelOptions.description()); + if (updateCustomModelOptions.description() != null) { + contentJson.addProperty("description", updateCustomModelOptions.description()); } - if (updateVoiceModelOptions.words() != null) { - contentJson.add("words", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateVoiceModelOptions - .words())); + if (updateCustomModelOptions.words() != null) { + contentJson.add( + "words", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateCustomModelOptions.words())); } builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); @@ -506,63 +593,66 @@ public ServiceCall updateVoiceModel(UpdateVoiceModelOptions updateVoiceMod /** * Get a custom model. * - * Gets all information about a specified custom voice model. In addition to metadata such as the name and description - * of the voice model, the output includes the words and their translations as defined in the model. To see just the - * metadata for a voice model, use the **List custom models** method. - * - * **Note:** This method is currently a beta release. + *

Gets all information about a specified custom model. In addition to metadata such as the + * name and description of the custom model, the output includes the words and their translations + * that are defined for the model, as well as any prompts that are defined for the model. To see + * just the metadata for a model, use the [List custom models](#listcustommodels) method. * - * **See also:** [Querying a custom + *

**See also:** [Querying a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery). * - * @param getVoiceModelOptions the {@link GetVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModel} + * @param getCustomModelOptions the {@link GetCustomModelOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link CustomModel} */ - public ServiceCall getVoiceModel(GetVoiceModelOptions getVoiceModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getVoiceModelOptions, - "getVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { getVoiceModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoiceModel"); + public ServiceCall getCustomModel(GetCustomModelOptions getCustomModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getCustomModelOptions, "getCustomModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getCustomModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "getCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a custom model. * - * Deletes the specified custom voice model. You must use credentials for the instance of the service that owns a - * model to delete it. - * - * **Note:** This method is currently a beta release. + *

Deletes the specified custom model. You must use credentials for the instance of the service + * that owns a model to delete it. * - * **See also:** [Deleting a custom + *

**See also:** [Deleting a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete). * - * @param deleteVoiceModelOptions the {@link DeleteVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteCustomModelOptions the {@link DeleteCustomModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall deleteVoiceModel(DeleteVoiceModelOptions deleteVoiceModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteVoiceModelOptions, - "deleteVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { deleteVoiceModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteVoiceModel"); + public ServiceCall deleteCustomModel(DeleteCustomModelOptions deleteCustomModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteCustomModelOptions, "deleteCustomModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteCustomModelOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -570,48 +660,52 @@ public ServiceCall deleteVoiceModel(DeleteVoiceModelOptions deleteVoiceMod /** * Add custom words. * - * Adds one or more words and their translations to the specified custom voice model. Adding a new translation for a - * word that already exists in a custom model overwrites the word's existing translation. A custom model can contain - * no more than 20,000 entries. You must use credentials for the instance of the service that owns a model to add - * words to it. + *

Adds one or more words and their translations to the specified custom model. Adding a new + * translation for a word that already exists in a custom model overwrites the word's existing + * translation. A custom model can contain no more than 20,000 entries. You must use credentials + * for the instance of the service that owns a model to add words to it. * - * You can define sounds-like or phonetic translations for words. A sounds-like translation consists of one or more - * words that, when combined, sound like the word. Phonetic translations are based on the SSML phoneme format for - * representing a word. You can specify them in standard International Phonetic Alphabet (IPA) representation + *

You can define sounds-like or phonetic translations for words. A sounds-like translation + * consists of one or more words that, when combined, sound like the word. Phonetic translations + * are based on the SSML phoneme format for representing a word. You can specify them in standard + * International Phonetic Alphabet (IPA) representation * - * <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme> + *

<code>&lt;phoneme alphabet="ipa" + * ph="t&#601;m&#712;&#593;to"&gt;&lt;/phoneme&gt;</code> * - * or in the proprietary IBM Symbolic Phonetic Representation (SPR) + *

or in the proprietary IBM Symbolic Phonetic Representation (SPR) * - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> * - * **Note:** This method is currently a beta release. - * - * **See also:** - * * [Adding multiple words to a custom - * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd) - * * [Adding words to a Japanese custom + *

**See also:** * [Adding multiple words to a custom + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd) * + * [Adding words to a Japanese custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd) * * [Understanding * customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). * * @param addWordsOptions the {@link AddWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWords(AddWordsOptions addWordsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addWordsOptions, - "addWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + addWordsOptions, "addWordsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordsOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "addWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("words", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addWordsOptions.words())); + contentJson.add( + "words", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(addWordsOptions.words())); builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); @@ -620,75 +714,78 @@ public ServiceCall addWords(AddWordsOptions addWordsOptions) { /** * List custom words. * - * Lists all of the words and their translations for the specified custom voice model. The output shows the - * translations as they are defined in the model. You must use credentials for the instance of the service that owns a - * model to list its words. + *

Lists all of the words and their translations for the specified custom model. The output + * shows the translations as they are defined in the model. You must use credentials for the + * instance of the service that owns a model to list its words. * - * **Note:** This method is currently a beta release. - * - * **See also:** [Querying all words from a custom + *

**See also:** [Querying all words from a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel). * * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Words} + * @return a {@link ServiceCall} with a result of type {@link Words} */ public ServiceCall listWords(ListWordsOptions listWordsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listWordsOptions, - "listWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { listWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + listWordsOptions, "listWordsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listWordsOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Add a custom word. * - * Adds a single word and its translation to the specified custom voice model. Adding a new translation for a word - * that already exists in a custom model overwrites the word's existing translation. A custom model can contain no - * more than 20,000 entries. You must use credentials for the instance of the service that owns a model to add a word - * to it. - * - * You can define sounds-like or phonetic translations for words. A sounds-like translation consists of one or more - * words that, when combined, sound like the word. Phonetic translations are based on the SSML phoneme format for - * representing a word. You can specify them in standard International Phonetic Alphabet (IPA) representation + *

Adds a single word and its translation to the specified custom model. Adding a new + * translation for a word that already exists in a custom model overwrites the word's existing + * translation. A custom model can contain no more than 20,000 entries. You must use credentials + * for the instance of the service that owns a model to add a word to it. * - * <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme> + *

You can define sounds-like or phonetic translations for words. A sounds-like translation + * consists of one or more words that, when combined, sound like the word. Phonetic translations + * are based on the SSML phoneme format for representing a word. You can specify them in standard + * International Phonetic Alphabet (IPA) representation * - * or in the proprietary IBM Symbolic Phonetic Representation (SPR) + *

<code>&lt;phoneme alphabet="ipa" + * ph="t&#601;m&#712;&#593;to"&gt;&lt;/phoneme&gt;</code> * - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> + *

or in the proprietary IBM Symbolic Phonetic Representation (SPR) * - * **Note:** This method is currently a beta release. + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> * - * **See also:** - * * [Adding a single word to a custom - * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordAdd) - * * [Adding words to a Japanese custom + *

**See also:** * [Adding a single word to a custom + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordAdd) * + * [Adding words to a Japanese custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd) * * [Understanding * customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). * * @param addWordOptions the {@link AddWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWord(AddWordOptions addWordOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addWordOptions, - "addWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordOptions.customizationId(), addWordOptions.word() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull(addWordOptions, "addWordOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordOptions.customizationId()); + pathParamsMap.put("word", addWordOptions.word()); + RequestBuilder builder = + RequestBuilder.put( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "addWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -706,63 +803,492 @@ public ServiceCall addWord(AddWordOptions addWordOptions) { /** * Get a custom word. * - * Gets the translation for a single word from the specified custom model. The output shows the translation as it is - * defined in the model. You must use credentials for the instance of the service that owns a model to list its words. - * - * - * **Note:** This method is currently a beta release. + *

Gets the translation for a single word from the specified custom model. The output shows the + * translation as it is defined in the model. You must use credentials for the instance of the + * service that owns a model to list its words. * - * **See also:** [Querying a single word from a custom + *

**See also:** [Querying a single word from a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel). * * @param getWordOptions the {@link GetWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Translation} + * @return a {@link ServiceCall} with a result of type {@link Translation} */ public ServiceCall getWord(GetWordOptions getWordOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getWordOptions, - "getWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.word() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull(getWordOptions, "getWordOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getWordOptions.customizationId()); + pathParamsMap.put("word", getWordOptions.word()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a custom word. * - * Deletes a single word from the specified custom voice model. You must use credentials for the instance of the - * service that owns a model to delete its words. - * - * **Note:** This method is currently a beta release. + *

Deletes a single word from the specified custom model. You must use credentials for the + * instance of the service that owns a model to delete its words. * - * **See also:** [Deleting a word from a custom + *

**See also:** [Deleting a word from a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordDelete). * * @param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteWordOptions, - "deleteWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { deleteWordOptions.customizationId(), deleteWordOptions.word() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteWordOptions, "deleteWordOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteWordOptions.customizationId()); + pathParamsMap.put("word", deleteWordOptions.word()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + /** + * List custom prompts. + * + *

Lists information about all custom prompts that are defined for a custom model. The + * information includes the prompt ID, prompt text, status, and optional speaker ID for each + * prompt of the custom model. You must use credentials for the instance of the service that owns + * the custom model. The same information about all of the prompts for a custom model is also + * provided by the [Get a custom model](#getcustommodel) method. That method provides complete + * details about a specified custom model, including its language, owner, custom words, and more. + * Custom prompts are supported only for use with US English custom models and voices. + * + *

**See also:** [Listing custom + * prompts](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-custom-prompts#tbe-custom-prompts-list). + * + * @param listCustomPromptsOptions the {@link ListCustomPromptsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Prompts} + */ + public ServiceCall listCustomPrompts(ListCustomPromptsOptions listCustomPromptsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + listCustomPromptsOptions, "listCustomPromptsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listCustomPromptsOptions.customizationId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/prompts", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "listCustomPrompts"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Add a custom prompt. + * + *

Adds a custom prompt to a custom model. A prompt is defined by the text that is to be + * spoken, the audio for that text, a unique user-specified ID for the prompt, and an optional + * speaker ID. The information is used to generate prosodic data that is not visible to the user. + * This data is used by the service to produce the synthesized audio upon request. You must use + * credentials for the instance of the service that owns a custom model to add a prompt to it. You + * can add a maximum of 1000 custom prompts to a single custom model. + * + *

You are recommended to assign meaningful values for prompt IDs. For example, use `goodbye` + * to identify a prompt that speaks a farewell message. Prompt IDs must be unique within a given + * custom model. You cannot define two prompts with the same name for the same custom model. If + * you provide the ID of an existing prompt, the previously uploaded prompt is replaced by the new + * information. The existing prompt is reprocessed by using the new text and audio and, if + * provided, new speaker model, and the prosody data associated with the prompt is updated. + * + *

The quality of a prompt is undefined if the language of a prompt does not match the language + * of its custom model. This is consistent with any text or SSML that is specified for a speech + * synthesis request. The service makes a best-effort attempt to render the specified text for the + * prompt; it does not validate that the language of the text matches the language of the model. + * + *

Adding a prompt is an asynchronous operation. Although it accepts less audio than speaker + * enrollment, the service must align the audio with the provided text. The time that it takes to + * process a prompt depends on the prompt itself. The processing time for a reasonably sized + * prompt generally matches the length of the audio (for example, it takes 20 seconds to process a + * 20-second prompt). + * + *

For shorter prompts, you can wait for a reasonable amount of time and then check the status + * of the prompt with the [Get a custom prompt](#getcustomprompt) method. For longer prompts, + * consider using that method to poll the service every few seconds to determine when the prompt + * becomes available. No prompt can be used for speech synthesis if it is in the `processing` or + * `failed` state. Only prompts that are in the `available` state can be used for speech + * synthesis. + * + *

When it processes a request, the service attempts to align the text and the audio that are + * provided for the prompt. The text that is passed with a prompt must match the spoken audio as + * closely as possible. Optimally, the text and audio match exactly. The service does its best to + * align the specified text with the audio, and it can often compensate for mismatches between the + * two. But if the service cannot effectively align the text and the audio, possibly because the + * magnitude of mismatches between the two is too great, processing of the prompt fails. + * + *

### Evaluating a prompt + * + *

Always listen to and evaluate a prompt to determine its quality before using it in + * production. To evaluate a prompt, include only the single prompt in a speech synthesis request + * by using the following SSML extension, in this case for a prompt whose ID is `goodbye`: + * + *

`<ibm:prompt id="goodbye"/>` + * + *

In some cases, you might need to rerecord and resubmit a prompt as many as five times to + * address the following possible problems: * The service might fail to detect a mismatch between + * the prompt’s text and audio. The longer the prompt, the greater the chance for misalignment + * between its text and audio. Therefore, multiple shorter prompts are preferable to a single long + * prompt. * The text of a prompt might include a word that the service does not recognize. In + * this case, you can create a custom word and pronunciation pair to tell the service how to + * pronounce the word. You must then re-create the prompt. * The quality of the input audio might + * be insufficient or the service’s processing of the audio might fail to detect the intended + * prosody. Submitting new audio for the prompt can correct these issues. + * + *

If a prompt that is created without a speaker ID does not adequately reflect the intended + * prosody, enrolling the speaker and providing a speaker ID for the prompt is one recommended + * means of potentially improving the quality of the prompt. This is especially important for + * shorter prompts such as "good-bye" or "thank you," where less audio data makes it more + * difficult to match the prosody of the speaker. Custom prompts are supported only for use with + * US English custom models and voices. + * + *

**See also:** * [Add a custom + * prompt](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-create#tbe-create-add-prompt) + * * [Evaluate a custom + * prompt](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-create#tbe-create-evaluate-prompt) + * * [Rules for creating custom + * prompts](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-rules#tbe-rules-prompts). + * + * @param addCustomPromptOptions the {@link AddCustomPromptOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Prompt} + */ + public ServiceCall addCustomPrompt(AddCustomPromptOptions addCustomPromptOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + addCustomPromptOptions, "addCustomPromptOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addCustomPromptOptions.customizationId()); + pathParamsMap.put("prompt_id", addCustomPromptOptions.promptId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/prompts/{prompt_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "addCustomPrompt"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + multipartBuilder.addFormDataPart("metadata", addCustomPromptOptions.metadata().toString()); + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody(addCustomPromptOptions.file(), "audio/wav"); + multipartBuilder.addFormDataPart("file", "filename", fileBody); + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a custom prompt. + * + *

Gets information about a specified custom prompt for a specified custom model. The + * information includes the prompt ID, prompt text, status, and optional speaker ID for each + * prompt of the custom model. You must use credentials for the instance of the service that owns + * the custom model. Custom prompts are supported only for use with US English custom models and + * voices. + * + *

**See also:** [Listing custom + * prompts](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-custom-prompts#tbe-custom-prompts-list). + * + * @param getCustomPromptOptions the {@link GetCustomPromptOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link Prompt} + */ + public ServiceCall getCustomPrompt(GetCustomPromptOptions getCustomPromptOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getCustomPromptOptions, "getCustomPromptOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getCustomPromptOptions.customizationId()); + pathParamsMap.put("prompt_id", getCustomPromptOptions.promptId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/prompts/{prompt_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "getCustomPrompt"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a custom prompt. + * + *

Deletes an existing custom prompt from a custom model. The service deletes the prompt with + * the specified ID. You must use credentials for the instance of the service that owns the custom + * model from which the prompt is to be deleted. + * + *

**Caution:** Deleting a custom prompt elicits a 400 response code from synthesis requests + * that attempt to use the prompt. Make sure that you do not attempt to use a deleted prompt in a + * production application. Custom prompts are supported only for use with US English custom models + * and voices. + * + *

**See also:** [Deleting a custom + * prompt](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-custom-prompts#tbe-custom-prompts-delete). + * + * @param deleteCustomPromptOptions the {@link DeleteCustomPromptOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteCustomPrompt(DeleteCustomPromptOptions deleteCustomPromptOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteCustomPromptOptions, "deleteCustomPromptOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteCustomPromptOptions.customizationId()); + pathParamsMap.put("prompt_id", deleteCustomPromptOptions.promptId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/prompts/{prompt_id}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteCustomPrompt"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List speaker models. + * + *

Lists information about all speaker models that are defined for a service instance. The + * information includes the speaker ID and speaker name of each defined speaker. You must use + * credentials for the instance of a service to list its speakers. Speaker models and the custom + * prompts with which they are used are supported only for use with US English custom models and + * voices. + * + *

**See also:** [Listing speaker + * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-speaker-models#tbe-speaker-models-list). + * + * @param listSpeakerModelsOptions the {@link ListSpeakerModelsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Speakers} + */ + public ServiceCall listSpeakerModels( + ListSpeakerModelsOptions listSpeakerModelsOptions) { + RequestBuilder builder = + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/speakers")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "listSpeakerModels"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List speaker models. + * + *

Lists information about all speaker models that are defined for a service instance. The + * information includes the speaker ID and speaker name of each defined speaker. You must use + * credentials for the instance of a service to list its speakers. Speaker models and the custom + * prompts with which they are used are supported only for use with US English custom models and + * voices. + * + *

**See also:** [Listing speaker + * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-speaker-models#tbe-speaker-models-list). + * + * @return a {@link ServiceCall} with a result of type {@link Speakers} + */ + public ServiceCall listSpeakerModels() { + return listSpeakerModels(null); + } + + /** + * Create a speaker model. + * + *

Creates a new speaker model, which is an optional enrollment token for users who are to add + * prompts to custom models. A speaker model contains information about a user's voice. The + * service extracts this information from a WAV audio sample that you pass as the body of the + * request. Associating a speaker model with a prompt is optional, but the information that is + * extracted from the speaker model helps the service learn about the speaker's voice. + * + *

A speaker model can make an appreciable difference in the quality of prompts, especially + * short prompts with relatively little audio, that are associated with that speaker. A speaker + * model can help the service produce a prompt with more confidence; the lack of a speaker model + * can potentially compromise the quality of a prompt. + * + *

The gender of the speaker who creates a speaker model does not need to match the gender of a + * voice that is used with prompts that are associated with that speaker model. For example, a + * speaker model that is created by a male speaker can be associated with prompts that are spoken + * by female voices. + * + *

You create a speaker model for a given instance of the service. The new speaker model is + * owned by the service instance whose credentials are used to create it. That same speaker can + * then be used to create prompts for all custom models within that service instance. No language + * is associated with a speaker model, but each custom model has a single specified language. You + * can add prompts only to US English models. + * + *

You specify a name for the speaker when you create it. The name must be unique among all + * speaker names for the owning service instance. To re-create a speaker model for an existing + * speaker name, you must first delete the existing speaker model that has that name. + * + *

Speaker enrollment is a synchronous operation. Although it accepts more audio data than a + * prompt, the process of adding a speaker is very fast. The service simply extracts information + * about the speaker’s voice from the audio. Unlike prompts, speaker models neither need nor + * accept a transcription of the audio. When the call returns, the audio is fully processed and + * the speaker enrollment is complete. + * + *

The service returns a speaker ID with the request. A speaker ID is globally unique + * identifier (GUID) that you use to identify the speaker in subsequent requests to the service. + * Speaker models and the custom prompts with which they are used are supported only for use with + * US English custom models and voices. + * + *

**See also:** * [Create a speaker + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-create#tbe-create-speaker-model) + * * [Rules for creating speaker + * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-rules#tbe-rules-speakers). + * + * @param createSpeakerModelOptions the {@link CreateSpeakerModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a result of type {@link SpeakerModel} + */ + public ServiceCall createSpeakerModel( + CreateSpeakerModelOptions createSpeakerModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + createSpeakerModelOptions, "createSpeakerModelOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/speakers")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "createSpeakerModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("speaker_name", String.valueOf(createSpeakerModelOptions.speakerName())); + builder.bodyContent(createSpeakerModelOptions.audio(), "audio/wav"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a speaker model. + * + *

Gets information about all prompts that are defined by a specified speaker for all custom + * models that are owned by a service instance. The information is grouped by the customization + * IDs of the custom models. For each custom model, the information lists information about each + * prompt that is defined for that custom model by the speaker. You must use credentials for the + * instance of the service that owns a speaker model to list its prompts. Speaker models and the + * custom prompts with which they are used are supported only for use with US English custom + * models and voices. + * + *

**See also:** [Listing the custom prompts for a speaker + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-speaker-models#tbe-speaker-models-list-prompts). + * + * @param getSpeakerModelOptions the {@link GetSpeakerModelOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link SpeakerCustomModels} + */ + public ServiceCall getSpeakerModel( + GetSpeakerModelOptions getSpeakerModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + getSpeakerModelOptions, "getSpeakerModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("speaker_id", getSpeakerModelOptions.speakerId()); + RequestBuilder builder = + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/speakers/{speaker_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "getSpeakerModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a speaker model. + * + *

Deletes an existing speaker model from the service instance. The service deletes the + * enrolled speaker with the specified speaker ID. You must use credentials for the instance of + * the service that owns a speaker model to delete the speaker. + * + *

Any prompts that are associated with the deleted speaker are not affected by the speaker's + * deletion. The prosodic data that defines the quality of a prompt is established when the prompt + * is created. A prompt is static and remains unaffected by deletion of its associated speaker. + * However, the prompt cannot be resubmitted or updated with its original speaker once that + * speaker is deleted. Speaker models and the custom prompts with which they are used are + * supported only for use with US English custom models and voices. + * + *

**See also:** [Deleting a speaker + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-speaker-models#tbe-speaker-models-delete). + * + * @param deleteSpeakerModelOptions the {@link DeleteSpeakerModelOptions} containing the options + * for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteSpeakerModel(DeleteSpeakerModelOptions deleteSpeakerModelOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteSpeakerModelOptions, "deleteSpeakerModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("speaker_id", deleteSpeakerModelOptions.speakerId()); + RequestBuilder builder = + RequestBuilder.delete( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/speakers/{speaker_id}", pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteSpeakerModel"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -770,34 +1296,36 @@ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { /** * Delete labeled data. * - * Deletes all data that is associated with a specified customer ID. The method deletes all data for the customer ID, - * regardless of the method by which the information was added. The method has no effect if no data is associated with - * the customer ID. You must issue the request with credentials for the same instance of the service that was used to - * associate the customer ID with the data. + *

Deletes all data that is associated with a specified customer ID. The method deletes all + * data for the customer ID, regardless of the method by which the information was added. The + * method has no effect if no data is associated with the customer ID. You must issue the request + * with credentials for the same instance of the service that was used to associate the customer + * ID with the data. You associate a customer ID with data by passing the `X-Watson-Metadata` + * header with a request that passes the data. * - * You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes the - * data. + *

**Note:** If you delete an instance of the service from the service console, all data + * associated with that service instance is automatically deleted. This includes all custom models + * and word/translation pairs, and all data related to speech synthesis requests. * - * **See also:** [Information - * security] - * (https://cloud.ibm.com/docs/text-to-speech - * ?topic=text-to-speech-information-security#information-security). + *

**See also:** [Information + * security](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-information-security#information-security). * - * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, - "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteUserData"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + deleteUserDataOptions, "deleteUserDataOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } - } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddCustomPromptOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddCustomPromptOptions.java new file mode 100644 index 00000000000..17fad790a93 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddCustomPromptOptions.java @@ -0,0 +1,215 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The addCustomPrompt options. */ +public class AddCustomPromptOptions extends GenericModel { + + protected String customizationId; + protected String promptId; + protected PromptMetadata metadata; + protected InputStream file; + + /** Builder. */ + public static class Builder { + private String customizationId; + private String promptId; + private PromptMetadata metadata; + private InputStream file; + + /** + * Instantiates a new Builder from an existing AddCustomPromptOptions instance. + * + * @param addCustomPromptOptions the instance to initialize the Builder with + */ + private Builder(AddCustomPromptOptions addCustomPromptOptions) { + this.customizationId = addCustomPromptOptions.customizationId; + this.promptId = addCustomPromptOptions.promptId; + this.metadata = addCustomPromptOptions.metadata; + this.file = addCustomPromptOptions.file; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param promptId the promptId + * @param metadata the metadata + * @param file the file + */ + public Builder( + String customizationId, String promptId, PromptMetadata metadata, InputStream file) { + this.customizationId = customizationId; + this.promptId = promptId; + this.metadata = metadata; + this.file = file; + } + + /** + * Builds a AddCustomPromptOptions. + * + * @return the new AddCustomPromptOptions instance + */ + public AddCustomPromptOptions build() { + return new AddCustomPromptOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddCustomPromptOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the promptId. + * + * @param promptId the promptId + * @return the AddCustomPromptOptions builder + */ + public Builder promptId(String promptId) { + this.promptId = promptId; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the AddCustomPromptOptions builder + */ + public Builder metadata(PromptMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AddCustomPromptOptions builder + */ + public Builder file(InputStream file) { + this.file = file; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AddCustomPromptOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder file(File file) throws FileNotFoundException { + this.file = new FileInputStream(file); + return this; + } + } + + protected AddCustomPromptOptions() {} + + protected AddCustomPromptOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.promptId, "promptId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.metadata, "metadata cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.file, "file cannot be null"); + customizationId = builder.customizationId; + promptId = builder.promptId; + metadata = builder.metadata; + file = builder.file; + } + + /** + * New builder. + * + * @return a AddCustomPromptOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the promptId. + * + *

The identifier of the prompt that is to be added to the custom model: * Include a maximum of + * 49 characters in the ID. * Include only alphanumeric characters and `_` (underscores) in the + * ID. * Do not include XML sensitive characters (double quotes, single quotes, ampersands, angle + * brackets, and slashes) in the ID. * To add a new prompt, the ID must be unique for the + * specified custom model. Otherwise, the new information for the prompt overwrites the existing + * prompt that has that ID. + * + * @return the promptId + */ + public String promptId() { + return promptId; + } + + /** + * Gets the metadata. + * + *

Information about the prompt that is to be added to a custom model. The following example of + * a `PromptMetadata` object includes both the required prompt text and an optional speaker model + * ID: + * + *

`{ "prompt_text": "Thank you and good-bye!", "speaker_id": + * "823068b2-ed4e-11ea-b6e0-7b6456aa95cc" }`. + * + * @return the metadata + */ + public PromptMetadata metadata() { + return metadata; + } + + /** + * Gets the file. + * + *

An audio file that speaks the text of the prompt with intonation and prosody that matches + * how you would like the prompt to be spoken. * The prompt audio must be in WAV format and must + * have a minimum sampling rate of 16 kHz. The service accepts audio with higher sampling rates. + * The service transcodes all audio to 16 kHz before processing it. * The length of the prompt + * audio is limited to 30 seconds. + * + * @return the file + */ + public InputStream file() { + return file; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java index 1fe7b514281..2019a77f488 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,20 +10,20 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The addWord options. - */ +/** The addWord options. */ public class AddWordOptions extends GenericModel { /** - * **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation - * for the word. You can create only a single entry, with or without a single part of speech, for any word; you cannot - * create multiple entries with different parts of speech for the same word. For more information, see [Working with - * Japanese entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). + * **Japanese only.** The part of speech for the word. The service uses the value to produce the + * correct intonation for the word. You can create only a single entry, with or without a single + * part of speech, for any word; you cannot create multiple entries with different parts of speech + * for the same word. For more information, see [Working with Japanese + * entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). */ public interface PartOfSpeech { /** Dosi. */ @@ -67,15 +67,18 @@ public interface PartOfSpeech { protected String translation; protected String partOfSpeech; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String word; private String translation; private String partOfSpeech; + /** + * Instantiates a new Builder from an existing AddWordOptions instance. + * + * @param addWordOptions the instance to initialize the Builder with + */ private Builder(AddWordOptions addWordOptions) { this.customizationId = addWordOptions.customizationId; this.word = addWordOptions.word; @@ -83,11 +86,8 @@ private Builder(AddWordOptions addWordOptions) { this.partOfSpeech = addWordOptions.partOfSpeech; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -105,7 +105,7 @@ public Builder(String customizationId, String word, String translation) { /** * Builds a AddWordOptions. * - * @return the addWordOptions + * @return the new AddWordOptions instance */ public AddWordOptions build() { return new AddWordOptions(this); @@ -168,13 +168,14 @@ public Builder translation(Translation translation) { } } + protected AddWordOptions() {} + protected AddWordOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.word, - "word cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.translation, - "translation cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.word, "word cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.translation, "translation cannot be null"); customizationId = builder.customizationId; word = builder.word; translation = builder.translation; @@ -193,8 +194,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -205,7 +206,7 @@ public String customizationId() { /** * Gets the word. * - * The word that is to be added or updated for the custom voice model. + *

The word that is to be added or updated for the custom model. * * @return the word */ @@ -216,9 +217,10 @@ public String word() { /** * Gets the translation. * - * The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for - * representing the phonetic string of a word either as an IPA translation or as an IBM SPR translation. A sounds-like - * is one or more words that, when combined, sound like the word. + *

The phonetic or sounds-like translation for the word. A phonetic translation is based on the + * SSML format for representing the phonetic string of a word either as an IPA translation or as + * an IBM SPR translation. A sounds-like is one or more words that, when combined, sound like the + * word. * * @return the translation */ @@ -229,10 +231,11 @@ public String translation() { /** * Gets the partOfSpeech. * - * **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation - * for the word. You can create only a single entry, with or without a single part of speech, for any word; you cannot - * create multiple entries with different parts of speech for the same word. For more information, see [Working with - * Japanese entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). + *

**Japanese only.** The part of speech for the word. The service uses the value to produce + * the correct intonation for the word. You can create only a single entry, with or without a + * single part of speech, for any word; you cannot create multiple entries with different parts of + * speech for the same word. For more information, see [Working with Japanese + * entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). * * @return the partOfSpeech */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java index feb47a05fb2..53407fc0c94 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,36 @@ * 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.text_to_speech.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addWords options. - */ +/** The addWords options. */ public class AddWordsOptions extends GenericModel { protected String customizationId; protected List words; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private List words; + /** + * Instantiates a new Builder from an existing AddWordsOptions instance. + * + * @param addWordsOptions the instance to initialize the Builder with + */ private Builder(AddWordsOptions addWordsOptions) { this.customizationId = addWordsOptions.customizationId; this.words = addWordsOptions.words; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -57,21 +55,20 @@ public Builder(String customizationId, List words) { /** * Builds a AddWordsOptions. * - * @return the addWordsOptions + * @return the new AddWordsOptions instance */ public AddWordsOptions build() { return new AddWordsOptions(this); } /** - * Adds an word to words. + * Adds a new element to words. * - * @param word the new word + * @param word the new element to be added * @return the AddWordsOptions builder */ public Builder addWord(Word word) { - com.ibm.cloud.sdk.core.util.Validator.notNull(word, - "word cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(word, "word cannot be null"); if (this.words == null) { this.words = new ArrayList(); } @@ -91,8 +88,7 @@ public Builder customizationId(String customizationId) { } /** - * Set the words. - * Existing words will be replaced. + * Set the words. Existing words will be replaced. * * @param words the words * @return the AddWordsOptions builder @@ -114,11 +110,12 @@ public Builder words(Words words) { } } + protected AddWordsOptions() {} + protected AddWordsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, - "words cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, "words cannot be null"); customizationId = builder.customizationId; words = builder.words; } @@ -135,8 +132,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -147,12 +144,13 @@ public String customizationId() { /** * Gets the words. * - * The **Add custom words** method accepts an array of `Word` objects. Each object provides a word that is to be added - * or updated for the custom voice model and the word's translation. + *

The [Add custom words](#addwords) method accepts an array of `Word` objects. Each object + * provides a word that is to be added or updated for the custom model and the word's translation. * - * The **List custom words** method returns an array of `Word` objects. Each object shows a word and its translation - * from the custom voice model. The words are listed in alphabetical order, with uppercase letters listed before - * lowercase letters. The array is empty if the custom model contains no words. + *

The [List custom words](#listwords) method returns an array of `Word` objects. Each object + * shows a word and its translation from the custom model. The words are listed in alphabetical + * order, with uppercase letters listed before lowercase letters. The array is empty if the custom + * model contains no words. * * @return the words */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptions.java new file mode 100644 index 00000000000..694c69c911c --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptions.java @@ -0,0 +1,190 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The createCustomModel options. */ +public class CreateCustomModelOptions extends GenericModel { + + /** + * The language of the new custom model. You create a custom model for a specific language, not + * for a specific voice. A custom model can be used with any voice for its specified language. + * Omit the parameter to use the the default language, `en-US`. + */ + public interface Language { + /** de-DE. */ + String DE_DE = "de-DE"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-GB. */ + String EN_GB = "en-GB"; + /** en-US. */ + String EN_US = "en-US"; + /** es-ES. */ + String ES_ES = "es-ES"; + /** es-LA. */ + String ES_LA = "es-LA"; + /** es-US. */ + String ES_US = "es-US"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-FR. */ + String FR_FR = "fr-FR"; + /** it-IT. */ + String IT_IT = "it-IT"; + /** ja-JP. */ + String JA_JP = "ja-JP"; + /** nl-NL. */ + String NL_NL = "nl-NL"; + /** pt-BR. */ + String PT_BR = "pt-BR"; + } + + protected String name; + protected String language; + protected String description; + + /** Builder. */ + public static class Builder { + private String name; + private String language; + private String description; + + /** + * Instantiates a new Builder from an existing CreateCustomModelOptions instance. + * + * @param createCustomModelOptions the instance to initialize the Builder with + */ + private Builder(CreateCustomModelOptions createCustomModelOptions) { + this.name = createCustomModelOptions.name; + this.language = createCustomModelOptions.language; + this.description = createCustomModelOptions.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + */ + public Builder(String name) { + this.name = name; + } + + /** + * Builds a CreateCustomModelOptions. + * + * @return the new CreateCustomModelOptions instance + */ + public CreateCustomModelOptions build() { + return new CreateCustomModelOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateCustomModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateCustomModelOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateCustomModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected CreateCustomModelOptions() {} + + protected CreateCustomModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); + name = builder.name; + language = builder.language; + description = builder.description; + } + + /** + * New builder. + * + * @return a CreateCustomModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of the new custom model. Use a localized name that matches the language of the + * custom model. Use a name that describes the purpose of the custom model, such as `Medical + * custom model` or `Legal custom model`. Use a name that is unique among all custom models that + * you own. + * + *

Include a maximum of 256 characters in the name. Do not use backslashes, slashes, colons, + * equal signs, ampersands, or question marks in the name. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the language. + * + *

The language of the new custom model. You create a custom model for a specific language, not + * for a specific voice. A custom model can be used with any voice for its specified language. + * Omit the parameter to use the the default language, `en-US`. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the description. + * + *

A recommended description of the new custom model. Use a localized description that matches + * the language of the custom model. Include a maximum of 128 characters in the description. + * + * @return the description + */ + public String description() { + return description; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateSpeakerModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateSpeakerModelOptions.java new file mode 100644 index 00000000000..4309b4911de --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateSpeakerModelOptions.java @@ -0,0 +1,149 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The createSpeakerModel options. */ +public class CreateSpeakerModelOptions extends GenericModel { + + protected String speakerName; + protected InputStream audio; + + /** Builder. */ + public static class Builder { + private String speakerName; + private InputStream audio; + + /** + * Instantiates a new Builder from an existing CreateSpeakerModelOptions instance. + * + * @param createSpeakerModelOptions the instance to initialize the Builder with + */ + private Builder(CreateSpeakerModelOptions createSpeakerModelOptions) { + this.speakerName = createSpeakerModelOptions.speakerName; + this.audio = createSpeakerModelOptions.audio; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param speakerName the speakerName + * @param audio the audio + */ + public Builder(String speakerName, InputStream audio) { + this.speakerName = speakerName; + this.audio = audio; + } + + /** + * Builds a CreateSpeakerModelOptions. + * + * @return the new CreateSpeakerModelOptions instance + */ + public CreateSpeakerModelOptions build() { + return new CreateSpeakerModelOptions(this); + } + + /** + * Set the speakerName. + * + * @param speakerName the speakerName + * @return the CreateSpeakerModelOptions builder + */ + public Builder speakerName(String speakerName) { + this.speakerName = speakerName; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the CreateSpeakerModelOptions builder + */ + public Builder audio(InputStream audio) { + this.audio = audio; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the CreateSpeakerModelOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder audio(File audio) throws FileNotFoundException { + this.audio = new FileInputStream(audio); + return this; + } + } + + protected CreateSpeakerModelOptions() {} + + protected CreateSpeakerModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.speakerName, "speakerName cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, "audio cannot be null"); + speakerName = builder.speakerName; + audio = builder.audio; + } + + /** + * New builder. + * + * @return a CreateSpeakerModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the speakerName. + * + *

The name of the speaker that is to be added to the service instance. * Include a maximum of + * 49 characters in the name. * Include only alphanumeric characters and `_` (underscores) in the + * name. * Do not include XML sensitive characters (double quotes, single quotes, ampersands, + * angle brackets, and slashes) in the name. * Do not use the name of an existing speaker that is + * already defined for the service instance. + * + * @return the speakerName + */ + public String speakerName() { + return speakerName; + } + + /** + * Gets the audio. + * + *

An enrollment audio file that contains a sample of the speaker’s voice. * The enrollment + * audio must be in WAV format and must have a minimum sampling rate of 16 kHz. The service + * accepts audio with higher sampling rates. It transcodes all audio to 16 kHz before processing + * it. * The length of the enrollment audio is limited to 1 minute. Speaking one or two paragraphs + * of text that include five to ten sentences is recommended. + * + * @return the audio + */ + public InputStream audio() { + return audio; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateVoiceModelOptions.java deleted file mode 100644 index 5011d4ed725..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateVoiceModelOptions.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createVoiceModel options. - */ -public class CreateVoiceModelOptions extends GenericModel { - - /** - * The language of the new custom voice model. Omit the parameter to use the the default language, `en-US`. - */ - public interface Language { - /** de-DE. */ - String DE_DE = "de-DE"; - /** en-GB. */ - String EN_GB = "en-GB"; - /** en-US. */ - String EN_US = "en-US"; - /** es-ES. */ - String ES_ES = "es-ES"; - /** es-LA. */ - String ES_LA = "es-LA"; - /** es-US. */ - String ES_US = "es-US"; - /** fr-FR. */ - String FR_FR = "fr-FR"; - /** it-IT. */ - String IT_IT = "it-IT"; - /** ja-JP. */ - String JA_JP = "ja-JP"; - /** pt-BR. */ - String PT_BR = "pt-BR"; - } - - protected String name; - protected String language; - protected String description; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String language; - private String description; - - private Builder(CreateVoiceModelOptions createVoiceModelOptions) { - this.name = createVoiceModelOptions.name; - this.language = createVoiceModelOptions.language; - this.description = createVoiceModelOptions.description; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this.name = name; - } - - /** - * Builds a CreateVoiceModelOptions. - * - * @return the createVoiceModelOptions - */ - public CreateVoiceModelOptions build() { - return new CreateVoiceModelOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateVoiceModelOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the CreateVoiceModelOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateVoiceModelOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - } - - protected CreateVoiceModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - name = builder.name; - language = builder.language; - description = builder.description; - } - - /** - * New builder. - * - * @return a CreateVoiceModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * The name of the new custom voice model. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the language. - * - * The language of the new custom voice model. Omit the parameter to use the the default language, `en-US`. - * - * @return the language - */ - public String language() { - return language; - } - - /** - * Gets the description. - * - * A description of the new custom voice model. Specifying a description is recommended. - * - * @return the description - */ - public String description() { - return description; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModel.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModel.java new file mode 100644 index 00000000000..20d9c97161f --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModel.java @@ -0,0 +1,148 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Information about an existing custom model. */ +public class CustomModel extends GenericModel { + + @SerializedName("customization_id") + protected String customizationId; + + protected String name; + protected String language; + protected String owner; + protected String created; + + @SerializedName("last_modified") + protected String lastModified; + + protected String description; + protected List words; + protected List prompts; + + protected CustomModel() {} + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. The [Create a custom + * model](#createcustommodel) method returns only this field. It does not not return the other + * fields of this object. + * + * @return the customizationId + */ + public String getCustomizationId() { + return customizationId; + } + + /** + * Gets the name. + * + *

The name of the custom model. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the language. + * + *

The language identifier of the custom model (for example, `en-US`). + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the owner. + * + *

The GUID of the credentials for the instance of the service that owns the custom model. + * + * @return the owner + */ + public String getOwner() { + return owner; + } + + /** + * Gets the created. + * + *

The date and time in Coordinated Universal Time (UTC) at which the custom model was created. + * The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + * + * @return the created + */ + public String getCreated() { + return created; + } + + /** + * Gets the lastModified. + * + *

The date and time in Coordinated Universal Time (UTC) at which the custom model was last + * modified. The `created` and `updated` fields are equal when a model is first added but has yet + * to be updated. The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + * + * @return the lastModified + */ + public String getLastModified() { + return lastModified; + } + + /** + * Gets the description. + * + *

The description of the custom model. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the words. + * + *

An array of `Word` objects that lists the words and their translations from the custom + * model. The words are listed in alphabetical order, with uppercase letters listed before + * lowercase letters. The array is empty if no words are defined for the custom model. This field + * is returned only by the [Get a custom model](#getcustommodel) method. + * + * @return the words + */ + public List getWords() { + return words; + } + + /** + * Gets the prompts. + * + *

An array of `Prompt` objects that provides information about the prompts that are defined + * for the specified custom model. The array is empty if no prompts are defined for the custom + * model. This field is returned only by the [Get a custom model](#getcustommodel) method. + * + * @return the prompts + */ + public List getPrompts() { + return prompts; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModels.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModels.java new file mode 100644 index 00000000000..a4d6639a5ba --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModels.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Information about existing custom models. */ +public class CustomModels extends GenericModel { + + protected List customizations; + + protected CustomModels() {} + + /** + * Gets the customizations. + * + *

An array of `CustomModel` objects that provides information about each available custom + * model. The array is empty if the requesting credentials own no custom models (if no language is + * specified) or own no custom models for the specified language. + * + * @return the customizations + */ + public List getCustomizations() { + return customizations; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptions.java new file mode 100644 index 00000000000..f42a289a06d --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptions.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteCustomModel options. */ +public class DeleteCustomModelOptions extends GenericModel { + + protected String customizationId; + + /** Builder. */ + public static class Builder { + private String customizationId; + + /** + * Instantiates a new Builder from an existing DeleteCustomModelOptions instance. + * + * @param deleteCustomModelOptions the instance to initialize the Builder with + */ + private Builder(DeleteCustomModelOptions deleteCustomModelOptions) { + this.customizationId = deleteCustomModelOptions.customizationId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a DeleteCustomModelOptions. + * + * @return the new DeleteCustomModelOptions instance + */ + public DeleteCustomModelOptions build() { + return new DeleteCustomModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteCustomModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected DeleteCustomModelOptions() {} + + protected DeleteCustomModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a DeleteCustomModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomPromptOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomPromptOptions.java new file mode 100644 index 00000000000..2f784782043 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomPromptOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteCustomPrompt options. */ +public class DeleteCustomPromptOptions extends GenericModel { + + protected String customizationId; + protected String promptId; + + /** Builder. */ + public static class Builder { + private String customizationId; + private String promptId; + + /** + * Instantiates a new Builder from an existing DeleteCustomPromptOptions instance. + * + * @param deleteCustomPromptOptions the instance to initialize the Builder with + */ + private Builder(DeleteCustomPromptOptions deleteCustomPromptOptions) { + this.customizationId = deleteCustomPromptOptions.customizationId; + this.promptId = deleteCustomPromptOptions.promptId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param promptId the promptId + */ + public Builder(String customizationId, String promptId) { + this.customizationId = customizationId; + this.promptId = promptId; + } + + /** + * Builds a DeleteCustomPromptOptions. + * + * @return the new DeleteCustomPromptOptions instance + */ + public DeleteCustomPromptOptions build() { + return new DeleteCustomPromptOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteCustomPromptOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the promptId. + * + * @param promptId the promptId + * @return the DeleteCustomPromptOptions builder + */ + public Builder promptId(String promptId) { + this.promptId = promptId; + return this; + } + } + + protected DeleteCustomPromptOptions() {} + + protected DeleteCustomPromptOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.promptId, "promptId cannot be empty"); + customizationId = builder.customizationId; + promptId = builder.promptId; + } + + /** + * New builder. + * + * @return a DeleteCustomPromptOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the promptId. + * + *

The identifier (name) of the prompt that is to be deleted. + * + * @return the promptId + */ + public String promptId() { + return promptId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteSpeakerModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteSpeakerModelOptions.java new file mode 100644 index 00000000000..0c0d92ccf76 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteSpeakerModelOptions.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteSpeakerModel options. */ +public class DeleteSpeakerModelOptions extends GenericModel { + + protected String speakerId; + + /** Builder. */ + public static class Builder { + private String speakerId; + + /** + * Instantiates a new Builder from an existing DeleteSpeakerModelOptions instance. + * + * @param deleteSpeakerModelOptions the instance to initialize the Builder with + */ + private Builder(DeleteSpeakerModelOptions deleteSpeakerModelOptions) { + this.speakerId = deleteSpeakerModelOptions.speakerId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param speakerId the speakerId + */ + public Builder(String speakerId) { + this.speakerId = speakerId; + } + + /** + * Builds a DeleteSpeakerModelOptions. + * + * @return the new DeleteSpeakerModelOptions instance + */ + public DeleteSpeakerModelOptions build() { + return new DeleteSpeakerModelOptions(this); + } + + /** + * Set the speakerId. + * + * @param speakerId the speakerId + * @return the DeleteSpeakerModelOptions builder + */ + public Builder speakerId(String speakerId) { + this.speakerId = speakerId; + return this; + } + } + + protected DeleteSpeakerModelOptions() {} + + protected DeleteSpeakerModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.speakerId, "speakerId cannot be empty"); + speakerId = builder.speakerId; + } + + /** + * New builder. + * + * @return a DeleteSpeakerModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the speakerId. + * + *

The speaker ID (GUID) of the speaker model. You must make the request with service + * credentials for the instance of the service that owns the speaker model. + * + * @return the speakerId + */ + public String speakerId() { + return speakerId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java index eea947ca862..fa61d47dce8 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteUserData options. - */ +/** The deleteUserData options. */ public class DeleteUserDataOptions extends GenericModel { protected String customerId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customerId; + /** + * Instantiates a new Builder from an existing DeleteUserDataOptions instance. + * + * @param deleteUserDataOptions the instance to initialize the Builder with + */ private Builder(DeleteUserDataOptions deleteUserDataOptions) { this.customerId = deleteUserDataOptions.customerId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); @@ -67,9 +66,10 @@ public Builder customerId(String customerId) { } } + protected DeleteUserDataOptions() {} + protected DeleteUserDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, - "customerId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, "customerId cannot be null"); customerId = builder.customerId; } @@ -85,7 +85,7 @@ public Builder newBuilder() { /** * Gets the customerId. * - * The customer ID for which all data is to be deleted. + *

The customer ID for which all data is to be deleted. * * @return the customerId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteVoiceModelOptions.java deleted file mode 100644 index 41f469c46c0..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteVoiceModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteVoiceModel options. - */ -public class DeleteVoiceModelOptions extends GenericModel { - - protected String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(DeleteVoiceModelOptions deleteVoiceModelOptions) { - this.customizationId = deleteVoiceModelOptions.customizationId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - */ - public Builder(String customizationId) { - this.customizationId = customizationId; - } - - /** - * Builds a DeleteVoiceModelOptions. - * - * @return the deleteVoiceModelOptions - */ - public DeleteVoiceModelOptions build() { - return new DeleteVoiceModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteVoiceModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - protected DeleteVoiceModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a DeleteVoiceModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java index 945a1ba5539..59e067532a4 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The deleteWord options. - */ +/** The deleteWord options. */ public class DeleteWordOptions extends GenericModel { protected String customizationId; protected String word; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String word; + /** + * Instantiates a new Builder from an existing DeleteWordOptions instance. + * + * @param deleteWordOptions the instance to initialize the Builder with + */ private Builder(DeleteWordOptions deleteWordOptions) { this.customizationId = deleteWordOptions.customizationId; this.word = deleteWordOptions.word; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String word) { /** * Builds a DeleteWordOptions. * - * @return the deleteWordOptions + * @return the new DeleteWordOptions instance */ public DeleteWordOptions build() { return new DeleteWordOptions(this); @@ -83,11 +82,12 @@ public Builder word(String word) { } } + protected DeleteWordOptions() {} + protected DeleteWordOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.word, - "word cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.word, "word cannot be empty"); customizationId = builder.customizationId; word = builder.word; } @@ -104,8 +104,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -116,7 +116,7 @@ public String customizationId() { /** * Gets the word. * - * The word that is to be deleted from the custom voice model. + *

The word that is to be deleted from the custom model. * * @return the word */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptions.java new file mode 100644 index 00000000000..7dc78c7533c --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptions.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getCustomModel options. */ +public class GetCustomModelOptions extends GenericModel { + + protected String customizationId; + + /** Builder. */ + public static class Builder { + private String customizationId; + + /** + * Instantiates a new Builder from an existing GetCustomModelOptions instance. + * + * @param getCustomModelOptions the instance to initialize the Builder with + */ + private Builder(GetCustomModelOptions getCustomModelOptions) { + this.customizationId = getCustomModelOptions.customizationId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a GetCustomModelOptions. + * + * @return the new GetCustomModelOptions instance + */ + public GetCustomModelOptions build() { + return new GetCustomModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetCustomModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected GetCustomModelOptions() {} + + protected GetCustomModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a GetCustomModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomPromptOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomPromptOptions.java new file mode 100644 index 00000000000..8bb49f1e94a --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomPromptOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getCustomPrompt options. */ +public class GetCustomPromptOptions extends GenericModel { + + protected String customizationId; + protected String promptId; + + /** Builder. */ + public static class Builder { + private String customizationId; + private String promptId; + + /** + * Instantiates a new Builder from an existing GetCustomPromptOptions instance. + * + * @param getCustomPromptOptions the instance to initialize the Builder with + */ + private Builder(GetCustomPromptOptions getCustomPromptOptions) { + this.customizationId = getCustomPromptOptions.customizationId; + this.promptId = getCustomPromptOptions.promptId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param promptId the promptId + */ + public Builder(String customizationId, String promptId) { + this.customizationId = customizationId; + this.promptId = promptId; + } + + /** + * Builds a GetCustomPromptOptions. + * + * @return the new GetCustomPromptOptions instance + */ + public GetCustomPromptOptions build() { + return new GetCustomPromptOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetCustomPromptOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the promptId. + * + * @param promptId the promptId + * @return the GetCustomPromptOptions builder + */ + public Builder promptId(String promptId) { + this.promptId = promptId; + return this; + } + } + + protected GetCustomPromptOptions() {} + + protected GetCustomPromptOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.promptId, "promptId cannot be empty"); + customizationId = builder.customizationId; + promptId = builder.promptId; + } + + /** + * New builder. + * + * @return a GetCustomPromptOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the promptId. + * + *

The identifier (name) of the prompt. + * + * @return the promptId + */ + public String promptId() { + return promptId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java index 8bd9cf70334..45edefb78e9 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,81 +10,120 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getPronunciation options. - */ +/** The getPronunciation options. */ public class GetPronunciationOptions extends GenericModel { /** - * A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language - * (for example, `en-US`) return the same translation. + * A voice that specifies the language in which the pronunciation is to be returned. If you omit + * the `voice` parameter, the service uses the US English `en-US_MichaelV3Voice` by default. All + * voices for the same language (for example, `en-US`) return the same translation. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_MichaelV3Voice`, you must + * either specify a voice with the request or specify a new default voice for your installation of + * the service. + * + *

**See also:** [Using the default + * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-use#specify-voice-default). */ public interface Voice { - /** de-DE_BirgitVoice. */ - String DE_DE_BIRGITVOICE = "de-DE_BirgitVoice"; /** de-DE_BirgitV3Voice. */ String DE_DE_BIRGITV3VOICE = "de-DE_BirgitV3Voice"; - /** de-DE_DieterVoice. */ - String DE_DE_DIETERVOICE = "de-DE_DieterVoice"; /** de-DE_DieterV3Voice. */ String DE_DE_DIETERV3VOICE = "de-DE_DieterV3Voice"; - /** en-GB_KateVoice. */ - String EN_GB_KATEVOICE = "en-GB_KateVoice"; + /** de-DE_ErikaV3Voice. */ + String DE_DE_ERIKAV3VOICE = "de-DE_ErikaV3Voice"; + /** en-AU_HeidiExpressive. */ + String EN_AU_HEIDIEXPRESSIVE = "en-AU_HeidiExpressive"; + /** en-AU_JackExpressive. */ + String EN_AU_JACKEXPRESSIVE = "en-AU_JackExpressive"; + /** en-CA_HannahNatural. */ + String EN_CA_HANNAHNATURAL = "en-CA_HannahNatural"; + /** en-GB_CharlotteV3Voice. */ + String EN_GB_CHARLOTTEV3VOICE = "en-GB_CharlotteV3Voice"; + /** en-GB_ChloeNatural. */ + String EN_GB_CHLOENATURAL = "en-GB_ChloeNatural"; + /** en-GB_GeorgeExpressive. */ + String EN_GB_GEORGEEXPRESSIVE = "en-GB_GeorgeExpressive"; + /** en-GB_JamesV3Voice. */ + String EN_GB_JAMESV3VOICE = "en-GB_JamesV3Voice"; + /** en-GB_GeorgeNatural. */ + String EN_GB_GEORGENATURAL = "en-GB_GeorgeNatural"; /** en-GB_KateV3Voice. */ String EN_GB_KATEV3VOICE = "en-GB_KateV3Voice"; - /** en-US_AllisonVoice. */ - String EN_US_ALLISONVOICE = "en-US_AllisonVoice"; + /** en-US_AllisonExpressive. */ + String EN_US_ALLISONEXPRESSIVE = "en-US_AllisonExpressive"; /** en-US_AllisonV3Voice. */ String EN_US_ALLISONV3VOICE = "en-US_AllisonV3Voice"; - /** en-US_LisaVoice. */ - String EN_US_LISAVOICE = "en-US_LisaVoice"; + /** en-US_EllieNatural. */ + String EN_US_ELLIENATURAL = "en-US_EllieNatural"; + /** en-US_EmilyV3Voice. */ + String EN_US_EMILYV3VOICE = "en-US_EmilyV3Voice"; + /** en-US_EmmaExpressive. */ + String EN_US_EMMAEXPRESSIVE = "en-US_EmmaExpressive"; + /** en-US_EmmaNatural. */ + String EN_US_EMMANATURAL = "en-US_EmmaNatural"; + /** en-US_EthanNatural. */ + String EN_US_ETHANNATURAL = "en-US_EthanNatural"; + /** en-US_HenryV3Voice. */ + String EN_US_HENRYV3VOICE = "en-US_HenryV3Voice"; + /** en-US_JacksonNatural. */ + String EN_US_JACKSONNATURAL = "en-US_JacksonNatural"; + /** en-US_KevinV3Voice. */ + String EN_US_KEVINV3VOICE = "en-US_KevinV3Voice"; + /** en-US_LisaExpressive. */ + String EN_US_LISAEXPRESSIVE = "en-US_LisaExpressive"; /** en-US_LisaV3Voice. */ String EN_US_LISAV3VOICE = "en-US_LisaV3Voice"; - /** en-US_MichaelVoice. */ - String EN_US_MICHAELVOICE = "en-US_MichaelVoice"; + /** en-US_MichaelExpressive. */ + String EN_US_MICHAELEXPRESSIVE = "en-US_MichaelExpressive"; /** en-US_MichaelV3Voice. */ String EN_US_MICHAELV3VOICE = "en-US_MichaelV3Voice"; - /** es-ES_EnriqueVoice. */ - String ES_ES_ENRIQUEVOICE = "es-ES_EnriqueVoice"; + /** en-US_OliviaV3Voice. */ + String EN_US_OLIVIAV3VOICE = "en-US_OliviaV3Voice"; + /** en-US_VictoriaNatural. */ + String EN_US_VICTORIANATURAL = "en-US_VictoriaNatural"; /** es-ES_EnriqueV3Voice. */ String ES_ES_ENRIQUEV3VOICE = "es-ES_EnriqueV3Voice"; - /** es-ES_LauraVoice. */ - String ES_ES_LAURAVOICE = "es-ES_LauraVoice"; /** es-ES_LauraV3Voice. */ String ES_ES_LAURAV3VOICE = "es-ES_LauraV3Voice"; - /** es-LA_SofiaVoice. */ - String ES_LA_SOFIAVOICE = "es-LA_SofiaVoice"; + /** es-LA_DanielaExpressive. */ + String ES_LA_DANIELAEXPRESSIVE = "es-LA_DanielaExpressive"; /** es-LA_SofiaV3Voice. */ String ES_LA_SOFIAV3VOICE = "es-LA_SofiaV3Voice"; - /** es-US_SofiaVoice. */ - String ES_US_SOFIAVOICE = "es-US_SofiaVoice"; /** es-US_SofiaV3Voice. */ String ES_US_SOFIAV3VOICE = "es-US_SofiaV3Voice"; - /** fr-FR_ReneeVoice. */ - String FR_FR_RENEEVOICE = "fr-FR_ReneeVoice"; + /** fr-CA_LouiseV3Voice. */ + String FR_CA_LOUISEV3VOICE = "fr-CA_LouiseV3Voice"; + /** fr-FR_NicolasV3Voice. */ + String FR_FR_NICOLASV3VOICE = "fr-FR_NicolasV3Voice"; /** fr-FR_ReneeV3Voice. */ String FR_FR_RENEEV3VOICE = "fr-FR_ReneeV3Voice"; - /** it-IT_FrancescaVoice. */ - String IT_IT_FRANCESCAVOICE = "it-IT_FrancescaVoice"; /** it-IT_FrancescaV3Voice. */ String IT_IT_FRANCESCAV3VOICE = "it-IT_FrancescaV3Voice"; - /** ja-JP_EmiVoice. */ - String JA_JP_EMIVOICE = "ja-JP_EmiVoice"; /** ja-JP_EmiV3Voice. */ String JA_JP_EMIV3VOICE = "ja-JP_EmiV3Voice"; - /** pt-BR_IsabelaVoice. */ - String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice"; + /** ko-KR_JinV3Voice. */ + String KO_KR_JINV3VOICE = "ko-KR_JinV3Voice"; + /** nl-NL_MerelV3Voice. */ + String NL_NL_MERELV3VOICE = "nl-NL_MerelV3Voice"; + /** pt-BR_CamilaNatural. */ + String PT_BR_CAMILANATURAL = "pt-BR_CamilaNatural"; /** pt-BR_IsabelaV3Voice. */ String PT_BR_ISABELAV3VOICE = "pt-BR_IsabelaV3Voice"; + /** pt-BR_LucasExpressive. */ + String PT_BR_LUCASEXPRESSIVE = "pt-BR_LucasExpressive"; + /** pt-BR_LucasNatural. */ + String PT_BR_LUCASNATURAL = "pt-BR_LucasNatural"; } /** - * The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the - * default format. + * The phoneme format in which to return the pronunciation. Omit the parameter to obtain the + * pronunciation in the default format. */ public interface Format { /** ibm. */ @@ -98,15 +137,18 @@ public interface Format { protected String format; protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String text; private String voice; private String format; private String customizationId; + /** + * Instantiates a new Builder from an existing GetPronunciationOptions instance. + * + * @param getPronunciationOptions the instance to initialize the Builder with + */ private Builder(GetPronunciationOptions getPronunciationOptions) { this.text = getPronunciationOptions.text; this.voice = getPronunciationOptions.voice; @@ -114,11 +156,8 @@ private Builder(GetPronunciationOptions getPronunciationOptions) { this.customizationId = getPronunciationOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -132,7 +171,7 @@ public Builder(String text) { /** * Builds a GetPronunciationOptions. * - * @return the getPronunciationOptions + * @return the new GetPronunciationOptions instance */ public GetPronunciationOptions build() { return new GetPronunciationOptions(this); @@ -183,9 +222,10 @@ public Builder customizationId(String customizationId) { } } + protected GetPronunciationOptions() {} + protected GetPronunciationOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); text = builder.text; voice = builder.voice; format = builder.format; @@ -204,7 +244,7 @@ public Builder newBuilder() { /** * Gets the text. * - * The word for which the pronunciation is requested. + *

The word for which the pronunciation is requested. * * @return the text */ @@ -215,8 +255,16 @@ public String text() { /** * Gets the voice. * - * A voice that specifies the language in which the pronunciation is to be returned. All voices for the same language - * (for example, `en-US`) return the same translation. + *

A voice that specifies the language in which the pronunciation is to be returned. If you + * omit the `voice` parameter, the service uses the US English `en-US_MichaelV3Voice` by default. + * All voices for the same language (for example, `en-US`) return the same translation. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_MichaelV3Voice`, you must + * either specify a voice with the request or specify a new default voice for your installation of + * the service. + * + *

**See also:** [Using the default + * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-use#specify-voice-default). * * @return the voice */ @@ -227,8 +275,8 @@ public String voice() { /** * Gets the format. * - * The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the - * default format. + *

The phoneme format in which to return the pronunciation. Omit the parameter to obtain the + * pronunciation in the default format. * * @return the format */ @@ -239,11 +287,12 @@ public String format() { /** * Gets the customizationId. * - * The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of - * a specified custom model must match the language of the specified voice. If the word is not defined in the - * specified custom model, the service returns the default translation for the custom model's language. You must make - * the request with credentials for the instance of the service that owns the custom model. Omit the parameter to see - * the translation for the specified voice with no customization. + *

The customization ID (GUID) of a custom model for which the pronunciation is to be returned. + * The language of a specified custom model must match the language of the specified voice. If the + * word is not defined in the specified custom model, the service returns the default translation + * for the custom model's language. You must make the request with credentials for the instance of + * the service that owns the custom model. Omit the parameter to see the translation for the + * specified voice with no customization. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetSpeakerModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetSpeakerModelOptions.java new file mode 100644 index 00000000000..bb8402d2b6b --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetSpeakerModelOptions.java @@ -0,0 +1,96 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getSpeakerModel options. */ +public class GetSpeakerModelOptions extends GenericModel { + + protected String speakerId; + + /** Builder. */ + public static class Builder { + private String speakerId; + + /** + * Instantiates a new Builder from an existing GetSpeakerModelOptions instance. + * + * @param getSpeakerModelOptions the instance to initialize the Builder with + */ + private Builder(GetSpeakerModelOptions getSpeakerModelOptions) { + this.speakerId = getSpeakerModelOptions.speakerId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param speakerId the speakerId + */ + public Builder(String speakerId) { + this.speakerId = speakerId; + } + + /** + * Builds a GetSpeakerModelOptions. + * + * @return the new GetSpeakerModelOptions instance + */ + public GetSpeakerModelOptions build() { + return new GetSpeakerModelOptions(this); + } + + /** + * Set the speakerId. + * + * @param speakerId the speakerId + * @return the GetSpeakerModelOptions builder + */ + public Builder speakerId(String speakerId) { + this.speakerId = speakerId; + return this; + } + } + + protected GetSpeakerModelOptions() {} + + protected GetSpeakerModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.speakerId, "speakerId cannot be empty"); + speakerId = builder.speakerId; + } + + /** + * New builder. + * + * @return a GetSpeakerModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the speakerId. + * + *

The speaker ID (GUID) of the speaker model. You must make the request with service + * credentials for the instance of the service that owns the speaker model. + * + * @return the speakerId + */ + public String speakerId() { + return speakerId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceModelOptions.java deleted file mode 100644 index b3ed5dde2b3..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getVoiceModel options. - */ -public class GetVoiceModelOptions extends GenericModel { - - protected String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(GetVoiceModelOptions getVoiceModelOptions) { - this.customizationId = getVoiceModelOptions.customizationId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - */ - public Builder(String customizationId) { - this.customizationId = customizationId; - } - - /** - * Builds a GetVoiceModelOptions. - * - * @return the getVoiceModelOptions - */ - public GetVoiceModelOptions build() { - return new GetVoiceModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetVoiceModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - protected GetVoiceModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a GetVoiceModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java index be713e35d91..2dd82060203 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,97 +10,126 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getVoice options. - */ +/** The getVoice options. */ public class GetVoiceOptions extends GenericModel { - /** - * The voice for which information is to be returned. - */ + /** The voice for which information is to be returned. */ public interface Voice { - /** de-DE_BirgitVoice. */ - String DE_DE_BIRGITVOICE = "de-DE_BirgitVoice"; /** de-DE_BirgitV3Voice. */ String DE_DE_BIRGITV3VOICE = "de-DE_BirgitV3Voice"; - /** de-DE_DieterVoice. */ - String DE_DE_DIETERVOICE = "de-DE_DieterVoice"; /** de-DE_DieterV3Voice. */ String DE_DE_DIETERV3VOICE = "de-DE_DieterV3Voice"; - /** en-GB_KateVoice. */ - String EN_GB_KATEVOICE = "en-GB_KateVoice"; + /** de-DE_ErikaV3Voice. */ + String DE_DE_ERIKAV3VOICE = "de-DE_ErikaV3Voice"; + /** en-AU_HeidiExpressive. */ + String EN_AU_HEIDIEXPRESSIVE = "en-AU_HeidiExpressive"; + /** en-AU_JackExpressive. */ + String EN_AU_JACKEXPRESSIVE = "en-AU_JackExpressive"; + /** en-CA_HannahNatural. */ + String EN_CA_HANNAHNATURAL = "en-CA_HannahNatural"; + /** en-GB_CharlotteV3Voice. */ + String EN_GB_CHARLOTTEV3VOICE = "en-GB_CharlotteV3Voice"; + /** en-GB_ChloeNatural. */ + String EN_GB_CHLOENATURAL = "en-GB_ChloeNatural"; + /** en-GB_GeorgeExpressive. */ + String EN_GB_GEORGEEXPRESSIVE = "en-GB_GeorgeExpressive"; + /** en-GB_JamesV3Voice. */ + String EN_GB_JAMESV3VOICE = "en-GB_JamesV3Voice"; + /** en-GB_GeorgeNatural. */ + String EN_GB_GEORGENATURAL = "en-GB_GeorgeNatural"; /** en-GB_KateV3Voice. */ String EN_GB_KATEV3VOICE = "en-GB_KateV3Voice"; - /** en-US_AllisonVoice. */ - String EN_US_ALLISONVOICE = "en-US_AllisonVoice"; + /** en-US_AllisonExpressive. */ + String EN_US_ALLISONEXPRESSIVE = "en-US_AllisonExpressive"; /** en-US_AllisonV3Voice. */ String EN_US_ALLISONV3VOICE = "en-US_AllisonV3Voice"; - /** en-US_LisaVoice. */ - String EN_US_LISAVOICE = "en-US_LisaVoice"; + /** en-US_EllieNatural. */ + String EN_US_ELLIENATURAL = "en-US_EllieNatural"; + /** en-US_EmilyV3Voice. */ + String EN_US_EMILYV3VOICE = "en-US_EmilyV3Voice"; + /** en-US_EmmaExpressive. */ + String EN_US_EMMAEXPRESSIVE = "en-US_EmmaExpressive"; + /** en-US_EmmaNatural. */ + String EN_US_EMMANATURAL = "en-US_EmmaNatural"; + /** en-US_EthanNatural. */ + String EN_US_ETHANNATURAL = "en-US_EthanNatural"; + /** en-US_HenryV3Voice. */ + String EN_US_HENRYV3VOICE = "en-US_HenryV3Voice"; + /** en-US_JacksonNatural. */ + String EN_US_JACKSONNATURAL = "en-US_JacksonNatural"; + /** en-US_KevinV3Voice. */ + String EN_US_KEVINV3VOICE = "en-US_KevinV3Voice"; + /** en-US_LisaExpressive. */ + String EN_US_LISAEXPRESSIVE = "en-US_LisaExpressive"; /** en-US_LisaV3Voice. */ String EN_US_LISAV3VOICE = "en-US_LisaV3Voice"; - /** en-US_MichaelVoice. */ - String EN_US_MICHAELVOICE = "en-US_MichaelVoice"; + /** en-US_MichaelExpressive. */ + String EN_US_MICHAELEXPRESSIVE = "en-US_MichaelExpressive"; /** en-US_MichaelV3Voice. */ String EN_US_MICHAELV3VOICE = "en-US_MichaelV3Voice"; - /** es-ES_EnriqueVoice. */ - String ES_ES_ENRIQUEVOICE = "es-ES_EnriqueVoice"; + /** en-US_OliviaV3Voice. */ + String EN_US_OLIVIAV3VOICE = "en-US_OliviaV3Voice"; + /** en-US_VictoriaNatural. */ + String EN_US_VICTORIANATURAL = "en-US_VictoriaNatural"; /** es-ES_EnriqueV3Voice. */ String ES_ES_ENRIQUEV3VOICE = "es-ES_EnriqueV3Voice"; - /** es-ES_LauraVoice. */ - String ES_ES_LAURAVOICE = "es-ES_LauraVoice"; /** es-ES_LauraV3Voice. */ String ES_ES_LAURAV3VOICE = "es-ES_LauraV3Voice"; - /** es-LA_SofiaVoice. */ - String ES_LA_SOFIAVOICE = "es-LA_SofiaVoice"; + /** es-LA_DanielaExpressive. */ + String ES_LA_DANIELAEXPRESSIVE = "es-LA_DanielaExpressive"; /** es-LA_SofiaV3Voice. */ String ES_LA_SOFIAV3VOICE = "es-LA_SofiaV3Voice"; - /** es-US_SofiaVoice. */ - String ES_US_SOFIAVOICE = "es-US_SofiaVoice"; /** es-US_SofiaV3Voice. */ String ES_US_SOFIAV3VOICE = "es-US_SofiaV3Voice"; - /** fr-FR_ReneeVoice. */ - String FR_FR_RENEEVOICE = "fr-FR_ReneeVoice"; + /** fr-CA_LouiseV3Voice. */ + String FR_CA_LOUISEV3VOICE = "fr-CA_LouiseV3Voice"; + /** fr-FR_NicolasV3Voice. */ + String FR_FR_NICOLASV3VOICE = "fr-FR_NicolasV3Voice"; /** fr-FR_ReneeV3Voice. */ String FR_FR_RENEEV3VOICE = "fr-FR_ReneeV3Voice"; - /** it-IT_FrancescaVoice. */ - String IT_IT_FRANCESCAVOICE = "it-IT_FrancescaVoice"; /** it-IT_FrancescaV3Voice. */ String IT_IT_FRANCESCAV3VOICE = "it-IT_FrancescaV3Voice"; - /** ja-JP_EmiVoice. */ - String JA_JP_EMIVOICE = "ja-JP_EmiVoice"; /** ja-JP_EmiV3Voice. */ String JA_JP_EMIV3VOICE = "ja-JP_EmiV3Voice"; - /** pt-BR_IsabelaVoice. */ - String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice"; + /** ko-KR_JinV3Voice. */ + String KO_KR_JINV3VOICE = "ko-KR_JinV3Voice"; + /** nl-NL_MerelV3Voice. */ + String NL_NL_MERELV3VOICE = "nl-NL_MerelV3Voice"; + /** pt-BR_CamilaNatural. */ + String PT_BR_CAMILANATURAL = "pt-BR_CamilaNatural"; /** pt-BR_IsabelaV3Voice. */ String PT_BR_ISABELAV3VOICE = "pt-BR_IsabelaV3Voice"; + /** pt-BR_LucasExpressive. */ + String PT_BR_LUCASEXPRESSIVE = "pt-BR_LucasExpressive"; + /** pt-BR_LucasNatural. */ + String PT_BR_LUCASNATURAL = "pt-BR_LucasNatural"; } protected String voice; protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String voice; private String customizationId; + /** + * Instantiates a new Builder from an existing GetVoiceOptions instance. + * + * @param getVoiceOptions the instance to initialize the Builder with + */ private Builder(GetVoiceOptions getVoiceOptions) { this.voice = getVoiceOptions.voice; this.customizationId = getVoiceOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -114,7 +143,7 @@ public Builder(String voice) { /** * Builds a GetVoiceOptions. * - * @return the getVoiceOptions + * @return the new GetVoiceOptions instance */ public GetVoiceOptions build() { return new GetVoiceOptions(this); @@ -143,9 +172,10 @@ public Builder customizationId(String customizationId) { } } + protected GetVoiceOptions() {} + protected GetVoiceOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.voice, - "voice cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.voice, "voice cannot be empty"); voice = builder.voice; customizationId = builder.customizationId; } @@ -162,7 +192,7 @@ public Builder newBuilder() { /** * Gets the voice. * - * The voice for which information is to be returned. + *

The voice for which information is to be returned. * * @return the voice */ @@ -173,9 +203,9 @@ public String voice() { /** * Gets the customizationId. * - * The customization ID (GUID) of a custom voice model for which information is to be returned. You must make the - * request with credentials for the instance of the service that owns the custom model. Omit the parameter to see - * information about the specified voice with no customization. + *

The customization ID (GUID) of a custom model for which information is to be returned. You + * must make the request with credentials for the instance of the service that owns the custom + * model. Omit the parameter to see information about the specified voice with no customization. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java index 4364f2044b7..e81545b6fff 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,35 +10,34 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The getWord options. - */ +/** The getWord options. */ public class GetWordOptions extends GenericModel { protected String customizationId; protected String word; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; private String word; + /** + * Instantiates a new Builder from an existing GetWordOptions instance. + * + * @param getWordOptions the instance to initialize the Builder with + */ private Builder(GetWordOptions getWordOptions) { this.customizationId = getWordOptions.customizationId; this.word = getWordOptions.word; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -54,7 +53,7 @@ public Builder(String customizationId, String word) { /** * Builds a GetWordOptions. * - * @return the getWordOptions + * @return the new GetWordOptions instance */ public GetWordOptions build() { return new GetWordOptions(this); @@ -83,11 +82,12 @@ public Builder word(String word) { } } + protected GetWordOptions() {} + protected GetWordOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.word, - "word cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.word, "word cannot be empty"); customizationId = builder.customizationId; word = builder.word; } @@ -104,8 +104,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -116,7 +116,7 @@ public String customizationId() { /** * Gets the word. * - * The word that is to be queried from the custom voice model. + *

The word that is to be queried from the custom model. * * @return the word */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptions.java new file mode 100644 index 00000000000..643feba2c7d --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptions.java @@ -0,0 +1,119 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listCustomModels options. */ +public class ListCustomModelsOptions extends GenericModel { + + /** + * The language for which custom models that are owned by the requesting credentials are to be + * returned. Omit the parameter to see all custom models that are owned by the requester. + */ + public interface Language { + /** de-DE. */ + String DE_DE = "de-DE"; + /** en-AU. */ + String EN_AU = "en-AU"; + /** en-GB. */ + String EN_GB = "en-GB"; + /** en-US. */ + String EN_US = "en-US"; + /** es-ES. */ + String ES_ES = "es-ES"; + /** es-LA. */ + String ES_LA = "es-LA"; + /** es-US. */ + String ES_US = "es-US"; + /** fr-CA. */ + String FR_CA = "fr-CA"; + /** fr-FR. */ + String FR_FR = "fr-FR"; + /** it-IT. */ + String IT_IT = "it-IT"; + /** ja-JP. */ + String JA_JP = "ja-JP"; + /** nl-NL. */ + String NL_NL = "nl-NL"; + /** pt-BR. */ + String PT_BR = "pt-BR"; + } + + protected String language; + + /** Builder. */ + public static class Builder { + private String language; + + /** + * Instantiates a new Builder from an existing ListCustomModelsOptions instance. + * + * @param listCustomModelsOptions the instance to initialize the Builder with + */ + private Builder(ListCustomModelsOptions listCustomModelsOptions) { + this.language = listCustomModelsOptions.language; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a ListCustomModelsOptions. + * + * @return the new ListCustomModelsOptions instance + */ + public ListCustomModelsOptions build() { + return new ListCustomModelsOptions(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the ListCustomModelsOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + } + + protected ListCustomModelsOptions() {} + + protected ListCustomModelsOptions(Builder builder) { + language = builder.language; + } + + /** + * New builder. + * + * @return a ListCustomModelsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + *

The language for which custom models that are owned by the requesting credentials are to be + * returned. Omit the parameter to see all custom models that are owned by the requester. + * + * @return the language + */ + public String language() { + return language; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomPromptsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomPromptsOptions.java new file mode 100644 index 00000000000..a4cfca8f049 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomPromptsOptions.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listCustomPrompts options. */ +public class ListCustomPromptsOptions extends GenericModel { + + protected String customizationId; + + /** Builder. */ + public static class Builder { + private String customizationId; + + /** + * Instantiates a new Builder from an existing ListCustomPromptsOptions instance. + * + * @param listCustomPromptsOptions the instance to initialize the Builder with + */ + private Builder(ListCustomPromptsOptions listCustomPromptsOptions) { + this.customizationId = listCustomPromptsOptions.customizationId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ListCustomPromptsOptions. + * + * @return the new ListCustomPromptsOptions instance + */ + public ListCustomPromptsOptions build() { + return new ListCustomPromptsOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ListCustomPromptsOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ListCustomPromptsOptions() {} + + protected ListCustomPromptsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ListCustomPromptsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListSpeakerModelsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListSpeakerModelsOptions.java new file mode 100644 index 00000000000..6901eaa50f0 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListSpeakerModelsOptions.java @@ -0,0 +1,23 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listSpeakerModels options. */ +public class ListSpeakerModelsOptions extends GenericModel { + + /** Construct a new instance of ListSpeakerModelsOptions. */ + public ListSpeakerModelsOptions() {} +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoiceModelsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoiceModelsOptions.java deleted file mode 100644 index 484b3c3daa3..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoiceModelsOptions.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listVoiceModels options. - */ -public class ListVoiceModelsOptions extends GenericModel { - - /** - * The language for which custom voice models that are owned by the requesting credentials are to be returned. Omit - * the parameter to see all custom voice models that are owned by the requester. - */ - public interface Language { - /** de-DE. */ - String DE_DE = "de-DE"; - /** en-GB. */ - String EN_GB = "en-GB"; - /** en-US. */ - String EN_US = "en-US"; - /** es-ES. */ - String ES_ES = "es-ES"; - /** es-LA. */ - String ES_LA = "es-LA"; - /** es-US. */ - String ES_US = "es-US"; - /** fr-FR. */ - String FR_FR = "fr-FR"; - /** it-IT. */ - String IT_IT = "it-IT"; - /** ja-JP. */ - String JA_JP = "ja-JP"; - /** pt-BR. */ - String PT_BR = "pt-BR"; - } - - protected String language; - - /** - * Builder. - */ - public static class Builder { - private String language; - - private Builder(ListVoiceModelsOptions listVoiceModelsOptions) { - this.language = listVoiceModelsOptions.language; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListVoiceModelsOptions. - * - * @return the listVoiceModelsOptions - */ - public ListVoiceModelsOptions build() { - return new ListVoiceModelsOptions(this); - } - - /** - * Set the language. - * - * @param language the language - * @return the ListVoiceModelsOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - } - - protected ListVoiceModelsOptions(Builder builder) { - language = builder.language; - } - - /** - * New builder. - * - * @return a ListVoiceModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the language. - * - * The language for which custom voice models that are owned by the requesting credentials are to be returned. Omit - * the parameter to see all custom voice models that are owned by the requester. - * - * @return the language - */ - public String language() { - return language; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java index 0a72ab30d70..137036c253d 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,48 +10,14 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listVoices options. - */ +/** The listVoices options. */ public class ListVoicesOptions extends GenericModel { - /** - * Builder. - */ - public static class Builder { - - private Builder(ListVoicesOptions listVoicesOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListVoicesOptions. - * - * @return the listVoicesOptions - */ - public ListVoicesOptions build() { - return new ListVoicesOptions(this); - } - } - - private ListVoicesOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListVoicesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } + /** Construct a new instance of ListVoicesOptions. */ + public ListVoicesOptions() {} } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java index e77386fc5a4..83e345099e9 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,32 +10,31 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The listWords options. - */ +/** The listWords options. */ public class ListWordsOptions extends GenericModel { protected String customizationId; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String customizationId; + /** + * Instantiates a new Builder from an existing ListWordsOptions instance. + * + * @param listWordsOptions the instance to initialize the Builder with + */ private Builder(ListWordsOptions listWordsOptions) { this.customizationId = listWordsOptions.customizationId; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -49,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a ListWordsOptions. * - * @return the listWordsOptions + * @return the new ListWordsOptions instance */ public ListWordsOptions build() { return new ListWordsOptions(this); @@ -67,9 +66,11 @@ public Builder customizationId(String customizationId) { } } + protected ListWordsOptions() {} + protected ListWordsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; } @@ -85,8 +86,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java index 72c5f4a5c44..23fe18ec6fb 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java @@ -1,7 +1,6 @@ package com.ibm.watson.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; - import java.util.List; public class Marks extends GenericModel { diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Prompt.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Prompt.java new file mode 100644 index 00000000000..1eb893e17ed --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Prompt.java @@ -0,0 +1,95 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information about a custom prompt. */ +public class Prompt extends GenericModel { + + protected String prompt; + + @SerializedName("prompt_id") + protected String promptId; + + protected String status; + protected String error; + + @SerializedName("speaker_id") + protected String speakerId; + + protected Prompt() {} + + /** + * Gets the prompt. + * + *

The user-specified text of the prompt. + * + * @return the prompt + */ + public String getPrompt() { + return prompt; + } + + /** + * Gets the promptId. + * + *

The user-specified identifier (name) of the prompt. + * + * @return the promptId + */ + public String getPromptId() { + return promptId; + } + + /** + * Gets the status. + * + *

The status of the prompt: * `processing`: The service received the request to add the prompt + * and is analyzing the validity of the prompt. * `available`: The service successfully validated + * the prompt, which is now ready for use in a speech synthesis request. * `failed`: The service's + * validation of the prompt failed. The status of the prompt includes an `error` field that + * describes the reason for the failure. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the error. + * + *

If the status of the prompt is `failed`, an error message that describes the reason for the + * failure. The field is omitted if no error occurred. + * + * @return the error + */ + public String getError() { + return error; + } + + /** + * Gets the speakerId. + * + *

The speaker ID (GUID) of the speaker for which the prompt was defined. The field is omitted + * if no speaker ID was specified. + * + * @return the speakerId + */ + public String getSpeakerId() { + return speakerId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/PromptMetadata.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/PromptMetadata.java new file mode 100644 index 00000000000..5c7988a0960 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/PromptMetadata.java @@ -0,0 +1,136 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Information about the prompt that is to be added to a custom model. The following example of a + * `PromptMetadata` object includes both the required prompt text and an optional speaker model ID: + * + *

`{ "prompt_text": "Thank you and good-bye!", "speaker_id": + * "823068b2-ed4e-11ea-b6e0-7b6456aa95cc" }`. + */ +public class PromptMetadata extends GenericModel { + + @SerializedName("prompt_text") + protected String promptText; + + @SerializedName("speaker_id") + protected String speakerId; + + /** Builder. */ + public static class Builder { + private String promptText; + private String speakerId; + + /** + * Instantiates a new Builder from an existing PromptMetadata instance. + * + * @param promptMetadata the instance to initialize the Builder with + */ + private Builder(PromptMetadata promptMetadata) { + this.promptText = promptMetadata.promptText; + this.speakerId = promptMetadata.speakerId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param promptText the promptText + */ + public Builder(String promptText) { + this.promptText = promptText; + } + + /** + * Builds a PromptMetadata. + * + * @return the new PromptMetadata instance + */ + public PromptMetadata build() { + return new PromptMetadata(this); + } + + /** + * Set the promptText. + * + * @param promptText the promptText + * @return the PromptMetadata builder + */ + public Builder promptText(String promptText) { + this.promptText = promptText; + return this; + } + + /** + * Set the speakerId. + * + * @param speakerId the speakerId + * @return the PromptMetadata builder + */ + public Builder speakerId(String speakerId) { + this.speakerId = speakerId; + return this; + } + } + + protected PromptMetadata() {} + + protected PromptMetadata(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.promptText, "promptText cannot be null"); + promptText = builder.promptText; + speakerId = builder.speakerId; + } + + /** + * New builder. + * + * @return a PromptMetadata builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the promptText. + * + *

The required written text of the spoken prompt. The length of a prompt's text is limited to + * a few sentences. Speaking one or two sentences of text is the recommended limit. A prompt + * cannot contain more than 1000 characters of text. Escape any XML control characters (double + * quotes, single quotes, ampersands, angle brackets, and slashes) that appear in the text of the + * prompt. + * + * @return the promptText + */ + public String promptText() { + return promptText; + } + + /** + * Gets the speakerId. + * + *

The optional speaker ID (GUID) of a previously defined speaker model that is to be + * associated with the prompt. + * + * @return the speakerId + */ + public String speakerId() { + return speakerId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Prompts.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Prompts.java new file mode 100644 index 00000000000..f782e207a5d --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Prompts.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Information about the custom prompts that are defined for a custom model. */ +public class Prompts extends GenericModel { + + protected List prompts; + + protected Prompts() {} + + /** + * Gets the prompts. + * + *

An array of `Prompt` objects that provides information about the prompts that are defined + * for the specified custom model. The array is empty if no prompts are defined for the custom + * model. + * + * @return the prompts + */ + public List getPrompts() { + return prompts; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java index 23113e2a11a..8d57c9c8de2 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,22 +10,23 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * The pronunciation of the specified text. - */ +/** The pronunciation of the specified text. */ public class Pronunciation extends GenericModel { protected String pronunciation; + protected Pronunciation() {} + /** * Gets the pronunciation. * - * The pronunciation of the specified text in the requested voice and format. If a custom voice model is specified, - * the pronunciation also reflects that custom voice. + *

The pronunciation of the specified text in the requested voice and format. If a custom model + * is specified, the pronunciation also reflects that custom model. * * @return the pronunciation */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Speaker.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Speaker.java new file mode 100644 index 00000000000..7007445894d --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Speaker.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Information about a speaker model. */ +public class Speaker extends GenericModel { + + @SerializedName("speaker_id") + protected String speakerId; + + protected String name; + + protected Speaker() {} + + /** + * Gets the speakerId. + * + *

The speaker ID (GUID) of the speaker. + * + * @return the speakerId + */ + public String getSpeakerId() { + return speakerId; + } + + /** + * Gets the name. + * + *

The user-defined name of the speaker. + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModel.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModel.java new file mode 100644 index 00000000000..e4216bd8598 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModel.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** A custom models for which the speaker has defined prompts. */ +public class SpeakerCustomModel extends GenericModel { + + @SerializedName("customization_id") + protected String customizationId; + + protected List prompts; + + protected SpeakerCustomModel() {} + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of a custom model for which the speaker has defined one or more + * prompts. + * + * @return the customizationId + */ + public String getCustomizationId() { + return customizationId; + } + + /** + * Gets the prompts. + * + *

An array of `SpeakerPrompt` objects that provides information about each prompt that the + * user has defined for the custom model. + * + * @return the prompts + */ + public List getPrompts() { + return prompts; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModels.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModels.java new file mode 100644 index 00000000000..1895460def9 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModels.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Custom models for which the speaker has defined prompts. */ +public class SpeakerCustomModels extends GenericModel { + + protected List customizations; + + protected SpeakerCustomModels() {} + + /** + * Gets the customizations. + * + *

An array of `SpeakerCustomModel` objects. Each object provides information about the prompts + * that are defined for a specified speaker in the custom models that are owned by a specified + * service instance. The array is empty if no prompts are defined for the speaker. + * + * @return the customizations + */ + public List getCustomizations() { + return customizations; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerModel.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerModel.java new file mode 100644 index 00000000000..e2492ded6f2 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerModel.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The speaker ID of the speaker model. */ +public class SpeakerModel extends GenericModel { + + @SerializedName("speaker_id") + protected String speakerId; + + protected SpeakerModel() {} + + /** + * Gets the speakerId. + * + *

The speaker ID (GUID) of the speaker model. + * + * @return the speakerId + */ + public String getSpeakerId() { + return speakerId; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerPrompt.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerPrompt.java new file mode 100644 index 00000000000..504e5bad582 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SpeakerPrompt.java @@ -0,0 +1,80 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A prompt that a speaker has defined for a custom model. */ +public class SpeakerPrompt extends GenericModel { + + protected String prompt; + + @SerializedName("prompt_id") + protected String promptId; + + protected String status; + protected String error; + + protected SpeakerPrompt() {} + + /** + * Gets the prompt. + * + *

The user-specified text of the prompt. + * + * @return the prompt + */ + public String getPrompt() { + return prompt; + } + + /** + * Gets the promptId. + * + *

The user-specified identifier (name) of the prompt. + * + * @return the promptId + */ + public String getPromptId() { + return promptId; + } + + /** + * Gets the status. + * + *

The status of the prompt: * `processing`: The service received the request to add the prompt + * and is analyzing the validity of the prompt. * `available`: The service successfully validated + * the prompt, which is now ready for use in a speech synthesis request. * `failed`: The service's + * validation of the prompt failed. The status of the prompt includes an `error` field that + * describes the reason for the failure. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the error. + * + *

If the status of the prompt is `failed`, an error message that describes the reason for the + * failure. The field is omitted if no error occurred. + * + * @return the error + */ + public String getError() { + return error; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Speakers.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Speakers.java new file mode 100644 index 00000000000..a12dae5de1b --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Speakers.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Information about all speaker models for the service instance. */ +public class Speakers extends GenericModel { + + protected List speakers; + + protected Speakers() {} + + /** + * Gets the speakers. + * + *

An array of `Speaker` objects that provides information about the speakers for the service + * instance. The array is empty if the service instance has no speakers. + * + * @return the speakers + */ + public List getSpeakers() { + return speakers; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java index 4b6bd080da3..f947ee3e8cb 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,25 +10,28 @@ * 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.text_to_speech.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Additional service features that are supported with the voice. - */ +/** Additional service features that are supported with the voice. */ public class SupportedFeatures extends GenericModel { @SerializedName("custom_pronunciation") protected Boolean customPronunciation; + @SerializedName("voice_transformation") protected Boolean voiceTransformation; + protected SupportedFeatures() {} + /** * Gets the customPronunciation. * - * If `true`, the voice can be customized; if `false`, the voice cannot be customized. (Same as `customizable`.). + *

If `true`, the voice can be customized; if `false`, the voice cannot be customized. (Same as + * `customizable`.). * * @return the customPronunciation */ @@ -39,8 +42,10 @@ public Boolean isCustomPronunciation() { /** * Gets the voiceTransformation. * - * If `true`, the voice can be transformed by using the SSML <voice-transformation> element; if `false`, the - * voice cannot be transformed. + *

If `true`, the voice can be transformed by using the SSML `<voice-transformation>` + * element; if `false`, the voice cannot be transformed. **Note:** The SSML + * `<voice-transformation>` element is obsolete. You can no longer use the element with any + * supported voice. * * @return the voiceTransformation */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java index c634e488fa3..edead2d467c 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2025. * * 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 @@ -10,120 +10,180 @@ * 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.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; - import java.util.List; -/** - * The synthesize options. - */ +/** The synthesize options. */ public class SynthesizeOptions extends GenericModel { /** - * The voice to use for synthesis. + * The voice to use for speech synthesis. If you omit the `voice` parameter, the service uses the + * US English `en-US_MichaelV3Voice` by default. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_MichaelV3Voice`, you must + * either specify a voice with the request or specify a new default voice for your installation of + * the service. + * + *

**See also:** * [Languages and + * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices) * [Using the + * default + * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-use#specify-voice-default). */ public interface Voice { - /** ar-AR_OmarVoice. */ - String AR_AR_OMARVOICE = "ar-AR_OmarVoice"; - /** de-DE_BirgitVoice. */ - String DE_DE_BIRGITVOICE = "de-DE_BirgitVoice"; /** de-DE_BirgitV3Voice. */ String DE_DE_BIRGITV3VOICE = "de-DE_BirgitV3Voice"; - /** de-DE_DieterVoice. */ - String DE_DE_DIETERVOICE = "de-DE_DieterVoice"; /** de-DE_DieterV3Voice. */ String DE_DE_DIETERV3VOICE = "de-DE_DieterV3Voice"; - /** en-GB_KateVoice. */ - String EN_GB_KATEVOICE = "en-GB_KateVoice"; + /** de-DE_ErikaV3Voice. */ + String DE_DE_ERIKAV3VOICE = "de-DE_ErikaV3Voice"; + /** en-AU_HeidiExpressive. */ + String EN_AU_HEIDIEXPRESSIVE = "en-AU_HeidiExpressive"; + /** en-AU_JackExpressive. */ + String EN_AU_JACKEXPRESSIVE = "en-AU_JackExpressive"; + /** en-CA_HannahNatural. */ + String EN_CA_HANNAHNATURAL = "en-CA_HannahNatural"; + /** en-GB_CharlotteV3Voice. */ + String EN_GB_CHARLOTTEV3VOICE = "en-GB_CharlotteV3Voice"; + /** en-GB_ChloeNatural. */ + String EN_GB_CHLOENATURAL = "en-GB_ChloeNatural"; + /** en-GB_GeorgeExpressive. */ + String EN_GB_GEORGEEXPRESSIVE = "en-GB_GeorgeExpressive"; + /** en-GB_JamesV3Voice. */ + String EN_GB_JAMESV3VOICE = "en-GB_JamesV3Voice"; + /** en-GB_GeorgeNatural. */ + String EN_GB_GEORGENATURAL = "en-GB_GeorgeNatural"; /** en-GB_KateV3Voice. */ String EN_GB_KATEV3VOICE = "en-GB_KateV3Voice"; - /** en-US_AllisonVoice. */ - String EN_US_ALLISONVOICE = "en-US_AllisonVoice"; + /** en-US_AllisonExpressive. */ + String EN_US_ALLISONEXPRESSIVE = "en-US_AllisonExpressive"; /** en-US_AllisonV3Voice. */ String EN_US_ALLISONV3VOICE = "en-US_AllisonV3Voice"; - /** en-US_LisaVoice. */ - String EN_US_LISAVOICE = "en-US_LisaVoice"; + /** en-US_EllieNatural. */ + String EN_US_ELLIENATURAL = "en-US_EllieNatural"; + /** en-US_EmilyV3Voice. */ + String EN_US_EMILYV3VOICE = "en-US_EmilyV3Voice"; + /** en-US_EmmaExpressive. */ + String EN_US_EMMAEXPRESSIVE = "en-US_EmmaExpressive"; + /** en-US_EmmaNatural. */ + String EN_US_EMMANATURAL = "en-US_EmmaNatural"; + /** en-US_EthanNatural. */ + String EN_US_ETHANNATURAL = "en-US_EthanNatural"; + /** en-US_HenryV3Voice. */ + String EN_US_HENRYV3VOICE = "en-US_HenryV3Voice"; + /** en-US_JacksonNatural. */ + String EN_US_JACKSONNATURAL = "en-US_JacksonNatural"; + /** en-US_KevinV3Voice. */ + String EN_US_KEVINV3VOICE = "en-US_KevinV3Voice"; + /** en-US_LisaExpressive. */ + String EN_US_LISAEXPRESSIVE = "en-US_LisaExpressive"; /** en-US_LisaV3Voice. */ String EN_US_LISAV3VOICE = "en-US_LisaV3Voice"; - /** en-US_MichaelVoice. */ - String EN_US_MICHAELVOICE = "en-US_MichaelVoice"; + /** en-US_MichaelExpressive. */ + String EN_US_MICHAELEXPRESSIVE = "en-US_MichaelExpressive"; /** en-US_MichaelV3Voice. */ String EN_US_MICHAELV3VOICE = "en-US_MichaelV3Voice"; - /** es-ES_EnriqueVoice. */ - String ES_ES_ENRIQUEVOICE = "es-ES_EnriqueVoice"; + /** en-US_OliviaV3Voice. */ + String EN_US_OLIVIAV3VOICE = "en-US_OliviaV3Voice"; + /** en-US_VictoriaNatural. */ + String EN_US_VICTORIANATURAL = "en-US_VictoriaNatural"; /** es-ES_EnriqueV3Voice. */ String ES_ES_ENRIQUEV3VOICE = "es-ES_EnriqueV3Voice"; - /** es-ES_LauraVoice. */ - String ES_ES_LAURAVOICE = "es-ES_LauraVoice"; /** es-ES_LauraV3Voice. */ String ES_ES_LAURAV3VOICE = "es-ES_LauraV3Voice"; - /** es-LA_SofiaVoice. */ - String ES_LA_SOFIAVOICE = "es-LA_SofiaVoice"; + /** es-LA_DanielaExpressive. */ + String ES_LA_DANIELAEXPRESSIVE = "es-LA_DanielaExpressive"; /** es-LA_SofiaV3Voice. */ String ES_LA_SOFIAV3VOICE = "es-LA_SofiaV3Voice"; - /** es-US_SofiaVoice. */ - String ES_US_SOFIAVOICE = "es-US_SofiaVoice"; /** es-US_SofiaV3Voice. */ String ES_US_SOFIAV3VOICE = "es-US_SofiaV3Voice"; - /** fr-FR_ReneeVoice. */ - String FR_FR_RENEEVOICE = "fr-FR_ReneeVoice"; + /** fr-CA_LouiseV3Voice. */ + String FR_CA_LOUISEV3VOICE = "fr-CA_LouiseV3Voice"; + /** fr-FR_NicolasV3Voice. */ + String FR_FR_NICOLASV3VOICE = "fr-FR_NicolasV3Voice"; /** fr-FR_ReneeV3Voice. */ String FR_FR_RENEEV3VOICE = "fr-FR_ReneeV3Voice"; - /** it-IT_FrancescaVoice. */ - String IT_IT_FRANCESCAVOICE = "it-IT_FrancescaVoice"; /** it-IT_FrancescaV3Voice. */ String IT_IT_FRANCESCAV3VOICE = "it-IT_FrancescaV3Voice"; - /** ja-JP_EmiVoice. */ - String JA_JP_EMIVOICE = "ja-JP_EmiVoice"; /** ja-JP_EmiV3Voice. */ String JA_JP_EMIV3VOICE = "ja-JP_EmiV3Voice"; - /** nl-NL_EmmaVoice. */ - String NL_NL_EMMAVOICE = "nl-NL_EmmaVoice"; - /** nl-NL_LiamVoice. */ - String NL_NL_LIAMVOICE = "nl-NL_LiamVoice"; - /** pt-BR_IsabelaVoice. */ - String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice"; + /** ko-KR_JinV3Voice. */ + String KO_KR_JINV3VOICE = "ko-KR_JinV3Voice"; + /** nl-NL_MerelV3Voice. */ + String NL_NL_MERELV3VOICE = "nl-NL_MerelV3Voice"; + /** pt-BR_CamilaNatural. */ + String PT_BR_CAMILANATURAL = "pt-BR_CamilaNatural"; /** pt-BR_IsabelaV3Voice. */ String PT_BR_ISABELAV3VOICE = "pt-BR_IsabelaV3Voice"; - /** zh-CN_LiNaVoice. */ - String ZH_CN_LINAVOICE = "zh-CN_LiNaVoice"; - /** zh-CN_WangWeiVoice. */ - String ZH_CN_WANGWEIVOICE = "zh-CN_WangWeiVoice"; - /** zh-CN_ZhangJingVoice. */ - String ZH_CN_ZHANGJINGVOICE = "zh-CN_ZhangJingVoice"; + /** pt-BR_LucasExpressive. */ + String PT_BR_LUCASEXPRESSIVE = "pt-BR_LucasExpressive"; + /** pt-BR_LucasNatural. */ + String PT_BR_LUCASNATURAL = "pt-BR_LucasNatural"; + } + + /** + * *For German voices,* indicates how the service is to spell out strings of individual letters. + * To indicate the pace of the spelling, specify one of the following values: * `default` - The + * service reads the characters at the rate at which it synthesizes speech for the request. You + * can also omit the parameter entirely to achieve the default behavior. * `singles` - The service + * reads the characters one at a time, with a brief pause between each character. * `pairs` - The + * service reads the characters two at a time, with a brief pause between each pair. * `triples` - + * The service reads the characters three at a time, with a brief pause between each triplet. + * + *

For more information, see [Specifying how strings are spelled + * out](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-synthesis-params#params-spell-out-mode). + */ + public interface SpellOutMode { + /** default. */ + String X_DEFAULT = "default"; + /** singles. */ + String SINGLES = "singles"; + /** pairs. */ + String PAIRS = "pairs"; + /** triples. */ + String TRIPLES = "triples"; } protected String text; protected String accept; protected String voice; protected String customizationId; + protected String spellOutMode; + protected Long ratePercentage; + protected Long pitchPercentage; protected List timings; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String text; private String accept; private String voice; private String customizationId; + private String spellOutMode; + private Long ratePercentage; + private Long pitchPercentage; private List timings; + /** + * Instantiates a new Builder from an existing SynthesizeOptions instance. + * + * @param synthesizeOptions the instance to initialize the Builder with + */ private Builder(SynthesizeOptions synthesizeOptions) { this.text = synthesizeOptions.text; this.accept = synthesizeOptions.accept; this.voice = synthesizeOptions.voice; this.customizationId = synthesizeOptions.customizationId; + this.spellOutMode = synthesizeOptions.spellOutMode; + this.ratePercentage = synthesizeOptions.ratePercentage; + this.pitchPercentage = synthesizeOptions.pitchPercentage; this.timings = synthesizeOptions.timings; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -137,7 +197,7 @@ public Builder(String text) { /** * Builds a SynthesizeOptions. * - * @return the synthesizeOptions + * @return the new SynthesizeOptions instance */ public SynthesizeOptions build() { return new SynthesizeOptions(this); @@ -187,10 +247,43 @@ public Builder customizationId(String customizationId) { return this; } + /** + * Set the spellOutMode. + * + * @param spellOutMode the spellOutMode + * @return the SynthesizeOptions builder + */ + public Builder spellOutMode(String spellOutMode) { + this.spellOutMode = spellOutMode; + return this; + } + + /** + * Set the ratePercentage. + * + * @param ratePercentage the ratePercentage + * @return the SynthesizeOptions builder + */ + public Builder ratePercentage(long ratePercentage) { + this.ratePercentage = ratePercentage; + return this; + } + + /** + * Set the pitchPercentage. + * + * @param pitchPercentage the pitchPercentage + * @return the SynthesizeOptions builder + */ + public Builder pitchPercentage(long pitchPercentage) { + this.pitchPercentage = pitchPercentage; + return this; + } + /** * Set the timings. * - * @param timings the timings + * @param timings the list of timings * @return the SynthesizeOptions builder */ public Builder timings(List timings) { @@ -199,14 +292,17 @@ public Builder timings(List timings) { } } + protected SynthesizeOptions() {} + protected SynthesizeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); text = builder.text; accept = builder.accept; voice = builder.voice; customizationId = builder.customizationId; - timings = builder.timings; + spellOutMode = builder.spellOutMode; + ratePercentage = builder.ratePercentage; + pitchPercentage = builder.pitchPercentage; } /** @@ -221,7 +317,7 @@ public Builder newBuilder() { /** * Gets the text. * - * The text to synthesize. + *

The text to synthesize. * * @return the text */ @@ -232,9 +328,9 @@ public String text() { /** * Gets the accept. * - * The requested format (MIME type) of the audio. You can use the `Accept` header or the `accept` parameter to specify - * the audio format. For more information about specifying an audio format, see **Audio formats (accept types)** in - * the method description. + *

The requested format (MIME type) of the audio. You can use the `Accept` header or the + * `accept` parameter to specify the audio format. For more information about specifying an audio + * format, see **Audio formats (accept types)** in the method description. * * @return the accept */ @@ -245,7 +341,17 @@ public String accept() { /** * Gets the voice. * - * The voice to use for synthesis. + *

The voice to use for speech synthesis. If you omit the `voice` parameter, the service uses + * the US English `en-US_MichaelV3Voice` by default. + * + *

_For IBM Cloud Pak for Data,_ if you do not install the `en-US_MichaelV3Voice`, you must + * either specify a voice with the request or specify a new default voice for your installation of + * the service. + * + *

**See also:** * [Languages and + * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices) * [Using the + * default + * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-use#specify-voice-default). * * @return the voice */ @@ -256,10 +362,10 @@ public String voice() { /** * Gets the customizationId. * - * The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is specified, - * it is guaranteed to work only if it matches the language of the indicated voice. You must make the request with - * credentials for the instance of the service that owns the custom model. Omit the parameter to use the specified - * voice with no customization. + *

The customization ID (GUID) of a custom model to use for the synthesis. If a custom model is + * specified, it works only if it matches the language of the indicated voice. You must make the + * request with credentials for the instance of the service that owns the custom model. Omit the + * parameter to use the specified voice with no customization. * * @return the customizationId */ @@ -267,19 +373,87 @@ public String customizationId() { return customizationId; } + /** + * Gets the spellOutMode. + * + *

*For German voices,* indicates how the service is to spell out strings of individual + * letters. To indicate the pace of the spelling, specify one of the following values: * `default` + * - The service reads the characters at the rate at which it synthesizes speech for the request. + * You can also omit the parameter entirely to achieve the default behavior. * `singles` - The + * service reads the characters one at a time, with a brief pause between each character. * + * `pairs` - The service reads the characters two at a time, with a brief pause between each pair. + * * `triples` - The service reads the characters three at a time, with a brief pause between each + * triplet. + * + *

For more information, see [Specifying how strings are spelled + * out](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-synthesis-params#params-spell-out-mode). + * + * @return the spellOutMode + */ + public String spellOutMode() { + return spellOutMode; + } + + /** + * Gets the ratePercentage. + * + *

The percentage change from the default speaking rate of the voice that is used for speech + * synthesis. Each voice has a default speaking rate that is optimized to represent a normal rate + * of speech. The parameter accepts an integer that represents the percentage change from the + * voice's default rate: * Specify a signed negative integer to reduce the speaking rate by that + * percentage. For example, -10 reduces the rate by ten percent. * Specify an unsigned or signed + * positive integer to increase the speaking rate by that percentage. For example, 10 and +10 + * increase the rate by ten percent. * Specify 0 or omit the parameter to get the default speaking + * rate for the voice. + * + *

The parameter affects the rate for an entire request. + * + *

For more information, see [Modifying the speaking + * rate](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-synthesis-params#params-rate-percentage). + * + * @return the ratePercentage + */ + public Long ratePercentage() { + return ratePercentage; + } + + /** + * Gets the pitchPercentage. + * + *

The percentage change from the default speaking pitch of the voice that is used for speech + * synthesis. Each voice has a default speaking pitch that is optimized to represent a normal tone + * of voice. The parameter accepts an integer that represents the percentage change from the + * voice's default tone: * Specify a signed negative integer to lower the voice's pitch by that + * percentage. For example, -5 reduces the tone by five percent. * Specify an unsigned or signed + * positive integer to increase the voice's pitch by that percentage. For example, 5 and +5 + * increase the tone by five percent. * Specify 0 or omit the parameter to get the default + * speaking pitch for the voice. + * + *

The parameter affects the pitch for an entire request. + * + *

For more information, see [Modifying the speaking + * pitch](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-synthesis-params#params-pitch-percentage). + * + * @return the pitchPercentage + */ + public Long pitchPercentage() { + return pitchPercentage; + } + /** * Gets the timings. * - * An array that specifies whether the service is to return word timing information for all strings of the input - * text. Specify `words` as the element of the array to request word timing information. The service returns the - * start and end time of each word of the input. Specify an empty array or omit the parameter to receive no word - * timing information. Not supported for Japanese input text. + *

An array that specifies whether the service is to return word timing information for all + * strings of the input text. Specify `words` as the element of the array to request word timing + * information. The service returns the start and end time of each word of the input. Specify an + * empty array or omit the parameter to receive no word timing information. Not supported for + * Japanese input text. * - * NOTE: This parameter only works for the `synthesizeUsingWebSocket` method. + *

NOTE: This parameter only works for the `synthesizeUsingWebSocket` method. * * @return the timings */ - public List getTimings() { + public List timings() { return timings; } } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java index 5f85bea6938..5985a4932c8 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java @@ -1,7 +1,6 @@ package com.ibm.watson.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; - import java.util.List; public class Timings extends GenericModel { diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java index fc10ed5ea43..a2cc889579d 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,21 +10,21 @@ * 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.text_to_speech.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about the translation for the specified text. - */ +/** Information about the translation for the specified text. */ public class Translation extends GenericModel { /** - * **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation - * for the word. You can create only a single entry, with or without a single part of speech, for any word; you cannot - * create multiple entries with different parts of speech for the same word. For more information, see [Working with - * Japanese entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). + * **Japanese only.** The part of speech for the word. The service uses the value to produce the + * correct intonation for the word. You can create only a single entry, with or without a single + * part of speech, for any word; you cannot create multiple entries with different parts of speech + * for the same word. For more information, see [Working with Japanese + * entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). */ public interface PartOfSpeech { /** Dosi. */ @@ -64,26 +64,27 @@ public interface PartOfSpeech { } protected String translation; + @SerializedName("part_of_speech") protected String partOfSpeech; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String translation; private String partOfSpeech; + /** + * Instantiates a new Builder from an existing Translation instance. + * + * @param translation the instance to initialize the Builder with + */ private Builder(Translation translation) { this.translation = translation.translation; this.partOfSpeech = translation.partOfSpeech; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -97,7 +98,7 @@ public Builder(String translation) { /** * Builds a Translation. * - * @return the translation + * @return the new Translation instance */ public Translation build() { return new Translation(this); @@ -126,9 +127,11 @@ public Builder partOfSpeech(String partOfSpeech) { } } + protected Translation() {} + protected Translation(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.translation, - "translation cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.translation, "translation cannot be null"); translation = builder.translation; partOfSpeech = builder.partOfSpeech; } @@ -145,9 +148,10 @@ public Builder newBuilder() { /** * Gets the translation. * - * The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for - * representing the phonetic string of a word either as an IPA translation or as an IBM SPR translation. A sounds-like - * is one or more words that, when combined, sound like the word. + *

The phonetic or sounds-like translation for the word. A phonetic translation is based on the + * SSML format for representing the phonetic string of a word either as an IPA translation or as + * an IBM SPR translation. A sounds-like is one or more words that, when combined, sound like the + * word. * * @return the translation */ @@ -158,10 +162,11 @@ public String translation() { /** * Gets the partOfSpeech. * - * **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation - * for the word. You can create only a single entry, with or without a single part of speech, for any word; you cannot - * create multiple entries with different parts of speech for the same word. For more information, see [Working with - * Japanese entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). + *

**Japanese only.** The part of speech for the word. The service uses the value to produce + * the correct intonation for the word. You can create only a single entry, with or without a + * single part of speech, for any word; you cannot create multiple entries with different parts of + * speech for the same word. For more information, see [Working with Japanese + * entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). * * @return the partOfSpeech */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptions.java new file mode 100644 index 00000000000..29511013244 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptions.java @@ -0,0 +1,193 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The updateCustomModel options. */ +public class UpdateCustomModelOptions extends GenericModel { + + protected String customizationId; + protected String name; + protected String description; + protected List words; + + /** Builder. */ + public static class Builder { + private String customizationId; + private String name; + private String description; + private List words; + + /** + * Instantiates a new Builder from an existing UpdateCustomModelOptions instance. + * + * @param updateCustomModelOptions the instance to initialize the Builder with + */ + private Builder(UpdateCustomModelOptions updateCustomModelOptions) { + this.customizationId = updateCustomModelOptions.customizationId; + this.name = updateCustomModelOptions.name; + this.description = updateCustomModelOptions.description; + this.words = updateCustomModelOptions.words; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a UpdateCustomModelOptions. + * + * @return the new UpdateCustomModelOptions instance + */ + public UpdateCustomModelOptions build() { + return new UpdateCustomModelOptions(this); + } + + /** + * Adds a new element to words. + * + * @param word the new element to be added + * @return the UpdateCustomModelOptions builder + */ + public Builder addWord(Word word) { + com.ibm.cloud.sdk.core.util.Validator.notNull(word, "word cannot be null"); + if (this.words == null) { + this.words = new ArrayList(); + } + this.words.add(word); + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the UpdateCustomModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateCustomModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateCustomModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the words. Existing words will be replaced. + * + * @param words the words + * @return the UpdateCustomModelOptions builder + */ + public Builder words(List words) { + this.words = words; + return this; + } + } + + protected UpdateCustomModelOptions() {} + + protected UpdateCustomModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + name = builder.name; + description = builder.description; + words = builder.words; + } + + /** + * New builder. + * + * @return a UpdateCustomModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the customizationId. + * + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the name. + * + *

A new name for the custom model. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + *

A new description for the custom model. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the words. + * + *

An array of `Word` objects that provides the words and their translations that are to be + * added or updated for the custom model. Pass an empty array to make no additions or updates. + * + * @return the words + */ + public List words() { + return words; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateVoiceModelOptions.java deleted file mode 100644 index 3c4d113a33a..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateVoiceModelOptions.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateVoiceModel options. - */ -public class UpdateVoiceModelOptions extends GenericModel { - - protected String customizationId; - protected String name; - protected String description; - protected List words; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String name; - private String description; - private List words; - - private Builder(UpdateVoiceModelOptions updateVoiceModelOptions) { - this.customizationId = updateVoiceModelOptions.customizationId; - this.name = updateVoiceModelOptions.name; - this.description = updateVoiceModelOptions.description; - this.words = updateVoiceModelOptions.words; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - */ - public Builder(String customizationId) { - this.customizationId = customizationId; - } - - /** - * Builds a UpdateVoiceModelOptions. - * - * @return the updateVoiceModelOptions - */ - public UpdateVoiceModelOptions build() { - return new UpdateVoiceModelOptions(this); - } - - /** - * Adds an word to words. - * - * @param word the new word - * @return the UpdateVoiceModelOptions builder - */ - public Builder addWord(Word word) { - com.ibm.cloud.sdk.core.util.Validator.notNull(word, - "word cannot be null"); - if (this.words == null) { - this.words = new ArrayList(); - } - this.words.add(word); - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the UpdateVoiceModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateVoiceModelOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateVoiceModelOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the words. - * Existing words will be replaced. - * - * @param words the words - * @return the UpdateVoiceModelOptions builder - */ - public Builder words(List words) { - this.words = words; - return this; - } - } - - protected UpdateVoiceModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.customizationId, - "customizationId cannot be empty"); - customizationId = builder.customizationId; - name = builder.name; - description = builder.description; - words = builder.words; - } - - /** - * New builder. - * - * @return a UpdateVoiceModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom voice model. You must make the request with credentials for the instance - * of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the name. - * - * A new name for the custom voice model. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * A new description for the custom voice model. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the words. - * - * An array of `Word` objects that provides the words and their translations that are to be added or updated for the - * custom voice model. Pass an empty array to make no additions or updates. - * - * @return the words - */ - public List words() { - return words; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java index c6965d4dbb2..83c6966203a 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2016, 2024. * * 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 @@ -10,14 +10,13 @@ * 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.text_to_speech.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about an available voice model. - */ +/** Information about an available voice. */ public class Voice extends GenericModel { protected String url; @@ -26,14 +25,18 @@ public class Voice extends GenericModel { protected String language; protected String description; protected Boolean customizable; + @SerializedName("supported_features") protected SupportedFeatures supportedFeatures; - protected VoiceModel customization; + + protected CustomModel customization; + + protected Voice() {} /** * Gets the url. * - * The URI of the voice. + *

The URI of the voice. * * @return the url */ @@ -44,7 +47,7 @@ public String getUrl() { /** * Gets the gender. * - * The gender of the voice: `male` or `female`. + *

The gender of the voice: `male` or `female`. * * @return the gender */ @@ -55,7 +58,7 @@ public String getGender() { /** * Gets the name. * - * The name of the voice. Use this as the voice identifier in all requests. + *

The name of the voice. Use this as the voice identifier in all requests. * * @return the name */ @@ -66,7 +69,7 @@ public String getName() { /** * Gets the language. * - * The language and region of the voice (for example, `en-US`). + *

The language and region of the voice (for example, `en-US`). * * @return the language */ @@ -77,7 +80,7 @@ public String getLanguage() { /** * Gets the description. * - * A textual description of the voice. + *

A textual description of the voice. * * @return the description */ @@ -88,7 +91,7 @@ public String getDescription() { /** * Gets the customizable. * - * If `true`, the voice can be customized; if `false`, the voice cannot be customized. (Same as + *

If `true`, the voice can be customized; if `false`, the voice cannot be customized. (Same as * `custom_pronunciation`; maintained for backward compatibility.). * * @return the customizable @@ -100,7 +103,7 @@ public Boolean isCustomizable() { /** * Gets the supportedFeatures. * - * Additional service features that are supported with the voice. + *

Additional service features that are supported with the voice. * * @return the supportedFeatures */ @@ -111,12 +114,12 @@ public SupportedFeatures getSupportedFeatures() { /** * Gets the customization. * - * Returns information about a specified custom voice model. This field is returned only by the **Get a voice** method - * and only when you specify the customization ID of a custom voice model. + *

Returns information about a specified custom model. This field is returned only by the [Get + * a voice](#getvoice) method and only when you specify the customization ID of a custom model. * * @return the customization */ - public VoiceModel getCustomization() { + public CustomModel getCustomization() { return customization; } } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModel.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModel.java deleted file mode 100644 index 59ca6e5d2b9..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModel.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about an existing custom voice model. - */ -public class VoiceModel extends GenericModel { - - @SerializedName("customization_id") - protected String customizationId; - protected String name; - protected String language; - protected String owner; - protected String created; - @SerializedName("last_modified") - protected String lastModified; - protected String description; - protected List words; - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom voice model. The **Create a custom model** method returns only this - * field. It does not not return the other fields of this object. - * - * @return the customizationId - */ - public String getCustomizationId() { - return customizationId; - } - - /** - * Gets the name. - * - * The name of the custom voice model. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the language. - * - * The language identifier of the custom voice model (for example, `en-US`). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the owner. - * - * The GUID of the credentials for the instance of the service that owns the custom voice model. - * - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * Gets the created. - * - * The date and time in Coordinated Universal Time (UTC) at which the custom voice model was created. The value is - * provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). - * - * @return the created - */ - public String getCreated() { - return created; - } - - /** - * Gets the lastModified. - * - * The date and time in Coordinated Universal Time (UTC) at which the custom voice model was last modified. The - * `created` and `updated` fields are equal when a voice model is first added but has yet to be updated. The value is - * provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). - * - * @return the lastModified - */ - public String getLastModified() { - return lastModified; - } - - /** - * Gets the description. - * - * The description of the custom voice model. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the words. - * - * An array of `Word` objects that lists the words and their translations from the custom voice model. The words are - * listed in alphabetical order, with uppercase letters listed before lowercase letters. The array is empty if the - * custom model contains no words. This field is returned only by the **Get a voice** method and only when you specify - * the customization ID of a custom voice model. - * - * @return the words - */ - public List getWords() { - return words; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModels.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModels.java deleted file mode 100644 index b827b39b048..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModels.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.text_to_speech.v1.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about existing custom voice models. - */ -public class VoiceModels extends GenericModel { - - protected List customizations; - - /** - * Gets the customizations. - * - * An array of `VoiceModel` objects that provides information about each available custom voice model. The array is - * empty if the requesting credentials own no custom voice models (if no language is specified) or own no custom voice - * models for the specified language. - * - * @return the customizations - */ - public List getCustomizations() { - return customizations; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java index 71e0f9156ce..0d8d23cddc9 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,23 +10,23 @@ * 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.text_to_speech.v1.model; -import java.util.List; +package com.ibm.watson.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information about all available voice models. - */ +/** Information about all available voices. */ public class Voices extends GenericModel { protected List voices; + protected Voices() {} + /** * Gets the voices. * - * A list of available voices. + *

A list of available voices. * * @return the voices */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java index ef5498bcfb8..122155a54b6 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,21 +10,21 @@ * 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.text_to_speech.v1.model; import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** - * Information about a word for the custom voice model. - */ +/** Information about a word for the custom model. */ public class Word extends GenericModel { /** - * **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation - * for the word. You can create only a single entry, with or without a single part of speech, for any word; you cannot - * create multiple entries with different parts of speech for the same word. For more information, see [Working with - * Japanese entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). + * **Japanese only.** The part of speech for the word. The service uses the value to produce the + * correct intonation for the word. You can create only a single entry, with or without a single + * part of speech, for any word; you cannot create multiple entries with different parts of speech + * for the same word. For more information, see [Working with Japanese + * entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). */ public interface PartOfSpeech { /** Dosi. */ @@ -65,28 +65,29 @@ public interface PartOfSpeech { protected String word; protected String translation; + @SerializedName("part_of_speech") protected String partOfSpeech; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private String word; private String translation; private String partOfSpeech; + /** + * Instantiates a new Builder from an existing Word instance. + * + * @param word the instance to initialize the Builder with + */ private Builder(Word word) { this.word = word.word; this.translation = word.translation; this.partOfSpeech = word.partOfSpeech; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -102,7 +103,7 @@ public Builder(String word, String translation) { /** * Builds a Word. * - * @return the word + * @return the new Word instance */ public Word build() { return new Word(this); @@ -142,11 +143,12 @@ public Builder partOfSpeech(String partOfSpeech) { } } + protected Word() {} + protected Word(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.word, - "word cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.translation, - "translation cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.word, "word cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.translation, "translation cannot be null"); word = builder.word; translation = builder.translation; partOfSpeech = builder.partOfSpeech; @@ -164,7 +166,7 @@ public Builder newBuilder() { /** * Gets the word. * - * The word for the custom voice model. + *

The word for the custom model. The maximum length of a word is 49 characters. * * @return the word */ @@ -175,9 +177,10 @@ public String word() { /** * Gets the translation. * - * The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for - * representing the phonetic string of a word either as an IPA or IBM SPR translation. A sounds-like translation - * consists of one or more words that, when combined, sound like the word. + *

The phonetic or sounds-like translation for the word. A phonetic translation is based on the + * SSML format for representing the phonetic string of a word either as an IPA or IBM SPR + * translation. A sounds-like translation consists of one or more words that, when combined, sound + * like the word. The maximum length of a translation is 499 characters. * * @return the translation */ @@ -188,10 +191,11 @@ public String translation() { /** * Gets the partOfSpeech. * - * **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation - * for the word. You can create only a single entry, with or without a single part of speech, for any word; you cannot - * create multiple entries with different parts of speech for the same word. For more information, see [Working with - * Japanese entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). + *

**Japanese only.** The part of speech for the word. The service uses the value to produce + * the correct intonation for the word. You can create only a single entry, with or without a + * single part of speech, for any word; you cannot create multiple entries with different parts of + * speech for the same word. For more information, see [Working with Japanese + * entries](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-rules#jaNotes). * * @return the partOfSpeech */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java index c3c1601fe9d..2ad52030012 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2018, 2024. * * 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 @@ -10,38 +10,39 @@ * 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.text_to_speech.v1.model; +import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.ArrayList; import java.util.List; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - /** - * For the **Add custom words** method, one or more words that are to be added or updated for the custom voice model and - * the translation for each specified word. + * For the [Add custom words](#addwords) method, one or more words that are to be added or updated + * for the custom model and the translation for each specified word. * - * For the **List custom words** method, the words and their translations from the custom voice model. + *

For the [List custom words](#listwords) method, the words and their translations from the + * custom model. */ public class Words extends GenericModel { protected List words; - /** - * Builder. - */ + /** Builder. */ public static class Builder { private List words; + /** + * Instantiates a new Builder from an existing Words instance. + * + * @param words the instance to initialize the Builder with + */ private Builder(Words words) { this.words = words.words; } - /** - * Instantiates a new builder. - */ - public Builder() { - } + /** Instantiates a new builder. */ + public Builder() {} /** * Instantiates a new builder with required properties. @@ -55,21 +56,20 @@ public Builder(List words) { /** * Builds a Words. * - * @return the words + * @return the new Words instance */ public Words build() { return new Words(this); } /** - * Adds an word to words. + * Adds a new element to words. * - * @param word the new word + * @param word the new element to be added * @return the Words builder */ public Builder addWord(Word word) { - com.ibm.cloud.sdk.core.util.Validator.notNull(word, - "word cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(word, "word cannot be null"); if (this.words == null) { this.words = new ArrayList(); } @@ -78,8 +78,7 @@ public Builder addWord(Word word) { } /** - * Set the words. - * Existing words will be replaced. + * Set the words. Existing words will be replaced. * * @param words the words * @return the Words builder @@ -90,9 +89,10 @@ public Builder words(List words) { } } + protected Words() {} + protected Words(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, - "words cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, "words cannot be null"); words = builder.words; } @@ -108,12 +108,13 @@ public Builder newBuilder() { /** * Gets the words. * - * The **Add custom words** method accepts an array of `Word` objects. Each object provides a word that is to be added - * or updated for the custom voice model and the word's translation. + *

The [Add custom words](#addwords) method accepts an array of `Word` objects. Each object + * provides a word that is to be added or updated for the custom model and the word's translation. * - * The **List custom words** method returns an array of `Word` objects. Each object shows a word and its translation - * from the custom voice model. The words are listed in alphabetical order, with uppercase letters listed before - * lowercase letters. The array is empty if the custom model contains no words. + *

The [List custom words](#listwords) method returns an array of `Word` objects. Each object + * shows a word and its translation from the custom model. The words are listed in alphabetical + * order, with uppercase letters listed before lowercase letters. The array is empty if the custom + * model contains no words. * * @return the words */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java index e4bf11a05ae..276bcf449e5 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,7 +10,6 @@ * 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. */ -/** - * Text to Speech v1. - */ + +/** Text to Speech v1. */ package com.ibm.watson.text_to_speech.v1; diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/MarkTimingTypeAdapter.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/MarkTimingTypeAdapter.java index 729fd76b6b8..c7e748c978f 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/MarkTimingTypeAdapter.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/MarkTimingTypeAdapter.java @@ -5,7 +5,6 @@ import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.ibm.watson.text_to_speech.v1.model.MarkTiming; - import java.io.IOException; public class MarkTimingTypeAdapter extends TypeAdapter { diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java index b0f4b1e48b3..55d97710a3b 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2019. + * (C) Copyright IBM Corp. 2016, 2020. * * 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 @@ -13,14 +13,14 @@ package com.ibm.watson.text_to_speech.v1.util; import com.ibm.watson.text_to_speech.v1.TextToSpeech; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; /** - * Utility class to write the data size header in wave(.wav) files synthesized with the {@link TextToSpeech} service. + * Utility class to write the data size header in wave(.wav) files synthesized with the {@link + * TextToSpeech} service. */ public final class WaveUtils { /** The WAVE meta-data header size. (value is 8) */ @@ -72,8 +72,8 @@ public static InputStream reWriteWaveHeader(InputStream is) throws IOException { * * @param is the input stream * @return the byte array - * @throws IOException If the first byte cannot be read for any reason other than end of file, or if the input stream - * has been closed, or if some other I/O error occurs. + * @throws IOException If the first byte cannot be read for any reason other than end of file, or + * if the input stream has been closed, or if some other I/O error occurs. */ public static byte[] toByteArray(InputStream is) throws IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); @@ -88,5 +88,4 @@ public static byte[] toByteArray(InputStream is) throws IOException { buffer.flush(); return buffer.toByteArray(); } - } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WordTimingTypeAdapter.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WordTimingTypeAdapter.java index 27b355eeb36..775d801e7d7 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WordTimingTypeAdapter.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WordTimingTypeAdapter.java @@ -5,7 +5,6 @@ import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.ibm.watson.text_to_speech.v1.model.WordTiming; - import java.io.IOException; public class WordTimingTypeAdapter extends TypeAdapter { diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/BaseSynthesizeCallback.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/BaseSynthesizeCallback.java index f511d1af9cf..09c54dc94c3 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/BaseSynthesizeCallback.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/BaseSynthesizeCallback.java @@ -2,7 +2,6 @@ import com.ibm.watson.text_to_speech.v1.model.Marks; import com.ibm.watson.text_to_speech.v1.model.Timings; - import java.util.logging.Level; import java.util.logging.Logger; @@ -11,15 +10,14 @@ public class BaseSynthesizeCallback implements SynthesizeCallback { /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onConnected() + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onConnected() */ - public void onConnected() { - } + public void onConnected() {} /* * (non-Javadoc) * @see - * com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onError(java.lang + * com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onError(java.lang * .Exception) */ public void onError(Exception e) { @@ -29,7 +27,7 @@ public void onError(Exception e) { /* * (non-Javadoc) * @see - * com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onWarning(java.lang + * com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onWarning(java.lang * .Exception) */ public void onWarning(Exception e) { @@ -39,40 +37,35 @@ public void onWarning(Exception e) { /* * (non-Javadoc) * @see - * com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onDisconnected() + * com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onDisconnected() */ - public void onDisconnected() { - } + public void onDisconnected() {} /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onContentType() + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onContentType() */ @Override - public void onContentType(String contentType) { - } + public void onContentType(String contentType) {} /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onTimings() + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onTimings() */ @Override - public void onTimings(Timings timings) { - } + public void onTimings(Timings timings) {} /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onMarks() + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onMarks() */ @Override - public void onMarks(Marks marks) { - } + public void onMarks(Marks marks) {} /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.text_to_speech.v1.websocket.SynthesizeCallback#onAudioStream() + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onAudioStream() */ @Override - public void onAudioStream(byte[] bytes) { - } + public void onAudioStream(byte[] bytes) {} } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/SynthesizeCallback.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/SynthesizeCallback.java index 6099cd12f28..6dced0b10ef 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/SynthesizeCallback.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/SynthesizeCallback.java @@ -4,9 +4,7 @@ import com.ibm.watson.text_to_speech.v1.model.Timings; public interface SynthesizeCallback { - /** - * Called when a WebSocket connection was made. - */ + /** Called when a WebSocket connection was made. */ void onConnected(); /** @@ -23,9 +21,7 @@ public interface SynthesizeCallback { */ void onWarning(Exception e); - /** - * Called when a WebSocket connection was closed. - */ + /** Called when a WebSocket connection was closed. */ void onDisconnected(); /** @@ -50,11 +46,11 @@ public interface SynthesizeCallback { void onMarks(Marks marks); /** - * Called when the service returns byte info in the specified audio format as - * a result of synthesis. + * Called when the service returns byte info in the specified audio format as a result of + * synthesis. * * @param bytes array of bytes in the specified audio format or the default - * (audio/ogg;codecs=opus) + * (audio/ogg;codecs=opus) */ void onAudioStream(byte[] bytes); } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java index dfd1cd34aa5..a0284e07371 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java @@ -9,15 +9,14 @@ import com.ibm.watson.text_to_speech.v1.model.Marks; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; import com.ibm.watson.text_to_speech.v1.model.Timings; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; import okhttp3.Response; import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; - public class TextToSpeechWebSocketListener extends WebSocketListener { private static final String TEXT_TO_WEB_SOCKET = "TextToWebSocketThread"; private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); @@ -25,6 +24,7 @@ public class TextToSpeechWebSocketListener extends WebSocketListener { private static final String VOICE = "voice"; private static final String CUSTOMIZATION_ID = "customization_id"; + private static final String SPELL_OUT_MODE = "spell_out_mode"; private static final String ACTION = "action"; private static final String START = "start"; private static final String STOP = "stop"; @@ -40,7 +40,8 @@ public class TextToSpeechWebSocketListener extends WebSocketListener { private WebSocket socket; private boolean socketOpen = true; - public TextToSpeechWebSocketListener(final SynthesizeOptions options, final SynthesizeCallback callback) { + public TextToSpeechWebSocketListener( + final SynthesizeOptions options, final SynthesizeCallback callback) { this.options = options; this.callback = callback; } @@ -84,12 +85,13 @@ public void onMessage(WebSocket webSocket, String message) { String warning = json.get(WARNINGS).getAsString(); callback.onWarning(new RuntimeException(warning)); } else if (json.has(BINARY_STREAMS)) { - String contentType = json.get(BINARY_STREAMS) - .getAsJsonArray() - .get(0) - .getAsJsonObject() - .get(CONTENT_TYPE) - .getAsString(); + String contentType = + json.get(BINARY_STREAMS) + .getAsJsonArray() + .get(0) + .getAsJsonObject() + .get(CONTENT_TYPE) + .getAsString(); callback.onContentType(contentType); } else if (json.has(WORDS)) { callback.onTimings(GSON.fromJson(message, Timings.class)); @@ -147,16 +149,16 @@ private void sendText() { * @return the request */ private String buildStartMessage(SynthesizeOptions options) { - Gson gson = new GsonBuilder() - .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) - .create(); - JsonObject startMessage = new JsonParser() - .parse(gson.toJson(options)) - .getAsJsonObject(); + Gson gson = + new GsonBuilder() + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) + .create(); + JsonObject startMessage = new JsonParser().parse(gson.toJson(options)).getAsJsonObject(); // remove options that are already in query string startMessage.remove(VOICE); startMessage.remove(CUSTOMIZATION_ID); + startMessage.remove(SPELL_OUT_MODE); startMessage.addProperty(ACTION, START); return startMessage.toString(); diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsIT.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsIT.java index 096639c911d..22414a9e331 100755 --- a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsIT.java +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 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 @@ -12,50 +12,30 @@ */ package com.ibm.watson.text_to_speech.v1; -import com.google.common.collect.ImmutableList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.cloud.sdk.core.service.exception.UnauthorizedException; import com.ibm.watson.common.TestUtils; import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; -import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; -import com.ibm.watson.text_to_speech.v1.model.GetVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.text_to_speech.v1.model.ListVoiceModelsOptions; -import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.text_to_speech.v1.model.Translation; -import com.ibm.watson.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.Voice; -import com.ibm.watson.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.text_to_speech.v1.model.VoiceModels; -import com.ibm.watson.text_to_speech.v1.model.Word; -import com.ibm.watson.text_to_speech.v1.model.Words; +import com.ibm.watson.text_to_speech.v1.model.*; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.junit.After; -import org.junit.Assume; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -/** - * Integration tests for the Speech to text customization API. - */ +/** Integration tests for the Speech to text customization API. */ public class CustomizationsIT extends WatsonServiceTest { private TextToSpeech service; @@ -65,109 +45,116 @@ public class CustomizationsIT extends WatsonServiceTest { private static final String MODEL_LANGUAGE_JAPANESE = "ja-JP"; private static final String MODEL_DESCRIPTION = "a simple model for testing purposes"; - private VoiceModel model; + private CustomModel model; /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - String apiKey = getProperty("text_to_speech.apikey"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); + String apiKey = System.getenv("TEXT_TO_SPEECH_APIKEY"); + String serviceUrl = System.getenv("TEXT_TO_SPEECH_URL"); + + if (apiKey == null) { + apiKey = getProperty("text_to_speech.apikey"); + serviceUrl = getProperty("text_to_speech.url"); + } + + assertNotNull( + "TEXT_TO_SPEECH_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey); Authenticator authenticator = new IamAuthenticator(apiKey); service = new TextToSpeech(authenticator); - service.setServiceUrl(getProperty("text_to_speech.url")); + service.setServiceUrl(serviceUrl); service.setDefaultHeaders(getDefaultHeaders()); } private List instantiateWords() { - Word word1 = new Word.Builder() - .word("hodor") - .translation("hold the door") - .build(); - Word word2 = new Word.Builder() - .word("shocking") - .translation("") - .build(); - return ImmutableList.of(word1, word2); + Word word1 = new Word.Builder().word("hodor").translation("hold the door").build(); + Word word2 = + new Word.Builder() + .word("shocking") + .translation("") + .build(); + return Collections.unmodifiableList(Arrays.asList(word1, word2)); } private List instantiateWordsJapanese() { - Word word1 = new Word.Builder() - .word("hodor") - .translation("hold the door") - .partOfSpeech(Word.PartOfSpeech.JOSI) - .build(); - Word word2 = new Word.Builder() - .word("clodor") - .translation("close the door") - .partOfSpeech(Word.PartOfSpeech.HOKA) - .build(); - return ImmutableList.of(word1, word2); + Word word1 = + new Word.Builder() + .word("hodor") + .translation("hold the door") + .partOfSpeech(Word.PartOfSpeech.JOSI) + .build(); + Word word2 = + new Word.Builder() + .word("clodor") + .translation("close the door") + .partOfSpeech(Word.PartOfSpeech.HOKA) + .build(); + return Collections.unmodifiableList(Arrays.asList(word1, word2)); } - private VoiceModel createVoiceModel() { - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name(MODEL_NAME) - .language(MODEL_LANGUAGE) - .description(MODEL_DESCRIPTION) - .build(); - return service.createVoiceModel(createOptions).execute().getResult(); + private CustomModel createCustomModel() { + CreateCustomModelOptions createOptions = + new CreateCustomModelOptions.Builder() + .name(MODEL_NAME) + .language(MODEL_LANGUAGE) + .description(MODEL_DESCRIPTION) + .build(); + return service.createCustomModel(createOptions).execute().getResult(); } - private VoiceModel createVoiceModelJapanese() { - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name(MODEL_NAME) - .language(MODEL_LANGUAGE_JAPANESE) - .description(MODEL_DESCRIPTION) - .build(); - return service.createVoiceModel(createOptions).execute().getResult(); + private CustomModel createVoiceModelJapanese() { + CreateCustomModelOptions createOptions = + new CreateCustomModelOptions.Builder() + .name(MODEL_NAME) + .language(MODEL_LANGUAGE_JAPANESE) + .description(MODEL_DESCRIPTION) + .build(); + return service.createCustomModel(createOptions).execute().getResult(); } - private void assertModelsEqual(VoiceModel a, VoiceModel b) { + private void assertModelsEqual(CustomModel a, CustomModel b) { assertEquals(a.getCustomizationId(), b.getCustomizationId()); - GetVoiceModelOptions getOptionsA = new GetVoiceModelOptions.Builder() - .customizationId(a.getCustomizationId()) - .build(); - assertEquals((service.getVoiceModel(getOptionsA).execute().getResult()).getName(), b.getName()); - assertEquals((service.getVoiceModel(getOptionsA).execute().getResult()).getLanguage(), b.getLanguage()); + GetCustomModelOptions getOptionsA = + new GetCustomModelOptions.Builder().customizationId(a.getCustomizationId()).build(); + assertEquals( + (service.getCustomModel(getOptionsA).execute().getResult()).getName(), b.getName()); + assertEquals( + (service.getCustomModel(getOptionsA).execute().getResult()).getLanguage(), b.getLanguage()); } - /** - * Clean up. - */ + /** Clean up. */ @After public void cleanUp() { if ((model != null) && (model.getCustomizationId() != null)) { try { - DeleteVoiceModelOptions deleteOptions = new DeleteVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - service.deleteVoiceModel(deleteOptions).execute(); + DeleteCustomModelOptions deleteOptions = + new DeleteCustomModelOptions.Builder() + .customizationId(model.getCustomizationId()) + .build(); + service.deleteCustomModel(deleteOptions).execute(); } catch (Exception e) { // Exceptions are fine in the clean up method } } } - /** - * Test create voice model. - */ + /** Test create voice model. */ @Test @Ignore public void testCreateVoiceModel() { - model = createVoiceModel(); + model = createCustomModel(); assertNotNull(model.getCustomizationId()); } - /** - * Test create voice model for Japanese. - */ + /** Test create voice model for Japanese. */ @Test @Ignore public void testCreateVoiceModelJapanese() { @@ -176,17 +163,14 @@ public void testCreateVoiceModelJapanese() { assertNotNull(model.getCustomizationId()); } - /** - * Test get voice model. - */ + /** Test get voice model. */ @Test @Ignore public void testGetVoiceModelString() { - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final VoiceModel model2 = service.getVoiceModel(getOptions).execute().getResult(); + model = createCustomModel(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + final CustomModel model2 = service.getCustomModel(getOptions).execute().getResult(); assertNotNull(model2); assertModelsEqual(model, model2); @@ -195,17 +179,14 @@ public void testGetVoiceModelString() { assertNotNull(model2.getLastModified()); } - /** - * Test get voice model. - */ + /** Test get voice model. */ @Test @Ignore public void testGetVoiceModelObject() { - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final VoiceModel model2 = service.getVoiceModel(getOptions).execute().getResult(); + model = createCustomModel(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + final CustomModel model2 = service.getCustomModel(getOptions).execute().getResult(); assertNotNull(model2); assertModelsEqual(model, model2); @@ -214,21 +195,19 @@ public void testGetVoiceModelObject() { assertNotNull(model2.getLastModified()); } - /** - * Test get voice with customization. - */ + /** Test get voice with customization. */ @Test @Ignore public void testGetVoiceCustomization() { - model = createVoiceModel(); - GetVoiceModelOptions getVoiceModelOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final VoiceModel model2 = service.getVoiceModel(getVoiceModelOptions).execute().getResult(); - GetVoiceOptions getVoiceOptions = new GetVoiceOptions.Builder() - .customizationId(model.getCustomizationId()) - .voice(GetVoiceOptions.Voice.EN_US_ALLISONVOICE) - .build(); + model = createCustomModel(); + GetCustomModelOptions getVoiceModelOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + final CustomModel model2 = service.getCustomModel(getVoiceModelOptions).execute().getResult(); + GetVoiceOptions getVoiceOptions = + new GetVoiceOptions.Builder() + .customizationId(model.getCustomizationId()) + .voice(GetVoiceOptions.Voice.EN_US_ALLISONV3VOICE) + .build(); final Voice voice = service.getVoice(getVoiceOptions).execute().getResult(); assertNotNull(model); @@ -243,105 +222,91 @@ public void testGetVoiceCustomization() { assertEquals(model2.getLastModified(), voice.getCustomization().getLastModified()); } - /** - * Test update voice model with new name and ignored language change. - */ + /** Test update voice model with new name and ignored language change. */ @Test @Ignore public void testUpdateVoiceModel() { final String newName = "new test"; - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - model = service.getVoiceModel(getOptions).execute().getResult(); - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .name(newName) - .build(); - service.updateVoiceModel(updateOptions).execute().getResult(); - - final VoiceModel model2 = service.getVoiceModel(getOptions).execute().getResult(); + model = createCustomModel(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + model = service.getCustomModel(getOptions).execute().getResult(); + UpdateCustomModelOptions updateOptions = + new UpdateCustomModelOptions.Builder() + .customizationId(model.getCustomizationId()) + .name(newName) + .build(); + service.updateCustomModel(updateOptions).execute().getResult(); + + final CustomModel model2 = service.getCustomModel(getOptions).execute().getResult(); assertModelsEqual(model, model2); // comparison at service assertEquals(model2.getLanguage(), MODEL_LANGUAGE); // value at service } - /** - * Test update voice model with new name and new custom translations. - */ + /** Test update voice model with new name and new custom translations. */ @Test @Ignore public void testUpdateVoiceModelWords() { final String newName = "new test"; - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - model = service.getVoiceModel(getOptions).execute().getResult(); - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .name(newName) - .words(instantiateWords()) - .build(); - service.updateVoiceModel(updateOptions).execute().getResult(); - - final VoiceModel model2 = service.getVoiceModel(getOptions).execute().getResult(); + model = createCustomModel(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + model = service.getCustomModel(getOptions).execute().getResult(); + UpdateCustomModelOptions updateOptions = + new UpdateCustomModelOptions.Builder() + .customizationId(model.getCustomizationId()) + .name(newName) + .words(instantiateWords()) + .build(); + service.updateCustomModel(updateOptions).execute().getResult(); + + final CustomModel model2 = service.getCustomModel(getOptions).execute().getResult(); assertModelsEqual(model, model2); assertNotEquals(model.getWords(), model2.getWords()); } - /** - * Test delete voice model. - */ + /** Test delete voice model. */ @Test @Ignore public void testDeleteVoiceModel() { - model = createVoiceModel(); + model = createCustomModel(); - DeleteVoiceModelOptions deleteOptions = new DeleteVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - service.deleteVoiceModel(deleteOptions).execute(); + DeleteCustomModelOptions deleteOptions = + new DeleteCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + service.deleteCustomModel(deleteOptions).execute(); try { - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - service.getVoiceModel(getOptions).execute().getResult(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + service.getCustomModel(getOptions).execute().getResult(); fail("deleting customization failed"); } catch (UnauthorizedException e) { // success! } } - /** - * Test list models. - */ + /** Test list models. */ @Test public void testListModels() { - ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder() - .language(MODEL_LANGUAGE) - .build(); - service.listVoiceModels(listOptions); - service.listVoiceModels(); + ListCustomModelsOptions listOptions = + new ListCustomModelsOptions.Builder().language(MODEL_LANGUAGE).build(); + service.listCustomModels(listOptions); + service.listCustomModels(); } - /** - * Test list models after create. - */ + /** Test list models after create. */ @Test @Ignore public void testListModelsAfterCreate() { - model = createVoiceModel(); - ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder() - .language(model.getLanguage()) - .build(); - final VoiceModels models = service.listVoiceModels(listOptions).execute().getResult(); - VoiceModel model2 = null; - - for (VoiceModel m : models.getCustomizations()) { + model = createCustomModel(); + ListCustomModelsOptions listOptions = + new ListCustomModelsOptions.Builder().language(model.getLanguage()).build(); + final CustomModels models = service.listCustomModels(listOptions).execute().getResult(); + CustomModel model2 = null; + + for (CustomModel m : models.getCustomizations()) { if (m.getCustomizationId().equals(model.getCustomizationId())) { model2 = m; break; @@ -352,25 +317,23 @@ public void testListModelsAfterCreate() { assertModelsEqual(model, model2); } - /** - * Test add word. - */ + /** Test add word. */ @Test @Ignore public void testAddWord() { - model = createVoiceModel(); + model = createCustomModel(); final Word expected = instantiateWords().get(0); - AddWordOptions addOptions = new AddWordOptions.Builder() - .word(expected.word()) - .translation(expected.translation()) - .customizationId(model.getCustomizationId()) - .build(); + AddWordOptions addOptions = + new AddWordOptions.Builder() + .word(expected.word()) + .translation(expected.translation()) + .customizationId(model.getCustomizationId()) + .build(); service.addWord(addOptions).execute().getResult(); - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build(); final Words results = service.listWords(listOptions).execute().getResult(); assertEquals(1, results.words().size()); @@ -380,121 +343,116 @@ public void testAddWord() { assertEquals(expected.translation(), result.translation()); } - /** - * Test add words and list words. - */ + /** Test add words and list words. */ @Test @Ignore public void testAddWords() { - model = createVoiceModel(); + model = createCustomModel(); final List expected = instantiateWords(); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); + AddWordsOptions addOptions = + new AddWordsOptions.Builder() + .customizationId(model.getCustomizationId()) + .words(expected) + .build(); service.addWords(addOptions).execute().getResult(); - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build(); final Words words = service.listWords(listOptions).execute().getResult(); assertEquals(expected.size(), words.words().size()); } - /** - * Test add words and list words for Japanese. - */ + /** Test add words and list words for Japanese. */ @Test @Ignore public void testAddWordsJapanese() { model = createVoiceModelJapanese(); final List expected = instantiateWordsJapanese(); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); + AddWordsOptions addOptions = + new AddWordsOptions.Builder() + .customizationId(model.getCustomizationId()) + .words(expected) + .build(); service.addWords(addOptions).execute().getResult(); - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build(); final Words words = service.listWords(listOptions).execute().getResult(); assertEquals(expected.size(), words.words().size()); } - /** - * Test get word. - */ + /** Test get word. */ @Test @Ignore public void testGetWord() { - model = createVoiceModel(); + model = createCustomModel(); final List expected = instantiateWords(); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); + AddWordsOptions addOptions = + new AddWordsOptions.Builder() + .customizationId(model.getCustomizationId()) + .words(expected) + .build(); service.addWords(addOptions).execute().getResult(); - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(model.getCustomizationId()) - .word(expected.get(0).word()) - .build(); + GetWordOptions getOptions = + new GetWordOptions.Builder() + .customizationId(model.getCustomizationId()) + .word(expected.get(0).word()) + .build(); final Translation translation = service.getWord(getOptions).execute().getResult(); assertEquals(expected.get(0).translation(), translation.translation()); } - /** - * Test get word for Japanese. - */ + /** Test get word for Japanese. */ @Test @Ignore public void testGetWordJapanese() { model = createVoiceModelJapanese(); final List expected = instantiateWordsJapanese(); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); + AddWordsOptions addOptions = + new AddWordsOptions.Builder() + .customizationId(model.getCustomizationId()) + .words(expected) + .build(); service.addWords(addOptions).execute().getResult(); - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(model.getCustomizationId()) - .word(expected.get(0).word()) - .build(); + GetWordOptions getOptions = + new GetWordOptions.Builder() + .customizationId(model.getCustomizationId()) + .word(expected.get(0).word()) + .build(); final Translation translation = service.getWord(getOptions).execute().getResult(); assertEquals(expected.get(0).translation(), translation.translation()); assertEquals(expected.get(0).partOfSpeech(), translation.partOfSpeech()); } - /** - * Test delete word with string. - */ + /** Test delete word with string. */ @Test @Ignore public void testDeleteWord() { - model = createVoiceModel(); + model = createCustomModel(); final Word expected = instantiateWords().get(0); - AddWordOptions addOptions = new AddWordOptions.Builder() - .word(expected.word()) - .translation(expected.translation()) - .customizationId(model.getCustomizationId()) - .build(); + AddWordOptions addOptions = + new AddWordOptions.Builder() + .word(expected.word()) + .translation(expected.translation()) + .customizationId(model.getCustomizationId()) + .build(); service.addWord(addOptions).execute().getResult(); - DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder() - .customizationId(model.getCustomizationId()) - .word(expected.word()) - .build(); + DeleteWordOptions deleteOptions = + new DeleteWordOptions.Builder() + .customizationId(model.getCustomizationId()) + .word(expected.word()) + .build(); service.deleteWord(deleteOptions).execute(); - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build(); final Words results = service.listWords(listOptions).execute().getResult(); assertEquals(0, results.words().size()); } @@ -507,30 +465,32 @@ public void testDeleteWord() { @Test @Ignore public void testSynthesize() throws IOException { - model = createVoiceModel(); + model = createCustomModel(); final Word expected = instantiateWords().get(0); - AddWordOptions addOptions = new AddWordOptions.Builder() - .word(expected.word()) - .translation(expected.translation()) - .customizationId(model.getCustomizationId()) - .build(); + AddWordOptions addOptions = + new AddWordOptions.Builder() + .word(expected.word()) + .translation(expected.translation()) + .customizationId(model.getCustomizationId()) + .build(); service.addWord(addOptions).execute().getResult(); - SynthesizeOptions synthesizeOptions1 = new SynthesizeOptions.Builder() - .text(expected.word()) - .voice(SynthesizeOptions.Voice.EN_US_MICHAELVOICE) - .accept(HttpMediaType.AUDIO_WAV) - .build(); + SynthesizeOptions synthesizeOptions1 = + new SynthesizeOptions.Builder() + .text(expected.word()) + .voice(SynthesizeOptions.Voice.EN_US_MICHAELV3VOICE) + .accept(HttpMediaType.AUDIO_WAV) + .build(); final InputStream stream1 = service.synthesize(synthesizeOptions1).execute().getResult(); - SynthesizeOptions synthesizeOptions2 = new SynthesizeOptions.Builder() - .text(expected.word()) - .voice(SynthesizeOptions.Voice.EN_US_MICHAELVOICE) - .accept(HttpMediaType.AUDIO_WAV) - .customizationId(model.getCustomizationId()) - .build(); + SynthesizeOptions synthesizeOptions2 = + new SynthesizeOptions.Builder() + .text(expected.word()) + .voice(SynthesizeOptions.Voice.EN_US_MICHAELV3VOICE) + .accept(HttpMediaType.AUDIO_WAV) + .customizationId(model.getCustomizationId()) + .build(); final InputStream stream2 = service.synthesize(synthesizeOptions2).execute().getResult(); assertFalse(TestUtils.streamContentEquals(stream1, stream2)); } - } diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsTest.java index 13822672b74..75330adecd4 100755 --- a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsTest.java +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -12,42 +12,21 @@ */ package com.ibm.watson.text_to_speech.v1; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; -import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; -import com.ibm.watson.text_to_speech.v1.model.GetVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.text_to_speech.v1.model.ListVoiceModelsOptions; -import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.Translation; -import com.ibm.watson.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.text_to_speech.v1.model.Voice; -import com.ibm.watson.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.text_to_speech.v1.model.VoiceModels; -import com.ibm.watson.text_to_speech.v1.model.Word; -import com.ibm.watson.text_to_speech.v1.model.Words; +import com.ibm.watson.text_to_speech.v1.model.*; +import java.util.*; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.RecordedRequest; import org.junit.Before; import org.junit.Test; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -/** - * Unit tests for the Speech to text customization API. - */ +/** Unit tests for the Speech to text customization API. */ public class CustomizationsTest extends WatsonServiceUnitTest { private static final String VOICES_PATH = "/v1/voices"; @@ -65,9 +44,9 @@ public class CustomizationsTest extends WatsonServiceUnitTest { private static final String CUSTOMIZATION_ID = "cafebabe-1234-5678-9abc-def012345678"; - private VoiceModel voiceModel; - private VoiceModel voiceModelWords; - private VoiceModels voiceModels; + private CustomModel voiceModel; + private CustomModel voiceModelWords; + private CustomModels voiceModels; private Voice voice; /** The service. */ @@ -75,7 +54,7 @@ public class CustomizationsTest extends WatsonServiceUnitTest { /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before @@ -85,21 +64,21 @@ public void setUp() throws Exception { service = new TextToSpeech(new NoAuthAuthenticator()); service.setServiceUrl(getMockWebServerUrl()); - voiceModel = loadFixture("src/test/resources/text_to_speech/voice_model.json", VoiceModel.class); - voiceModelWords = loadFixture("src/test/resources/text_to_speech/voice_model_words.json", VoiceModel.class); - voiceModels = loadFixture("src/test/resources/text_to_speech/list_voice_model.json", VoiceModels.class); + voiceModel = + loadFixture("src/test/resources/text_to_speech/voice_model.json", CustomModel.class); + voiceModelWords = + loadFixture("src/test/resources/text_to_speech/voice_model_words.json", CustomModel.class); + voiceModels = + loadFixture("src/test/resources/text_to_speech/list_voice_model.json", CustomModels.class); voice = loadFixture("src/test/resources/text_to_speech/voice.json", Voice.class); } private static Word instantiateWord() { - return new Word.Builder() - .word("hodor") - .translation("hold the door") - .build(); + return new Word.Builder().word("hodor").translation("hold the door").build(); } private static List instantiateWords() { - return ImmutableList.of(instantiateWord()); + return Collections.unmodifiableList(Arrays.asList(instantiateWord())); } /** @@ -111,14 +90,16 @@ private static List instantiateWords() { public void testGetVoiceCustomization() throws InterruptedException { server.enqueue(jsonResponse(voice)); - GetVoiceOptions getOptions = new GetVoiceOptions.Builder() - .voice("en-US_TestMaleVoice") - .customizationId("cafebabe-1234-5678-9abc-def012345678") - .build(); + GetVoiceOptions getOptions = + new GetVoiceOptions.Builder() + .voice("en-US_TestMaleVoice") + .customizationId("cafebabe-1234-5678-9abc-def012345678") + .build(); final Voice result = service.getVoice(getOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); - assertEquals(VOICES_PATH + "/en-US_TestMaleVoice?customization_id=" + CUSTOMIZATION_ID, + assertEquals( + VOICES_PATH + "/en-US_TestMaleVoice?customization_id=" + CUSTOMIZATION_ID, request.getPath()); assertEquals("GET", request.getMethod()); assertEquals(voice, result); @@ -133,7 +114,7 @@ public void testGetVoiceCustomization() throws InterruptedException { public void testListVoiceModelsNull() throws InterruptedException { server.enqueue(jsonResponse(voiceModels)); - final VoiceModels result = service.listVoiceModels().execute().getResult(); + final CustomModels result = service.listCustomModels().execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(VOICE_MODELS_PATH, request.getPath()); @@ -151,10 +132,9 @@ public void testListVoiceModelsNull() throws InterruptedException { public void testListVoiceModelsLanguage() throws InterruptedException { server.enqueue(jsonResponse(voiceModels)); - ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder() - .language(MODEL_LANGUAGE) - .build(); - final VoiceModels result = service.listVoiceModels(listOptions).execute().getResult(); + ListCustomModelsOptions listOptions = + new ListCustomModelsOptions.Builder().language(MODEL_LANGUAGE).build(); + final CustomModels result = service.listCustomModels(listOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(VOICE_MODELS_PATH + "?language=" + MODEL_LANGUAGE, request.getPath()); @@ -173,10 +153,9 @@ public void testGetVoiceModel() throws InterruptedException { // Test with customization ID server.enqueue(jsonResponse(voiceModelWords)); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .build(); - VoiceModel result = service.getVoiceModel(getOptions).execute().getResult(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build(); + CustomModel result = service.getCustomModel(getOptions).execute().getResult(); RecordedRequest request = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), request.getPath()); @@ -196,12 +175,13 @@ public void testCreateVoiceModel() throws InterruptedException { // Create the custom voice model. server.enqueue(jsonResponse(voiceModel)); - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name(MODEL_NAME) - .language(MODEL_LANGUAGE) - .description(MODEL_DESCRIPTION) - .build(); - final VoiceModel result = service.createVoiceModel(createOptions).execute().getResult(); + CreateCustomModelOptions createOptions = + new CreateCustomModelOptions.Builder() + .name(MODEL_NAME) + .language(MODEL_LANGUAGE) + .description(MODEL_DESCRIPTION) + .build(); + final CustomModel result = service.createCustomModel(createOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(VOICE_MODELS_PATH, request.getPath()); @@ -211,10 +191,9 @@ public void testCreateVoiceModel() throws InterruptedException { // Compare expected with actual results. server.enqueue(jsonResponse(voiceModel)); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .build(); - final VoiceModel getResult = service.getVoiceModel(getOptions).execute().getResult(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build(); + final CustomModel getResult = service.getCustomModel(getOptions).execute().getResult(); final RecordedRequest getRequest = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath()); @@ -222,7 +201,6 @@ public void testCreateVoiceModel() throws InterruptedException { assertEquals(voiceModel, getResult); assertNull(voiceModel.getWords()); assertEquals(voiceModel.getWords(), getResult.getWords()); - } /** @@ -235,24 +213,26 @@ public void testUpdateVoiceModel() throws InterruptedException { // Create the custom voice model. server.enqueue(jsonResponse(voiceModel)); - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name(MODEL_NAME) - .language(MODEL_LANGUAGE) - .description(MODEL_DESCRIPTION) - .build(); - final VoiceModel result = service.createVoiceModel(createOptions).execute().getResult(); + CreateCustomModelOptions createOptions = + new CreateCustomModelOptions.Builder() + .name(MODEL_NAME) + .language(MODEL_LANGUAGE) + .description(MODEL_DESCRIPTION) + .build(); + final CustomModel result = service.createCustomModel(createOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(CUSTOMIZATION_ID, result.getCustomizationId()); // Update the custom voice model. server.enqueue(new MockResponse().setResponseCode(201)); - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .name(MODEL_NAME) - .description(MODEL_DESCRIPTION) - .build(); - service.updateVoiceModel(updateOptions).execute().getResult(); + UpdateCustomModelOptions updateOptions = + new UpdateCustomModelOptions.Builder() + .customizationId(CUSTOMIZATION_ID) + .name(MODEL_NAME) + .description(MODEL_DESCRIPTION) + .build(); + service.updateCustomModel(updateOptions).execute().getResult(); final RecordedRequest updateRequest = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), updateRequest.getPath()); @@ -261,10 +241,9 @@ public void testUpdateVoiceModel() throws InterruptedException { // Compare expected with actual results. server.enqueue(jsonResponse(voiceModel)); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .build(); - final VoiceModel getResult = service.getVoiceModel(getOptions).execute().getResult(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build(); + final CustomModel getResult = service.getCustomModel(getOptions).execute().getResult(); final RecordedRequest getRequest = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath()); @@ -284,24 +263,26 @@ public void testUpdateVoiceModelWords() throws InterruptedException { // Create the custom voice model. server.enqueue(jsonResponse(voiceModelWords)); - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name(MODEL_NAME) - .language(MODEL_LANGUAGE) - .description(MODEL_DESCRIPTION) - .build(); - final VoiceModel result = service.createVoiceModel(createOptions).execute().getResult(); + CreateCustomModelOptions createOptions = + new CreateCustomModelOptions.Builder() + .name(MODEL_NAME) + .language(MODEL_LANGUAGE) + .description(MODEL_DESCRIPTION) + .build(); + final CustomModel result = service.createCustomModel(createOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(CUSTOMIZATION_ID, result.getCustomizationId()); // Update the custom voice model with new words. server.enqueue(new MockResponse().setResponseCode(201)); - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .name(MODEL_NAME) - .description(MODEL_DESCRIPTION) - .words(instantiateWords()) - .build(); - service.updateVoiceModel(updateOptions).execute().getResult(); + UpdateCustomModelOptions updateOptions = + new UpdateCustomModelOptions.Builder() + .customizationId(CUSTOMIZATION_ID) + .name(MODEL_NAME) + .description(MODEL_DESCRIPTION) + .words(instantiateWords()) + .build(); + service.updateCustomModel(updateOptions).execute().getResult(); final RecordedRequest updateRequest = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), updateRequest.getPath()); @@ -310,10 +291,9 @@ public void testUpdateVoiceModelWords() throws InterruptedException { // Compare expected with actual results. server.enqueue(jsonResponse(voiceModelWords)); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .build(); - final VoiceModel getResult = service.getVoiceModel(getOptions).execute().getResult(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build(); + final CustomModel getResult = service.getCustomModel(getOptions).execute().getResult(); final RecordedRequest getRequest = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath()); @@ -331,10 +311,9 @@ public void testUpdateVoiceModelWords() throws InterruptedException { @Test public void testDeleteVoiceModel() throws InterruptedException { server.enqueue(new MockResponse().setResponseCode(204)); - DeleteVoiceModelOptions deleteOptions = new DeleteVoiceModelOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .build(); - service.deleteVoiceModel(deleteOptions).execute(); + DeleteCustomModelOptions deleteOptions = + new DeleteCustomModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build(); + service.deleteCustomModel(deleteOptions).execute(); final RecordedRequest request = server.takeRequest(); assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), request.getPath()); @@ -350,10 +329,15 @@ public void testDeleteVoiceModel() throws InterruptedException { public void testListWords() throws InterruptedException { final List expected = instantiateWords(); - server.enqueue(jsonResponse(ImmutableMap.of(WORDS, expected))); - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .build(); + server.enqueue( + hashmapToJsonResponse( + new HashMap>() { + { + put(WORDS, expected); + } + })); + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(CUSTOMIZATION_ID).build(); final Words result = service.listWords(listOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); @@ -371,15 +355,24 @@ public void testListWords() throws InterruptedException { public void testGetWord() throws InterruptedException { final Word expected = instantiateWords().get(0); - server.enqueue(jsonResponse(ImmutableMap.of(TRANSLATION, expected.translation()))); - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .word(expected.word()) - .build(); + Map map = + new HashMap() { + { + put(TRANSLATION, expected.translation()); + } + }; + + server.enqueue(hashmapToJsonResponse(map)); + GetWordOptions getOptions = + new GetWordOptions.Builder() + .customizationId(CUSTOMIZATION_ID) + .word(expected.word()) + .build(); final Translation result = service.getWord(getOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); - assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected.word(), request.getPath()); + assertEquals( + String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected.word(), request.getPath()); assertEquals("GET", request.getMethod()); assertEquals(expected.translation(), result.translation()); } @@ -394,10 +387,8 @@ public void testAddWords() throws InterruptedException { final List expected = instantiateWords(); server.enqueue(new MockResponse().setResponseCode(201)); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .words(expected) - .build(); + AddWordsOptions addOptions = + new AddWordsOptions.Builder().customizationId(CUSTOMIZATION_ID).words(expected).build(); service.addWords(addOptions).execute().getResult(); RecordedRequest request = server.takeRequest(); @@ -415,11 +406,12 @@ public void testAddWord() throws InterruptedException { final Word expected = instantiateWord(); server.enqueue(new MockResponse().setResponseCode(201)); - AddWordOptions addOptions = new AddWordOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .word(expected.word()) - .translation(expected.translation()) - .build(); + AddWordOptions addOptions = + new AddWordOptions.Builder() + .customizationId(CUSTOMIZATION_ID) + .word(expected.word()) + .translation(expected.translation()) + .build(); service.addWord(addOptions).execute().getResult(); RecordedRequest request = server.takeRequest(); @@ -437,15 +429,12 @@ public void testDeleteWord() throws InterruptedException { final String expected = instantiateWords().get(0).word(); server.enqueue(new MockResponse().setResponseCode(204)); - DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .word(expected) - .build(); + DeleteWordOptions deleteOptions = + new DeleteWordOptions.Builder().customizationId(CUSTOMIZATION_ID).word(expected).build(); service.deleteWord(deleteOptions).execute(); final RecordedRequest request = server.takeRequest(); assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected, request.getPath()); assertEquals("DELETE", request.getMethod()); } - } diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechIT.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechIT.java index f9b8dbac6af..8ac704c1099 100644 --- a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechIT.java +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2019, 2022. * * 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 @@ -12,17 +12,37 @@ */ package com.ibm.watson.text_to_speech.v1; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import com.ibm.cloud.sdk.core.http.HttpMediaType; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.IamAuthenticator; import com.ibm.watson.common.RetryRunner; import com.ibm.watson.common.WatsonServiceTest; +import com.ibm.watson.text_to_speech.v1.model.AddCustomPromptOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CustomModel; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteUserDataOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomPromptOptions; import com.ibm.watson.text_to_speech.v1.model.GetPronunciationOptions; +import com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions; import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions; import com.ibm.watson.text_to_speech.v1.model.MarkTiming; import com.ibm.watson.text_to_speech.v1.model.Marks; +import com.ibm.watson.text_to_speech.v1.model.Prompt; +import com.ibm.watson.text_to_speech.v1.model.PromptMetadata; +import com.ibm.watson.text_to_speech.v1.model.Prompts; import com.ibm.watson.text_to_speech.v1.model.Pronunciation; +import com.ibm.watson.text_to_speech.v1.model.SpeakerCustomModels; +import com.ibm.watson.text_to_speech.v1.model.SpeakerModel; +import com.ibm.watson.text_to_speech.v1.model.Speakers; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; import com.ibm.watson.text_to_speech.v1.model.Timings; import com.ibm.watson.text_to_speech.v1.model.Voice; @@ -30,13 +50,6 @@ import com.ibm.watson.text_to_speech.v1.model.WordTiming; import com.ibm.watson.text_to_speech.v1.util.WaveUtils; import com.ibm.watson.text_to_speech.v1.websocket.BaseSynthesizeCallback; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.UnsupportedAudioFileException; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -48,14 +61,13 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.UnsupportedAudioFileException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Text to Speech integration tests. - */ +/** Text to Speech integration tests. */ @RunWith(RetryRunner.class) public class TextToSpeechIT extends WatsonServiceTest { @@ -66,32 +78,47 @@ public class TextToSpeechIT extends WatsonServiceTest { private String returnedContentType; private List returnedTimings; private List returnedMarks; + private String customizationId; + private String speakerId; + private static final String RESOURCE = "src/test/resources/text_to_speech/"; + /** + * Sets up the tests. + * + * @throws Exception the exception + */ /* * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + * @see com.ibm.watson.common.WatsonServiceTest#setUp() */ @Override @Before public void setUp() throws Exception { super.setUp(); - String apiKey = getProperty("text_to_speech.apikey"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); + String apiKey = System.getenv("TEXT_TO_SPEECH_APIKEY"); + String serviceUrl = System.getenv("TEXT_TO_SPEECH_URL"); + + if (apiKey == null) { + apiKey = getProperty("text_to_speech.apikey"); + serviceUrl = getProperty("text_to_speech.url"); + } + + assertNotNull( + "TEXT_TO_SPEECH_APIKEY is not defined and config.properties doesn't have valid credentials.", + apiKey); Authenticator authenticator = new IamAuthenticator(apiKey); service = new TextToSpeech(authenticator); - service.setServiceUrl(getProperty("text_to_speech.url")); + service.setServiceUrl(serviceUrl); service.setDefaultHeaders(getDefaultHeaders()); - voiceName = getProperty("text_to_speech.voice_name"); + voiceName = "en-US_MichaelVoice"; byteArrayOutputStream = new ByteArrayOutputStream(); returnedTimings = new ArrayList<>(); returnedMarks = new ArrayList<>(); } - /** - * Test list voices. - */ + /** Test list voices. */ @Test public void testListVoices() { Voices voices = service.listVoices().execute().getResult(); @@ -104,14 +131,10 @@ public void testListVoices() { assertNotNull(voices.getVoices().get(0).getUrl()); } - /** - * Test get voice. - */ + /** Test get voice. */ @Test public void testGetVoice() { - GetVoiceOptions getOptions = new GetVoiceOptions.Builder() - .voice(voiceName) - .build(); + GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice(voiceName).build(); Voice voice = service.getVoice(getOptions).execute().getResult(); assertNotNull(voice); assertNotNull(voice.getDescription()); @@ -129,55 +152,57 @@ public void testGetVoice() { @Test public void testSynthesize() throws IOException { String text = "This is an integration test; 1,2 !, @, #, $, %, ^, 20."; - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_WAV) - .build(); + SynthesizeOptions synthesizeOptions = + new SynthesizeOptions.Builder() + .text(text) + .voice(SynthesizeOptions.Voice.EN_US_LISAV3VOICE) + .accept(HttpMediaType.AUDIO_WAV) + .build(); InputStream result = service.synthesize(synthesizeOptions).execute().getResult(); writeInputStreamToFile(result, File.createTempFile("tts-audio", "wav")); } - /** - * Test word pronunciation. - */ + /** Test word pronunciation. */ @Test public void testGetWordPronunciation() { String word = "Congressman"; - GetPronunciationOptions getOptions1 = new GetPronunciationOptions.Builder() - .text(word) - .voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE) - .format(GetPronunciationOptions.Format.IBM) - .build(); + GetPronunciationOptions getOptions1 = + new GetPronunciationOptions.Builder() + .text(word) + .voice(GetPronunciationOptions.Voice.EN_US_MICHAELV3VOICE) + .format(GetPronunciationOptions.Format.IBM) + .build(); Pronunciation pronunciation = service.getPronunciation(getOptions1).execute().getResult(); assertNotNull(pronunciation); assertNotNull(pronunciation.getPronunciation()); - GetPronunciationOptions getOptions2 = new GetPronunciationOptions.Builder() - .text(word) - .format(GetPronunciationOptions.Format.IBM) - .build(); + GetPronunciationOptions getOptions2 = + new GetPronunciationOptions.Builder() + .text(word) + .format(GetPronunciationOptions.Format.IBM) + .build(); pronunciation = service.getPronunciation(getOptions2).execute().getResult(); assertNotNull(pronunciation); assertNotNull(pronunciation.getPronunciation()); - GetPronunciationOptions getOptions3 = new GetPronunciationOptions.Builder() - .text(word) - .voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE) - .build(); + GetPronunciationOptions getOptions3 = + new GetPronunciationOptions.Builder() + .text(word) + .voice(GetPronunciationOptions.Voice.EN_US_MICHAELV3VOICE) + .build(); pronunciation = service.getPronunciation(getOptions3).execute().getResult(); assertNotNull(pronunciation); assertNotNull(pronunciation.getPronunciation()); - GetPronunciationOptions getOptions4 = new GetPronunciationOptions.Builder() - .text(word) - .voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE) - .format(GetPronunciationOptions.Format.IPA) - .build(); + GetPronunciationOptions getOptions4 = + new GetPronunciationOptions.Builder() + .text(word) + .voice(GetPronunciationOptions.Voice.EN_US_MICHAELV3VOICE) + .format(GetPronunciationOptions.Format.IPA) + .build(); pronunciation = service.getPronunciation(getOptions4).execute().getResult(); assertNotNull(pronunciation); assertNotNull(pronunciation.getPronunciation()); - } /** @@ -189,11 +214,12 @@ public void testGetWordPronunciation() { @Test public void testSynthesizeAndFixHeader() throws IOException, UnsupportedAudioFileException { String text = "one two three four five"; - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_WAV) - .build(); + SynthesizeOptions synthesizeOptions = + new SynthesizeOptions.Builder() + .text(text) + .voice(SynthesizeOptions.Voice.EN_US_LISAV3VOICE) + .accept(HttpMediaType.AUDIO_WAV) + .build(); InputStream result = service.synthesize(synthesizeOptions).execute().getResult(); assertNotNull(result); result = WaveUtils.reWriteWaveHeader(result); @@ -202,54 +228,64 @@ public void testSynthesizeAndFixHeader() throws IOException, UnsupportedAudioFil assertNotNull(AudioSystem.getAudioFileFormat(tempFile)); } + /** Test delete user data. */ @Test public void testDeleteUserData() { String customerId = "java_sdk_test_id"; try { - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); + DeleteUserDataOptions deleteOptions = + new DeleteUserDataOptions.Builder().customerId(customerId).build(); service.deleteUserData(deleteOptions); } catch (Exception ex) { fail(ex.getMessage()); } } + /** + * Test synthesize using web socket. + * + * @throws InterruptedException the interrupted exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testSynthesizeUsingWebSocket() throws InterruptedException, IOException { - String basicText = "One taught me love. One taught me patience, and one taught me pain. Now, I'm so amazing. Say " - + "I've loved and I've lost, but that's not what I see. So, look what I got. Look what you taught me. And for " - + "that, I say... thank u, next."; - - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(basicText) - .voice(SynthesizeOptions.Voice.EN_US_ALLISONVOICE) - .accept(HttpMediaType.AUDIO_OGG) - .timings(Collections.singletonList("words")) - .build(); - - service.synthesizeUsingWebSocket(synthesizeOptions, new BaseSynthesizeCallback() { - @Override - public void onContentType(String contentType) { - returnedContentType = contentType; - } - - @Override - public void onAudioStream(byte[] bytes) { - // build byte array of synthesized text - try { - byteArrayOutputStream.write(bytes); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void onTimings(Timings timings) { - returnedTimings.add(timings); - } - }); + String basicText = + "One taught me love. One taught me patience, and one taught me pain. Now, I'm so amazing. Say " + + "I've loved and I've lost, but that's not what I see. So, look what I got." + + " Look what you taught me. And for that, I say... thank u, next."; + + SynthesizeOptions synthesizeOptions = + new SynthesizeOptions.Builder() + .text(basicText) + .voice(SynthesizeOptions.Voice.EN_US_ALLISONV3VOICE) + .accept(HttpMediaType.AUDIO_OGG) + .timings(Collections.singletonList("words")) + .build(); + + service.synthesizeUsingWebSocket( + synthesizeOptions, + new BaseSynthesizeCallback() { + @Override + public void onContentType(String contentType) { + returnedContentType = contentType; + } + + @Override + public void onAudioStream(byte[] bytes) { + // build byte array of synthesized text + try { + byteArrayOutputStream.write(bytes); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void onTimings(Timings timings) { + returnedTimings.add(timings); + } + }); // wait for synthesis to complete lock.await(5, TimeUnit.SECONDS); @@ -278,27 +314,39 @@ public void onTimings(Timings timings) { } } + /** + * Test synthesize using web socket with ssml. + * + * @throws InterruptedException the interrupted exception + */ @Test public void testSynthesizeUsingWebSocketWithSsml() throws InterruptedException { List ssmlMarks = new ArrayList<>(); ssmlMarks.add("sean"); ssmlMarks.add("ricky"); - String ssmlText = String.format("Thought I'd end up with Sean, " - + "but he wasn't a match. Wrote some songs about Ricky, now I listen and " - + "laugh", ssmlMarks.get(0), ssmlMarks.get(1)); - - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(ssmlText) - .voice(SynthesizeOptions.Voice.EN_US_ALLISONVOICE) - .accept(HttpMediaType.AUDIO_OGG) - .build(); - - service.synthesizeUsingWebSocket(synthesizeOptions, new BaseSynthesizeCallback() { - @Override - public void onMarks(Marks marks) { - returnedMarks.add(marks); - } - }); + String ssmlText = + String.format( + "Thought I'd end up with Sean, " + + "but he wasn't a match. Wrote some songs " + + "about Ricky, now I listen and " + + "laugh", + ssmlMarks.get(0), ssmlMarks.get(1)); + + SynthesizeOptions synthesizeOptions = + new SynthesizeOptions.Builder() + .text(ssmlText) + .voice(SynthesizeOptions.Voice.EN_US_ALLISONV3VOICE) + .accept(HttpMediaType.AUDIO_OGG) + .build(); + + service.synthesizeUsingWebSocket( + synthesizeOptions, + new BaseSynthesizeCallback() { + @Override + public void onMarks(Marks marks) { + returnedMarks.add(marks); + } + }); // wait for synthesis to complete lock.await(5, TimeUnit.SECONDS); @@ -310,4 +358,228 @@ public void onMarks(Marks marks) { } } } + + /** Test listCustomPrompts. */ + @Test + public void testListCustomPrompts() { + CreateCustomModelOptions createCustomModelOptions = + new CreateCustomModelOptions.Builder() + .description("testdescription") + .name("testname") + .language(CreateCustomModelOptions.Language.EN_US) + .build(); + CustomModel customModel = + service.createCustomModel(createCustomModelOptions).execute().getResult(); + + customizationId = customModel.getCustomizationId(); + ListCustomPromptsOptions listCustomPromptsOptions = + new ListCustomPromptsOptions.Builder().customizationId(customizationId).build(); + Prompts prompts = service.listCustomPrompts(listCustomPromptsOptions).execute().getResult(); + + assertNotNull(prompts.getPrompts()); + + DeleteCustomModelOptions deleteCustomModelOptions = + new DeleteCustomModelOptions.Builder().customizationId(customizationId).build(); + service.deleteCustomModel(deleteCustomModelOptions).execute().getResult(); + } + + /** Test addCustomPrompts. */ + @Test + public void testAddCustomPrompts() { + try { + CreateCustomModelOptions createCustomModelOptions = + new CreateCustomModelOptions.Builder() + .description("testdescription") + .name("testname") + .language(CreateCustomModelOptions.Language.EN_US) + .build(); + CustomModel customModel = + service.createCustomModel(createCustomModelOptions).execute().getResult(); + customizationId = customModel.getCustomizationId(); + + PromptMetadata promptMetadata = new PromptMetadata.Builder().promptText("promptText").build(); + File file = new File(RESOURCE + "numbers.wav"); + AddCustomPromptOptions addCustomPromptOptions = + new AddCustomPromptOptions.Builder() + .customizationId(customizationId) + .promptId("testId") + .metadata(promptMetadata) + .file(file) + .build(); + Prompt prompt = service.addCustomPrompt(addCustomPromptOptions).execute().getResult(); + + assertNotNull(prompt.getStatus()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteCustomModelOptions deleteCustomModelOptions = + new DeleteCustomModelOptions.Builder().customizationId(customizationId).build(); + service.deleteCustomModel(deleteCustomModelOptions).execute().getResult(); + } + } + + /** Test getCustomPrompts. */ + @Test + public void testGetCustomPrompts() { + try { + CreateCustomModelOptions createCustomModelOptions = + new CreateCustomModelOptions.Builder() + .description("testdescription") + .name("testname") + .language(CreateCustomModelOptions.Language.EN_US) + .build(); + CustomModel customModel = + service.createCustomModel(createCustomModelOptions).execute().getResult(); + customizationId = customModel.getCustomizationId(); + + PromptMetadata promptMetadata = new PromptMetadata.Builder().promptText("promptText").build(); + File file = new File(RESOURCE + "numbers.wav"); + AddCustomPromptOptions addCustomPromptOptions = + new AddCustomPromptOptions.Builder() + .customizationId(customizationId) + .promptId("testId") + .metadata(promptMetadata) + .file(file) + .build(); + Prompt prompt = service.addCustomPrompt(addCustomPromptOptions).execute().getResult(); + + assertNotNull(prompt.getStatus()); + + GetCustomPromptOptions getCustomPromptOptions = + new GetCustomPromptOptions.Builder() + .customizationId(customizationId) + .promptId("testId") + .build(); + Prompt prompt1 = service.getCustomPrompt(getCustomPromptOptions).execute().getResult(); + + assertNotNull(prompt1.getStatus()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteCustomModelOptions deleteCustomModelOptions = + new DeleteCustomModelOptions.Builder().customizationId(customizationId).build(); + service.deleteCustomModel(deleteCustomModelOptions).execute().getResult(); + } + } + + /** Test deleteCustomPrompts. */ + @Test + public void testDeleteCustomPrompts() { + try { + CreateCustomModelOptions createCustomModelOptions = + new CreateCustomModelOptions.Builder() + .description("testdescription") + .name("testname") + .language(CreateCustomModelOptions.Language.EN_US) + .build(); + CustomModel customModel = + service.createCustomModel(createCustomModelOptions).execute().getResult(); + customizationId = customModel.getCustomizationId(); + + PromptMetadata promptMetadata = new PromptMetadata.Builder().promptText("promptText").build(); + File file = new File(RESOURCE + "numbers.wav"); + AddCustomPromptOptions addCustomPromptOptions = + new AddCustomPromptOptions.Builder() + .customizationId(customizationId) + .promptId("testId") + .metadata(promptMetadata) + .file(file) + .build(); + Prompt prompt = service.addCustomPrompt(addCustomPromptOptions).execute().getResult(); + + assertNotNull(prompt.getStatus()); + + DeleteCustomPromptOptions deleteCustomPromptOptions = + new DeleteCustomPromptOptions.Builder() + .customizationId(customizationId) + .promptId(prompt.getPromptId()) + .build(); + service.deleteCustomPrompt(deleteCustomPromptOptions).execute().getResult(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteCustomModelOptions deleteCustomModelOptions = + new DeleteCustomModelOptions.Builder().customizationId(customizationId).build(); + service.deleteCustomModel(deleteCustomModelOptions).execute().getResult(); + } + } + + /** Test createSpeakerModel. */ + @Test + public void testCreateSpeakerModel() { + try { + CreateSpeakerModelOptions createSpeakerModelOptions = + new CreateSpeakerModelOptions.Builder() + .speakerName("speakerName") + .audio(new File(RESOURCE + "numbers.wav")) + .build(); + SpeakerModel speakerModel = + service.createSpeakerModel(createSpeakerModelOptions).execute().getResult(); + + speakerId = speakerModel.getSpeakerId(); + assertNotNull(speakerModel.getSpeakerId()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteSpeakerModelOptions deleteSpeakerModelOptions = + new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build(); + service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult(); + } + } + + /** Test listSpeakerModel. */ + @Test + public void testListSpeakerModel() { + try { + CreateSpeakerModelOptions createSpeakerModelOptions = + new CreateSpeakerModelOptions.Builder() + .speakerName("speakerName") + .audio(new File(RESOURCE + "numbers.wav")) + .build(); + SpeakerModel speakerModel = + service.createSpeakerModel(createSpeakerModelOptions).execute().getResult(); + + speakerId = speakerModel.getSpeakerId(); + assertNotNull(speakerModel.getSpeakerId()); + + Speakers speakers = service.listSpeakerModels().execute().getResult(); + assertNotNull(speakers.getSpeakers()); + assertTrue(speakers.getSpeakers().size() > 0); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteSpeakerModelOptions deleteSpeakerModelOptions = + new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build(); + service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult(); + } + } + + /** Test getSpeakerModel. */ + @Test + public void testGetSpeakerModel() { + try { + CreateSpeakerModelOptions createSpeakerModelOptions = + new CreateSpeakerModelOptions.Builder() + .speakerName("speakerName") + .audio(new File(RESOURCE + "numbers.wav")) + .build(); + SpeakerModel speakerModel = + service.createSpeakerModel(createSpeakerModelOptions).execute().getResult(); + + speakerId = speakerModel.getSpeakerId(); + assertNotNull(speakerModel.getSpeakerId()); + + GetSpeakerModelOptions getSpeakerModelOptions = + new GetSpeakerModelOptions.Builder().speakerId(speakerId).build(); + SpeakerCustomModels speakerCustomModels = + service.getSpeakerModel(getSpeakerModelOptions).execute().getResult(); + assertNotNull(speakerCustomModels.getCustomizations()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + DeleteSpeakerModelOptions deleteSpeakerModelOptions = + new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build(); + service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult(); + } + } } diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java index c5bed604584..856b34c6f77 100644 --- a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019. + * (C) Copyright IBM Corp. 2019, 2024. * * 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 @@ -10,261 +10,1337 @@ * 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.text_to_speech.v1; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.common.TestUtils; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.model.AddCustomPromptOptions; +import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; +import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CustomModel; +import com.ibm.watson.text_to_speech.v1.model.CustomModels; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteUserDataOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomPromptOptions; +import com.ibm.watson.text_to_speech.v1.model.GetPronunciationOptions; +import com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions; import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; +import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListSpeakerModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions; +import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; +import com.ibm.watson.text_to_speech.v1.model.Prompt; +import com.ibm.watson.text_to_speech.v1.model.PromptMetadata; +import com.ibm.watson.text_to_speech.v1.model.Prompts; +import com.ibm.watson.text_to_speech.v1.model.Pronunciation; +import com.ibm.watson.text_to_speech.v1.model.SpeakerCustomModels; +import com.ibm.watson.text_to_speech.v1.model.SpeakerModel; +import com.ibm.watson.text_to_speech.v1.model.Speakers; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; +import com.ibm.watson.text_to_speech.v1.model.Translation; +import com.ibm.watson.text_to_speech.v1.model.UpdateCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.Voice; import com.ibm.watson.text_to_speech.v1.model.Voices; -import com.ibm.watson.text_to_speech.v1.util.WaveUtils; -import okhttp3.HttpUrl; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.UnsupportedAudioFileException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; +import com.ibm.watson.text_to_speech.v1.model.Word; +import com.ibm.watson.text_to_speech.v1.model.Words; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +/** Unit test class for the TextToSpeech service. */ +public class TextToSpeechTest { -/** - * The Class TextToSpeechTest. - */ -@FixMethodOrder(MethodSorters.JVM) -public class TextToSpeechTest extends WatsonServiceUnitTest { - - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - private static final String GET_VOICES_PATH = "/v1/voices"; - private static final String SYNTHESIZE_PATH = "/v1/synthesize"; - - private Voice getVoiceResponse; - private Voices listVoicesResponse; - - /** - * Write input stream to output stream. - * - * @param inputStream the input stream - * @param outputStream the output stream - */ - private static void writeInputStreamToOutputStream(InputStream inputStream, OutputStream outputStream) { - try { - try { - final byte[] buffer = new byte[1024]; - int read; - - while ((read = inputStream.read(buffer)) != -1) { - outputStream.write(buffer, 0, read); - } - - outputStream.flush(); - } catch (final Exception e) { - e.printStackTrace(); - } finally { - outputStream.close(); - inputStream.close(); - } - } catch (final Exception e) { - e.printStackTrace(); - } + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected TextToSpeech textToSpeechService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + new TextToSpeech(serviceName, null); + } + + // Test the listVoices operation with a valid options model parameter + @Test + public void testListVoicesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"voices\": [{\"url\": \"url\", \"gender\": \"gender\", \"name\": \"name\", \"language\": \"language\", \"description\": \"description\", \"customizable\": true, \"supported_features\": {\"custom_pronunciation\": false, \"voice_transformation\": false}, \"customization\": {\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}}]}"; + String listVoicesPath = "/v1/voices"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListVoicesOptions model + ListVoicesOptions listVoicesOptionsModel = new ListVoicesOptions(); + + // Invoke listVoices() with a valid options model and verify the result + Response response = textToSpeechService.listVoices(listVoicesOptionsModel).execute(); + assertNotNull(response); + Voices responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listVoicesPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); } - /** The service. */ - private TextToSpeech service; + // Test the listVoices operation with and without retries enabled + @Test + public void testListVoicesWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testListVoicesWOptions(); - /** The text. */ - private final String text = "IBM Watson Developer Cloud"; + textToSpeechService.disableRetries(); + testListVoicesWOptions(); + } - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); + // Test the getVoice operation with a valid options model parameter + @Test + public void testGetVoiceWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"url\": \"url\", \"gender\": \"gender\", \"name\": \"name\", \"language\": \"language\", \"description\": \"description\", \"customizable\": true, \"supported_features\": {\"custom_pronunciation\": false, \"voice_transformation\": false}, \"customization\": {\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}}"; + String getVoicePath = "/v1/voices/de-DE_BirgitV3Voice"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - service = new TextToSpeech(new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); + // Construct an instance of the GetVoiceOptions model + GetVoiceOptions getVoiceOptionsModel = + new GetVoiceOptions.Builder() + .voice("de-DE_BirgitV3Voice") + .customizationId("testString") + .build(); - getVoiceResponse = loadFixture("src/test/resources/text_to_speech/get_voice_response.json", Voice.class); - listVoicesResponse = loadFixture("src/test/resources/text_to_speech/list_voices_response.json", Voices.class); + // Invoke getVoice() with a valid options model and verify the result + Response response = textToSpeechService.getVoice(getVoiceOptionsModel).execute(); + assertNotNull(response); + Voice responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getVoicePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("customization_id"), "testString"); } - /** - * Test list voices. - * - * @throws InterruptedException the interrupted exception - */ + // Test the getVoice operation with and without retries enabled @Test - public void testListVoices() throws InterruptedException { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(listVoicesResponse))); + public void testGetVoiceWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetVoiceWOptions(); - final Voices result = service.listVoices().execute().getResult(); - final RecordedRequest request = server.takeRequest(); + textToSpeechService.disableRetries(); + testGetVoiceWOptions(); + } - assertEquals(GET_VOICES_PATH, request.getPath()); - assertNotNull(result); - assertFalse(result.getVoices().isEmpty()); - assertEquals(listVoicesResponse.getVoices(), result.getVoices()); + // Test the getVoice operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetVoiceNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.getVoice(null).execute(); } - /** - * Test get voice. - */ + // Test the synthesize operation with a valid options model parameter @Test - public void testGetVoice() { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(getVoiceResponse))); + public void testSynthesizeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "This is a mock binary response."; + String synthesizePath = "/v1/synthesize"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "audio/alaw") + .setResponseCode(200) + .setBody(mockResponseBody)); - GetVoiceOptions getOptions = new GetVoiceOptions.Builder() - .voice("en-US_TestMaleVoice") - .build(); - Voice result = service.getVoice(getOptions).execute().getResult(); - assertNotNull(result); - assertEquals(result, getVoiceResponse); + // Construct an instance of the SynthesizeOptions model + SynthesizeOptions synthesizeOptionsModel = + new SynthesizeOptions.Builder() + .text("testString") + .accept("audio/ogg;codecs=opus") + .voice("en-US_MichaelV3Voice") + .customizationId("testString") + .spellOutMode("default") + .ratePercentage(Long.valueOf("0")) + .pitchPercentage(Long.valueOf("0")) + .build(); - try { - TestUtils.assertNoExceptionsOnGetters(result); - } catch (final Exception e) { - Assert.fail(e.getMessage()); + // Invoke synthesize() with a valid options model and verify the result + Response response = + textToSpeechService.synthesize(synthesizeOptionsModel).execute(); + assertNotNull(response); + try (InputStream responseObj = response.getResult(); ) { + assertNotNull(responseObj); } + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, synthesizePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("voice"), "en-US_MichaelV3Voice"); + assertEquals(query.get("customization_id"), "testString"); + assertEquals(query.get("spell_out_mode"), "default"); + assertEquals(Long.valueOf(query.get("rate_percentage")), Long.valueOf("0")); + assertEquals(Long.valueOf(query.get("pitch_percentage")), Long.valueOf("0")); } - /** - * Test synthesize. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @SuppressWarnings("resource") - @Test - public void testSynthesize() throws IOException, InterruptedException { - final File audio = new File("src/test/resources/text_to_speech/sample1.wav"); - final Buffer buffer = new Buffer().write(Files.toByteArray(audio)); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.AUDIO_WAV).setBody(buffer)); - - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_PCM + "; rate=16000") - .build(); - final InputStream in = service.synthesize(synthesizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - final HttpUrl requestUrl = HttpUrl.parse("http://www.example.com" + request.getPath()); - - assertEquals(request.getBody().readUtf8(), "{\"text\":\"" + text + "\"}"); - assertEquals(SYNTHESIZE_PATH, requestUrl.encodedPath()); - assertEquals(SynthesizeOptions.Voice.EN_US_LISAVOICE, requestUrl.queryParameter("voice")); - assertEquals(HttpMediaType.AUDIO_PCM + "; rate=16000", request.getHeader("Accept")); - assertNotNull(in); - - writeInputStreamToOutputStream(in, new FileOutputStream("build/output.wav")); - } - - /** - * Test synthesize for WebM. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @SuppressWarnings("resource") - @Test - public void testSynthesizeWebM() throws IOException, InterruptedException { - final File audio = new File("src/test/resources/text_to_speech/sample1.webm"); - final Buffer buffer = new Buffer().write(Files.toByteArray(audio)); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.AUDIO_WEBM).setBody(buffer)); - - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_WEBM) - .build(); - final InputStream in = service.synthesize(synthesizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - final HttpUrl requestUrl = HttpUrl.parse("http://www.example.com" + request.getPath()); - - assertEquals(request.getBody().readUtf8(), "{\"text\":\"" + text + "\"}"); - assertEquals(SYNTHESIZE_PATH, requestUrl.encodedPath()); - assertEquals(SynthesizeOptions.Voice.EN_US_LISAVOICE, requestUrl.queryParameter("voice")); - assertEquals(HttpMediaType.AUDIO_WEBM, request.getHeader("Accept")); - assertNotNull(in); - - writeInputStreamToOutputStream(in, new FileOutputStream("build/output.webm")); - } - - /** - * Test with voice as AudioFormat.WAV. - */ - // @Test - public void testWithVoiceAsWav() { - SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_WAV) - .build(); - final InputStream is = service.synthesize(synthesizeOptions).execute().getResult(); - assertNotNull(is); + // Test the synthesize operation with and without retries enabled + @Test + public void testSynthesizeWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testSynthesizeWOptions(); - try { - writeInputStreamToOutputStream(is, new FileOutputStream("target/output.wav")); - } catch (final FileNotFoundException e) { - Assert.fail(e.getMessage()); - } + textToSpeechService.disableRetries(); + testSynthesizeWOptions(); + } + + // Test the synthesize operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSynthesizeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.synthesize(null).execute(); + } + + // Test the getPronunciation operation with a valid options model parameter + @Test + public void testGetPronunciationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"pronunciation\": \"pronunciation\"}"; + String getPronunciationPath = "/v1/pronunciation"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetPronunciationOptions model + GetPronunciationOptions getPronunciationOptionsModel = + new GetPronunciationOptions.Builder() + .text("testString") + .voice("en-US_MichaelV3Voice") + .format("ipa") + .customizationId("testString") + .build(); + + // Invoke getPronunciation() with a valid options model and verify the result + Response response = + textToSpeechService.getPronunciation(getPronunciationOptionsModel).execute(); + assertNotNull(response); + Pronunciation responseObj = response.getResult(); + assertNotNull(responseObj); + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getPronunciationPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("text"), "testString"); + assertEquals(query.get("voice"), "en-US_MichaelV3Voice"); + assertEquals(query.get("format"), "ipa"); + assertEquals(query.get("customization_id"), "testString"); } - /** - * Test the fix wave header not having the size due to be streamed. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws UnsupportedAudioFileException the unsupported audio file exception - */ + // Test the getPronunciation operation with and without retries enabled @Test - public void testSynthesizeAndFixHeader() throws IOException, UnsupportedAudioFileException { - File audio = new File("src/test/resources/text_to_speech/numbers.wav"); - InputStream stream = new FileInputStream(audio); - assertNotNull(stream); - stream = WaveUtils.reWriteWaveHeader(stream); - File tempFile = File.createTempFile("output", ".wav"); - writeInputStreamToFile(stream, tempFile); - assertNotNull(AudioSystem.getAudioFileFormat(tempFile)); + public void testGetPronunciationWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetPronunciationWOptions(); + + textToSpeechService.disableRetries(); + testGetPronunciationWOptions(); + } + + // Test the getPronunciation operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPronunciationNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.getPronunciation(null).execute(); + } + + // Test the createCustomModel operation with a valid options model parameter + @Test + public void testCreateCustomModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}"; + String createCustomModelPath = "/v1/customizations"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateCustomModelOptions model + CreateCustomModelOptions createCustomModelOptionsModel = + new CreateCustomModelOptions.Builder() + .name("testString") + .language("en-US") + .description("testString") + .build(); + + // Invoke createCustomModel() with a valid options model and verify the result + Response response = + textToSpeechService.createCustomModel(createCustomModelOptionsModel).execute(); + assertNotNull(response); + CustomModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCustomModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createCustomModel operation with and without retries enabled + @Test + public void testCreateCustomModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testCreateCustomModelWOptions(); + + textToSpeechService.disableRetries(); + testCreateCustomModelWOptions(); + } + + // Test the createCustomModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCustomModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.createCustomModel(null).execute(); + } + + // Test the listCustomModels operation with a valid options model parameter + @Test + public void testListCustomModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}]}"; + String listCustomModelsPath = "/v1/customizations"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListCustomModelsOptions model + ListCustomModelsOptions listCustomModelsOptionsModel = + new ListCustomModelsOptions.Builder().language("de-DE").build(); + + // Invoke listCustomModels() with a valid options model and verify the result + Response response = + textToSpeechService.listCustomModels(listCustomModelsOptionsModel).execute(); + assertNotNull(response); + CustomModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCustomModelsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("language"), "de-DE"); } + // Test the listCustomModels operation with and without retries enabled @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "java_sdk_test_id"; + public void testListCustomModelsWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testListCustomModelsWOptions(); + + textToSpeechService.disableRetries(); + testListCustomModelsWOptions(); + } + + // Test the updateCustomModel operation with a valid options model parameter + @Test + public void testUpdateCustomModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String updateCustomModelPath = "/v1/customizations/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the Word model + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + + // Construct an instance of the UpdateCustomModelOptions model + UpdateCustomModelOptions updateCustomModelOptionsModel = + new UpdateCustomModelOptions.Builder() + .customizationId("testString") + .name("testString") + .description("testString") + .words(java.util.Arrays.asList(wordModel)) + .build(); + + // Invoke updateCustomModel() with a valid options model and verify the result + Response response = + textToSpeechService.updateCustomModel(updateCustomModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCustomModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateCustomModel operation with and without retries enabled + @Test + public void testUpdateCustomModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testUpdateCustomModelWOptions(); + + textToSpeechService.disableRetries(); + testUpdateCustomModelWOptions(); + } + + // Test the updateCustomModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCustomModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.updateCustomModel(null).execute(); + } + + // Test the getCustomModel operation with a valid options model parameter + @Test + public void testGetCustomModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}"; + String getCustomModelPath = "/v1/customizations/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCustomModelOptions model + GetCustomModelOptions getCustomModelOptionsModel = + new GetCustomModelOptions.Builder().customizationId("testString").build(); + + // Invoke getCustomModel() with a valid options model and verify the result + Response response = + textToSpeechService.getCustomModel(getCustomModelOptionsModel).execute(); + assertNotNull(response); + CustomModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCustomModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getCustomModel operation with and without retries enabled + @Test + public void testGetCustomModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetCustomModelWOptions(); + + textToSpeechService.disableRetries(); + testGetCustomModelWOptions(); + } + + // Test the getCustomModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCustomModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.getCustomModel(null).execute(); + } + + // Test the deleteCustomModel operation with a valid options model parameter + @Test + public void testDeleteCustomModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteCustomModelPath = "/v1/customizations/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteCustomModelOptions model + DeleteCustomModelOptions deleteCustomModelOptionsModel = + new DeleteCustomModelOptions.Builder().customizationId("testString").build(); + + // Invoke deleteCustomModel() with a valid options model and verify the result + Response response = + textToSpeechService.deleteCustomModel(deleteCustomModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCustomModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteCustomModel operation with and without retries enabled + @Test + public void testDeleteCustomModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testDeleteCustomModelWOptions(); + + textToSpeechService.disableRetries(); + testDeleteCustomModelWOptions(); + } + + // Test the deleteCustomModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCustomModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.deleteCustomModel(null).execute(); + } + + // Test the addWords operation with a valid options model parameter + @Test + public void testAddWordsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addWordsPath = "/v1/customizations/testString/words"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the Word model + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + + // Construct an instance of the AddWordsOptions model + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(java.util.Arrays.asList(wordModel)) + .build(); + + // Invoke addWords() with a valid options model and verify the result + Response response = textToSpeechService.addWords(addWordsOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the addWords operation with and without retries enabled + @Test + public void testAddWordsWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testAddWordsWOptions(); + + textToSpeechService.disableRetries(); + testAddWordsWOptions(); + } + + // Test the addWords operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.addWords(null).execute(); + } + + // Test the listWords operation with a valid options model parameter + @Test + public void testListWordsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}"; + String listWordsPath = "/v1/customizations/testString/words"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListWordsOptions model + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder().customizationId("testString").build(); + + // Invoke listWords() with a valid options model and verify the result + Response response = textToSpeechService.listWords(listWordsOptionsModel).execute(); + assertNotNull(response); + Words responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listWordsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listWords operation with and without retries enabled + @Test + public void testListWordsWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testListWordsWOptions(); + + textToSpeechService.disableRetries(); + testListWordsWOptions(); + } + + // Test the listWords operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.listWords(null).execute(); + } + + // Test the addWord operation with a valid options model parameter + @Test + public void testAddWordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String addWordPath = "/v1/customizations/testString/words/testString"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the AddWordOptions model + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + + // Invoke addWord() with a valid options model and verify the result + Response response = textToSpeechService.addWord(addWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the addWord operation with and without retries enabled + @Test + public void testAddWordWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testAddWordWOptions(); + + textToSpeechService.disableRetries(); + testAddWordWOptions(); + } + + // Test the addWord operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.addWord(null).execute(); + } + + // Test the getWord operation with a valid options model parameter + @Test + public void testGetWordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}"; + String getWordPath = "/v1/customizations/testString/words/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetWordOptions model + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").word("testString").build(); + + // Invoke getWord() with a valid options model and verify the result + Response response = textToSpeechService.getWord(getWordOptionsModel).execute(); + assertNotNull(response); + Translation responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getWordPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getWord operation with and without retries enabled + @Test + public void testGetWordWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetWordWOptions(); + + textToSpeechService.disableRetries(); + testGetWordWOptions(); + } + + // Test the getWord operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.getWord(null).execute(); + } + + // Test the deleteWord operation with a valid options model parameter + @Test + public void testDeleteWordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteWordPath = "/v1/customizations/testString/words/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteWordOptions model + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder().customizationId("testString").word("testString").build(); + + // Invoke deleteWord() with a valid options model and verify the result + Response response = textToSpeechService.deleteWord(deleteWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteWordPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteWord operation with and without retries enabled + @Test + public void testDeleteWordWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testDeleteWordWOptions(); + + textToSpeechService.disableRetries(); + testDeleteWordWOptions(); + } + + // Test the deleteWord operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.deleteWord(null).execute(); + } + + // Test the listCustomPrompts operation with a valid options model parameter + @Test + public void testListCustomPromptsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}"; + String listCustomPromptsPath = "/v1/customizations/testString/prompts"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListCustomPromptsOptions model + ListCustomPromptsOptions listCustomPromptsOptionsModel = + new ListCustomPromptsOptions.Builder().customizationId("testString").build(); + + // Invoke listCustomPrompts() with a valid options model and verify the result + Response response = + textToSpeechService.listCustomPrompts(listCustomPromptsOptionsModel).execute(); + assertNotNull(response); + Prompts responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCustomPromptsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listCustomPrompts operation with and without retries enabled + @Test + public void testListCustomPromptsWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testListCustomPromptsWOptions(); + + textToSpeechService.disableRetries(); + testListCustomPromptsWOptions(); + } + + // Test the listCustomPrompts operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCustomPromptsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.listCustomPrompts(null).execute(); + } + + // Test the addCustomPrompt operation with a valid options model parameter + @Test + public void testAddCustomPromptWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}"; + String addCustomPromptPath = "/v1/customizations/testString/prompts/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the PromptMetadata model + PromptMetadata promptMetadataModel = + new PromptMetadata.Builder().promptText("testString").speakerId("testString").build(); + + // Construct an instance of the AddCustomPromptOptions model + AddCustomPromptOptions addCustomPromptOptionsModel = + new AddCustomPromptOptions.Builder() + .customizationId("testString") + .promptId("testString") + .metadata(promptMetadataModel) + .file(TestUtilities.createMockStream("This is a mock file.")) + .build(); + + // Invoke addCustomPrompt() with a valid options model and verify the result + Response response = + textToSpeechService.addCustomPrompt(addCustomPromptOptionsModel).execute(); + assertNotNull(response); + Prompt responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addCustomPromptPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the addCustomPrompt operation with and without retries enabled + @Test + public void testAddCustomPromptWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testAddCustomPromptWOptions(); + + textToSpeechService.disableRetries(); + testAddCustomPromptWOptions(); + } + + // Test the addCustomPrompt operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddCustomPromptNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.addCustomPrompt(null).execute(); + } + + // Test the getCustomPrompt operation with a valid options model parameter + @Test + public void testGetCustomPromptWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}"; + String getCustomPromptPath = "/v1/customizations/testString/prompts/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCustomPromptOptions model + GetCustomPromptOptions getCustomPromptOptionsModel = + new GetCustomPromptOptions.Builder() + .customizationId("testString") + .promptId("testString") + .build(); + + // Invoke getCustomPrompt() with a valid options model and verify the result + Response response = + textToSpeechService.getCustomPrompt(getCustomPromptOptionsModel).execute(); + assertNotNull(response); + Prompt responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCustomPromptPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getCustomPrompt operation with and without retries enabled + @Test + public void testGetCustomPromptWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetCustomPromptWOptions(); + + textToSpeechService.disableRetries(); + testGetCustomPromptWOptions(); + } + + // Test the getCustomPrompt operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCustomPromptNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.getCustomPrompt(null).execute(); + } + + // Test the deleteCustomPrompt operation with a valid options model parameter + @Test + public void testDeleteCustomPromptWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteCustomPromptPath = "/v1/customizations/testString/prompts/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteCustomPromptOptions model + DeleteCustomPromptOptions deleteCustomPromptOptionsModel = + new DeleteCustomPromptOptions.Builder() + .customizationId("testString") + .promptId("testString") + .build(); + + // Invoke deleteCustomPrompt() with a valid options model and verify the result + Response response = + textToSpeechService.deleteCustomPrompt(deleteCustomPromptOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCustomPromptPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteCustomPrompt operation with and without retries enabled + @Test + public void testDeleteCustomPromptWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testDeleteCustomPromptWOptions(); + + textToSpeechService.disableRetries(); + testDeleteCustomPromptWOptions(); + } + + // Test the deleteCustomPrompt operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCustomPromptNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.deleteCustomPrompt(null).execute(); + } + + // Test the listSpeakerModels operation with a valid options model parameter + @Test + public void testListSpeakerModelsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"speakers\": [{\"speaker_id\": \"speakerId\", \"name\": \"name\"}]}"; + String listSpeakerModelsPath = "/v1/speakers"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListSpeakerModelsOptions model + ListSpeakerModelsOptions listSpeakerModelsOptionsModel = new ListSpeakerModelsOptions(); + + // Invoke listSpeakerModels() with a valid options model and verify the result + Response response = + textToSpeechService.listSpeakerModels(listSpeakerModelsOptionsModel).execute(); + assertNotNull(response); + Speakers responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listSpeakerModelsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listSpeakerModels operation with and without retries enabled + @Test + public void testListSpeakerModelsWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testListSpeakerModelsWOptions(); + + textToSpeechService.disableRetries(); + testListSpeakerModelsWOptions(); + } + + // Test the createSpeakerModel operation with a valid options model parameter + @Test + public void testCreateSpeakerModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"speaker_id\": \"speakerId\"}"; + String createSpeakerModelPath = "/v1/speakers"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateSpeakerModelOptions model + CreateSpeakerModelOptions createSpeakerModelOptionsModel = + new CreateSpeakerModelOptions.Builder() + .speakerName("testString") + .audio(TestUtilities.createMockStream("This is a mock file.")) + .build(); + + // Invoke createSpeakerModel() with a valid options model and verify the result + Response response = + textToSpeechService.createSpeakerModel(createSpeakerModelOptionsModel).execute(); + assertNotNull(response); + SpeakerModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createSpeakerModelPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("speaker_name"), "testString"); + } + + // Test the createSpeakerModel operation with and without retries enabled + @Test + public void testCreateSpeakerModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testCreateSpeakerModelWOptions(); + + textToSpeechService.disableRetries(); + testCreateSpeakerModelWOptions(); + } + + // Test the createSpeakerModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSpeakerModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.createSpeakerModel(null).execute(); + } + + // Test the getSpeakerModel operation with a valid options model parameter + @Test + public void testGetSpeakerModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\"}]}]}"; + String getSpeakerModelPath = "/v1/speakers/testString"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetSpeakerModelOptions model + GetSpeakerModelOptions getSpeakerModelOptionsModel = + new GetSpeakerModelOptions.Builder().speakerId("testString").build(); + + // Invoke getSpeakerModel() with a valid options model and verify the result + Response response = + textToSpeechService.getSpeakerModel(getSpeakerModelOptionsModel).execute(); + assertNotNull(response); + SpeakerCustomModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getSpeakerModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getSpeakerModel operation with and without retries enabled + @Test + public void testGetSpeakerModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetSpeakerModelWOptions(); + + textToSpeechService.disableRetries(); + testGetSpeakerModelWOptions(); + } + + // Test the getSpeakerModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSpeakerModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.getSpeakerModel(null).execute(); + } + + // Test the deleteSpeakerModel operation with a valid options model parameter + @Test + public void testDeleteSpeakerModelWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteSpeakerModelPath = "/v1/speakers/testString"; + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + // Construct an instance of the DeleteSpeakerModelOptions model + DeleteSpeakerModelOptions deleteSpeakerModelOptionsModel = + new DeleteSpeakerModelOptions.Builder().speakerId("testString").build(); + + // Invoke deleteSpeakerModel() with a valid options model and verify the result + Response response = + textToSpeechService.deleteSpeakerModel(deleteSpeakerModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteSpeakerModelPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteSpeakerModel operation with and without retries enabled + @Test + public void testDeleteSpeakerModelWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testDeleteSpeakerModelWOptions(); + + textToSpeechService.disableRetries(); + testDeleteSpeakerModelWOptions(); + } + + // Test the deleteSpeakerModel operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSpeakerModelNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.deleteSpeakerModel(null).execute(); + } + + // Test the deleteUserData operation with a valid options model parameter + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke deleteUserData() with a valid options model and verify the result + Response response = + textToSpeechService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("customer_id"), "testString"); + } + + // Test the deleteUserData operation with and without retries enabled + @Test + public void testDeleteUserDataWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testDeleteUserDataWOptions(); + + textToSpeechService.disableRetries(); + testDeleteUserDataWOptions(); + } + + // Test the deleteUserData operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + textToSpeechService.deleteUserData(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + textToSpeechService = null; + } - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; - assertEquals(deleteOptions.customerId(), customerId); + final Authenticator authenticator = new NoAuthAuthenticator(); + textToSpeechService = new TextToSpeech(serviceName, authenticator); + String url = server.url("/").toString(); + textToSpeechService.setServiceUrl(url); } } diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddCustomPromptOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddCustomPromptOptionsTest.java new file mode 100644 index 00000000000..695d6b50fb1 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddCustomPromptOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddCustomPromptOptions model. */ +public class AddCustomPromptOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddCustomPromptOptions() throws Throwable { + PromptMetadata promptMetadataModel = + new PromptMetadata.Builder().promptText("testString").speakerId("testString").build(); + assertEquals(promptMetadataModel.promptText(), "testString"); + assertEquals(promptMetadataModel.speakerId(), "testString"); + + AddCustomPromptOptions addCustomPromptOptionsModel = + new AddCustomPromptOptions.Builder() + .customizationId("testString") + .promptId("testString") + .metadata(promptMetadataModel) + .file(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals(addCustomPromptOptionsModel.customizationId(), "testString"); + assertEquals(addCustomPromptOptionsModel.promptId(), "testString"); + assertEquals(addCustomPromptOptionsModel.metadata(), promptMetadataModel); + assertEquals( + IOUtils.toString(addCustomPromptOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddCustomPromptOptionsError() throws Throwable { + new AddCustomPromptOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptionsTest.java new file mode 100644 index 00000000000..01d5f2e87e7 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordOptions model. */ +public class AddWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordOptions() throws Throwable { + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(addWordOptionsModel.customizationId(), "testString"); + assertEquals(addWordOptionsModel.word(), "testString"); + assertEquals(addWordOptionsModel.translation(), "testString"); + assertEquals(addWordOptionsModel.partOfSpeech(), "Dosi"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordOptionsError() throws Throwable { + new AddWordOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptionsTest.java new file mode 100644 index 00000000000..95dbbd38554 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordsOptions model. */ +public class AddWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordsOptions() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(java.util.Arrays.asList(wordModel)) + .build(); + assertEquals(addWordsOptionsModel.customizationId(), "testString"); + assertEquals(addWordsOptionsModel.words(), java.util.Arrays.asList(wordModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsOptionsError() throws Throwable { + new AddWordsOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptionsTest.java new file mode 100644 index 00000000000..c7239529f1f --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCustomModelOptions model. */ +public class CreateCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCustomModelOptions() throws Throwable { + CreateCustomModelOptions createCustomModelOptionsModel = + new CreateCustomModelOptions.Builder() + .name("testString") + .language("en-US") + .description("testString") + .build(); + assertEquals(createCustomModelOptionsModel.name(), "testString"); + assertEquals(createCustomModelOptionsModel.language(), "en-US"); + assertEquals(createCustomModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCustomModelOptionsError() throws Throwable { + new CreateCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateSpeakerModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateSpeakerModelOptionsTest.java new file mode 100644 index 00000000000..f6a5b283a1c --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateSpeakerModelOptionsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateSpeakerModelOptions model. */ +public class CreateSpeakerModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateSpeakerModelOptions() throws Throwable { + CreateSpeakerModelOptions createSpeakerModelOptionsModel = + new CreateSpeakerModelOptions.Builder() + .speakerName("testString") + .audio(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals(createSpeakerModelOptionsModel.speakerName(), "testString"); + assertEquals( + IOUtils.toString(createSpeakerModelOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSpeakerModelOptionsError() throws Throwable { + new CreateSpeakerModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelTest.java new file mode 100644 index 00000000000..629faf803e1 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CustomModel model. */ +public class CustomModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCustomModel() throws Throwable { + CustomModel customModelModel = new CustomModel(); + assertNull(customModelModel.getCustomizationId()); + assertNull(customModelModel.getName()); + assertNull(customModelModel.getLanguage()); + assertNull(customModelModel.getOwner()); + assertNull(customModelModel.getCreated()); + assertNull(customModelModel.getLastModified()); + assertNull(customModelModel.getDescription()); + assertNull(customModelModel.getWords()); + assertNull(customModelModel.getPrompts()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelsTest.java new file mode 100644 index 00000000000..ebab4cb8c35 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CustomModels model. */ +public class CustomModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCustomModels() throws Throwable { + CustomModels customModelsModel = new CustomModels(); + assertNull(customModelsModel.getCustomizations()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptionsTest.java new file mode 100644 index 00000000000..8221daf6f1b --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCustomModelOptions model. */ +public class DeleteCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCustomModelOptions() throws Throwable { + DeleteCustomModelOptions deleteCustomModelOptionsModel = + new DeleteCustomModelOptions.Builder().customizationId("testString").build(); + assertEquals(deleteCustomModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCustomModelOptionsError() throws Throwable { + new DeleteCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomPromptOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomPromptOptionsTest.java new file mode 100644 index 00000000000..dc646b8f6c6 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomPromptOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCustomPromptOptions model. */ +public class DeleteCustomPromptOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCustomPromptOptions() throws Throwable { + DeleteCustomPromptOptions deleteCustomPromptOptionsModel = + new DeleteCustomPromptOptions.Builder() + .customizationId("testString") + .promptId("testString") + .build(); + assertEquals(deleteCustomPromptOptionsModel.customizationId(), "testString"); + assertEquals(deleteCustomPromptOptionsModel.promptId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCustomPromptOptionsError() throws Throwable { + new DeleteCustomPromptOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteSpeakerModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteSpeakerModelOptionsTest.java new file mode 100644 index 00000000000..8585c8f8527 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteSpeakerModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteSpeakerModelOptions model. */ +public class DeleteSpeakerModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteSpeakerModelOptions() throws Throwable { + DeleteSpeakerModelOptions deleteSpeakerModelOptionsModel = + new DeleteSpeakerModelOptions.Builder().speakerId("testString").build(); + assertEquals(deleteSpeakerModelOptionsModel.speakerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSpeakerModelOptionsError() throws Throwable { + new DeleteSpeakerModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..68120530071 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptionsTest.java new file mode 100644 index 00000000000..caf757eb8a9 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteWordOptions model. */ +public class DeleteWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteWordOptions() throws Throwable { + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder().customizationId("testString").word("testString").build(); + assertEquals(deleteWordOptionsModel.customizationId(), "testString"); + assertEquals(deleteWordOptionsModel.word(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordOptionsError() throws Throwable { + new DeleteWordOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptionsTest.java new file mode 100644 index 00000000000..4897230e53d --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCustomModelOptions model. */ +public class GetCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCustomModelOptions() throws Throwable { + GetCustomModelOptions getCustomModelOptionsModel = + new GetCustomModelOptions.Builder().customizationId("testString").build(); + assertEquals(getCustomModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCustomModelOptionsError() throws Throwable { + new GetCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomPromptOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomPromptOptionsTest.java new file mode 100644 index 00000000000..27ed258a38f --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomPromptOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCustomPromptOptions model. */ +public class GetCustomPromptOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCustomPromptOptions() throws Throwable { + GetCustomPromptOptions getCustomPromptOptionsModel = + new GetCustomPromptOptions.Builder() + .customizationId("testString") + .promptId("testString") + .build(); + assertEquals(getCustomPromptOptionsModel.customizationId(), "testString"); + assertEquals(getCustomPromptOptionsModel.promptId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCustomPromptOptionsError() throws Throwable { + new GetCustomPromptOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptionsTest.java new file mode 100644 index 00000000000..a8e0b63689b --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020, 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetPronunciationOptions model. */ +public class GetPronunciationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetPronunciationOptions() throws Throwable { + GetPronunciationOptions getPronunciationOptionsModel = + new GetPronunciationOptions.Builder() + .text("testString") + .voice("en-US_MichaelV3Voice") + .format("ipa") + .customizationId("testString") + .build(); + assertEquals(getPronunciationOptionsModel.text(), "testString"); + assertEquals(getPronunciationOptionsModel.voice(), "en-US_MichaelV3Voice"); + assertEquals(getPronunciationOptionsModel.format(), "ipa"); + assertEquals(getPronunciationOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPronunciationOptionsError() throws Throwable { + new GetPronunciationOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetSpeakerModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetSpeakerModelOptionsTest.java new file mode 100644 index 00000000000..47f11bec0bc --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetSpeakerModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetSpeakerModelOptions model. */ +public class GetSpeakerModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetSpeakerModelOptions() throws Throwable { + GetSpeakerModelOptions getSpeakerModelOptionsModel = + new GetSpeakerModelOptions.Builder().speakerId("testString").build(); + assertEquals(getSpeakerModelOptionsModel.speakerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSpeakerModelOptionsError() throws Throwable { + new GetSpeakerModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptionsTest.java new file mode 100644 index 00000000000..cf16adc9dda --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetVoiceOptions model. */ +public class GetVoiceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetVoiceOptions() throws Throwable { + GetVoiceOptions getVoiceOptionsModel = + new GetVoiceOptions.Builder() + .voice("de-DE_BirgitV3Voice") + .customizationId("testString") + .build(); + assertEquals(getVoiceOptionsModel.voice(), "de-DE_BirgitV3Voice"); + assertEquals(getVoiceOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetVoiceOptionsError() throws Throwable { + new GetVoiceOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptionsTest.java new file mode 100644 index 00000000000..bb9c7f06276 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetWordOptions model. */ +public class GetWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetWordOptions() throws Throwable { + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").word("testString").build(); + assertEquals(getWordOptionsModel.customizationId(), "testString"); + assertEquals(getWordOptionsModel.word(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordOptionsError() throws Throwable { + new GetWordOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptionsTest.java new file mode 100644 index 00000000000..c0eed90ac1d --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCustomModelsOptions model. */ +public class ListCustomModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCustomModelsOptions() throws Throwable { + ListCustomModelsOptions listCustomModelsOptionsModel = + new ListCustomModelsOptions.Builder().language("de-DE").build(); + assertEquals(listCustomModelsOptionsModel.language(), "de-DE"); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomPromptsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomPromptsOptionsTest.java new file mode 100644 index 00000000000..e6c4dd88a03 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomPromptsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCustomPromptsOptions model. */ +public class ListCustomPromptsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCustomPromptsOptions() throws Throwable { + ListCustomPromptsOptions listCustomPromptsOptionsModel = + new ListCustomPromptsOptions.Builder().customizationId("testString").build(); + assertEquals(listCustomPromptsOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCustomPromptsOptionsError() throws Throwable { + new ListCustomPromptsOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListSpeakerModelsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListSpeakerModelsOptionsTest.java new file mode 100644 index 00000000000..3322773194e --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListSpeakerModelsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListSpeakerModelsOptions model. */ +public class ListSpeakerModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListSpeakerModelsOptions() throws Throwable { + ListSpeakerModelsOptions listSpeakerModelsOptionsModel = new ListSpeakerModelsOptions(); + assertNotNull(listSpeakerModelsOptionsModel); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptionsTest.java new file mode 100644 index 00000000000..d0fbb5d9d30 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListVoicesOptions model. */ +public class ListVoicesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListVoicesOptions() throws Throwable { + ListVoicesOptions listVoicesOptionsModel = new ListVoicesOptions(); + assertNotNull(listVoicesOptionsModel); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptionsTest.java new file mode 100644 index 00000000000..968173ff392 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListWordsOptions model. */ +public class ListWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListWordsOptions() throws Throwable { + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder().customizationId("testString").build(); + assertEquals(listWordsOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsOptionsError() throws Throwable { + new ListWordsOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptMetadataTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptMetadataTest.java new file mode 100644 index 00000000000..f172b6c1edb --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptMetadataTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PromptMetadata model. */ +public class PromptMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPromptMetadata() throws Throwable { + PromptMetadata promptMetadataModel = + new PromptMetadata.Builder().promptText("testString").speakerId("testString").build(); + assertEquals(promptMetadataModel.promptText(), "testString"); + assertEquals(promptMetadataModel.speakerId(), "testString"); + + String json = TestUtilities.serialize(promptMetadataModel); + + PromptMetadata promptMetadataModelNew = TestUtilities.deserialize(json, PromptMetadata.class); + assertTrue(promptMetadataModelNew instanceof PromptMetadata); + assertEquals(promptMetadataModelNew.promptText(), "testString"); + assertEquals(promptMetadataModelNew.speakerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPromptMetadataError() throws Throwable { + new PromptMetadata.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptTest.java new file mode 100644 index 00000000000..9de09dcc340 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Prompt model. */ +public class PromptTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPrompt() throws Throwable { + Prompt promptModel = new Prompt(); + assertNull(promptModel.getPrompt()); + assertNull(promptModel.getPromptId()); + assertNull(promptModel.getStatus()); + assertNull(promptModel.getError()); + assertNull(promptModel.getSpeakerId()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptsTest.java new file mode 100644 index 00000000000..3071c1d4858 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PromptsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Prompts model. */ +public class PromptsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPrompts() throws Throwable { + Prompts promptsModel = new Prompts(); + assertNull(promptsModel.getPrompts()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PronunciationTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PronunciationTest.java new file mode 100644 index 00000000000..e514d0f5ac0 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PronunciationTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Pronunciation model. */ +public class PronunciationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPronunciation() throws Throwable { + Pronunciation pronunciationModel = new Pronunciation(); + assertNull(pronunciationModel.getPronunciation()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModelTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModelTest.java new file mode 100644 index 00000000000..cc54bd06af3 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModelTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeakerCustomModel model. */ +public class SpeakerCustomModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakerCustomModel() throws Throwable { + SpeakerCustomModel speakerCustomModelModel = new SpeakerCustomModel(); + assertNull(speakerCustomModelModel.getCustomizationId()); + assertNull(speakerCustomModelModel.getPrompts()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModelsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModelsTest.java new file mode 100644 index 00000000000..f064fa153da --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerCustomModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeakerCustomModels model. */ +public class SpeakerCustomModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakerCustomModels() throws Throwable { + SpeakerCustomModels speakerCustomModelsModel = new SpeakerCustomModels(); + assertNull(speakerCustomModelsModel.getCustomizations()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerModelTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerModelTest.java new file mode 100644 index 00000000000..a5f4b1f3ac2 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerModelTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeakerModel model. */ +public class SpeakerModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakerModel() throws Throwable { + SpeakerModel speakerModelModel = new SpeakerModel(); + assertNull(speakerModelModel.getSpeakerId()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerPromptTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerPromptTest.java new file mode 100644 index 00000000000..42ac74ffe40 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerPromptTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeakerPrompt model. */ +public class SpeakerPromptTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakerPrompt() throws Throwable { + SpeakerPrompt speakerPromptModel = new SpeakerPrompt(); + assertNull(speakerPromptModel.getPrompt()); + assertNull(speakerPromptModel.getPromptId()); + assertNull(speakerPromptModel.getStatus()); + assertNull(speakerPromptModel.getError()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerTest.java new file mode 100644 index 00000000000..5d99da13769 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakerTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Speaker model. */ +public class SpeakerTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeaker() throws Throwable { + Speaker speakerModel = new Speaker(); + assertNull(speakerModel.getSpeakerId()); + assertNull(speakerModel.getName()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakersTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakersTest.java new file mode 100644 index 00000000000..fa7dcef3954 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SpeakersTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2021. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Speakers model. */ +public class SpeakersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakers() throws Throwable { + Speakers speakersModel = new Speakers(); + assertNull(speakersModel.getSpeakers()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeaturesTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeaturesTest.java new file mode 100644 index 00000000000..8b52449d6b8 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeaturesTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SupportedFeatures model. */ +public class SupportedFeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSupportedFeatures() throws Throwable { + SupportedFeatures supportedFeaturesModel = new SupportedFeatures(); + assertNull(supportedFeaturesModel.isCustomPronunciation()); + assertNull(supportedFeaturesModel.isVoiceTransformation()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptionsTest.java new file mode 100644 index 00000000000..f4a262248e6 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SynthesizeOptions model. */ +public class SynthesizeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSynthesizeOptions() throws Throwable { + SynthesizeOptions synthesizeOptionsModel = + new SynthesizeOptions.Builder() + .text("testString") + .accept("audio/ogg;codecs=opus") + .voice("en-US_MichaelV3Voice") + .customizationId("testString") + .spellOutMode("default") + .ratePercentage(Long.valueOf("0")) + .pitchPercentage(Long.valueOf("0")) + .build(); + assertEquals(synthesizeOptionsModel.text(), "testString"); + assertEquals(synthesizeOptionsModel.accept(), "audio/ogg;codecs=opus"); + assertEquals(synthesizeOptionsModel.voice(), "en-US_MichaelV3Voice"); + assertEquals(synthesizeOptionsModel.customizationId(), "testString"); + assertEquals(synthesizeOptionsModel.spellOutMode(), "default"); + assertEquals(synthesizeOptionsModel.ratePercentage(), Long.valueOf("0")); + assertEquals(synthesizeOptionsModel.pitchPercentage(), Long.valueOf("0")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSynthesizeOptionsError() throws Throwable { + new SynthesizeOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/TranslationTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/TranslationTest.java new file mode 100644 index 00000000000..daa2712b124 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/TranslationTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Translation model. */ +public class TranslationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslation() throws Throwable { + Translation translationModel = + new Translation.Builder().translation("testString").partOfSpeech("Dosi").build(); + assertEquals(translationModel.translation(), "testString"); + assertEquals(translationModel.partOfSpeech(), "Dosi"); + + String json = TestUtilities.serialize(translationModel); + + Translation translationModelNew = TestUtilities.deserialize(json, Translation.class); + assertTrue(translationModelNew instanceof Translation); + assertEquals(translationModelNew.translation(), "testString"); + assertEquals(translationModelNew.partOfSpeech(), "Dosi"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTranslationError() throws Throwable { + new Translation.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptionsTest.java new file mode 100644 index 00000000000..7ca6e815339 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptionsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCustomModelOptions model. */ +public class UpdateCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCustomModelOptions() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + UpdateCustomModelOptions updateCustomModelOptionsModel = + new UpdateCustomModelOptions.Builder() + .customizationId("testString") + .name("testString") + .description("testString") + .words(java.util.Arrays.asList(wordModel)) + .build(); + assertEquals(updateCustomModelOptionsModel.customizationId(), "testString"); + assertEquals(updateCustomModelOptionsModel.name(), "testString"); + assertEquals(updateCustomModelOptionsModel.description(), "testString"); + assertEquals(updateCustomModelOptionsModel.words(), java.util.Arrays.asList(wordModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCustomModelOptionsError() throws Throwable { + new UpdateCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoiceTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoiceTest.java new file mode 100644 index 00000000000..cfb8f59b5cf --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoiceTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Voice model. */ +public class VoiceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testVoice() throws Throwable { + Voice voiceModel = new Voice(); + assertNull(voiceModel.getUrl()); + assertNull(voiceModel.getGender()); + assertNull(voiceModel.getName()); + assertNull(voiceModel.getLanguage()); + assertNull(voiceModel.getDescription()); + assertNull(voiceModel.isCustomizable()); + assertNull(voiceModel.getSupportedFeatures()); + assertNull(voiceModel.getCustomization()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoicesTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoicesTest.java new file mode 100644 index 00000000000..57645bb3d3f --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoicesTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Voices model. */ +public class VoicesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testVoices() throws Throwable { + Voices voicesModel = new Voices(); + assertNull(voicesModel.getVoices()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordTest.java new file mode 100644 index 00000000000..98fc7bba43c --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Word model. */ +public class WordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWord() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + String json = TestUtilities.serialize(wordModel); + + Word wordModelNew = TestUtilities.deserialize(json, Word.class); + assertTrue(wordModelNew instanceof Word); + assertEquals(wordModelNew.word(), "testString"); + assertEquals(wordModelNew.translation(), "testString"); + assertEquals(wordModelNew.partOfSpeech(), "Dosi"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWordError() throws Throwable { + new Word.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordsTest.java new file mode 100644 index 00000000000..efc209101ca --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020, 2022. + * + * 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.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Words model. */ +public class WordsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWords() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + Words wordsModel = new Words.Builder().words(java.util.Arrays.asList(wordModel)).build(); + assertEquals(wordsModel.words(), java.util.Arrays.asList(wordModel)); + + String json = TestUtilities.serialize(wordsModel); + + Words wordsModelNew = TestUtilities.deserialize(json, Words.class); + assertTrue(wordsModelNew instanceof Words); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWordsError() throws Throwable { + new Words.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/testng.xml b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/testng.xml new file mode 100644 index 00000000000..a34b1bb311c --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/utils/TestUtilities.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..2bef2503ebc --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/utils/TestUtilities.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2020, 2024. + * + * 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.text_to_speech.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} diff --git a/tone-analyzer/README.md b/tone-analyzer/README.md deleted file mode 100755 index 0a79a180f99..00000000000 --- a/tone-analyzer/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Tone Analyzer - -## Installation - -##### Maven - -```xml - - com.ibm.watson - tone-analyzer - 8.3.1 - -``` - -##### Gradle - -```gradle -'com.ibm.watson:tone-analyzer:8.3.1' -``` - -## Usage - -Use the [Tone Analyzer][tone_analyzer] service to get the tone of your email. - -```java -Authenticator authenticator = new IamAuthenticator(""); -ToneAnalyzer service = new ToneAnalyzer("2017-09-21", authenticator); - -String text = - "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! " - + "We need to acknowledge and fix our sales challenges. " - + "We can’t blame the economy for our lack of execution! " - + "We are missing critical sales opportunities. " - + "Our product is in no way inferior to the competitor products. " - + "Our clients are hungry for analytical tools to improve their " - + "business outcomes. Economy has nothing to do with it."; - -// Call the service and get the tone -ToneOptions toneOptions = new ToneOptions.Builder() - .text(text) - .build(); - -ToneAnalysis tone = service.tone(toneOptions).execute().getResult(); -System.out.println(tone); -``` - -[tone_analyzer]: https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-about diff --git a/tone-analyzer/build.gradle b/tone-analyzer/build.gradle deleted file mode 100644 index e63b7d64fa9..00000000000 --- a/tone-analyzer/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/tone-analyzer/gradle.properties b/tone-analyzer/gradle.properties deleted file mode 100644 index 6a6b33dca9e..00000000000 --- a/tone-analyzer/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:tone-analyzer -ARTIFACT_ID=tone-analyzer -NAME=IBM Watson Java SDK - Tone Analyzer -DESCRIPTION=Java client library to use the IBM Tone Analyzer API \ No newline at end of file diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java deleted file mode 100644 index ccfa7b09297..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.tone_analyzer.v3; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.tone_analyzer.v3.model.ToneOptions; -import com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses; -import java.util.Map; -import java.util.Map.Entry; - -/** - * The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect emotional and language tones in - * written text. The service can analyze tone at both the document and sentence levels. You can use the service to - * understand how your written communications are perceived and then to improve the tone of your communications. - * Businesses can use the service to learn the tone of their customers' communications and to respond to each customer - * appropriately, or to understand and improve their customer conversations. - * - * **Note:** Request logging is disabled for the Tone Analyzer service. Regardless of whether you set the - * `X-Watson-Learning-Opt-Out` request header, the service does not log or retain data from requests and responses. - * - * @version v3 - * @see Tone Analyzer - */ -public class ToneAnalyzer extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "tone_analyzer"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/tone-analyzer/api"; - - private String versionDate; - - /** - * Constructs a new `ToneAnalyzer` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public ToneAnalyzer(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `ToneAnalyzer` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public ToneAnalyzer(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `ToneAnalyzer` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public ToneAnalyzer(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `ToneAnalyzer` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public ToneAnalyzer(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Analyze general tone. - * - * Use the general-purpose endpoint to analyze the tone of your input content. The service analyzes the content for - * emotional and language tones. The method always analyzes the tone of the full document; by default, it also - * analyzes the tone of each individual sentence of the content. - * - * You can submit no more than 128 KB of total input content and no more than 1000 individual sentences in JSON, plain - * text, or HTML format. The service analyzes the first 1000 sentences for document-level analysis and only the first - * 100 sentences for sentence-level analysis. - * - * Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8; per the - * HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII character - * set). When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the - * character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. For `text/html`, the - * service removes HTML tags and analyzes only the textual content. - * - * **See also:** [Using the general-purpose - * endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe#utgpe). - * - * @param toneOptions the {@link ToneOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ToneAnalysis} - */ - public ServiceCall tone(ToneOptions toneOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(toneOptions, - "toneOptions cannot be null"); - String[] pathSegments = { "v3/tone" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "tone"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (toneOptions.contentType() != null) { - builder.header("Content-Type", toneOptions.contentType()); - } - if (toneOptions.contentLanguage() != null) { - builder.header("Content-Language", toneOptions.contentLanguage()); - } - if (toneOptions.acceptLanguage() != null) { - builder.header("Accept-Language", toneOptions.acceptLanguage()); - } - if (toneOptions.sentences() != null) { - builder.query("sentences", String.valueOf(toneOptions.sentences())); - } - if (toneOptions.tones() != null) { - builder.query("tones", RequestUtils.join(toneOptions.tones(), ",")); - } - builder.bodyContent(toneOptions.contentType(), toneOptions.toneInput(), - null, toneOptions.body()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Analyze customer-engagement tone. - * - * Use the customer-engagement endpoint to analyze the tone of customer service and customer support conversations. - * For each utterance of a conversation, the method reports the most prevalent subset of the following seven tones: - * sad, frustrated, satisfied, excited, polite, impolite, and sympathetic. - * - * If you submit more than 50 utterances, the service returns a warning for the overall content and analyzes only the - * first 50 utterances. If you submit a single utterance that contains more than 500 characters, the service returns - * an error for that utterance and does not analyze the utterance. The request fails if all utterances have more than - * 500 characters. Per the JSON specification, the default character encoding for JSON content is effectively always - * UTF-8. - * - * **See also:** [Using the customer-engagement - * endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utco#utco). - * - * @param toneChatOptions the {@link ToneChatOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link UtteranceAnalyses} - */ - public ServiceCall toneChat(ToneChatOptions toneChatOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(toneChatOptions, - "toneChatOptions cannot be null"); - String[] pathSegments = { "v3/tone_chat" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "toneChat"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (toneChatOptions.contentLanguage() != null) { - builder.header("Content-Language", toneChatOptions.contentLanguage()); - } - if (toneChatOptions.acceptLanguage() != null) { - builder.header("Accept-Language", toneChatOptions.acceptLanguage()); - } - final JsonObject contentJson = new JsonObject(); - contentJson.add("utterances", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(toneChatOptions - .utterances())); - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java deleted file mode 100644 index 2c2664b3251..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of the analysis for the full input content. - */ -public class DocumentAnalysis extends GenericModel { - - protected List tones; - @SerializedName("tone_categories") - protected List toneCategories; - protected String warning; - - /** - * Gets the tones. - * - * **`2017-09-21`:** An array of `ToneScore` objects that provides the results of the analysis for each qualifying - * tone of the document. The array includes results for any tone whose score is at least 0.5. The array is empty if no - * tone has a score that meets this threshold. **`2016-05-19`:** Not returned. - * - * @return the tones - */ - public List getTones() { - return tones; - } - - /** - * Gets the toneCategories. - * - * **`2017-09-21`:** Not returned. **`2016-05-19`:** An array of `ToneCategory` objects that provides the results of - * the tone analysis for the full document of the input content. The service returns results only for the tones - * specified with the `tones` parameter of the request. - * - * @return the toneCategories - */ - public List getToneCategories() { - return toneCategories; - } - - /** - * Gets the warning. - * - * **`2017-09-21`:** A warning message if the overall content exceeds 128 KB or contains more than 1000 sentences. The - * service analyzes only the first 1000 sentences for document-level analysis and the first 100 sentences for - * sentence-level analysis. **`2016-05-19`:** Not returned. - * - * @return the warning - */ - public String getWarning() { - return warning; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java deleted file mode 100644 index 100bc0f6cf2..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of the analysis for the individual sentences of the input content. - */ -public class SentenceAnalysis extends GenericModel { - - @SerializedName("sentence_id") - protected Long sentenceId; - protected String text; - protected List tones; - @SerializedName("tone_categories") - protected List toneCategories; - @SerializedName("input_from") - protected Long inputFrom; - @SerializedName("input_to") - protected Long inputTo; - - /** - * Gets the sentenceId. - * - * The unique identifier of a sentence of the input content. The first sentence has ID 0, and the ID of each - * subsequent sentence is incremented by one. - * - * @return the sentenceId - */ - public Long getSentenceId() { - return sentenceId; - } - - /** - * Gets the text. - * - * The text of the input sentence. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the tones. - * - * **`2017-09-21`:** An array of `ToneScore` objects that provides the results of the analysis for each qualifying - * tone of the sentence. The array includes results for any tone whose score is at least 0.5. The array is empty if no - * tone has a score that meets this threshold. **`2016-05-19`:** Not returned. - * - * @return the tones - */ - public List getTones() { - return tones; - } - - /** - * Gets the toneCategories. - * - * **`2017-09-21`:** Not returned. **`2016-05-19`:** An array of `ToneCategory` objects that provides the results of - * the tone analysis for the sentence. The service returns results only for the tones specified with the `tones` - * parameter of the request. - * - * @return the toneCategories - */ - public List getToneCategories() { - return toneCategories; - } - - /** - * Gets the inputFrom. - * - * **`2017-09-21`:** Not returned. **`2016-05-19`:** The offset of the first character of the sentence in the overall - * input content. - * - * @return the inputFrom - */ - public Long getInputFrom() { - return inputFrom; - } - - /** - * Gets the inputTo. - * - * **`2017-09-21`:** Not returned. **`2016-05-19`:** The offset of the last character of the sentence in the overall - * input content. - * - * @return the inputTo - */ - public Long getInputTo() { - return inputTo; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java deleted file mode 100644 index 93d5307a0c1..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The tone analysis results for the input from the general-purpose endpoint. - */ -public class ToneAnalysis extends GenericModel { - - @SerializedName("document_tone") - protected DocumentAnalysis documentTone; - @SerializedName("sentences_tone") - protected List sentencesTone; - - /** - * Gets the documentTone. - * - * The results of the analysis for the full input content. - * - * @return the documentTone - */ - public DocumentAnalysis getDocumentTone() { - return documentTone; - } - - /** - * Gets the sentencesTone. - * - * An array of `SentenceAnalysis` objects that provides the results of the analysis for the individual sentences of - * the input content. The service returns results only for the first 100 sentences of the input. The field is omitted - * if the `sentences` parameter of the request is set to `false`. - * - * @return the sentencesTone - */ - public List getSentencesTone() { - return sentencesTone; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java deleted file mode 100644 index df71f552b4c..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The category for a tone from the input content. - */ -public class ToneCategory extends GenericModel { - - protected List tones; - @SerializedName("category_id") - protected String categoryId; - @SerializedName("category_name") - protected String categoryName; - - /** - * Gets the tones. - * - * An array of `ToneScore` objects that provides the results for the tones of the category. - * - * @return the tones - */ - public List getTones() { - return tones; - } - - /** - * Gets the categoryId. - * - * The unique, non-localized identifier of the category for the results. The service can return results for the - * following category IDs: `emotion_tone`, `language_tone`, and `social_tone`. - * - * @return the categoryId - */ - public String getCategoryId() { - return categoryId; - } - - /** - * Gets the categoryName. - * - * The user-visible, localized name of the category. - * - * @return the categoryName - */ - public String getCategoryName() { - return categoryName; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java deleted file mode 100644 index ea67f58c5f3..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The toneChat options. - */ -public class ToneChatOptions extends GenericModel { - - /** - * The language of the input text for the request: English or French. Regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not - * submit content that contains both languages. You can use different languages for **Content-Language** and - * **Accept-Language**. - * * **`2017-09-21`:** Accepts `en` or `fr`. - * * **`2016-05-19`:** Accepts only `en`. - */ - public interface ContentLanguage { - /** en. */ - String EN = "en"; - /** fr. */ - String FR = "fr"; - } - - /** - * The desired language of the response. For two-character arguments, regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and - * **Accept-Language**. - */ - public interface AcceptLanguage { - /** ar. */ - String AR = "ar"; - /** de. */ - String DE = "de"; - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** fr. */ - String FR = "fr"; - /** it. */ - String IT = "it"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - /** pt-br. */ - String PT_BR = "pt-br"; - /** zh-cn. */ - String ZH_CN = "zh-cn"; - /** zh-tw. */ - String ZH_TW = "zh-tw"; - } - - protected List utterances; - protected String contentLanguage; - protected String acceptLanguage; - - /** - * Builder. - */ - public static class Builder { - private List utterances; - private String contentLanguage; - private String acceptLanguage; - - private Builder(ToneChatOptions toneChatOptions) { - this.utterances = toneChatOptions.utterances; - this.contentLanguage = toneChatOptions.contentLanguage; - this.acceptLanguage = toneChatOptions.acceptLanguage; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param utterances the utterances - */ - public Builder(List utterances) { - this.utterances = utterances; - } - - /** - * Builds a ToneChatOptions. - * - * @return the toneChatOptions - */ - public ToneChatOptions build() { - return new ToneChatOptions(this); - } - - /** - * Adds an utterances to utterances. - * - * @param utterances the new utterances - * @return the ToneChatOptions builder - */ - public Builder addUtterances(Utterance utterances) { - com.ibm.cloud.sdk.core.util.Validator.notNull(utterances, - "utterances cannot be null"); - if (this.utterances == null) { - this.utterances = new ArrayList(); - } - this.utterances.add(utterances); - return this; - } - - /** - * Set the utterances. - * Existing utterances will be replaced. - * - * @param utterances the utterances - * @return the ToneChatOptions builder - */ - public Builder utterances(List utterances) { - this.utterances = utterances; - return this; - } - - /** - * Set the contentLanguage. - * - * @param contentLanguage the contentLanguage - * @return the ToneChatOptions builder - */ - public Builder contentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Set the acceptLanguage. - * - * @param acceptLanguage the acceptLanguage - * @return the ToneChatOptions builder - */ - public Builder acceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - } - - protected ToneChatOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.utterances, - "utterances cannot be null"); - utterances = builder.utterances; - contentLanguage = builder.contentLanguage; - acceptLanguage = builder.acceptLanguage; - } - - /** - * New builder. - * - * @return a ToneChatOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the utterances. - * - * An array of `Utterance` objects that provides the input content that the service is to analyze. - * - * @return the utterances - */ - public List utterances() { - return utterances; - } - - /** - * Gets the contentLanguage. - * - * The language of the input text for the request: English or French. Regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not - * submit content that contains both languages. You can use different languages for **Content-Language** and - * **Accept-Language**. - * * **`2017-09-21`:** Accepts `en` or `fr`. - * * **`2016-05-19`:** Accepts only `en`. - * - * @return the contentLanguage - */ - public String contentLanguage() { - return contentLanguage; - } - - /** - * Gets the acceptLanguage. - * - * The desired language of the response. For two-character arguments, regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and - * **Accept-Language**. - * - * @return the acceptLanguage - */ - public String acceptLanguage() { - return acceptLanguage; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java deleted file mode 100644 index 61c67c84051..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The score for an utterance from the input content. - */ -public class ToneChatScore extends GenericModel { - - /** - * The unique, non-localized identifier of the tone for the results. The service returns results only for tones whose - * scores meet a minimum threshold of 0.5. - */ - public interface ToneId { - /** excited. */ - String EXCITED = "excited"; - /** frustrated. */ - String FRUSTRATED = "frustrated"; - /** impolite. */ - String IMPOLITE = "impolite"; - /** polite. */ - String POLITE = "polite"; - /** sad. */ - String SAD = "sad"; - /** satisfied. */ - String SATISFIED = "satisfied"; - /** sympathetic. */ - String SYMPATHETIC = "sympathetic"; - } - - protected Double score; - @SerializedName("tone_id") - protected String toneId; - @SerializedName("tone_name") - protected String toneName; - - /** - * Gets the score. - * - * The score for the tone in the range of 0.5 to 1. A score greater than 0.75 indicates a high likelihood that the - * tone is perceived in the utterance. - * - * @return the score - */ - public Double getScore() { - return score; - } - - /** - * Gets the toneId. - * - * The unique, non-localized identifier of the tone for the results. The service returns results only for tones whose - * scores meet a minimum threshold of 0.5. - * - * @return the toneId - */ - public String getToneId() { - return toneId; - } - - /** - * Gets the toneName. - * - * The user-visible, localized name of the tone. - * - * @return the toneName - */ - public String getToneName() { - return toneName; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java deleted file mode 100644 index b597f65afb7..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Input for the general-purpose endpoint. - */ -public class ToneInput extends GenericModel { - - protected String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(ToneInput toneInput) { - this.text = toneInput.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param text the text - */ - public Builder(String text) { - this.text = text; - } - - /** - * Builds a ToneInput. - * - * @return the toneInput - */ - public ToneInput build() { - return new ToneInput(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the ToneInput builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - protected ToneInput(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a ToneInput builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * The input content that the service is to analyze. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java deleted file mode 100644 index 2423d7d2589..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The tone options. - */ -public class ToneOptions extends GenericModel { - - public interface Tone { - /** emotion. */ - String EMOTION = "emotion"; - /** language. */ - String LANGUAGE = "language"; - /** social. */ - String SOCIAL = "social"; - } - - /** - * The language of the input text for the request: English or French. Regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not - * submit content that contains both languages. You can use different languages for **Content-Language** and - * **Accept-Language**. - * * **`2017-09-21`:** Accepts `en` or `fr`. - * * **`2016-05-19`:** Accepts only `en`. - */ - public interface ContentLanguage { - /** en. */ - String EN = "en"; - /** fr. */ - String FR = "fr"; - } - - /** - * The desired language of the response. For two-character arguments, regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and - * **Accept-Language**. - */ - public interface AcceptLanguage { - /** ar. */ - String AR = "ar"; - /** de. */ - String DE = "de"; - /** en. */ - String EN = "en"; - /** es. */ - String ES = "es"; - /** fr. */ - String FR = "fr"; - /** it. */ - String IT = "it"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - /** pt-br. */ - String PT_BR = "pt-br"; - /** zh-cn. */ - String ZH_CN = "zh-cn"; - /** zh-tw. */ - String ZH_TW = "zh-tw"; - } - - protected ToneInput toneInput; - protected String body; - protected String contentType; - protected Boolean sentences; - protected List tones; - protected String contentLanguage; - protected String acceptLanguage; - - /** - * Builder. - */ - public static class Builder { - private ToneInput toneInput; - private String body; - private String contentType; - private Boolean sentences; - private List tones; - private String contentLanguage; - private String acceptLanguage; - - private Builder(ToneOptions toneOptions) { - this.toneInput = toneOptions.toneInput; - this.body = toneOptions.body; - this.contentType = toneOptions.contentType; - this.sentences = toneOptions.sentences; - this.tones = toneOptions.tones; - this.contentLanguage = toneOptions.contentLanguage; - this.acceptLanguage = toneOptions.acceptLanguage; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ToneOptions. - * - * @return the toneOptions - */ - public ToneOptions build() { - return new ToneOptions(this); - } - - /** - * Adds an tone to tones. - * - * @param tone the new tone - * @return the ToneOptions builder - */ - public Builder addTone(String tone) { - com.ibm.cloud.sdk.core.util.Validator.notNull(tone, - "tone cannot be null"); - if (this.tones == null) { - this.tones = new ArrayList(); - } - this.tones.add(tone); - return this; - } - - /** - * Set the sentences. - * - * @param sentences the sentences - * @return the ToneOptions builder - */ - public Builder sentences(Boolean sentences) { - this.sentences = sentences; - return this; - } - - /** - * Set the tones. - * Existing tones will be replaced. - * - * @param tones the tones - * @return the ToneOptions builder - */ - public Builder tones(List tones) { - this.tones = tones; - return this; - } - - /** - * Set the contentLanguage. - * - * @param contentLanguage the contentLanguage - * @return the ToneOptions builder - */ - public Builder contentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Set the acceptLanguage. - * - * @param acceptLanguage the acceptLanguage - * @return the ToneOptions builder - */ - public Builder acceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** - * Set the toneInput. - * - * @param toneInput the toneInput - * @return the ToneOptions builder - */ - public Builder toneInput(ToneInput toneInput) { - this.toneInput = toneInput; - this.contentType = "application/json"; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the ToneOptions builder - */ - public Builder text(String text) { - this.body = text; - this.contentType = "text/plain"; - return this; - } - - /** - * Set the html. - * - * @param html the html - * @return the ToneOptions builder - */ - public Builder html(String html) { - this.body = html; - this.contentType = "text/html"; - return this; - } - } - - protected ToneOptions(Builder builder) { - toneInput = builder.toneInput; - body = builder.body; - contentType = builder.contentType; - sentences = builder.sentences; - tones = builder.tones; - contentLanguage = builder.contentLanguage; - acceptLanguage = builder.acceptLanguage; - } - - /** - * New builder. - * - * @return a ToneOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the toneInput. - * - * JSON, plain text, or HTML input that contains the content to be analyzed. For JSON input, provide an object of type - * `ToneInput`. - * - * @return the toneInput - */ - public ToneInput toneInput() { - return toneInput; - } - - /** - * Gets the body. - * - * JSON, plain text, or HTML input that contains the content to be analyzed. For JSON input, provide an object of type - * `ToneInput`. - * - * @return the body - */ - public String body() { - return body; - } - - /** - * Gets the contentType. - * - * The type of the input. A character encoding can be specified by including a `charset` parameter. For example, - * 'text/plain;charset=utf-8'. - * - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * Gets the sentences. - * - * Indicates whether the service is to return an analysis of each individual sentence in addition to its analysis of - * the full document. If `true` (the default), the service returns results for each sentence. - * - * @return the sentences - */ - public Boolean sentences() { - return sentences; - } - - /** - * Gets the tones. - * - * **`2017-09-21`:** Deprecated. The service continues to accept the parameter for backward-compatibility, but the - * parameter no longer affects the response. - * - * **`2016-05-19`:** A comma-separated list of tones for which the service is to return its analysis of the input; the - * indicated tones apply both to the full document and to individual sentences of the document. You can specify one or - * more of the valid values. Omit the parameter to request results for all three tones. - * - * @return the tones - */ - public List tones() { - return tones; - } - - /** - * Gets the contentLanguage. - * - * The language of the input text for the request: English or French. Regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not - * submit content that contains both languages. You can use different languages for **Content-Language** and - * **Accept-Language**. - * * **`2017-09-21`:** Accepts `en` or `fr`. - * * **`2016-05-19`:** Accepts only `en`. - * - * @return the contentLanguage - */ - public String contentLanguage() { - return contentLanguage; - } - - /** - * Gets the acceptLanguage. - * - * The desired language of the response. For two-character arguments, regional variants are treated as their parent - * language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and - * **Accept-Language**. - * - * @return the acceptLanguage - */ - public String acceptLanguage() { - return acceptLanguage; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java deleted file mode 100644 index 04583cbfa54..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.tone_analyzer.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The score for a tone from the input content. - */ -public class ToneScore extends GenericModel { - - protected Double score; - @SerializedName("tone_id") - protected String toneId; - @SerializedName("tone_name") - protected String toneName; - - /** - * Gets the score. - * - * The score for the tone. - * * **`2017-09-21`:** The score that is returned lies in the range of 0.5 to 1. A score greater than 0.75 indicates a - * high likelihood that the tone is perceived in the content. - * * **`2016-05-19`:** The score that is returned lies in the range of 0 to 1. A score less than 0.5 indicates that - * the tone is unlikely to be perceived in the content; a score greater than 0.75 indicates a high likelihood that the - * tone is perceived. - * - * @return the score - */ - public Double getScore() { - return score; - } - - /** - * Gets the toneId. - * - * The unique, non-localized identifier of the tone. - * * **`2017-09-21`:** The service can return results for the following tone IDs: `anger`, `fear`, `joy`, and - * `sadness` (emotional tones); `analytical`, `confident`, and `tentative` (language tones). The service returns - * results only for tones whose scores meet a minimum threshold of 0.5. - * * **`2016-05-19`:** The service can return results for the following tone IDs of the different categories: for the - * `emotion` category: `anger`, `disgust`, `fear`, `joy`, and `sadness`; for the `language` category: `analytical`, - * `confident`, and `tentative`; for the `social` category: `openness_big5`, `conscientiousness_big5`, - * `extraversion_big5`, `agreeableness_big5`, and `emotional_range_big5`. The service returns scores for all tones of - * a category, regardless of their values. - * - * @return the toneId - */ - public String getToneId() { - return toneId; - } - - /** - * Gets the toneName. - * - * The user-visible, localized name of the tone. - * - * @return the toneName - */ - public String getToneName() { - return toneName; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java deleted file mode 100644 index 4fbd3a7a791..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * An utterance for the input of the general-purpose endpoint. - */ -public class Utterance extends GenericModel { - - protected String text; - protected String user; - - /** - * Builder. - */ - public static class Builder { - private String text; - private String user; - - private Builder(Utterance utterance) { - this.text = utterance.text; - this.user = utterance.user; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param text the text - */ - public Builder(String text) { - this.text = text; - } - - /** - * Builds a Utterance. - * - * @return the utterance - */ - public Utterance build() { - return new Utterance(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the Utterance builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the user. - * - * @param user the user - * @return the Utterance builder - */ - public Builder user(String user) { - this.user = user; - return this; - } - } - - protected Utterance(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, - "text cannot be null"); - text = builder.text; - user = builder.user; - } - - /** - * New builder. - * - * @return a Utterance builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * An utterance contributed by a user in the conversation that is to be analyzed. The utterance can contain multiple - * sentences. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the user. - * - * A string that identifies the user who contributed the utterance specified by the `text` parameter. - * - * @return the user - */ - public String user() { - return user; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java deleted file mode 100644 index 467c12df1a8..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of the analysis for the utterances of the input content. - */ -public class UtteranceAnalyses extends GenericModel { - - @SerializedName("utterances_tone") - protected List utterancesTone; - protected String warning; - - /** - * Gets the utterancesTone. - * - * An array of `UtteranceAnalysis` objects that provides the results for each utterance of the input. - * - * @return the utterancesTone - */ - public List getUtterancesTone() { - return utterancesTone; - } - - /** - * Gets the warning. - * - * **`2017-09-21`:** A warning message if the content contains more than 50 utterances. The service analyzes only the - * first 50 utterances. **`2016-05-19`:** Not returned. - * - * @return the warning - */ - public String getWarning() { - return warning; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java deleted file mode 100644 index 3457ec2333e..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The results of the analysis for an utterance of the input content. - */ -public class UtteranceAnalysis extends GenericModel { - - @SerializedName("utterance_id") - protected Long utteranceId; - @SerializedName("utterance_text") - protected String utteranceText; - protected List tones; - protected String error; - - /** - * Gets the utteranceId. - * - * The unique identifier of the utterance. The first utterance has ID 0, and the ID of each subsequent utterance is - * incremented by one. - * - * @return the utteranceId - */ - public Long getUtteranceId() { - return utteranceId; - } - - /** - * Gets the utteranceText. - * - * The text of the utterance. - * - * @return the utteranceText - */ - public String getUtteranceText() { - return utteranceText; - } - - /** - * Gets the tones. - * - * An array of `ToneChatScore` objects that provides results for the most prevalent tones of the utterance. The array - * includes results for any tone whose score is at least 0.5. The array is empty if no tone has a score that meets - * this threshold. - * - * @return the tones - */ - public List getTones() { - return tones; - } - - /** - * Gets the error. - * - * **`2017-09-21`:** An error message if the utterance contains more than 500 characters. The service does not analyze - * the utterance. **`2016-05-19`:** Not returned. - * - * @return the error - */ - public String getError() { - return error; - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java deleted file mode 100644 index 240abaea91a..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Tone Analyzer v3. - */ -package com.ibm.watson.tone_analyzer.v3; diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerIT.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerIT.java deleted file mode 100755 index 1d5bc99a1be..00000000000 --- a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerIT.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.tone_analyzer.v3; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.common.RetryRunner; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.tone_analyzer.v3.model.ToneOptions; -import com.ibm.watson.tone_analyzer.v3.model.Utterance; -import com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.ArrayList; -import java.util.List; - -/** - * Tone Analyzer Integration tests. - */ -@RunWith(RetryRunner.class) -public class ToneAnalyzerIT extends WatsonServiceTest { - - /** The service. */ - private ToneAnalyzer service; - private static final String VERSION_DATE_VALUE = "2017-09-21"; - private String text = "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! "; - - private String[] users = { "customer", "agent", "customer", "agent" }; - private String[] texts = { "My charger isn't working.", - "Thanks for reaching out. Can you give me some more detail about the issue?", - "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" - + " charging. The charging icon comes on, but it stays on even when I take the charger out. " - + "Which is ridiculous, it's brand new.", - "I'm sorry you're having issues with charging. What kind of charger are you using?" }; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - String apiKey = getProperty("tone_analyzer.apikey"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null); - - Authenticator authenticator = new IamAuthenticator(apiKey); - service = new ToneAnalyzer(VERSION_DATE_VALUE, authenticator); - service.setServiceUrl(getProperty("tone_analyzer.url")); - service.setDefaultHeaders(getDefaultHeaders()); - - } - - /** - * Test ToneExample. - */ - @Test - public void testToneExample() { - String text = "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! " - + "We need to acknowledge and fix our sales challenges. " - + "We can’t blame the economy for our lack of execution! " + "We are missing critical sales opportunities. " - + "Our product is in no way inferior to the competitor products. " - + "Our clients are hungry for analytical tools to improve their " - + "business outcomes. Economy has nothing to do with it."; - - // Call the service and get the tone - ToneOptions tonOptions = new ToneOptions.Builder().text(text).build(); - ToneAnalysis tone = service.tone(tonOptions).execute().getResult(); - System.out.println(tone); - - } - - /** - * Test ChatExample. - */ - @Test - public void testChatExample() { - String[] texts = { - "My charger isn't working.", - "Thanks for reaching out. Can you give me some more detail about the issue?", - "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" - + " charging. The charging icon comes on, but it stays on even when I take the charger out. " - + "Which is ridiculous, it's brand new.", - "I'm sorry you're having issues with charging. What kind of charger are you using?" - }; - - List utterances = new ArrayList<>(); - for (int i = 0; i < texts.length; i++) { - Utterance utterance = new Utterance.Builder() - .text(texts[i]) - .user(users[i]) - .build(); - utterances.add(utterance); - } - ToneChatOptions toneChatOptions = new ToneChatOptions.Builder() - .utterances(utterances) - .build(); - - // Call the service - UtteranceAnalyses utterancesTone = service.toneChat(toneChatOptions).execute().getResult(); - System.out.println(utterancesTone); - } - - /** - * Test get tone from text. - */ - @Test - public void testtoneFromText() { - ToneOptions options = new ToneOptions.Builder() - .text(text) - .addTone(ToneOptions.Tone.EMOTION) - .addTone(ToneOptions.Tone.LANGUAGE) - .addTone(ToneOptions.Tone.SOCIAL) - .build(); - - ToneAnalysis tone = service.tone(options).execute().getResult(); - assertToneAnalysis(tone); - } - - /** - * Test get tone from html. - */ - @Test - public void testtoneFromHtml() { - ToneOptions options = new ToneOptions.Builder().html(text).build(); - ToneAnalysis tone = service.tone(options).execute().getResult(); - assertToneAnalysis(tone); - } - - private void assertToneAnalysis(ToneAnalysis tone) { - Assert.assertNotNull(tone); - Assert.assertNotNull(tone.getDocumentTone()); - Assert.assertEquals(2, tone.getDocumentTone().getTones().size()); - Assert.assertNotNull(tone.getSentencesTone()); - Assert.assertEquals(4, tone.getSentencesTone().size()); - Assert.assertEquals("I know the times are difficult!", tone.getSentencesTone().get(0).getText()); - } - - /** - * Test to get chat tones from jsonText. - */ - @Test - public void testGetChatTone() { - List utterances = new ArrayList<>(); - for (int i = 0; i < texts.length; i++) { - Utterance utterance = new Utterance.Builder() - .text(texts[i]) - .user(users[i]) - .build(); - utterances.add(utterance); - } - ToneChatOptions toneChatOptions = new ToneChatOptions.Builder() - .utterances(utterances) - .build(); - - UtteranceAnalyses utterancesTone = service.toneChat(toneChatOptions).execute().getResult(); - - Assert.assertNotNull(utterancesTone); - Assert.assertNotNull(utterancesTone.getUtterancesTone()); - Assert.assertEquals(4, utterancesTone.getUtterancesTone().size()); - Assert.assertEquals("My charger isn't working.", utterancesTone.getUtterancesTone().get(0).getUtteranceText()); - } -} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java deleted file mode 100644 index efdacfc1dc5..00000000000 --- a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * (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.tone_analyzer.v3; - -import com.ibm.cloud.sdk.core.http.HttpHeaders; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.tone_analyzer.v3.model.ToneOptions; -import com.ibm.watson.tone_analyzer.v3.model.Utterance; -import com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses; -import okhttp3.mockwebserver.RecordedRequest; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tone Analyzer unit test. - */ -public class ToneAnalyzerTest extends WatsonServiceUnitTest { - - private static final String VERSION_DATE = "version"; - private static final String FIXTURE = "src/test/resources/tone_analyzer/tone.json"; - private static final String CHAT_FIXTURE = "src/test/resources/tone_analyzer/tone_chat.json"; - private static final String TONE_PATH = "/v3/tone"; - private static final String CHAT_TONE_PATH = "/v3/tone_chat"; - - /** The service. */ - private ToneAnalyzer service; - private static final String VERSION_DATE_VALUE = "2017-09-21"; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new ToneAnalyzer(VERSION_DATE_VALUE, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - } - - /** - * Test README. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - - ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE, new NoAuthAuthenticator()); - - service.setServiceUrl(getMockWebServerUrl()); // exclude - ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class); // exclude - server.enqueue(jsonResponse(mockResponse)); // exclude - - String text = "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! " - + "We need to acknowledge and fix our sales challenges. " - + "We can’t blame the economy for our lack of execution! " - + "We are missing critical sales opportunities. " - + "Our product is in no way inferior to the competitor products. " - + "Our clients are hungry for analytical tools to improve their " - + "business outcomes. Economy has nothing to do with it."; - - // Call the service and get the tone - ToneOptions toneOptions = new ToneOptions.Builder().html(text).build(); - ToneAnalysis tone = service.tone(toneOptions).execute().getResult(); - System.out.println(tone); - } - - /** - * Test tone with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testtoneWithNull() { - service.tone(null); - } - - /** - * Test get tones. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testtones() throws InterruptedException, IOException { - String text = "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! "; - - ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - - // execute request - ToneOptions toneOptions = new ToneOptions.Builder().html(text).build(); - ToneAnalysis serviceResponse = service.tone(toneOptions).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); - assertEquals(path, request.getPath()); - assertEquals(serviceResponse, mockResponse); - assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT)); - - // second request - serviceResponse = service.tone(new ToneOptions.Builder().html(text).build()).execute().getResult(); - request = server.takeRequest(); - assertEquals(path, request.getPath()); - assertTrue(request.getHeader(HttpHeaders.CONTENT_TYPE).startsWith(HttpMediaType.TEXT_HTML)); - - // third request - ToneOptions toneOptions1 = new ToneOptions.Builder() - .html(text) - .addTone(ToneOptions.Tone.EMOTION) - .addTone(ToneOptions.Tone.LANGUAGE) - .addTone(ToneOptions.Tone.SOCIAL) - .build(); - serviceResponse = service.tone(toneOptions1).execute().getResult(); - request = server.takeRequest(); - path = path + "&tones=" + RequestUtils.encode("emotion,language,social"); - assertEquals(path, request.getPath()); - } - - /** - * Test to get Chat tones. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testGetChatTones() throws IOException, InterruptedException { - - String[] users = { "customer", "agent", "customer", "agent" }; - - String[] texts = { - "My charger isn't working.", - "Thanks for reaching out. Can you give me some more detail about the issue?", - "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" - + " charging. The charging icon comes on, but it stays on even when I take the charger out. " - + "Which is ridiculous, it's brand new.", - "I'm sorry you're having issues with charging. What kind of charger are you using?" - }; - - List utterances = new ArrayList<>(); - for (int i = 0; i < texts.length; i++) { - Utterance utterance = new Utterance.Builder() - .text(texts[i]) - .user(users[i]) - .build(); - utterances.add(utterance); - } - - ToneChatOptions toneChatOptions = new ToneChatOptions.Builder() - .utterances(utterances) - .build(); - - UtteranceAnalyses mockResponse = loadFixture(CHAT_FIXTURE, UtteranceAnalyses.class); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - - // execute request - UtteranceAnalyses serviceResponse = service.toneChat(toneChatOptions).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(CHAT_TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); - assertEquals(path, request.getPath()); - assertEquals(serviceResponse, mockResponse); - assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT)); - } -} diff --git a/tone-analyzer/src/test/resources/tone_analyzer/chat.json b/tone-analyzer/src/test/resources/tone_analyzer/chat.json deleted file mode 100644 index 58420890e4e..00000000000 --- a/tone-analyzer/src/test/resources/tone_analyzer/chat.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "utterances": [ - {"text": "My charger isn't working.", "user": "customer"}, - {"text": "Thanks for reaching out. Can you give me some more detail about the issue?", "user": "agent"}, - {"text": "I put my charger in my tablet to charge it up last night and it keeps saying it isn't charging. The charging icon comes on, but it stays on even when I take the charger out. Which is ridiculous, it's brand new.", "user": "customer"}, - {"text": "I'm sorry you're having issues with charging. What kind of charger are you using?", "user": "agent"} - ] -} diff --git a/tone-analyzer/src/test/resources/tone_analyzer/email.txt b/tone-analyzer/src/test/resources/tone_analyzer/email.txt deleted file mode 100644 index 9e22d1e6bdc..00000000000 --- a/tone-analyzer/src/test/resources/tone_analyzer/email.txt +++ /dev/null @@ -1,11 +0,0 @@ -Hi Team, - -I know the times are difficult! Our sales have been disappointing for the past three quarters for our data analytics product suite. We have a competitive data analytics product suite in the industry. But we need to do our job selling it! - -We need to acknowledge and fix our sales challenges. We can’t blame the economy for our lack of execution! We are missing critical sales opportunities. Our product is in no way inferior to the competitor products. Our clients are hungry for analytical tools to improve their business outcomes. Economy has nothing to do with it. In fact, it is in times such as this, our clients want to get the insights they need to turn their businesses around. Let’s buckle up and execute. - -In summary, we have a competitive product, and a hungry market. We have to do our job to close the deals. - -Jennifer Baker -Sales Leader, North-East Geo, -Data Analytics Inc. diff --git a/tone-analyzer/src/test/resources/tone_analyzer/message.txt b/tone-analyzer/src/test/resources/tone_analyzer/message.txt deleted file mode 100644 index ad0a25289bd..00000000000 --- a/tone-analyzer/src/test/resources/tone_analyzer/message.txt +++ /dev/null @@ -1 +0,0 @@ -I know the times are difficult! Our sales have been disappointing for the past three quarters for our data analytics product suite. We have a competitive data analytics product suite in the industry. But we need to do our job selling it! diff --git a/tone-analyzer/src/test/resources/tone_analyzer/tone.json b/tone-analyzer/src/test/resources/tone_analyzer/tone.json deleted file mode 100644 index 076fb18cd7c..00000000000 --- a/tone-analyzer/src/test/resources/tone_analyzer/tone.json +++ /dev/null @@ -1,455 +0,0 @@ -{ - "document_tone": { - "tone_categories": [ - { - "tones": [ - { - "score": 0.105802, - "tone_id": "anger", - "tone_name": "Anger" - }, - { - "score": 0.280862, - "tone_id": "disgust", - "tone_name": "Disgust" - }, - { - "score": 0.299966, - "tone_id": "fear", - "tone_name": "Fear" - }, - { - "score": 0.222444, - "tone_id": "joy", - "tone_name": "Joy" - }, - { - "score": 0.090926, - "tone_id": "sadness", - "tone_name": "Sadness" - } - ], - "category_id": "emotion_tone", - "category_name": "Emotion Tone" - }, - { - "tones": [ - { - "score": 0.951, - "tone_id": "analytical", - "tone_name": "Analytical" - }, - { - "score": 0.999, - "tone_id": "confident", - "tone_name": "Confident" - }, - { - "score": 0.999, - "tone_id": "tentative", - "tone_name": "Tentative" - } - ], - "category_id": "writing_tone", - "category_name": "Writing Tone" - }, - { - "tones": [ - { - "score": 0.037, - "tone_id": "openness_big5", - "tone_name": "Openness" - }, - { - "score": 0.172, - "tone_id": "conscientiousness_big5", - "tone_name": "Conscientiousness" - }, - { - "score": 0.263, - "tone_id": "extraversion_big5", - "tone_name": "Extraversion" - }, - { - "score": 0.831, - "tone_id": "agreeableness_big5", - "tone_name": "Agreeableness" - }, - { - "score": 0.967, - "tone_id": "neuroticism_big5", - "tone_name": "Emotional Range" - } - ], - "category_id": "social_tone", - "category_name": "Social Tone" - } - ] - }, - "sentences_tone": [ - { - "sentence_id": 0, - "text": "I know the times are difficult!", - "input_from": 0, - "input_to": 31, - "tone_categories": [ - { - "tones": [ - { - "score": 0.276294, - "tone_id": "anger", - "tone_name": "Anger" - }, - { - "score": 0.280268, - "tone_id": "disgust", - "tone_name": "Disgust" - }, - { - "score": 0.236519, - "tone_id": "fear", - "tone_name": "Fear" - }, - { - "score": 0.15242, - "tone_id": "joy", - "tone_name": "Joy" - }, - { - "score": 0.054499, - "tone_id": "sadness", - "tone_name": "Sadness" - } - ], - "category_id": "emotion_tone", - "category_name": "Emotion Tone" - }, - { - "tones": [ - { - "score": 0.892, - "tone_id": "analytical", - "tone_name": "Analytical" - }, - { - "score": 0.999, - "tone_id": "confident", - "tone_name": "Confident" - }, - { - "score": 0.999, - "tone_id": "tentative", - "tone_name": "Tentative" - } - ], - "category_id": "writing_tone", - "category_name": "Writing Tone" - }, - { - "tones": [ - { - "score": 0.07, - "tone_id": "openness_big5", - "tone_name": "Openness" - }, - { - "score": 0.291, - "tone_id": "conscientiousness_big5", - "tone_name": "Conscientiousness" - }, - { - "score": 0.37, - "tone_id": "extraversion_big5", - "tone_name": "Extraversion" - }, - { - "score": 0.165, - "tone_id": "agreeableness_big5", - "tone_name": "Agreeableness" - }, - { - "score": 0.959, - "tone_id": "neuroticism_big5", - "tone_name": "Emotional Range" - } - ], - "category_id": "social_tone", - "category_name": "Social Tone" - } - ] - }, - { - "sentence_id": 1, - "text": "Our sales have been disappointing for the past three quarters for our data analytics product suite.", - "input_from": 32, - "input_to": 131, - "tone_categories": [ - { - "tones": [ - { - "score": 0.144036, - "tone_id": "anger", - "tone_name": "Anger" - }, - { - "score": 0.235218, - "tone_id": "disgust", - "tone_name": "Disgust" - }, - { - "score": 0.18726, - "tone_id": "fear", - "tone_name": "Fear" - }, - { - "score": 0.141991, - "tone_id": "joy", - "tone_name": "Joy" - }, - { - "score": 0.291495, - "tone_id": "sadness", - "tone_name": "Sadness" - } - ], - "category_id": "emotion_tone", - "category_name": "Emotion Tone" - }, - { - "tones": [ - { - "score": 0.379, - "tone_id": "analytical", - "tone_name": "Analytical" - }, - { - "score": 0.999, - "tone_id": "confident", - "tone_name": "Confident" - }, - { - "score": 0.999, - "tone_id": "tentative", - "tone_name": "Tentative" - } - ], - "category_id": "writing_tone", - "category_name": "Writing Tone" - }, - { - "tones": [ - { - "score": 0.174, - "tone_id": "openness_big5", - "tone_name": "Openness" - }, - { - "score": 0.367, - "tone_id": "conscientiousness_big5", - "tone_name": "Conscientiousness" - }, - { - "score": 0.41, - "tone_id": "extraversion_big5", - "tone_name": "Extraversion" - }, - { - "score": 0.753, - "tone_id": "agreeableness_big5", - "tone_name": "Agreeableness" - }, - { - "score": 0.803, - "tone_id": "neuroticism_big5", - "tone_name": "Emotional Range" - } - ], - "category_id": "social_tone", - "category_name": "Social Tone" - } - ] - }, - { - "sentence_id": 2, - "text": "We have a competitive data analytics product suite in the industry.", - "input_from": 132, - "input_to": 199, - "tone_categories": [ - { - "tones": [ - { - "score": 0.209645, - "tone_id": "anger", - "tone_name": "Anger" - }, - { - "score": 0.193127, - "tone_id": "disgust", - "tone_name": "Disgust" - }, - { - "score": 0.22004, - "tone_id": "fear", - "tone_name": "Fear" - }, - { - "score": 0.206854, - "tone_id": "joy", - "tone_name": "Joy" - }, - { - "score": 0.170334, - "tone_id": "sadness", - "tone_name": "Sadness" - } - ], - "category_id": "emotion_tone", - "category_name": "Emotion Tone" - }, - { - "tones": [ - { - "score": 0.608, - "tone_id": "analytical", - "tone_name": "Analytical" - }, - { - "score": 0.999, - "tone_id": "confident", - "tone_name": "Confident" - }, - { - "score": 0.999, - "tone_id": "tentative", - "tone_name": "Tentative" - } - ], - "category_id": "writing_tone", - "category_name": "Writing Tone" - }, - { - "tones": [ - { - "score": 0.627, - "tone_id": "openness_big5", - "tone_name": "Openness" - }, - { - "score": 0.928, - "tone_id": "conscientiousness_big5", - "tone_name": "Conscientiousness" - }, - { - "score": 0.035, - "tone_id": "extraversion_big5", - "tone_name": "Extraversion" - }, - { - "score": 0.526, - "tone_id": "agreeableness_big5", - "tone_name": "Agreeableness" - }, - { - "score": 0.548, - "tone_id": "neuroticism_big5", - "tone_name": "Emotional Range" - } - ], - "category_id": "social_tone", - "category_name": "Social Tone" - } - ] - }, - { - "sentence_id": 3, - "text": "But we need to do our job selling it!", - "input_from": 200, - "input_to": 237, - "tone_categories": [ - { - "tones": [ - { - "score": 0.056075, - "tone_id": "anger", - "tone_name": "Anger" - }, - { - "score": 0.226992, - "tone_id": "disgust", - "tone_name": "Disgust" - }, - { - "score": 0.252165, - "tone_id": "fear", - "tone_name": "Fear" - }, - { - "score": 0.315444, - "tone_id": "joy", - "tone_name": "Joy" - }, - { - "score": 0.149324, - "tone_id": "sadness", - "tone_name": "Sadness" - } - ], - "category_id": "emotion_tone", - "category_name": "Emotion Tone" - }, - { - "tones": [ - { - "score": 0.722, - "tone_id": "analytical", - "tone_name": "Analytical" - }, - { - "score": 0.999, - "tone_id": "confident", - "tone_name": "Confident" - }, - { - "score": 0.999, - "tone_id": "tentative", - "tone_name": "Tentative" - } - ], - "category_id": "writing_tone", - "category_name": "Writing Tone" - }, - { - "tones": [ - { - "score": 0.02, - "tone_id": "openness_big5", - "tone_name": "Openness" - }, - { - "score": 0.024, - "tone_id": "conscientiousness_big5", - "tone_name": "Conscientiousness" - }, - { - "score": 0.828, - "tone_id": "extraversion_big5", - "tone_name": "Extraversion" - }, - { - "score": 0.946, - "tone_id": "agreeableness_big5", - "tone_name": "Agreeableness" - }, - { - "score": 0.969, - "tone_id": "neuroticism_big5", - "tone_name": "Emotional Range" - } - ], - "category_id": "social_tone", - "category_name": "Social Tone" - } - ] - } - ] -} diff --git a/tone-analyzer/src/test/resources/tone_analyzer/tone_chat.json b/tone-analyzer/src/test/resources/tone_analyzer/tone_chat.json deleted file mode 100644 index f748757adbe..00000000000 --- a/tone-analyzer/src/test/resources/tone_analyzer/tone_chat.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "utterances_tone": [ - { - "utterance_id": 0, - "utterance_text": "My charger isn't working.", - "tones": [ - { - "score": 0.536082, - "tone_id": "sad", - "tone_name": "sad" - } - ] - }, - { - "utterance_id": 1, - "utterance_text": "Thanks for reaching out. Can you give me some more detail about the issue?", - "tones": [ - { - "score": 0.956453, - "tone_id": "polite", - "tone_name": "polite" - } - ] - }, - { - "utterance_id": 2, - "utterance_text": "I put my charger in my tablet to charge it up last night and it keeps saying it isn't charging. The charging icon comes on, but it stays on even when I take the charger out. Which is ridiculous, it's brand new.", - "tones": [] - }, - { - "utterance_id": 3, - "utterance_text": "I'm sorry you're having issues with charging. What kind of charger are you using?", - "tones": [ - { - "score": 0.856453, - "tone_id": "polite", - "tone_name": "polite" - } - ] - } - ] -} diff --git a/utils.gradle b/utils.gradle deleted file mode 100644 index 7fc816409cb..00000000000 --- a/utils.gradle +++ /dev/null @@ -1,9 +0,0 @@ -def getDate() { - def date = new Date() - def formattedDate = date.format('yyyyMMddHHmmss') - return formattedDate -} - -ext { - getDate = this.&getDate -} \ No newline at end of file diff --git a/visual-recognition/README.md b/visual-recognition/README.md deleted file mode 100644 index 1057b2f0e13..00000000000 --- a/visual-recognition/README.md +++ /dev/null @@ -1,108 +0,0 @@ -# Visual Recognition - -## Installation - -##### Maven - -```xml - - com.ibm.watson - visual-recognition - 8.3.1 - -``` - -##### Gradle - -```gradle -'com.ibm.watson:visual-recognition:8.3.1' -``` - -## Usage - -Use the [Visual Recognition][visual_recognition] service to analyze image data. Use either v3 or v4 to analyze the following image: - -![Dog](https://visual-recognition-demo.ng.bluemix.net/images/samples/5.jpg) - -### Using Visual Recognition v3 - -```java -// make sure to use the Visual Recognition v3 import! -import com.ibm.watson.visual_recognition.v3.VisualRecognition; - -Authenticator authenticator = new IamAuthenticator(""); -VisualRecognition service = new VisualRecognition("2018-03-19", authenticator); - -System.out.println("Classify an image"); -ClassifyOptions options = new ClassifyOptions.Builder() - .imagesFile(new File(IMAGE_FILE)) // replace with path to file - .build(); -ClassifiedImages result = service.classify(options).execute().getResult(); -System.out.println(result); -``` - -### Using Visual Recognition v4 - -```java -// make sure to use the Visual Recognition v4 import! -import com.ibm.watson.visual_recognition.v4.VisualRecognition; - -Authenticator authenticator = new IamAuthenticator(""); -VisualRecognition service = new VisualRecognition("2019-02-11", authenticator); - -// create a new collection -CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder() - .name("example-collection") - .build(); -Collection exampleCollection = service.createCollection(createCollectionOptions).execute().getResult(); -String exampleCollectionId = exampleCollection.getCollectionId(); - -// add the above image to your collection -String imageUrl = "https://visual-recognition-demo.ng.bluemix.net/images/samples/5.jpg"; -AddImagesOptions addImagesOptions = new AddImagesOptions.Builder() - .addImageUrl(imageUrl) - .collectionId(exampleCollectionId) - .build(); -ImageDetailsList imageDetailsList = service.addImages(addImagesOptions).execute().getResult(); -String testImageId = imageDetailsList.getImages().get(0).getImageId(); - -// . -// . -// add more images to fill up your collection for training -// . -// . - -// train the collection on your first image -Location location = new Location.Builder() - .top(25L) - .left(35L) - .width(105L) - .height(215L) - .build(); -TrainingDataObject trainingDataObject = new TrainingDataObject.Builder() - .object("dog") - .location(location) - .build(); -AddImageTrainingDataOptions addTrainingDataOptions = new AddImageTrainingDataOptions.Builder() - .collectionId(exampleCollectionId) - .addObjects(trainingDataObject) - .imageId(testImageId) - .build(); -service.addImageTrainingData(addTrainingDataOptions).execute(); -TrainOptions trainOptions = new TrainOptions.Builder() - .collectionId(exampleCollectionId) - .build(); -service.train(trainOptions).execute().getResult(); - -// analyze the image! -AnalyzeOptions options = new AnalyzeOptions.Builder() - .addImageUrl(imageUrl) - .addCollectionIds(exampleCollectionId) - .addFeatures(AnalyzeOptions.Features.OBJECTS) - .build(); -AnalyzeResponse response = service.analyze(options).execute().getResult(); - -System.out.println(response); -``` - -[visual_recognition]: https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-getting-started-tutorial diff --git a/visual-recognition/build.gradle b/visual-recognition/build.gradle deleted file mode 100644 index d9dc2b74f77..00000000000 --- a/visual-recognition/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' -} - -defaultTasks 'clean' - -apply from: '../utils.gradle' -import org.apache.tools.ant.filters.* - -apply plugin: 'java' -apply plugin: 'ru.vyarus.animalsniffer' -apply plugin: 'maven' -apply plugin: 'signing' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' - -project.tasks.assemble.dependsOn project.tasks.shadowJar - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - maven { url "https://repo.maven.apache.org/maven2" } - maven { url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo" } -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -signing { - sign configurations.archives -} - -signArchives { - onlyIf { Task task -> - def shouldExec = false - for (myArg in project.gradle.startParameter.taskRequests[0].args) { - if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) { - shouldExec = true - } - } - return shouldExec - } -} - -checkstyleTest { - ignoreFailures = false -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') - ignoreFailures = false -} - -dependencies { - compile project(':common') - testCompile project(':common').sourceSets.test.output - compile 'com.ibm.cloud:sdk-core:8.1.0' - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -apply from: rootProject.file('.utility/bintray-properties.gradle') diff --git a/visual-recognition/gradle.properties b/visual-recognition/gradle.properties deleted file mode 100644 index 41d7a5f4204..00000000000 --- a/visual-recognition/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -PACKAGE_NAME=com.ibm.watson:visual-recognition -ARTIFACT_ID=visual-recognition -NAME=IBM Watson Java SDK - Visual Recognition -DESCRIPTION=Java client library to use the IBM Visual Recognition API \ No newline at end of file diff --git a/visual-recognition/ibm-credentials.env b/visual-recognition/ibm-credentials.env deleted file mode 100644 index 50a18af741a..00000000000 --- a/visual-recognition/ibm-credentials.env +++ /dev/null @@ -1,3 +0,0 @@ -VISUAL_RECOGNITION_USERNAME=username -VISUAL_RECOGNITION_PASSWORD=password -VISUAL_RECOGNITION_AUTH_TYPE=basic \ No newline at end of file diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java deleted file mode 100644 index a008d08f9ee..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2016, 2020. - * - * 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.visual_recognition.v3; - -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.visual_recognition.v3.model.Classifier; -import com.ibm.watson.visual_recognition.v3.model.Classifiers; -import com.ibm.watson.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions; -import com.ibm.watson.visual_recognition.v3.model.UpdateClassifierOptions; -import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; -import okhttp3.MultipartBody; - -/** - * The IBM Watson™ Visual Recognition service uses deep learning algorithms to identify scenes and objects in - * images that you upload to the service. You can create and train a custom classifier to identify subjects that suit - * your needs. - * - * @version v3 - * @see Visual Recognition - */ -public class VisualRecognition extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "visual_recognition"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/visual-recognition/api"; - - private String versionDate; - - /** - * Constructs a new `VisualRecognition` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public VisualRecognition(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `VisualRecognition` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public VisualRecognition(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `VisualRecognition` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public VisualRecognition(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `VisualRecognition` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public VisualRecognition(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Classify images. - * - * Classify images with built-in or custom classifiers. - * - * @param classifyOptions the {@link ClassifyOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ClassifiedImages} - */ - public ServiceCall classify(ClassifyOptions classifyOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classifyOptions, - "classifyOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((classifyOptions.imagesFile() != null) || (classifyOptions - .url() != null) || (classifyOptions.threshold() != null) || (classifyOptions.owners() != null) - || (classifyOptions.classifierIds() != null), - "At least one of imagesFile, url, threshold, owners, or classifierIds must be supplied."); - String[] pathSegments = { "v3/classify" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "classify"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (classifyOptions.acceptLanguage() != null) { - builder.header("Accept-Language", classifyOptions.acceptLanguage()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (classifyOptions.imagesFile() != null) { - okhttp3.RequestBody imagesFileBody = RequestUtils.inputStreamBody(classifyOptions.imagesFile(), classifyOptions - .imagesFileContentType()); - multipartBuilder.addFormDataPart("images_file", classifyOptions.imagesFilename(), imagesFileBody); - } - if (classifyOptions.url() != null) { - multipartBuilder.addFormDataPart("url", classifyOptions.url()); - } - if (classifyOptions.threshold() != null) { - multipartBuilder.addFormDataPart("threshold", String.valueOf(classifyOptions.threshold())); - } - if (classifyOptions.owners() != null) { - multipartBuilder.addFormDataPart("owners", RequestUtils.join(classifyOptions.owners(), ",")); - } - if (classifyOptions.classifierIds() != null) { - multipartBuilder.addFormDataPart("classifier_ids", RequestUtils.join(classifyOptions.classifierIds(), ",")); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Classify images. - * - * Classify images with built-in or custom classifiers. - * - * @return a {@link ServiceCall} with a response type of {@link ClassifiedImages} - */ - public ServiceCall classify() { - return classify(null); - } - - /** - * Create a classifier. - * - * Train a new multi-faceted classifier on the uploaded image data. Create your custom classifier with positive or - * negative example training images. Include at least two sets of examples, either two positive example files or one - * positive and one negative file. You can upload a maximum of 256 MB per call. - * - * **Tips when creating:** - * - * - If you set the **X-Watson-Learning-Opt-Out** header parameter to `true` when you create a classifier, the example - * training images are not stored. Save your training images locally. For more information, see [Data - * collection](#data-collection). - * - * - Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and - * class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters. - * - * @param createClassifierOptions the {@link CreateClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} - */ - public ServiceCall createClassifier(CreateClassifierOptions createClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createClassifierOptions, - "createClassifierOptions cannot be null"); - String[] pathSegments = { "v3/classifiers" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "createClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - multipartBuilder.addFormDataPart("name", createClassifierOptions.name()); - for (Map.Entry entry : createClassifierOptions.positiveExamples().entrySet()) { - String partName = String.format("%s_positive_examples", entry.getKey()); - okhttp3.RequestBody part = RequestUtils.inputStreamBody(entry.getValue(), "application/octet-stream"); - multipartBuilder.addFormDataPart(partName, entry.getKey() + ".zip", part); - } - if (createClassifierOptions.negativeExamples() != null) { - okhttp3.RequestBody negativeExamplesBody = RequestUtils.inputStreamBody(createClassifierOptions - .negativeExamples(), "application/octet-stream"); - String negativeExamplesFilename = createClassifierOptions.negativeExamplesFilename(); - if (!negativeExamplesFilename.contains(".")) { - negativeExamplesFilename += ".zip"; - } - multipartBuilder.addFormDataPart("negative_examples", negativeExamplesFilename, negativeExamplesBody); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Retrieve a list of classifiers. - * - * @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classifiers} - */ - public ServiceCall listClassifiers(ListClassifiersOptions listClassifiersOptions) { - String[] pathSegments = { "v3/classifiers" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "listClassifiers"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listClassifiersOptions != null) { - if (listClassifiersOptions.verbose() != null) { - builder.query("verbose", String.valueOf(listClassifiersOptions.verbose())); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Retrieve a list of classifiers. - * - * @return a {@link ServiceCall} with a response type of {@link Classifiers} - */ - public ServiceCall listClassifiers() { - return listClassifiers(null); - } - - /** - * Retrieve classifier details. - * - * Retrieve information about a custom classifier. - * - * @param getClassifierOptions the {@link GetClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} - */ - public ServiceCall getClassifier(GetClassifierOptions getClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getClassifierOptions, - "getClassifierOptions cannot be null"); - String[] pathSegments = { "v3/classifiers" }; - String[] pathParameters = { getClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update a classifier. - * - * Update a custom classifier by adding new positive or negative classes or by adding new images to existing classes. - * You must supply at least one set of positive or negative examples. For details, see [Updating custom - * classifiers] - * (https://cloud.ibm.com/docs/visual-recognition - * ?topic=visual-recognition-customizing#updating-custom-classifiers). - * - * Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class - * names). The service assumes UTF-8 encoding if it encounters non-ASCII characters. - * - * **Tips about retraining:** - * - * - You can't update the classifier if the **X-Watson-Learning-Opt-Out** header parameter was set to `true` when the - * classifier was created. Training images are not stored in that case. Instead, create another classifier. For more - * information, see [Data collection](#data-collection). - * - * - Don't make retraining calls on a classifier until the status is ready. When you submit retraining requests in - * parallel, the last request overwrites the previous requests. The `retrained` property shows the last time the - * classifier retraining finished. - * - * @param updateClassifierOptions the {@link UpdateClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} - */ - public ServiceCall updateClassifier(UpdateClassifierOptions updateClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateClassifierOptions, - "updateClassifierOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((updateClassifierOptions.positiveExamples() != null) - || (updateClassifierOptions.negativeExamples() != null), - "At least one of positiveExamples or negativeExamples must be supplied."); - String[] pathSegments = { "v3/classifiers" }; - String[] pathParameters = { updateClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "updateClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (updateClassifierOptions.positiveExamples() != null) { - for (Map.Entry entry : updateClassifierOptions.positiveExamples().entrySet()) { - String partName = String.format("%s_positive_examples", entry.getKey()); - okhttp3.RequestBody part = RequestUtils.inputStreamBody(entry.getValue(), "application/octet-stream"); - multipartBuilder.addFormDataPart(partName, entry.getKey(), part); - } - } - if (updateClassifierOptions.negativeExamples() != null) { - okhttp3.RequestBody negativeExamplesBody = RequestUtils.inputStreamBody(updateClassifierOptions - .negativeExamples(), "application/octet-stream"); - multipartBuilder.addFormDataPart("negative_examples", updateClassifierOptions.negativeExamplesFilename(), - negativeExamplesBody); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a classifier. - * - * @param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteClassifier(DeleteClassifierOptions deleteClassifierOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteClassifierOptions, - "deleteClassifierOptions cannot be null"); - String[] pathSegments = { "v3/classifiers" }; - String[] pathParameters = { deleteClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteClassifier"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Retrieve a Core ML model of a classifier. - * - * Download a Core ML model file (.mlmodel) of a custom classifier that returns "core_ml_enabled": true in - * the classifier details. - * - * @param getCoreMlModelOptions the {@link GetCoreMlModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} - */ - public ServiceCall getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getCoreMlModelOptions, - "getCoreMlModelOptions cannot be null"); - String[] pathSegments = { "v3/classifiers", "core_ml_model" }; - String[] pathParameters = { getCoreMlModelOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getCoreMlModel"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/octet-stream"); - - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete labeled data. - * - * Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with - * the customer ID. - * - * 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/visual-recognition?topic=visual-recognition-information-security). - * - * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, - "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v3/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteUserData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java deleted file mode 100644 index 60de13f10c6..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A category within a classifier. - */ -public class Class extends GenericModel { - - @SerializedName("class") - protected String xClass; - - /** - * Gets the xClass. - * - * The name of the class. - * - * @return the xClass - */ - public String getXClass() { - return xClass; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java deleted file mode 100644 index d3fc75b9834..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Result of a class within a classifier. - */ -public class ClassResult extends GenericModel { - - @SerializedName("class") - protected String xClass; - protected Float score; - @SerializedName("type_hierarchy") - protected String typeHierarchy; - - /** - * Gets the xClass. - * - * Name of the class. - * - * Class names are translated in the language defined by the **Accept-Language** request header for the build-in - * classifier IDs (`default`, `food`, and `explicit`). Class names of custom classifiers are not translated. The - * response might not be in the specified language when the requested language is not supported or when there is no - * translation for the class name. - * - * @return the xClass - */ - public String getXClass() { - return xClass; - } - - /** - * Gets the score. - * - * Confidence score for the property in the range of 0 to 1. A higher score indicates greater likelihood that the - * class is depicted in the image. The default threshold for returning scores from a classifier is 0.5. - * - * @return the score - */ - public Float getScore() { - return score; - } - - /** - * Gets the typeHierarchy. - * - * Knowledge graph of the property. For example, `/fruit/pome/apple/eating apple/Granny Smith`. Included only if - * identified. - * - * @return the typeHierarchy - */ - public String getTypeHierarchy() { - return typeHierarchy; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java deleted file mode 100644 index 399b35a4b48..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Results for one image. - */ -public class ClassifiedImage extends GenericModel { - - @SerializedName("source_url") - protected String sourceUrl; - @SerializedName("resolved_url") - protected String resolvedUrl; - protected String image; - protected ErrorInfo error; - protected List classifiers; - - /** - * Gets the sourceUrl. - * - * Source of the image before any redirects. Not returned when the image is uploaded. - * - * @return the sourceUrl - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * Gets the resolvedUrl. - * - * Fully resolved URL of the image after redirects are followed. Not returned when the image is uploaded. - * - * @return the resolvedUrl - */ - public String getResolvedUrl() { - return resolvedUrl; - } - - /** - * Gets the image. - * - * Relative path of the image file if uploaded directly. Not returned when the image is passed by URL. - * - * @return the image - */ - public String getImage() { - return image; - } - - /** - * Gets the error. - * - * Information about what might have caused a failure, such as an image that is too large. Not returned when there is - * no error. - * - * @return the error - */ - public ErrorInfo getError() { - return error; - } - - /** - * Gets the classifiers. - * - * The classifiers. - * - * @return the classifiers - */ - public List getClassifiers() { - return classifiers; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java deleted file mode 100644 index 178d9bbe60b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Results for all images. - */ -public class ClassifiedImages extends GenericModel { - - @SerializedName("custom_classes") - protected Long customClasses; - @SerializedName("images_processed") - protected Long imagesProcessed; - protected List images; - protected List warnings; - - /** - * Gets the customClasses. - * - * Number of custom classes identified in the images. - * - * @return the customClasses - */ - public Long getCustomClasses() { - return customClasses; - } - - /** - * Gets the imagesProcessed. - * - * Number of images processed for the API call. - * - * @return the imagesProcessed - */ - public Long getImagesProcessed() { - return imagesProcessed; - } - - /** - * Gets the images. - * - * Classified images. - * - * @return the images - */ - public List getImages() { - return images; - } - - /** - * Gets the warnings. - * - * Information about what might cause less than optimal output. For example, a request sent with a corrupt .zip file - * and a list of image URLs will still complete, but does not return the expected output. Not returned when there is - * no warning. - * - * @return the warnings - */ - public List getWarnings() { - return warnings; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java deleted file mode 100644 index 7fb6e4ff99a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about a classifier. - */ -public class Classifier extends GenericModel { - - /** - * Training status of classifier. - */ - public interface Status { - /** ready. */ - String READY = "ready"; - /** training. */ - String TRAINING = "training"; - /** retraining. */ - String RETRAINING = "retraining"; - /** failed. */ - String FAILED = "failed"; - } - - @SerializedName("classifier_id") - protected String classifierId; - protected String name; - protected String owner; - protected String status; - @SerializedName("core_ml_enabled") - protected Boolean coreMlEnabled; - protected String explanation; - protected Date created; - protected List classes; - protected Date retrained; - protected Date updated; - - /** - * Gets the classifierId. - * - * ID of a classifier identified in the image. - * - * @return the classifierId - */ - public String getClassifierId() { - return classifierId; - } - - /** - * Gets the name. - * - * Name of the classifier. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the owner. - * - * Unique ID of the account who owns the classifier. Might not be returned by some requests. - * - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * Gets the status. - * - * Training status of classifier. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the coreMlEnabled. - * - * Whether the classifier can be downloaded as a Core ML model after the training status is `ready`. - * - * @return the coreMlEnabled - */ - public Boolean isCoreMlEnabled() { - return coreMlEnabled; - } - - /** - * Gets the explanation. - * - * If classifier training has failed, this field might explain why. - * - * @return the explanation - */ - public String getExplanation() { - return explanation; - } - - /** - * Gets the created. - * - * Date and time in Coordinated Universal Time (UTC) that the classifier was created. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the classes. - * - * Classes that define a classifier. - * - * @return the classes - */ - public List getClasses() { - return classes; - } - - /** - * Gets the retrained. - * - * Date and time in Coordinated Universal Time (UTC) that the classifier was updated. Might not be returned by some - * requests. Identical to `updated` and retained for backward compatibility. - * - * @return the retrained - */ - public Date getRetrained() { - return retrained; - } - - /** - * Gets the updated. - * - * Date and time in Coordinated Universal Time (UTC) that the classifier was most recently updated. The field matches - * either `retrained` or `created`. Might not be returned by some requests. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java deleted file mode 100644 index b2d13980f30..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Classifier and score combination. - */ -public class ClassifierResult extends GenericModel { - - protected String name; - @SerializedName("classifier_id") - protected String classifierId; - protected List classes; - - /** - * Gets the name. - * - * Name of the classifier. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the classifierId. - * - * ID of a classifier identified in the image. - * - * @return the classifierId - */ - public String getClassifierId() { - return classifierId; - } - - /** - * Gets the classes. - * - * Classes within the classifier. - * - * @return the classes - */ - public List getClasses() { - return classes; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java deleted file mode 100644 index 1be88b2b400..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v3.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A container for the list of classifiers. - */ -public class Classifiers extends GenericModel { - - protected List classifiers; - - /** - * Gets the classifiers. - * - * List of classifiers. - * - * @return the classifiers - */ - public List getClassifiers() { - return classifiers; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java deleted file mode 100644 index 88099ebbd0f..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The classify options. - */ -public class ClassifyOptions extends GenericModel { - - /** - * The desired language of parts of the response. See the response for details. - */ - public interface AcceptLanguage { - /** en. */ - String EN = "en"; - /** ar. */ - String AR = "ar"; - /** de. */ - String DE = "de"; - /** es. */ - String ES = "es"; - /** fr. */ - String FR = "fr"; - /** it. */ - String IT = "it"; - /** ja. */ - String JA = "ja"; - /** ko. */ - String KO = "ko"; - /** pt-br. */ - String PT_BR = "pt-br"; - /** zh-cn. */ - String ZH_CN = "zh-cn"; - /** zh-tw. */ - String ZH_TW = "zh-tw"; - } - - protected InputStream imagesFile; - protected String imagesFilename; - protected String imagesFileContentType; - protected String url; - protected Float threshold; - protected List owners; - protected List classifierIds; - protected String acceptLanguage; - - /** - * Builder. - */ - public static class Builder { - private InputStream imagesFile; - private String imagesFilename; - private String imagesFileContentType; - private String url; - private Float threshold; - private List owners; - private List classifierIds; - private String acceptLanguage; - - private Builder(ClassifyOptions classifyOptions) { - this.imagesFile = classifyOptions.imagesFile; - this.imagesFilename = classifyOptions.imagesFilename; - this.imagesFileContentType = classifyOptions.imagesFileContentType; - this.url = classifyOptions.url; - this.threshold = classifyOptions.threshold; - this.owners = classifyOptions.owners; - this.classifierIds = classifyOptions.classifierIds; - this.acceptLanguage = classifyOptions.acceptLanguage; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ClassifyOptions. - * - * @return the classifyOptions - */ - public ClassifyOptions build() { - return new ClassifyOptions(this); - } - - /** - * Adds an owner to owners. - * - * @param owner the new owner - * @return the ClassifyOptions builder - */ - public Builder addOwner(String owner) { - com.ibm.cloud.sdk.core.util.Validator.notNull(owner, - "owner cannot be null"); - if (this.owners == null) { - this.owners = new ArrayList(); - } - this.owners.add(owner); - return this; - } - - /** - * Adds an classifierId to classifierIds. - * - * @param classifierId the new classifierId - * @return the ClassifyOptions builder - */ - public Builder addClassifierId(String classifierId) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classifierId, - "classifierId cannot be null"); - if (this.classifierIds == null) { - this.classifierIds = new ArrayList(); - } - this.classifierIds.add(classifierId); - return this; - } - - /** - * Set the imagesFile. - * - * @param imagesFile the imagesFile - * @return the ClassifyOptions builder - */ - public Builder imagesFile(InputStream imagesFile) { - this.imagesFile = imagesFile; - return this; - } - - /** - * Set the imagesFilename. - * - * @param imagesFilename the imagesFilename - * @return the ClassifyOptions builder - */ - public Builder imagesFilename(String imagesFilename) { - this.imagesFilename = imagesFilename; - return this; - } - - /** - * Set the imagesFileContentType. - * - * @param imagesFileContentType the imagesFileContentType - * @return the ClassifyOptions builder - */ - public Builder imagesFileContentType(String imagesFileContentType) { - this.imagesFileContentType = imagesFileContentType; - return this; - } - - /** - * Set the url. - * - * @param url the url - * @return the ClassifyOptions builder - */ - public Builder url(String url) { - this.url = url; - return this; - } - - /** - * Set the threshold. - * - * @param threshold the threshold - * @return the ClassifyOptions builder - */ - public Builder threshold(Float threshold) { - this.threshold = threshold; - return this; - } - - /** - * Set the owners. - * Existing owners will be replaced. - * - * @param owners the owners - * @return the ClassifyOptions builder - */ - public Builder owners(List owners) { - this.owners = owners; - return this; - } - - /** - * Set the classifierIds. - * Existing classifierIds will be replaced. - * - * @param classifierIds the classifierIds - * @return the ClassifyOptions builder - */ - public Builder classifierIds(List classifierIds) { - this.classifierIds = classifierIds; - return this; - } - - /** - * Set the acceptLanguage. - * - * @param acceptLanguage the acceptLanguage - * @return the ClassifyOptions builder - */ - public Builder acceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** - * Set the imagesFile. - * - * @param imagesFile the imagesFile - * @return the ClassifyOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder imagesFile(File imagesFile) throws FileNotFoundException { - this.imagesFile = new FileInputStream(imagesFile); - this.imagesFilename = imagesFile.getName(); - return this; - } - } - - protected ClassifyOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.isTrue((builder.imagesFile == null) || (builder.imagesFilename != null), - "imagesFilename cannot be null if imagesFile is not null."); - imagesFile = builder.imagesFile; - imagesFilename = builder.imagesFilename; - imagesFileContentType = builder.imagesFileContentType; - url = builder.url; - threshold = builder.threshold; - owners = builder.owners; - classifierIds = builder.classifierIds; - acceptLanguage = builder.acceptLanguage; - } - - /** - * New builder. - * - * @return a ClassifyOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the imagesFile. - * - * An image file (.gif, .jpg, .png, .tif) or .zip file with images. Maximum image size is 10 MB. Include no more than - * 20 images and limit the .zip file to 100 MB. Encode the image and .zip file names in UTF-8 if they contain - * non-ASCII characters. The service assumes UTF-8 encoding if it encounters non-ASCII characters. - * - * You can also include an image with the **url** parameter. - * - * @return the imagesFile - */ - public InputStream imagesFile() { - return imagesFile; - } - - /** - * Gets the imagesFilename. - * - * The filename for imagesFile. - * - * @return the imagesFilename - */ - public String imagesFilename() { - return imagesFilename; - } - - /** - * Gets the imagesFileContentType. - * - * The content type of imagesFile. Values for this parameter can be obtained from the HttpMediaType class. - * - * @return the imagesFileContentType - */ - public String imagesFileContentType() { - return imagesFileContentType; - } - - /** - * Gets the url. - * - * The URL of an image (.gif, .jpg, .png, .tif) to analyze. The minimum recommended pixel density is 32X32 pixels, but - * the service tends to perform better with images that are at least 224 x 224 pixels. The maximum image size is 10 - * MB. - * - * You can also include images with the **images_file** parameter. - * - * @return the url - */ - public String url() { - return url; - } - - /** - * Gets the threshold. - * - * The minimum score a class must have to be displayed in the response. Set the threshold to `0.0` to return all - * identified classes. - * - * @return the threshold - */ - public Float threshold() { - return threshold; - } - - /** - * Gets the owners. - * - * The categories of classifiers to apply. The **classifier_ids** parameter overrides **owners**, so make sure that - * **classifier_ids** is empty. - * - Use `IBM` to classify against the `default` general classifier. You get the same result if both - * **classifier_ids** and **owners** parameters are empty. - * - Use `me` to classify against all your custom classifiers. However, for better performance use **classifier_ids** - * to specify the specific custom classifiers to apply. - * - Use both `IBM` and `me` to analyze the image against both classifier categories. - * - * @return the owners - */ - public List owners() { - return owners; - } - - /** - * Gets the classifierIds. - * - * Which classifiers to apply. Overrides the **owners** parameter. You can specify both custom and built-in classifier - * IDs. The built-in `default` classifier is used if both **classifier_ids** and **owners** parameters are empty. - * - * The following built-in classifier IDs require no training: - * - `default`: Returns classes from thousands of general tags. - * - `food`: Enhances specificity and accuracy for images of food items. - * - `explicit`: Evaluates whether the image might be pornographic. - * - * @return the classifierIds - */ - public List classifierIds() { - return classifierIds; - } - - /** - * Gets the acceptLanguage. - * - * The desired language of parts of the response. See the response for details. - * - * @return the acceptLanguage - */ - public String acceptLanguage() { - return acceptLanguage; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java deleted file mode 100644 index b9234d3f919..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createClassifier options. - */ -public class CreateClassifierOptions extends GenericModel { - - protected String name; - protected Map positiveExamples; - protected InputStream negativeExamples; - protected String negativeExamplesFilename; - - /** - * Builder. - */ - public static class Builder { - private String name; - private Map positiveExamples; - private InputStream negativeExamples; - private String negativeExamplesFilename; - - private Builder(CreateClassifierOptions createClassifierOptions) { - this.name = createClassifierOptions.name; - this.positiveExamples = createClassifierOptions.positiveExamples; - this.negativeExamples = createClassifierOptions.negativeExamples; - this.negativeExamplesFilename = createClassifierOptions.negativeExamplesFilename; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this.name = name; - } - - /** - * Builds a CreateClassifierOptions. - * - * @return the createClassifierOptions - */ - public CreateClassifierOptions build() { - return new CreateClassifierOptions(this); - } - - /** - * Adds an entry to the positiveExamples map. - * - * @param classname the key associated with the map entry to be added - * @param positiveExamples the value associated with the map entry to be added - * @return the CreateClassifierOptions builder - */ - public Builder addPositiveExamples(String classname, InputStream positiveExamples) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classname, - "classname cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(positiveExamples, - "positiveExamples cannot be null"); - if (this.positiveExamples == null) { - this.positiveExamples = new HashMap(); - } - this.positiveExamples.put(classname, positiveExamples); - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateClassifierOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the positiveExamples. - * Existing positiveExamples map will be replaced. - * - * @param positiveExamples the positiveExamples - * @return the CreateClassifierOptions builder - */ - public Builder positiveExamples(Map positiveExamples) { - this.positiveExamples = positiveExamples; - return this; - } - - /** - * Set the negativeExamples. - * - * @param negativeExamples the negativeExamples - * @return the CreateClassifierOptions builder - */ - public Builder negativeExamples(InputStream negativeExamples) { - this.negativeExamples = negativeExamples; - return this; - } - - /** - * Set the negativeExamplesFilename. - * - * @param negativeExamplesFilename the negativeExamplesFilename - * @return the CreateClassifierOptions builder - */ - public Builder negativeExamplesFilename(String negativeExamplesFilename) { - this.negativeExamplesFilename = negativeExamplesFilename; - return this; - } - - /** - * Adds an entry to the positiveExamples map. - * - * @param classname the key associated with the map entry to be added - * @param positiveExamples the value associated with the map entry to be added - * @return the CreateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder addPositiveExamples(String classname, File positiveExamples) throws FileNotFoundException { - this.addPositiveExamples(classname, new FileInputStream(positiveExamples)); - return this; - } - - /** - * Set the negativeExamples. - * - * @param negativeExamples the negativeExamples - * @return the CreateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder negativeExamples(File negativeExamples) throws FileNotFoundException { - this.negativeExamples = new FileInputStream(negativeExamples); - this.negativeExamplesFilename = negativeExamples.getName(); - return this; - } - } - - protected CreateClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, - "name cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((builder.negativeExamples == null) - || (builder.negativeExamplesFilename != null), - "negativeExamplesFilename cannot be null if negativeExamples is not null."); - com.ibm.cloud.sdk.core.util.Validator.isTrue(builder.positiveExamples != null && !builder.positiveExamples - .isEmpty(), - "positiveExamples cannot be null or empty"); - name = builder.name; - positiveExamples = builder.positiveExamples; - negativeExamples = builder.negativeExamples; - negativeExamplesFilename = builder.negativeExamplesFilename; - } - - /** - * New builder. - * - * @return a CreateClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * The name of the new classifier. Encode special characters in UTF-8. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the positiveExamples. - * - * A .zip file of images that depict the visual subject of a class in the new classifier. You can include more than - * one positive example file in a call. - * - * Specify the parameter name by appending `_positive_examples` to the class name. For example, - * `goldenretriever_positive_examples` creates the class **goldenretriever**. The string cannot contain the following - * characters: ``$ * - { } \ | / ' " ` [ ]``. - * - * Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The - * maximum number of images is 10,000 images or 100 MB per .zip file. - * - * Encode special characters in the file name in UTF-8. - * - * @return the positiveExamples - */ - public Map positiveExamples() { - return positiveExamples; - } - - /** - * Gets the negativeExamples. - * - * A .zip file of images that do not depict the visual subject of any of the classes of the new classifier. Must - * contain a minimum of 10 images. - * - * Encode special characters in the file name in UTF-8. - * - * @return the negativeExamples - */ - public InputStream negativeExamples() { - return negativeExamples; - } - - /** - * Gets the negativeExamplesFilename. - * - * The filename for negativeExamples. - * - * @return the negativeExamplesFilename - */ - public String negativeExamplesFilename() { - return negativeExamplesFilename; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java deleted file mode 100644 index ef88d9b4f04..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteClassifier options. - */ -public class DeleteClassifierOptions extends GenericModel { - - protected String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(DeleteClassifierOptions deleteClassifierOptions) { - this.classifierId = deleteClassifierOptions.classifierId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this.classifierId = classifierId; - } - - /** - * Builds a DeleteClassifierOptions. - * - * @return the deleteClassifierOptions - */ - public DeleteClassifierOptions build() { - return new DeleteClassifierOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the DeleteClassifierOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - } - - protected DeleteClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - classifierId = builder.classifierId; - } - - /** - * New builder. - * - * @return a DeleteClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * The ID of the classifier. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java deleted file mode 100644 index 253a4991b67..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.visual_recognition.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - protected String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - this.customerId = deleteUserDataOptions.customerId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customerId the customerId - */ - public Builder(String customerId) { - this.customerId = customerId; - } - - /** - * Builds a DeleteUserDataOptions. - * - * @return the deleteUserDataOptions - */ - public DeleteUserDataOptions build() { - return new DeleteUserDataOptions(this); - } - - /** - * Set the customerId. - * - * @param customerId the customerId - * @return the DeleteUserDataOptions builder - */ - public Builder customerId(String customerId) { - this.customerId = customerId; - return this; - } - } - - protected DeleteUserDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, - "customerId cannot be null"); - customerId = builder.customerId; - } - - /** - * New builder. - * - * @return a DeleteUserDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customerId. - * - * The customer ID for which all data is to be deleted. - * - * @return the customerId - */ - public String customerId() { - return customerId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java deleted file mode 100644 index c6d744dce03..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about what might have caused a failure, such as an image that is too large. Not returned when there is no - * error. - */ -public class ErrorInfo extends GenericModel { - - protected Long code; - protected String description; - @SerializedName("error_id") - protected String errorId; - - /** - * Gets the code. - * - * HTTP status code. - * - * @return the code - */ - public Long getCode() { - return code; - } - - /** - * Gets the description. - * - * Human-readable error description. For example, `File size limit exceeded`. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the errorId. - * - * Codified error string. For example, `limit_exceeded`. - * - * @return the errorId - */ - public String getErrorId() { - return errorId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java deleted file mode 100644 index 2b0ef882d83..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getClassifier options. - */ -public class GetClassifierOptions extends GenericModel { - - protected String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(GetClassifierOptions getClassifierOptions) { - this.classifierId = getClassifierOptions.classifierId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this.classifierId = classifierId; - } - - /** - * Builds a GetClassifierOptions. - * - * @return the getClassifierOptions - */ - public GetClassifierOptions build() { - return new GetClassifierOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the GetClassifierOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - } - - protected GetClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - classifierId = builder.classifierId; - } - - /** - * New builder. - * - * @return a GetClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * The ID of the classifier. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java deleted file mode 100644 index 73da207856a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.visual_recognition.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getCoreMlModel options. - */ -public class GetCoreMlModelOptions extends GenericModel { - - protected String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(GetCoreMlModelOptions getCoreMlModelOptions) { - this.classifierId = getCoreMlModelOptions.classifierId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this.classifierId = classifierId; - } - - /** - * Builds a GetCoreMlModelOptions. - * - * @return the getCoreMlModelOptions - */ - public GetCoreMlModelOptions build() { - return new GetCoreMlModelOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the GetCoreMlModelOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - } - - protected GetCoreMlModelOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - classifierId = builder.classifierId; - } - - /** - * New builder. - * - * @return a GetCoreMlModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * The ID of the classifier. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java deleted file mode 100644 index e6ab7d0b53b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listClassifiers options. - */ -public class ListClassifiersOptions extends GenericModel { - - protected Boolean verbose; - - /** - * Builder. - */ - public static class Builder { - private Boolean verbose; - - private Builder(ListClassifiersOptions listClassifiersOptions) { - this.verbose = listClassifiersOptions.verbose; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListClassifiersOptions. - * - * @return the listClassifiersOptions - */ - public ListClassifiersOptions build() { - return new ListClassifiersOptions(this); - } - - /** - * Set the verbose. - * - * @param verbose the verbose - * @return the ListClassifiersOptions builder - */ - public Builder verbose(Boolean verbose) { - this.verbose = verbose; - return this; - } - } - - protected ListClassifiersOptions(Builder builder) { - verbose = builder.verbose; - } - - /** - * New builder. - * - * @return a ListClassifiersOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the verbose. - * - * Specify `true` to return details about the classifiers. Omit this parameter to return a brief list of classifiers. - * - * @return the verbose - */ - public Boolean verbose() { - return verbose; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java deleted file mode 100644 index 01a81792d0a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2017, 2020. - * - * 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.visual_recognition.v3.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateClassifier options. - */ -public class UpdateClassifierOptions extends GenericModel { - - protected String classifierId; - protected Map positiveExamples; - protected InputStream negativeExamples; - protected String negativeExamplesFilename; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - private Map positiveExamples; - private InputStream negativeExamples; - private String negativeExamplesFilename; - - private Builder(UpdateClassifierOptions updateClassifierOptions) { - this.classifierId = updateClassifierOptions.classifierId; - this.positiveExamples = updateClassifierOptions.positiveExamples; - this.negativeExamples = updateClassifierOptions.negativeExamples; - this.negativeExamplesFilename = updateClassifierOptions.negativeExamplesFilename; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this.classifierId = classifierId; - } - - /** - * Builds a UpdateClassifierOptions. - * - * @return the updateClassifierOptions - */ - public UpdateClassifierOptions build() { - return new UpdateClassifierOptions(this); - } - - /** - * Adds an entry to the positiveExamples map. - * - * @param classname the key associated with the map entry to be added - * @param positiveExamples the value associated with the map entry to be added - * @return the UpdateClassifierOptions builder - */ - public Builder addPositiveExamples(String classname, InputStream positiveExamples) { - com.ibm.cloud.sdk.core.util.Validator.notNull(classname, - "classname cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(positiveExamples, - "positiveExamples cannot be null"); - if (this.positiveExamples == null) { - this.positiveExamples = new HashMap(); - } - this.positiveExamples.put(classname, positiveExamples); - return this; - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the UpdateClassifierOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - - /** - * Set the positiveExamples. - * Existing positiveExamples map will be replaced. - * - * @param positiveExamples the positiveExamples - * @return the UpdateClassifierOptions builder - */ - public Builder positiveExamples(Map positiveExamples) { - this.positiveExamples = positiveExamples; - return this; - } - - /** - * Set the negativeExamples. - * - * @param negativeExamples the negativeExamples - * @return the UpdateClassifierOptions builder - */ - public Builder negativeExamples(InputStream negativeExamples) { - this.negativeExamples = negativeExamples; - return this; - } - - /** - * Set the negativeExamplesFilename. - * - * @param negativeExamplesFilename the negativeExamplesFilename - * @return the UpdateClassifierOptions builder - */ - public Builder negativeExamplesFilename(String negativeExamplesFilename) { - this.negativeExamplesFilename = negativeExamplesFilename; - return this; - } - - /** - * Adds an entry to the positiveExamples map. - * - * @param classname the key associated with the map entry to be added - * @param positiveExamples the value associated with the map entry to be added - * @return the UpdateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder addPositiveExamples(String classname, File positiveExamples) throws FileNotFoundException { - this.addPositiveExamples(classname, new FileInputStream(positiveExamples)); - return this; - } - - /** - * Set the negativeExamples. - * - * @param negativeExamples the negativeExamples - * @return the UpdateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder negativeExamples(File negativeExamples) throws FileNotFoundException { - this.negativeExamples = new FileInputStream(negativeExamples); - this.negativeExamplesFilename = negativeExamples.getName(); - return this; - } - } - - protected UpdateClassifierOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.classifierId, - "classifierId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((builder.negativeExamples == null) - || (builder.negativeExamplesFilename != null), - "negativeExamplesFilename cannot be null if negativeExamples is not null."); - classifierId = builder.classifierId; - positiveExamples = builder.positiveExamples; - negativeExamples = builder.negativeExamples; - negativeExamplesFilename = builder.negativeExamplesFilename; - } - - /** - * New builder. - * - * @return a UpdateClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the classifierId. - * - * The ID of the classifier. - * - * @return the classifierId - */ - public String classifierId() { - return classifierId; - } - - /** - * Gets the positiveExamples. - * - * A .zip file of images that depict the visual subject of a class in the classifier. The positive examples create or - * update classes in the classifier. You can include more than one positive example file in a call. - * - * Specify the parameter name by appending `_positive_examples` to the class name. For example, - * `goldenretriever_positive_examples` creates the class `goldenretriever`. The string cannot contain the following - * characters: ``$ * - { } \ | / ' " ` [ ]``. - * - * Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The - * maximum number of images is 10,000 images or 100 MB per .zip file. - * - * Encode special characters in the file name in UTF-8. - * - * @return the positiveExamples - */ - public Map positiveExamples() { - return positiveExamples; - } - - /** - * Gets the negativeExamples. - * - * A .zip file of images that do not depict the visual subject of any of the classes of the new classifier. Must - * contain a minimum of 10 images. - * - * Encode special characters in the file name in UTF-8. - * - * @return the negativeExamples - */ - public InputStream negativeExamples() { - return negativeExamples; - } - - /** - * Gets the negativeExamplesFilename. - * - * The filename for negativeExamples. - * - * @return the negativeExamplesFilename - */ - public String negativeExamplesFilename() { - return negativeExamplesFilename; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java deleted file mode 100644 index 4098ae8b399..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Information about something that went wrong. - */ -public class WarningInfo extends GenericModel { - - @SerializedName("warning_id") - protected String warningId; - protected String description; - - /** - * Gets the warningId. - * - * Codified warning string, such as `limit_reached`. - * - * @return the warningId - */ - public String getWarningId() { - return warningId; - } - - /** - * Gets the description. - * - * Information about the error. - * - * @return the description - */ - public String getDescription() { - return description; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java deleted file mode 100644 index 4fd8dfa691d..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Visual Recognition v3. - */ -package com.ibm.watson.visual_recognition.v3; diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java deleted file mode 100644 index 2d2463c9bd5..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java +++ /dev/null @@ -1,781 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4; - -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.RequestBuilder; -import com.ibm.cloud.sdk.core.http.ResponseConverter; -import com.ibm.cloud.sdk.core.http.ServiceCall; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; -import com.ibm.cloud.sdk.core.service.BaseService; -import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; -import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; -import com.ibm.watson.common.SdkCommon; -import com.ibm.watson.visual_recognition.v4.model.AddImageTrainingDataOptions; -import com.ibm.watson.visual_recognition.v4.model.AddImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeResponse; -import com.ibm.watson.visual_recognition.v4.model.Collection; -import com.ibm.watson.visual_recognition.v4.model.CollectionsList; -import com.ibm.watson.visual_recognition.v4.model.CreateCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteImageOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteObjectOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteUserDataOptions; -import com.ibm.watson.visual_recognition.v4.model.GetCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.GetImageDetailsOptions; -import com.ibm.watson.visual_recognition.v4.model.GetJpegImageOptions; -import com.ibm.watson.visual_recognition.v4.model.GetObjectMetadataOptions; -import com.ibm.watson.visual_recognition.v4.model.GetTrainingUsageOptions; -import com.ibm.watson.visual_recognition.v4.model.ImageDetails; -import com.ibm.watson.visual_recognition.v4.model.ImageDetailsList; -import com.ibm.watson.visual_recognition.v4.model.ImageSummaryList; -import com.ibm.watson.visual_recognition.v4.model.ListCollectionsOptions; -import com.ibm.watson.visual_recognition.v4.model.ListImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.ListObjectMetadataOptions; -import com.ibm.watson.visual_recognition.v4.model.ObjectMetadata; -import com.ibm.watson.visual_recognition.v4.model.ObjectMetadataList; -import com.ibm.watson.visual_recognition.v4.model.TrainOptions; -import com.ibm.watson.visual_recognition.v4.model.TrainingDataObjects; -import com.ibm.watson.visual_recognition.v4.model.TrainingEvents; -import com.ibm.watson.visual_recognition.v4.model.UpdateCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadata; -import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadataOptions; -import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; -import okhttp3.MultipartBody; - -/** - * Provide images to the IBM Watson™ Visual Recognition service for analysis. The service detects objects based on - * a set of images with training data. - * - * @version v4 - * @see Visual - * Recognition - */ -public class VisualRecognition extends BaseService { - - private static final String DEFAULT_SERVICE_NAME = "visual_recognition"; - - private static final String DEFAULT_SERVICE_URL = "https://gateway.watsonplatform.net/visual-recognition/api"; - - private String versionDate; - - /** - * Constructs a new `VisualRecognition` client using the DEFAULT_SERVICE_NAME. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - */ - public VisualRecognition(String versionDate) { - this(versionDate, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); - } - - /** - * Constructs a new `VisualRecognition` client with the DEFAULT_SERVICE_NAME - * and the specified Authenticator. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service - */ - public VisualRecognition(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); - } - - /** - * Constructs a new `VisualRecognition` client with the specified serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - */ - public VisualRecognition(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); - } - - /** - * Constructs a new `VisualRecognition` client with the specified Authenticator - * and serviceName. - * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API - * calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service - */ - public VisualRecognition(String versionDate, String serviceName, Authenticator authenticator) { - super(serviceName, authenticator); - setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), - "version cannot be null."); - this.versionDate = versionDate; - this.configureService(serviceName); - } - - /** - * Analyze images. - * - * Analyze images by URL, by file, or both against your own collection. Make sure that - * **training_status.objects.ready** is `true` for the feature before you use a collection to analyze images. - * - * Encode the image and .zip file names in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 - * encoding if it encounters non-ASCII characters. - * - * @param analyzeOptions the {@link AnalyzeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AnalyzeResponse} - */ - public ServiceCall analyze(AnalyzeOptions analyzeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(analyzeOptions, - "analyzeOptions cannot be null"); - String[] pathSegments = { "v4/analyze" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "analyze"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - multipartBuilder.addFormDataPart("collection_ids", RequestUtils.join(analyzeOptions.collectionIds(), ",")); - multipartBuilder.addFormDataPart("features", RequestUtils.join(analyzeOptions.features(), ",")); - - if (analyzeOptions.imagesFile() != null) { - for (FileWithMetadata item : analyzeOptions.imagesFile()) { - okhttp3.RequestBody itemBody = RequestUtils.inputStreamBody(item.data(), item.contentType()); - multipartBuilder.addFormDataPart("images_file", item.filename(), itemBody); - } - } - if (analyzeOptions.imageUrl() != null) { - for (String item : analyzeOptions.imageUrl()) { - multipartBuilder.addFormDataPart("image_url", item); - } - } - if (analyzeOptions.threshold() != null) { - multipartBuilder.addFormDataPart("threshold", String.valueOf(analyzeOptions.threshold())); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create a collection. - * - * Create a collection that can be used to store images. - * - * To create a collection without specifying a name and description, include an empty JSON object in the request body. - * - * Encode the name and description in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 encoding - * if it encounters non-ASCII characters. - * - * @param createCollectionOptions the {@link CreateCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall createCollection(CreateCollectionOptions createCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(createCollectionOptions, - "createCollectionOptions cannot be null"); - String[] pathSegments = { "v4/collections" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "createCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (createCollectionOptions != null) { - if (createCollectionOptions.name() != null) { - contentJson.addProperty("name", createCollectionOptions.name()); - } - if (createCollectionOptions.description() != null) { - contentJson.addProperty("description", createCollectionOptions.description()); - } - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create a collection. - * - * Create a collection that can be used to store images. - * - * To create a collection without specifying a name and description, include an empty JSON object in the request body. - * - * Encode the name and description in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 encoding - * if it encounters non-ASCII characters. - * - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall createCollection() { - return createCollection(null); - } - - /** - * List collections. - * - * Retrieves a list of collections for the service instance. - * - * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link CollectionsList} - */ - public ServiceCall listCollections(ListCollectionsOptions listCollectionsOptions) { - String[] pathSegments = { "v4/collections" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listCollections"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (listCollectionsOptions != null) { - - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List collections. - * - * Retrieves a list of collections for the service instance. - * - * @return a {@link ServiceCall} with a response type of {@link CollectionsList} - */ - public ServiceCall listCollections() { - return listCollections(null); - } - - /** - * Get collection details. - * - * Get details of one collection. - * - * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall getCollection(GetCollectionOptions getCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getCollectionOptions, - "getCollectionOptions cannot be null"); - String[] pathSegments = { "v4/collections" }; - String[] pathParameters = { getCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update a collection. - * - * Update the name or description of a collection. - * - * Encode the name and description in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 encoding - * if it encounters non-ASCII characters. - * - * @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall updateCollection(UpdateCollectionOptions updateCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateCollectionOptions, - "updateCollectionOptions cannot be null"); - String[] pathSegments = { "v4/collections" }; - String[] pathParameters = { updateCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "updateCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (updateCollectionOptions.name() != null) { - contentJson.addProperty("name", updateCollectionOptions.name()); - } - if (updateCollectionOptions.description() != null) { - contentJson.addProperty("description", updateCollectionOptions.description()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete a collection. - * - * Delete a collection from the service instance. - * - * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollectionOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteCollectionOptions, - "deleteCollectionOptions cannot be null"); - String[] pathSegments = { "v4/collections" }; - String[] pathParameters = { deleteCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteCollection"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add images. - * - * Add images to a collection by URL, by file, or both. - * - * Encode the image and .zip file names in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 - * encoding if it encounters non-ASCII characters. - * - * @param addImagesOptions the {@link AddImagesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ImageDetailsList} - */ - public ServiceCall addImages(AddImagesOptions addImagesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addImagesOptions, - "addImagesOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((addImagesOptions.imagesFile() != null) || (addImagesOptions - .imageUrl() != null) || (addImagesOptions.trainingData() != null), - "At least one of imagesFile, imageUrl, or trainingData must be supplied."); - String[] pathSegments = { "v4/collections", "images" }; - String[] pathParameters = { addImagesOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "addImages"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (addImagesOptions.imagesFile() != null) { - for (FileWithMetadata item : addImagesOptions.imagesFile()) { - okhttp3.RequestBody itemBody = RequestUtils.inputStreamBody(item.data(), item.contentType()); - multipartBuilder.addFormDataPart("images_file", item.filename(), itemBody); - } - } - if (addImagesOptions.imageUrl() != null) { - for (String item : addImagesOptions.imageUrl()) { - multipartBuilder.addFormDataPart("image_url", item); - } - } - if (addImagesOptions.trainingData() != null) { - multipartBuilder.addFormDataPart("training_data", addImagesOptions.trainingData()); - } - builder.body(multipartBuilder.build()); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List images. - * - * Retrieves a list of images in a collection. - * - * @param listImagesOptions the {@link ListImagesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ImageSummaryList} - */ - public ServiceCall listImages(ListImagesOptions listImagesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listImagesOptions, - "listImagesOptions cannot be null"); - String[] pathSegments = { "v4/collections", "images" }; - String[] pathParameters = { listImagesOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listImages"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get image details. - * - * Get the details of an image in a collection. - * - * @param getImageDetailsOptions the {@link GetImageDetailsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ImageDetails} - */ - public ServiceCall getImageDetails(GetImageDetailsOptions getImageDetailsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getImageDetailsOptions, - "getImageDetailsOptions cannot be null"); - String[] pathSegments = { "v4/collections", "images" }; - String[] pathParameters = { getImageDetailsOptions.collectionId(), getImageDetailsOptions.imageId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getImageDetails"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete an image. - * - * Delete one image from a collection. - * - * @param deleteImageOptions the {@link DeleteImageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteImage(DeleteImageOptions deleteImageOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteImageOptions, - "deleteImageOptions cannot be null"); - String[] pathSegments = { "v4/collections", "images" }; - String[] pathParameters = { deleteImageOptions.collectionId(), deleteImageOptions.imageId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteImage"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get a JPEG file of an image. - * - * Download a JPEG representation of an image. - * - * @param getJpegImageOptions the {@link GetJpegImageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} - */ - public ServiceCall getJpegImage(GetJpegImageOptions getJpegImageOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getJpegImageOptions, - "getJpegImageOptions cannot be null"); - String[] pathSegments = { "v4/collections", "images", "jpeg" }; - String[] pathParameters = { getJpegImageOptions.collectionId(), getJpegImageOptions.imageId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getJpegImage"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "image/jpeg"); - if (getJpegImageOptions.size() != null) { - builder.query("size", getJpegImageOptions.size()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * List object metadata. - * - * Retrieves a list of object names in a collection. - * - * @param listObjectMetadataOptions the {@link ListObjectMetadataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ObjectMetadataList} - */ - public ServiceCall listObjectMetadata(ListObjectMetadataOptions listObjectMetadataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(listObjectMetadataOptions, - "listObjectMetadataOptions cannot be null"); - String[] pathSegments = { "v4/collections", "objects" }; - String[] pathParameters = { listObjectMetadataOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listObjectMetadata"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Update an object name. - * - * Update the name of an object. A successful request updates the training data for all images that use the object. - * - * @param updateObjectMetadataOptions the {@link UpdateObjectMetadataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link UpdateObjectMetadata} - */ - public ServiceCall updateObjectMetadata( - UpdateObjectMetadataOptions updateObjectMetadataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(updateObjectMetadataOptions, - "updateObjectMetadataOptions cannot be null"); - String[] pathSegments = { "v4/collections", "objects" }; - String[] pathParameters = { updateObjectMetadataOptions.collectionId(), updateObjectMetadataOptions.object() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "updateObjectMetadata"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("object", updateObjectMetadataOptions.newObject()); - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get object metadata. - * - * Get the number of bounding boxes for a single object in a collection. - * - * @param getObjectMetadataOptions the {@link GetObjectMetadataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ObjectMetadata} - */ - public ServiceCall getObjectMetadata(GetObjectMetadataOptions getObjectMetadataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getObjectMetadataOptions, - "getObjectMetadataOptions cannot be null"); - String[] pathSegments = { "v4/collections", "objects" }; - String[] pathParameters = { getObjectMetadataOptions.collectionId(), getObjectMetadataOptions.object() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getObjectMetadata"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete an object. - * - * Delete one object from a collection. A successful request deletes the training data from all images that use the - * object. - * - * @param deleteObjectOptions the {@link DeleteObjectOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteObject(DeleteObjectOptions deleteObjectOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteObjectOptions, - "deleteObjectOptions cannot be null"); - String[] pathSegments = { "v4/collections", "objects" }; - String[] pathParameters = { deleteObjectOptions.collectionId(), deleteObjectOptions.object() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteObject"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Train a collection. - * - * Start training on images in a collection. The collection must have enough training data and untrained data (the - * **training_status.objects.data_changed** is `true`). If training is in progress, the request queues the next - * training job. - * - * @param trainOptions the {@link TrainOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} - */ - public ServiceCall train(TrainOptions trainOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(trainOptions, - "trainOptions cannot be null"); - String[] pathSegments = { "v4/collections", "train" }; - String[] pathParameters = { trainOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "train"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Add training data to an image. - * - * Add, update, or delete training data for an image. Encode the object name in UTF-8 if it contains non-ASCII - * characters. The service assumes UTF-8 encoding if it encounters non-ASCII characters. - * - * Elements in the request replace the existing elements. - * - * - To update the training data, provide both the unchanged and the new or changed values. - * - * - To delete the training data, provide an empty value for the training data. - * - * @param addImageTrainingDataOptions the {@link AddImageTrainingDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingDataObjects} - */ - public ServiceCall addImageTrainingData( - AddImageTrainingDataOptions addImageTrainingDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(addImageTrainingDataOptions, - "addImageTrainingDataOptions cannot be null"); - String[] pathSegments = { "v4/collections", "images", "training_data" }; - String[] pathParameters = { addImageTrainingDataOptions.collectionId(), addImageTrainingDataOptions.imageId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, - pathParameters)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "addImageTrainingData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (addImageTrainingDataOptions.objects() != null) { - contentJson.add("objects", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree( - addImageTrainingDataOptions.objects())); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get training usage. - * - * Information about the completed training events. You can use this information to determine how close you are to the - * training limits for the month. - * - * @param getTrainingUsageOptions the {@link GetTrainingUsageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingEvents} - */ - public ServiceCall getTrainingUsage(GetTrainingUsageOptions getTrainingUsageOptions) { - String[] pathSegments = { "v4/training_usage" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getTrainingUsage"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - if (getTrainingUsageOptions != null) { - if (getTrainingUsageOptions.startTime() != null) { - builder.query("start_time", getTrainingUsageOptions.startTime()); - } - if (getTrainingUsageOptions.endTime() != null) { - builder.query("end_time", getTrainingUsageOptions.endTime()); - } - } - ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() { - }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Get training usage. - * - * Information about the completed training events. You can use this information to determine how close you are to the - * training limits for the month. - * - * @return a {@link ServiceCall} with a response type of {@link TrainingEvents} - */ - public ServiceCall getTrainingUsage() { - return getTrainingUsage(null); - } - - /** - * Delete labeled data. - * - * Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with - * the customer ID. - * - * 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/visual-recognition?topic=visual-recognition-information-security). - * - * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteUserDataOptions, - "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v4/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); - Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteUserData"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java deleted file mode 100644 index 982f214b084..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addImageTrainingData options. - */ -public class AddImageTrainingDataOptions extends GenericModel { - - protected String collectionId; - protected String imageId; - protected List objects; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String imageId; - private List objects; - - private Builder(AddImageTrainingDataOptions addImageTrainingDataOptions) { - this.collectionId = addImageTrainingDataOptions.collectionId; - this.imageId = addImageTrainingDataOptions.imageId; - this.objects = addImageTrainingDataOptions.objects; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param imageId the imageId - */ - public Builder(String collectionId, String imageId) { - this.collectionId = collectionId; - this.imageId = imageId; - } - - /** - * Builds a AddImageTrainingDataOptions. - * - * @return the addImageTrainingDataOptions - */ - public AddImageTrainingDataOptions build() { - return new AddImageTrainingDataOptions(this); - } - - /** - * Adds an objects to objects. - * - * @param objects the new objects - * @return the AddImageTrainingDataOptions builder - */ - public Builder addObjects(TrainingDataObject objects) { - com.ibm.cloud.sdk.core.util.Validator.notNull(objects, - "objects cannot be null"); - if (this.objects == null) { - this.objects = new ArrayList(); - } - this.objects.add(objects); - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the AddImageTrainingDataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the imageId. - * - * @param imageId the imageId - * @return the AddImageTrainingDataOptions builder - */ - public Builder imageId(String imageId) { - this.imageId = imageId; - return this; - } - - /** - * Set the objects. - * Existing objects will be replaced. - * - * @param objects the objects - * @return the AddImageTrainingDataOptions builder - */ - public Builder objects(List objects) { - this.objects = objects; - return this; - } - } - - protected AddImageTrainingDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.imageId, - "imageId cannot be empty"); - collectionId = builder.collectionId; - imageId = builder.imageId; - objects = builder.objects; - } - - /** - * New builder. - * - * @return a AddImageTrainingDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the imageId. - * - * The identifier of the image. - * - * @return the imageId - */ - public String imageId() { - return imageId; - } - - /** - * Gets the objects. - * - * Training data for specific objects. - * - * @return the objects - */ - public List objects() { - return objects; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java deleted file mode 100644 index be7225d601e..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The addImages options. - */ -public class AddImagesOptions extends GenericModel { - - protected String collectionId; - protected List imagesFile; - protected List imageUrl; - protected String trainingData; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private List imagesFile; - private List imageUrl; - private String trainingData; - - private Builder(AddImagesOptions addImagesOptions) { - this.collectionId = addImagesOptions.collectionId; - this.imagesFile = addImagesOptions.imagesFile; - this.imageUrl = addImagesOptions.imageUrl; - this.trainingData = addImagesOptions.trainingData; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a AddImagesOptions. - * - * @return the addImagesOptions - */ - public AddImagesOptions build() { - return new AddImagesOptions(this); - } - - /** - * Adds an imagesFile to imagesFile. - * - * @param imagesFile the new imagesFile - * @return the AddImagesOptions builder - */ - public Builder addImagesFile(FileWithMetadata imagesFile) { - com.ibm.cloud.sdk.core.util.Validator.notNull(imagesFile, - "imagesFile cannot be null"); - if (this.imagesFile == null) { - this.imagesFile = new ArrayList(); - } - this.imagesFile.add(imagesFile); - return this; - } - - /** - * Adds an imageUrl to imageUrl. - * - * @param imageUrl the new imageUrl - * @return the AddImagesOptions builder - */ - public Builder addImageUrl(String imageUrl) { - com.ibm.cloud.sdk.core.util.Validator.notNull(imageUrl, - "imageUrl cannot be null"); - if (this.imageUrl == null) { - this.imageUrl = new ArrayList(); - } - this.imageUrl.add(imageUrl); - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the AddImagesOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the imagesFile. - * Existing imagesFile will be replaced. - * - * @param imagesFile the imagesFile - * @return the AddImagesOptions builder - */ - public Builder imagesFile(List imagesFile) { - this.imagesFile = imagesFile; - return this; - } - - /** - * Set the imageUrl. - * Existing imageUrl will be replaced. - * - * @param imageUrl the imageUrl - * @return the AddImagesOptions builder - */ - public Builder imageUrl(List imageUrl) { - this.imageUrl = imageUrl; - return this; - } - - /** - * Set the trainingData. - * - * @param trainingData the trainingData - * @return the AddImagesOptions builder - */ - public Builder trainingData(String trainingData) { - this.trainingData = trainingData; - return this; - } - } - - protected AddImagesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - imagesFile = builder.imagesFile; - imageUrl = builder.imageUrl; - trainingData = builder.trainingData; - } - - /** - * New builder. - * - * @return a AddImagesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the imagesFile. - * - * An array of image files (.jpg or .png) or .zip files with images. - * - Include a maximum of 20 images in a request. - * - Limit the .zip file to 100 MB. - * - Limit each image file to 10 MB. - * - * You can also include an image with the **image_url** parameter. - * - * @return the imagesFile - */ - public List imagesFile() { - return imagesFile; - } - - /** - * Gets the imageUrl. - * - * The array of URLs of image files (.jpg or .png). - * - Include a maximum of 20 images in a request. - * - Limit each image file to 10 MB. - * - Minimum width and height is 30 pixels, but the service tends to perform better with images that are at least 300 - * x 300 pixels. Maximum is 5400 pixels for either height or width. - * - * You can also include images with the **images_file** parameter. - * - * @return the imageUrl - */ - public List imageUrl() { - return imageUrl; - } - - /** - * Gets the trainingData. - * - * Training data for a single image. Include training data only if you add one image with the request. - * - * The `object` property can contain alphanumeric, underscore, hyphen, space, and dot characters. It cannot begin with - * the reserved prefix `sys-` and must be no longer than 32 characters. - * - * @return the trainingData - */ - public String trainingData() { - return trainingData; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java deleted file mode 100644 index 0b6aace7777..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The analyze options. - */ -public class AnalyzeOptions extends GenericModel { - - public interface Features { - /** objects. */ - String OBJECTS = "objects"; - } - - protected List collectionIds; - protected List features; - protected List imagesFile; - protected List imageUrl; - protected Float threshold; - - /** - * Builder. - */ - public static class Builder { - private List collectionIds; - private List features; - private List imagesFile; - private List imageUrl; - private Float threshold; - - private Builder(AnalyzeOptions analyzeOptions) { - this.collectionIds = analyzeOptions.collectionIds; - this.features = analyzeOptions.features; - this.imagesFile = analyzeOptions.imagesFile; - this.imageUrl = analyzeOptions.imageUrl; - this.threshold = analyzeOptions.threshold; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionIds the collectionIds - * @param features the features - */ - public Builder(List collectionIds, List features) { - this.collectionIds = collectionIds; - this.features = features; - } - - /** - * Builds a AnalyzeOptions. - * - * @return the analyzeOptions - */ - public AnalyzeOptions build() { - return new AnalyzeOptions(this); - } - - /** - * Adds an collectionIds to collectionIds. - * - * @param collectionIds the new collectionIds - * @return the AnalyzeOptions builder - */ - public Builder addCollectionIds(String collectionIds) { - com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds, - "collectionIds cannot be null"); - if (this.collectionIds == null) { - this.collectionIds = new ArrayList(); - } - this.collectionIds.add(collectionIds); - return this; - } - - /** - * Adds an features to features. - * - * @param features the new features - * @return the AnalyzeOptions builder - */ - public Builder addFeatures(String features) { - com.ibm.cloud.sdk.core.util.Validator.notNull(features, - "features cannot be null"); - if (this.features == null) { - this.features = new ArrayList(); - } - this.features.add(features); - return this; - } - - /** - * Adds an imagesFile to imagesFile. - * - * @param imagesFile the new imagesFile - * @return the AnalyzeOptions builder - */ - public Builder addImagesFile(FileWithMetadata imagesFile) { - com.ibm.cloud.sdk.core.util.Validator.notNull(imagesFile, - "imagesFile cannot be null"); - if (this.imagesFile == null) { - this.imagesFile = new ArrayList(); - } - this.imagesFile.add(imagesFile); - return this; - } - - /** - * Adds an imageUrl to imageUrl. - * - * @param imageUrl the new imageUrl - * @return the AnalyzeOptions builder - */ - public Builder addImageUrl(String imageUrl) { - com.ibm.cloud.sdk.core.util.Validator.notNull(imageUrl, - "imageUrl cannot be null"); - if (this.imageUrl == null) { - this.imageUrl = new ArrayList(); - } - this.imageUrl.add(imageUrl); - return this; - } - - /** - * Set the collectionIds. - * Existing collectionIds will be replaced. - * - * @param collectionIds the collectionIds - * @return the AnalyzeOptions builder - */ - public Builder collectionIds(List collectionIds) { - this.collectionIds = collectionIds; - return this; - } - - /** - * Set the features. - * Existing features will be replaced. - * - * @param features the features - * @return the AnalyzeOptions builder - */ - public Builder features(List features) { - this.features = features; - return this; - } - - /** - * Set the imagesFile. - * Existing imagesFile will be replaced. - * - * @param imagesFile the imagesFile - * @return the AnalyzeOptions builder - */ - public Builder imagesFile(List imagesFile) { - this.imagesFile = imagesFile; - return this; - } - - /** - * Set the imageUrl. - * Existing imageUrl will be replaced. - * - * @param imageUrl the imageUrl - * @return the AnalyzeOptions builder - */ - public Builder imageUrl(List imageUrl) { - this.imageUrl = imageUrl; - return this; - } - - /** - * Set the threshold. - * - * @param threshold the threshold - * @return the AnalyzeOptions builder - */ - public Builder threshold(Float threshold) { - this.threshold = threshold; - return this; - } - } - - protected AnalyzeOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.collectionIds, - "collectionIds cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.features, - "features cannot be null"); - collectionIds = builder.collectionIds; - features = builder.features; - imagesFile = builder.imagesFile; - imageUrl = builder.imageUrl; - threshold = builder.threshold; - } - - /** - * New builder. - * - * @return a AnalyzeOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionIds. - * - * The IDs of the collections to analyze. - * - * @return the collectionIds - */ - public List collectionIds() { - return collectionIds; - } - - /** - * Gets the features. - * - * The features to analyze. - * - * @return the features - */ - public List features() { - return features; - } - - /** - * Gets the imagesFile. - * - * An array of image files (.jpg or .png) or .zip files with images. - * - Include a maximum of 20 images in a request. - * - Limit the .zip file to 100 MB. - * - Limit each image file to 10 MB. - * - * You can also include an image with the **image_url** parameter. - * - * @return the imagesFile - */ - public List imagesFile() { - return imagesFile; - } - - /** - * Gets the imageUrl. - * - * An array of URLs of image files (.jpg or .png). - * - Include a maximum of 20 images in a request. - * - Limit each image file to 10 MB. - * - Minimum width and height is 30 pixels, but the service tends to perform better with images that are at least 300 - * x 300 pixels. Maximum is 5400 pixels for either height or width. - * - * You can also include images with the **images_file** parameter. - * - * @return the imageUrl - */ - public List imageUrl() { - return imageUrl; - } - - /** - * Gets the threshold. - * - * The minimum score a feature must have to be returned. - * - * @return the threshold - */ - public Float threshold() { - return threshold; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java deleted file mode 100644 index 1a0fb3d121a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Results for all images. - */ -public class AnalyzeResponse extends GenericModel { - - protected List images; - protected List warnings; - protected String trace; - - /** - * Gets the images. - * - * Analyzed images. - * - * @return the images - */ - public List getImages() { - return images; - } - - /** - * Gets the warnings. - * - * Information about what might cause less than optimal output. - * - * @return the warnings - */ - public List getWarnings() { - return warnings; - } - - /** - * Gets the trace. - * - * A unique identifier of the request. Included only when an error or warning is returned. - * - * @return the trace - */ - public String getTrace() { - return trace; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java deleted file mode 100644 index f35d605edb1..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about a collection. - */ -public class Collection extends GenericModel { - - @SerializedName("collection_id") - protected String collectionId; - protected String name; - protected String description; - protected Date created; - protected Date updated; - @SerializedName("image_count") - protected Long imageCount; - @SerializedName("training_status") - protected TrainingStatus trainingStatus; - - /** - * Gets the collectionId. - * - * The 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; - } - - /** - * Gets the description. - * - * The description of the collection. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the created. - * - * Date and time in Coordinated Universal Time (UTC) that the collection was created. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * Date and time in Coordinated Universal Time (UTC) that the collection was most recently updated. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the imageCount. - * - * Number of images in the collection. - * - * @return the imageCount - */ - public Long getImageCount() { - return imageCount; - } - - /** - * Gets the trainingStatus. - * - * Training status information for the collection. - * - * @return the trainingStatus - */ - public TrainingStatus getTrainingStatus() { - return trainingStatus; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java deleted file mode 100644 index 09766c05b8f..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The objects in a collection that are detected in an image. - */ -public class CollectionObjects extends GenericModel { - - @SerializedName("collection_id") - protected String collectionId; - protected List objects; - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } - - /** - * Gets the objects. - * - * The identified objects in a collection. - * - * @return the objects - */ - public List getObjects() { - return objects; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java deleted file mode 100644 index fa6ee33e2dd..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * A container for the list of collections. - */ -public class CollectionsList extends GenericModel { - - protected List collections; - - /** - * Gets the collections. - * - * The collections in this service instance. - * - * @return the collections - */ - public List getCollections() { - return collections; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java deleted file mode 100644 index 0eefcb1b47c..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The createCollection options. - */ -public class CreateCollectionOptions extends GenericModel { - - protected String name; - protected String description; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String description; - - private Builder(CreateCollectionOptions createCollectionOptions) { - this.name = createCollectionOptions.name; - this.description = createCollectionOptions.description; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CreateCollectionOptions. - * - * @return the createCollectionOptions - */ - public CreateCollectionOptions build() { - return new CreateCollectionOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateCollectionOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateCollectionOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - } - - protected CreateCollectionOptions(Builder builder) { - name = builder.name; - description = builder.description; - } - - /** - * New builder. - * - * @return a CreateCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the name. - * - * The name of the collection. The name can contain alphanumeric, underscore, hyphen, and dot characters. It cannot - * begin with the reserved prefix `sys-`. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * The description of the collection. - * - * @return the description - */ - public String description() { - return description; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java deleted file mode 100644 index 8cf3e8771ed..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteCollection options. - */ -public class DeleteCollectionOptions extends GenericModel { - - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - - private Builder(DeleteCollectionOptions deleteCollectionOptions) { - this.collectionId = deleteCollectionOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a DeleteCollectionOptions. - * - * @return the deleteCollectionOptions - */ - public DeleteCollectionOptions build() { - return new DeleteCollectionOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteCollectionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected DeleteCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a DeleteCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java deleted file mode 100644 index 3be4aa2e251..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteImage options. - */ -public class DeleteImageOptions extends GenericModel { - - protected String collectionId; - protected String imageId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String imageId; - - private Builder(DeleteImageOptions deleteImageOptions) { - this.collectionId = deleteImageOptions.collectionId; - this.imageId = deleteImageOptions.imageId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param imageId the imageId - */ - public Builder(String collectionId, String imageId) { - this.collectionId = collectionId; - this.imageId = imageId; - } - - /** - * Builds a DeleteImageOptions. - * - * @return the deleteImageOptions - */ - public DeleteImageOptions build() { - return new DeleteImageOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteImageOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the imageId. - * - * @param imageId the imageId - * @return the DeleteImageOptions builder - */ - public Builder imageId(String imageId) { - this.imageId = imageId; - return this; - } - } - - protected DeleteImageOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.imageId, - "imageId cannot be empty"); - collectionId = builder.collectionId; - imageId = builder.imageId; - } - - /** - * New builder. - * - * @return a DeleteImageOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the imageId. - * - * The identifier of the image. - * - * @return the imageId - */ - public String imageId() { - return imageId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java deleted file mode 100644 index c0d2b81db0c..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteObject options. - */ -public class DeleteObjectOptions extends GenericModel { - - protected String collectionId; - protected String object; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String object; - - private Builder(DeleteObjectOptions deleteObjectOptions) { - this.collectionId = deleteObjectOptions.collectionId; - this.object = deleteObjectOptions.object; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param object the object - */ - public Builder(String collectionId, String object) { - this.collectionId = collectionId; - this.object = object; - } - - /** - * Builds a DeleteObjectOptions. - * - * @return the deleteObjectOptions - */ - public DeleteObjectOptions build() { - return new DeleteObjectOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the DeleteObjectOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the object. - * - * @param object the object - * @return the DeleteObjectOptions builder - */ - public Builder object(String object) { - this.object = object; - return this; - } - } - - protected DeleteObjectOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.object, - "object cannot be empty"); - collectionId = builder.collectionId; - object = builder.object; - } - - /** - * New builder. - * - * @return a DeleteObjectOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the object. - * - * The name of the object. - * - * @return the object - */ - public String object() { - return object; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java deleted file mode 100644 index 1e14d6ecd3c..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2018, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - protected String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - this.customerId = deleteUserDataOptions.customerId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customerId the customerId - */ - public Builder(String customerId) { - this.customerId = customerId; - } - - /** - * Builds a DeleteUserDataOptions. - * - * @return the deleteUserDataOptions - */ - public DeleteUserDataOptions build() { - return new DeleteUserDataOptions(this); - } - - /** - * Set the customerId. - * - * @param customerId the customerId - * @return the DeleteUserDataOptions builder - */ - public Builder customerId(String customerId) { - this.customerId = customerId; - return this; - } - } - - protected DeleteUserDataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.customerId, - "customerId cannot be null"); - customerId = builder.customerId; - } - - /** - * New builder. - * - * @return a DeleteUserDataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customerId. - * - * The customer ID for which all data is to be deleted. - * - * @return the customerId - */ - public String customerId() { - return customerId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java deleted file mode 100644 index de8d64622da..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Container for the list of collections that have objects detected in an image. - */ -public class DetectedObjects extends GenericModel { - - protected List collections; - - /** - * Gets the collections. - * - * The collections with identified objects. - * - * @return the collections - */ - public List getCollections() { - return collections; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java deleted file mode 100644 index 22b549c7733..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about an error. - */ -public class Error extends GenericModel { - - /** - * Identifier of the problem. - */ - public interface Code { - /** invalid_field. */ - String INVALID_FIELD = "invalid_field"; - /** invalid_header. */ - String INVALID_HEADER = "invalid_header"; - /** invalid_method. */ - String INVALID_METHOD = "invalid_method"; - /** missing_field. */ - String MISSING_FIELD = "missing_field"; - /** server_error. */ - String SERVER_ERROR = "server_error"; - } - - protected String code; - protected String message; - @SerializedName("more_info") - protected String moreInfo; - protected ErrorTarget target; - - /** - * Gets the code. - * - * Identifier of the problem. - * - * @return the code - */ - public String getCode() { - return code; - } - - /** - * Gets the message. - * - * An explanation of the problem with possible solutions. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Gets the moreInfo. - * - * A URL for more information about the solution. - * - * @return the moreInfo - */ - public String getMoreInfo() { - return moreInfo; - } - - /** - * Gets the target. - * - * Details about the specific area of the problem. - * - * @return the target - */ - public ErrorTarget getTarget() { - return target; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java deleted file mode 100644 index c027cd3d508..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about the specific area of the problem. - */ -public class ErrorTarget extends GenericModel { - - /** - * The parameter or property that is the focus of the problem. - */ - public interface Type { - /** field. */ - String FIELD = "field"; - /** parameter. */ - String PARAMETER = "parameter"; - /** header. */ - String HEADER = "header"; - } - - protected String type; - protected String name; - - /** - * Gets the type. - * - * The parameter or property that is the focus of the problem. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the name. - * - * The property that is identified with the problem. - * - * @return the name - */ - public String getName() { - return name; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java deleted file mode 100644 index 8e53493408e..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getCollection options. - */ -public class GetCollectionOptions extends GenericModel { - - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - - private Builder(GetCollectionOptions getCollectionOptions) { - this.collectionId = getCollectionOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a GetCollectionOptions. - * - * @return the getCollectionOptions - */ - public GetCollectionOptions build() { - return new GetCollectionOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetCollectionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected GetCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a GetCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java deleted file mode 100644 index e3ea1542630..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getImageDetails options. - */ -public class GetImageDetailsOptions extends GenericModel { - - protected String collectionId; - protected String imageId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String imageId; - - private Builder(GetImageDetailsOptions getImageDetailsOptions) { - this.collectionId = getImageDetailsOptions.collectionId; - this.imageId = getImageDetailsOptions.imageId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param imageId the imageId - */ - public Builder(String collectionId, String imageId) { - this.collectionId = collectionId; - this.imageId = imageId; - } - - /** - * Builds a GetImageDetailsOptions. - * - * @return the getImageDetailsOptions - */ - public GetImageDetailsOptions build() { - return new GetImageDetailsOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetImageDetailsOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the imageId. - * - * @param imageId the imageId - * @return the GetImageDetailsOptions builder - */ - public Builder imageId(String imageId) { - this.imageId = imageId; - return this; - } - } - - protected GetImageDetailsOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.imageId, - "imageId cannot be empty"); - collectionId = builder.collectionId; - imageId = builder.imageId; - } - - /** - * New builder. - * - * @return a GetImageDetailsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the imageId. - * - * The identifier of the image. - * - * @return the imageId - */ - public String imageId() { - return imageId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java deleted file mode 100644 index bfdef905a43..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getJpegImage options. - */ -public class GetJpegImageOptions extends GenericModel { - - /** - * The image size. Specify `thumbnail` to return a version that maintains the original aspect ratio but is no larger - * than 200 pixels in the larger dimension. For example, an original 800 x 1000 image is resized to 160 x 200 pixels. - */ - public interface Size { - /** full. */ - String FULL = "full"; - /** thumbnail. */ - String THUMBNAIL = "thumbnail"; - } - - protected String collectionId; - protected String imageId; - protected String size; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String imageId; - private String size; - - private Builder(GetJpegImageOptions getJpegImageOptions) { - this.collectionId = getJpegImageOptions.collectionId; - this.imageId = getJpegImageOptions.imageId; - this.size = getJpegImageOptions.size; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param imageId the imageId - */ - public Builder(String collectionId, String imageId) { - this.collectionId = collectionId; - this.imageId = imageId; - } - - /** - * Builds a GetJpegImageOptions. - * - * @return the getJpegImageOptions - */ - public GetJpegImageOptions build() { - return new GetJpegImageOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetJpegImageOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the imageId. - * - * @param imageId the imageId - * @return the GetJpegImageOptions builder - */ - public Builder imageId(String imageId) { - this.imageId = imageId; - return this; - } - - /** - * Set the size. - * - * @param size the size - * @return the GetJpegImageOptions builder - */ - public Builder size(String size) { - this.size = size; - return this; - } - } - - protected GetJpegImageOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.imageId, - "imageId cannot be empty"); - collectionId = builder.collectionId; - imageId = builder.imageId; - size = builder.size; - } - - /** - * New builder. - * - * @return a GetJpegImageOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the imageId. - * - * The identifier of the image. - * - * @return the imageId - */ - public String imageId() { - return imageId; - } - - /** - * Gets the size. - * - * The image size. Specify `thumbnail` to return a version that maintains the original aspect ratio but is no larger - * than 200 pixels in the larger dimension. For example, an original 800 x 1000 image is resized to 160 x 200 pixels. - * - * @return the size - */ - public String size() { - return size; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java deleted file mode 100644 index c5f1bf805e2..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getObjectMetadata options. - */ -public class GetObjectMetadataOptions extends GenericModel { - - protected String collectionId; - protected String object; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String object; - - private Builder(GetObjectMetadataOptions getObjectMetadataOptions) { - this.collectionId = getObjectMetadataOptions.collectionId; - this.object = getObjectMetadataOptions.object; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param object the object - */ - public Builder(String collectionId, String object) { - this.collectionId = collectionId; - this.object = object; - } - - /** - * Builds a GetObjectMetadataOptions. - * - * @return the getObjectMetadataOptions - */ - public GetObjectMetadataOptions build() { - return new GetObjectMetadataOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the GetObjectMetadataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the object. - * - * @param object the object - * @return the GetObjectMetadataOptions builder - */ - public Builder object(String object) { - this.object = object; - return this; - } - } - - protected GetObjectMetadataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.object, - "object cannot be empty"); - collectionId = builder.collectionId; - object = builder.object; - } - - /** - * New builder. - * - * @return a GetObjectMetadataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the object. - * - * The name of the object. - * - * @return the object - */ - public String object() { - return object; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java deleted file mode 100644 index 91e0c240678..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The getTrainingUsage options. - */ -public class GetTrainingUsageOptions extends GenericModel { - - protected String startTime; - protected String endTime; - - /** - * Builder. - */ - public static class Builder { - private String startTime; - private String endTime; - - private Builder(GetTrainingUsageOptions getTrainingUsageOptions) { - this.startTime = getTrainingUsageOptions.startTime; - this.endTime = getTrainingUsageOptions.endTime; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a GetTrainingUsageOptions. - * - * @return the getTrainingUsageOptions - */ - public GetTrainingUsageOptions build() { - return new GetTrainingUsageOptions(this); - } - - /** - * Set the startTime. - * - * @param startTime the startTime - * @return the GetTrainingUsageOptions builder - */ - public Builder startTime(String startTime) { - this.startTime = startTime; - return this; - } - - /** - * Set the endTime. - * - * @param endTime the endTime - * @return the GetTrainingUsageOptions builder - */ - public Builder endTime(String endTime) { - this.endTime = endTime; - return this; - } - } - - protected GetTrainingUsageOptions(Builder builder) { - startTime = builder.startTime; - endTime = builder.endTime; - } - - /** - * New builder. - * - * @return a GetTrainingUsageOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the startTime. - * - * The earliest day to include training events. Specify dates in YYYY-MM-DD format. If empty or not specified, the - * earliest training event is included. - * - * @return the startTime - */ - public String startTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * The most recent day to include training events. Specify dates in YYYY-MM-DD format. All events for the day are - * included. If empty or not specified, the current day is used. Specify the same value as `start_time` to request - * events for a single day. - * - * @return the endTime - */ - public String endTime() { - return endTime; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java deleted file mode 100644 index d352f09e141..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about an image. - */ -public class Image extends GenericModel { - - protected ImageSource source; - protected ImageDimensions dimensions; - protected DetectedObjects objects; - protected List errors; - - /** - * Gets the source. - * - * The source type of the image. - * - * @return the source - */ - public ImageSource getSource() { - return source; - } - - /** - * Gets the dimensions. - * - * Height and width of an image. - * - * @return the dimensions - */ - public ImageDimensions getDimensions() { - return dimensions; - } - - /** - * Gets the objects. - * - * Container for the list of collections that have objects detected in an image. - * - * @return the objects - */ - public DetectedObjects getObjects() { - return objects; - } - - /** - * Gets the errors. - * - * A container for the problems in the request. - * - * @return the errors - */ - public List getErrors() { - return errors; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java deleted file mode 100644 index 6a2dbbaaa67..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about an image. - */ -public class ImageDetails extends GenericModel { - - @SerializedName("image_id") - protected String imageId; - protected Date updated; - protected Date created; - protected ImageSource source; - protected ImageDimensions dimensions; - protected List errors; - @SerializedName("training_data") - protected TrainingDataObjects trainingData; - - /** - * Gets the imageId. - * - * The identifier of the image. - * - * @return the imageId - */ - public String getImageId() { - return imageId; - } - - /** - * Gets the updated. - * - * Date and time in Coordinated Universal Time (UTC) that the image was most recently updated. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the created. - * - * Date and time in Coordinated Universal Time (UTC) that the image was created. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the source. - * - * The source type of the image. - * - * @return the source - */ - public ImageSource getSource() { - return source; - } - - /** - * Gets the dimensions. - * - * Height and width of an image. - * - * @return the dimensions - */ - public ImageDimensions getDimensions() { - return dimensions; - } - - /** - * Gets the errors. - * - * @return the errors - */ - public List getErrors() { - return errors; - } - - /** - * Gets the trainingData. - * - * Training data for all objects. - * - * @return the trainingData - */ - public TrainingDataObjects getTrainingData() { - return trainingData; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java deleted file mode 100644 index 6158ed57312..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * List of information about the images. - */ -public class ImageDetailsList extends GenericModel { - - protected List images; - protected List warnings; - protected String trace; - - /** - * Gets the images. - * - * The images in the collection. - * - * @return the images - */ - public List getImages() { - return images; - } - - /** - * Gets the warnings. - * - * Information about what might cause less than optimal output. - * - * @return the warnings - */ - public List getWarnings() { - return warnings; - } - - /** - * Gets the trace. - * - * A unique identifier of the request. Included only when an error or warning is returned. - * - * @return the trace - */ - public String getTrace() { - return trace; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java deleted file mode 100644 index 51bdeb665b0..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Height and width of an image. - */ -public class ImageDimensions extends GenericModel { - - protected Long height; - protected Long width; - - /** - * Gets the height. - * - * Height in pixels of the image. - * - * @return the height - */ - public Long getHeight() { - return height; - } - - /** - * Gets the width. - * - * Width in pixels of the image. - * - * @return the width - */ - public Long getWidth() { - return width; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java deleted file mode 100644 index 7aa33f39931..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The source type of the image. - */ -public class ImageSource extends GenericModel { - - /** - * The source type of the image. - */ - public interface Type { - /** file. */ - String FILE = "file"; - /** url. */ - String URL = "url"; - } - - protected String type; - protected String filename; - @SerializedName("archive_filename") - protected String archiveFilename; - @SerializedName("source_url") - protected String sourceUrl; - @SerializedName("resolved_url") - protected String resolvedUrl; - - /** - * Gets the type. - * - * The source type of the image. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the filename. - * - * Name of the image file if uploaded. Not returned when the image is passed by URL. - * - * @return the filename - */ - public String getFilename() { - return filename; - } - - /** - * Gets the archiveFilename. - * - * Name of the .zip file of images if uploaded. Not returned when the image is passed directly or by URL. - * - * @return the archiveFilename - */ - public String getArchiveFilename() { - return archiveFilename; - } - - /** - * Gets the sourceUrl. - * - * Source of the image before any redirects. Not returned when the image is uploaded. - * - * @return the sourceUrl - */ - public String getSourceUrl() { - return sourceUrl; - } - - /** - * Gets the resolvedUrl. - * - * Fully resolved URL of the image after redirects are followed. Not returned when the image is uploaded. - * - * @return the resolvedUrl - */ - public String getResolvedUrl() { - return resolvedUrl; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java deleted file mode 100644 index f220e60c54b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Basic information about an image. - */ -public class ImageSummary extends GenericModel { - - @SerializedName("image_id") - protected String imageId; - protected Date updated; - - /** - * Gets the imageId. - * - * The identifier of the image. - * - * @return the imageId - */ - public String getImageId() { - return imageId; - } - - /** - * Gets the updated. - * - * Date and time in Coordinated Universal Time (UTC) that the image was most recently updated. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java deleted file mode 100644 index 93b750e8389..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * List of images. - */ -public class ImageSummaryList extends GenericModel { - - protected List images; - - /** - * Gets the images. - * - * The images in the collection. - * - * @return the images - */ - public List getImages() { - return images; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java deleted file mode 100644 index 77f1ca4c1ed..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listCollections options. - */ -public class ListCollectionsOptions extends GenericModel { - - /** - * Builder. - */ - public static class Builder { - - private Builder(ListCollectionsOptions listCollectionsOptions) { - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListCollectionsOptions. - * - * @return the listCollectionsOptions - */ - public ListCollectionsOptions build() { - return new ListCollectionsOptions(this); - } - } - - private ListCollectionsOptions(Builder builder) { - } - - /** - * New builder. - * - * @return a ListCollectionsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java deleted file mode 100644 index c2df9ea4be9..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listImages options. - */ -public class ListImagesOptions extends GenericModel { - - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - - private Builder(ListImagesOptions listImagesOptions) { - this.collectionId = listImagesOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a ListImagesOptions. - * - * @return the listImagesOptions - */ - public ListImagesOptions build() { - return new ListImagesOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the ListImagesOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected ListImagesOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a ListImagesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java deleted file mode 100644 index 366687dacf4..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The listObjectMetadata options. - */ -public class ListObjectMetadataOptions extends GenericModel { - - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - - private Builder(ListObjectMetadataOptions listObjectMetadataOptions) { - this.collectionId = listObjectMetadataOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a ListObjectMetadataOptions. - * - * @return the listObjectMetadataOptions - */ - public ListObjectMetadataOptions build() { - return new ListObjectMetadataOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the ListObjectMetadataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected ListObjectMetadataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a ListObjectMetadataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java deleted file mode 100644 index eaa314f93e7..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Defines the location of the bounding box around the object. - */ -public class Location extends GenericModel { - - protected Long top; - protected Long left; - protected Long width; - protected Long height; - - /** - * Builder. - */ - public static class Builder { - private Long top; - private Long left; - private Long width; - private Long height; - - private Builder(Location location) { - this.top = location.top; - this.left = location.left; - this.width = location.width; - this.height = location.height; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param top the top - * @param left the left - * @param width the width - * @param height the height - */ - public Builder(Long top, Long left, Long width, Long height) { - this.top = top; - this.left = left; - this.width = width; - this.height = height; - } - - /** - * Builds a Location. - * - * @return the location - */ - public Location build() { - return new Location(this); - } - - /** - * Set the top. - * - * @param top the top - * @return the Location builder - */ - public Builder top(long top) { - this.top = top; - return this; - } - - /** - * Set the left. - * - * @param left the left - * @return the Location builder - */ - public Builder left(long left) { - this.left = left; - return this; - } - - /** - * Set the width. - * - * @param width the width - * @return the Location builder - */ - public Builder width(long width) { - this.width = width; - return this; - } - - /** - * Set the height. - * - * @param height the height - * @return the Location builder - */ - public Builder height(long height) { - this.height = height; - return this; - } - } - - protected Location(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.top, - "top cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.left, - "left cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.width, - "width cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.height, - "height cannot be null"); - top = builder.top; - left = builder.left; - width = builder.width; - height = builder.height; - } - - /** - * New builder. - * - * @return a Location builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the top. - * - * Y-position of top-left pixel of the bounding box. - * - * @return the top - */ - public Long top() { - return top; - } - - /** - * Gets the left. - * - * X-position of top-left pixel of the bounding box. - * - * @return the left - */ - public Long left() { - return left; - } - - /** - * Gets the width. - * - * Width in pixels of of the bounding box. - * - * @return the width - */ - public Long width() { - return width; - } - - /** - * Gets the height. - * - * Height in pixels of the bounding box. - * - * @return the height - */ - public Long height() { - return height; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java deleted file mode 100644 index 61cad1827ed..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about an object in the collection. - */ -public class ObjectDetail extends GenericModel { - - protected String object; - protected Location location; - protected Float score; - - /** - * Gets the object. - * - * The label for the object. - * - * @return the object - */ - public String getObject() { - return object; - } - - /** - * Gets the location. - * - * Defines the location of the bounding box around the object. - * - * @return the location - */ - public Location getLocation() { - return location; - } - - /** - * Gets the score. - * - * Confidence score for the object in the range of 0 to 1. A higher score indicates greater likelihood that the object - * is depicted at this location in the image. - * - * @return the score - */ - public Float getScore() { - return score; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadata.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadata.java deleted file mode 100644 index d0ad0e5cdcb..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadata.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Basic information about an object. - */ -public class ObjectMetadata extends GenericModel { - - protected String object; - protected Long count; - - /** - * Gets the object. - * - * The name of the object. - * - * @return the object - */ - public String getObject() { - return object; - } - - /** - * Gets the count. - * - * Number of bounding boxes with this object name in the collection. - * - * @return the count - */ - public Long getCount() { - return count; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataList.java deleted file mode 100644 index e0effe3785a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataList.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * List of objects. - */ -public class ObjectMetadataList extends GenericModel { - - @SerializedName("object_count") - protected Long objectCount; - protected List objects; - - /** - * Gets the objectCount. - * - * Number of unique named objects in the collection. - * - * @return the objectCount - */ - public Long getObjectCount() { - return objectCount; - } - - /** - * Gets the objects. - * - * The objects in the collection. - * - * @return the objects - */ - public List getObjects() { - return objects; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java deleted file mode 100644 index c22e0616680..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training status for the objects in the collection. - */ -public class ObjectTrainingStatus extends GenericModel { - - protected Boolean ready; - @SerializedName("in_progress") - protected Boolean inProgress; - @SerializedName("data_changed") - protected Boolean dataChanged; - @SerializedName("latest_failed") - protected Boolean latestFailed; - protected String description; - - /** - * Builder. - */ - public static class Builder { - private Boolean ready; - private Boolean inProgress; - private Boolean dataChanged; - private Boolean latestFailed; - private String description; - - private Builder(ObjectTrainingStatus objectTrainingStatus) { - this.ready = objectTrainingStatus.ready; - this.inProgress = objectTrainingStatus.inProgress; - this.dataChanged = objectTrainingStatus.dataChanged; - this.latestFailed = objectTrainingStatus.latestFailed; - this.description = objectTrainingStatus.description; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param ready the ready - * @param inProgress the inProgress - * @param dataChanged the dataChanged - * @param latestFailed the latestFailed - * @param description the description - */ - public Builder(Boolean ready, Boolean inProgress, Boolean dataChanged, Boolean latestFailed, String description) { - this.ready = ready; - this.inProgress = inProgress; - this.dataChanged = dataChanged; - this.latestFailed = latestFailed; - this.description = description; - } - - /** - * Builds a ObjectTrainingStatus. - * - * @return the objectTrainingStatus - */ - public ObjectTrainingStatus build() { - return new ObjectTrainingStatus(this); - } - - /** - * Set the ready. - * - * @param ready the ready - * @return the ObjectTrainingStatus builder - */ - public Builder ready(Boolean ready) { - this.ready = ready; - return this; - } - - /** - * Set the inProgress. - * - * @param inProgress the inProgress - * @return the ObjectTrainingStatus builder - */ - public Builder inProgress(Boolean inProgress) { - this.inProgress = inProgress; - return this; - } - - /** - * Set the dataChanged. - * - * @param dataChanged the dataChanged - * @return the ObjectTrainingStatus builder - */ - public Builder dataChanged(Boolean dataChanged) { - this.dataChanged = dataChanged; - return this; - } - - /** - * Set the latestFailed. - * - * @param latestFailed the latestFailed - * @return the ObjectTrainingStatus builder - */ - public Builder latestFailed(Boolean latestFailed) { - this.latestFailed = latestFailed; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the ObjectTrainingStatus builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - } - - protected ObjectTrainingStatus(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.ready, - "ready cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.inProgress, - "inProgress cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.dataChanged, - "dataChanged cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.latestFailed, - "latestFailed cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.description, - "description cannot be null"); - ready = builder.ready; - inProgress = builder.inProgress; - dataChanged = builder.dataChanged; - latestFailed = builder.latestFailed; - description = builder.description; - } - - /** - * New builder. - * - * @return a ObjectTrainingStatus builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the ready. - * - * Whether you can analyze images in the collection with the **objects** feature. - * - * @return the ready - */ - public Boolean ready() { - return ready; - } - - /** - * Gets the inProgress. - * - * Whether training is in progress. - * - * @return the inProgress - */ - public Boolean inProgress() { - return inProgress; - } - - /** - * Gets the dataChanged. - * - * Whether there are changes to the training data since the most recent training. - * - * @return the dataChanged - */ - public Boolean dataChanged() { - return dataChanged; - } - - /** - * Gets the latestFailed. - * - * Whether the most recent training failed. - * - * @return the latestFailed - */ - public Boolean latestFailed() { - return latestFailed; - } - - /** - * Gets the description. - * - * Details about the training. If training is in progress, includes information about the status. If training is not - * in progress, includes a success message or information about why training failed. - * - * @return the description - */ - public String description() { - return description; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java deleted file mode 100644 index 3d955fab63a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The train options. - */ -public class TrainOptions extends GenericModel { - - protected String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - - private Builder(TrainOptions trainOptions) { - this.collectionId = trainOptions.collectionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a TrainOptions. - * - * @return the trainOptions - */ - public TrainOptions build() { - return new TrainOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the TrainOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - } - - protected TrainOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - } - - /** - * New builder. - * - * @return a TrainOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java deleted file mode 100644 index cd7eb6a3b89..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about the training data. - */ -public class TrainingDataObject extends GenericModel { - - protected String object; - protected Location location; - - /** - * Builder. - */ - public static class Builder { - private String object; - private Location location; - - private Builder(TrainingDataObject trainingDataObject) { - this.object = trainingDataObject.object; - this.location = trainingDataObject.location; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a TrainingDataObject. - * - * @return the trainingDataObject - */ - public TrainingDataObject build() { - return new TrainingDataObject(this); - } - - /** - * Set the object. - * - * @param object the object - * @return the TrainingDataObject builder - */ - public Builder object(String object) { - this.object = object; - return this; - } - - /** - * Set the location. - * - * @param location the location - * @return the TrainingDataObject builder - */ - public Builder location(Location location) { - this.location = location; - return this; - } - } - - protected TrainingDataObject(Builder builder) { - object = builder.object; - location = builder.location; - } - - /** - * New builder. - * - * @return a TrainingDataObject builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the object. - * - * The name of the object. - * - * @return the object - */ - public String object() { - return object; - } - - /** - * Gets the location. - * - * Defines the location of the bounding box around the object. - * - * @return the location - */ - public Location location() { - return location; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java deleted file mode 100644 index 58d4c3143ea..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.List; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training data for all objects. - */ -public class TrainingDataObjects extends GenericModel { - - protected List objects; - - /** - * Gets the objects. - * - * Training data for specific objects. - * - * @return the objects - */ - public List getObjects() { - return objects; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java deleted file mode 100644 index 41756f4378a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about the training event. - */ -public class TrainingEvent extends GenericModel { - - /** - * Trained object type. Only `objects` is currently supported. - */ - public interface Type { - /** objects. */ - String OBJECTS = "objects"; - } - - /** - * Training status of the training event. - */ - public interface Status { - /** failed. */ - String FAILED = "failed"; - /** succeeded. */ - String SUCCEEDED = "succeeded"; - } - - protected String type; - @SerializedName("collection_id") - protected String collectionId; - @SerializedName("completion_time") - protected Date completionTime; - protected String status; - @SerializedName("image_count") - protected Long imageCount; - - /** - * Gets the type. - * - * Trained object type. Only `objects` is currently supported. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the collectionId. - * - * Identifier of the trained collection. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } - - /** - * Gets the completionTime. - * - * Date and time in Coordinated Universal Time (UTC) that training on the collection finished. - * - * @return the completionTime - */ - public Date getCompletionTime() { - return completionTime; - } - - /** - * Gets the status. - * - * Training status of the training event. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the imageCount. - * - * The total number of images that were used in training for this training event. - * - * @return the imageCount - */ - public Long getImageCount() { - return imageCount; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java deleted file mode 100644 index 39a31daac7b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about the training events. - */ -public class TrainingEvents extends GenericModel { - - @SerializedName("start_time") - protected Date startTime; - @SerializedName("end_time") - protected Date endTime; - @SerializedName("completed_events") - protected Long completedEvents; - @SerializedName("trained_images") - protected Long trainedImages; - protected List events; - - /** - * Gets the startTime. - * - * The starting day for the returned training events in Coordinated Universal Time (UTC). If not specified in the - * request, it identifies the earliest training event. - * - * @return the startTime - */ - public Date getStartTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * The ending day for the returned training events in Coordinated Universal Time (UTC). If not specified in the - * request, it lists the current time. - * - * @return the endTime - */ - public Date getEndTime() { - return endTime; - } - - /** - * Gets the completedEvents. - * - * The total number of training events in the response for the start and end times. - * - * @return the completedEvents - */ - public Long getCompletedEvents() { - return completedEvents; - } - - /** - * Gets the trainedImages. - * - * The total number of images that were used in training for the start and end times. - * - * @return the trainedImages - */ - public Long getTrainedImages() { - return trainedImages; - } - - /** - * Gets the events. - * - * The completed training events for the start and end time. - * - * @return the events - */ - public List getEvents() { - return events; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java deleted file mode 100644 index 836791b8c11..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Training status information for the collection. - */ -public class TrainingStatus extends GenericModel { - - protected ObjectTrainingStatus objects; - - /** - * Builder. - */ - public static class Builder { - private ObjectTrainingStatus objects; - - private Builder(TrainingStatus trainingStatus) { - this.objects = trainingStatus.objects; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param objects the objects - */ - public Builder(ObjectTrainingStatus objects) { - this.objects = objects; - } - - /** - * Builds a TrainingStatus. - * - * @return the trainingStatus - */ - public TrainingStatus build() { - return new TrainingStatus(this); - } - - /** - * Set the objects. - * - * @param objects the objects - * @return the TrainingStatus builder - */ - public Builder objects(ObjectTrainingStatus objects) { - this.objects = objects; - return this; - } - } - - protected TrainingStatus(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.objects, - "objects cannot be null"); - objects = builder.objects; - } - - /** - * New builder. - * - * @return a TrainingStatus builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the objects. - * - * Training status for the objects in the collection. - * - * @return the objects - */ - public ObjectTrainingStatus objects() { - return objects; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java deleted file mode 100644 index ed5c417ab15..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateCollection options. - */ -public class UpdateCollectionOptions extends GenericModel { - - protected String collectionId; - protected String name; - protected String description; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String name; - private String description; - - private Builder(UpdateCollectionOptions updateCollectionOptions) { - this.collectionId = updateCollectionOptions.collectionId; - this.name = updateCollectionOptions.name; - this.description = updateCollectionOptions.description; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - */ - public Builder(String collectionId) { - this.collectionId = collectionId; - } - - /** - * Builds a UpdateCollectionOptions. - * - * @return the updateCollectionOptions - */ - public UpdateCollectionOptions build() { - return new UpdateCollectionOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the UpdateCollectionOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateCollectionOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateCollectionOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - } - - protected UpdateCollectionOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - collectionId = builder.collectionId; - name = builder.name; - description = builder.description; - } - - /** - * New builder. - * - * @return a UpdateCollectionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the name. - * - * The name of the collection. The name can contain alphanumeric, underscore, hyphen, and dot characters. It cannot - * begin with the reserved prefix `sys-`. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * Gets the description. - * - * The description of the collection. - * - * @return the description - */ - public String description() { - return description; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java deleted file mode 100644 index 39d20206cb8..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Basic information about an updated object. - */ -public class UpdateObjectMetadata extends GenericModel { - - protected String object; - protected Long count; - - /** - * Builder. - */ - public static class Builder { - private String object; - private Long count; - - private Builder(UpdateObjectMetadata updateObjectMetadata) { - this.object = updateObjectMetadata.object; - this.count = updateObjectMetadata.count; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param object the object - * @param count the count - */ - public Builder(String object, Long count) { - this.object = object; - this.count = count; - } - - /** - * Builds a UpdateObjectMetadata. - * - * @return the updateObjectMetadata - */ - public UpdateObjectMetadata build() { - return new UpdateObjectMetadata(this); - } - - /** - * Set the object. - * - * @param object the object - * @return the UpdateObjectMetadata builder - */ - public Builder object(String object) { - this.object = object; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the UpdateObjectMetadata builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - } - - protected UpdateObjectMetadata(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.object, - "object cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.count, - "count cannot be null"); - object = builder.object; - count = builder.count; - } - - /** - * New builder. - * - * @return a UpdateObjectMetadata builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the object. - * - * The updated name of the object. The name can contain alphanumeric, underscore, hyphen, space, and dot characters. - * It cannot begin with the reserved prefix `sys-`. - * - * @return the object - */ - public String object() { - return object; - } - - /** - * Gets the count. - * - * Number of bounding boxes in the collection with the updated object name. - * - * @return the count - */ - public Long count() { - return count; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java deleted file mode 100644 index d9ff5d0499a..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020. - * - * 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.visual_recognition.v4.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * The updateObjectMetadata options. - */ -public class UpdateObjectMetadataOptions extends GenericModel { - - protected String collectionId; - protected String object; - protected String newObject; - - /** - * Builder. - */ - public static class Builder { - private String collectionId; - private String object; - private String newObject; - - private Builder(UpdateObjectMetadataOptions updateObjectMetadataOptions) { - this.collectionId = updateObjectMetadataOptions.collectionId; - this.object = updateObjectMetadataOptions.object; - this.newObject = updateObjectMetadataOptions.newObject; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param collectionId the collectionId - * @param object the object - * @param newObject the newObject - */ - public Builder(String collectionId, String object, String newObject) { - this.collectionId = collectionId; - this.object = object; - this.newObject = newObject; - } - - /** - * Builds a UpdateObjectMetadataOptions. - * - * @return the updateObjectMetadataOptions - */ - public UpdateObjectMetadataOptions build() { - return new UpdateObjectMetadataOptions(this); - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the UpdateObjectMetadataOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the object. - * - * @param object the object - * @return the UpdateObjectMetadataOptions builder - */ - public Builder object(String object) { - this.object = object; - return this; - } - - /** - * Set the newObject. - * - * @param newObject the newObject - * @return the UpdateObjectMetadataOptions builder - */ - public Builder newObject(String newObject) { - this.newObject = newObject; - return this; - } - - /** - * Set the updateObjectMetadata. - * - * @param updateObjectMetadata the updateObjectMetadata - * @return the UpdateObjectMetadataOptions builder - */ - public Builder updateObjectMetadata(UpdateObjectMetadata updateObjectMetadata) { - return this; - } - } - - protected UpdateObjectMetadataOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId, - "collectionId cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.object, - "object cannot be empty"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.newObject, - "newObject cannot be null"); - collectionId = builder.collectionId; - object = builder.object; - newObject = builder.newObject; - } - - /** - * New builder. - * - * @return a UpdateObjectMetadataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the collectionId. - * - * The identifier of the collection. - * - * @return the collectionId - */ - public String collectionId() { - return collectionId; - } - - /** - * Gets the object. - * - * The name of the object. - * - * @return the object - */ - public String object() { - return object; - } - - /** - * Gets the newObject. - * - * The updated name of the object. The name can contain alphanumeric, underscore, hyphen, space, and dot characters. - * It cannot begin with the reserved prefix `sys-`. - * - * @return the newObject - */ - public String newObject() { - return newObject; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java deleted file mode 100644 index 0ba6ae9db24..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v4.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Details about a problem. - */ -public class Warning extends GenericModel { - - /** - * Identifier of the problem. - */ - public interface Code { - /** invalid_field. */ - String INVALID_FIELD = "invalid_field"; - /** invalid_header. */ - String INVALID_HEADER = "invalid_header"; - /** invalid_method. */ - String INVALID_METHOD = "invalid_method"; - /** missing_field. */ - String MISSING_FIELD = "missing_field"; - /** server_error. */ - String SERVER_ERROR = "server_error"; - } - - protected String code; - protected String message; - @SerializedName("more_info") - protected String moreInfo; - - /** - * Gets the code. - * - * Identifier of the problem. - * - * @return the code - */ - public String getCode() { - return code; - } - - /** - * Gets the message. - * - * An explanation of the problem with possible solutions. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Gets the moreInfo. - * - * A URL for more information about the solution. - * - * @return the moreInfo - */ - public String getMoreInfo() { - return moreInfo; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java deleted file mode 100644 index 2465fc5bc8e..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (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. - */ -/** - * Visual Recognition v4 v4. - */ -package com.ibm.watson.visual_recognition.v4; diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionIT.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionIT.java deleted file mode 100644 index 3e6665fea49..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionIT.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * (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.visual_recognition.v3; - -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.watson.common.RetryRunner; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.visual_recognition.v3.model.Classifier; -import com.ibm.watson.visual_recognition.v3.model.Classifier.Status; -import com.ibm.watson.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Visual Recognition Integration test. - * - * @version v3 - */ -@RunWith(RetryRunner.class) -public class VisualRecognitionIT extends WatsonServiceTest { - private static final String VERSION = "2018-03-19"; - private static final String IMAGE_FILE = "src/test/resources/visual_recognition/v3/test.zip"; - private static final String IMAGE_URL = "https://watson-test-resources.mybluemix.net/resources/car.png"; - private static final String SINGLE_IMAGE_FILE = "src/test/resources/visual_recognition/v3/car.png"; - - private String classifierId; - private VisualRecognition service; - - private void assertClassifyImage(ClassifiedImages result, ClassifyOptions options) { - assertNotNull(result); - assertNotNull(result.getImages()); - assertTrue(result.getImages().size() > 0); - assertNull(result.getImages().get(0).getError()); - assertNotNull(result.getImages().get(0).getClassifiers()); - assertTrue(!result.getImages().get(0).getClassifiers().isEmpty()); - - if (options.url() != null) { - assertNotNull(result.getImages().get(0).getResolvedUrl()); - assertNotNull(result.getImages().get(0).getSourceUrl()); - } else { - assertNotNull(result.getImages().get(0).getImage()); - } - } - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String iamApiKey = getProperty("visual_recognition.apikey"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (iamApiKey == null) || iamApiKey.equals("API_KEY")); - - String url = getProperty("visual_recognition.url"); - classifierId = getProperty("visual_recognition.classifier_id"); - - Authenticator authenticator = new IamAuthenticator(iamApiKey); - service = new VisualRecognition(VERSION, authenticator); - service.setDefaultHeaders(getDefaultHeaders()); - service.setServiceUrl(url); - } - - /** - * Test classify a single jpg image. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testClassifyImagesFromBytes() throws IOException { - InputStream imagesStream = new FileInputStream(SINGLE_IMAGE_FILE); - ClassifyOptions options = new ClassifyOptions.Builder() - .imagesFile(imagesStream) - .imagesFilename("car.png") - .build(); - ClassifiedImages result = service.classify(options).execute().getResult(); - assertClassifyImage(result, options); - } - - /** - * Test classify images from zip file. - */ - @Test - public void testClassifyImagesFromFile() throws FileNotFoundException { - File images = new File(IMAGE_FILE); - ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(images).build(); - ClassifiedImages result = service.classify(options).execute().getResult(); - - assertClassifyImage(result, options); - } - - /** - * Test classify images from url. - */ - @Test - public void testClassifyImagesFromUrl() { - ClassifyOptions options = new ClassifyOptions.Builder() - .url(IMAGE_URL) - .build(); - ClassifiedImages result = service.classify(options).execute().getResult(); - assertClassifyImage(result, options); - } - - /** - * Test create a classifier. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Ignore - @Test - public void testCreateClassifierAndClassifyImage() throws FileNotFoundException, InterruptedException { - String classifierName = "integration-test-java-sdk"; - String carClassifier = "car"; - String baseballClassifier = "baseball"; - - File carImages = new File("src/test/resources/visual_recognition/v3/car_positive.zip"); - File baseballImages = new File("src/test/resources/visual_recognition/v3/baseball_positive.zip"); - File negativeImages = new File("src/test/resources/visual_recognition/v3/negative.zip"); - File imageToClassify = new File("src/test/resources/visual_recognition/v3/car.png"); - - CreateClassifierOptions.Builder builder = new CreateClassifierOptions.Builder().name(classifierName); - builder.addPositiveExamples(carClassifier, carImages); - builder.addPositiveExamples(baseballClassifier, baseballImages); - builder.negativeExamples(negativeImages); - - Classifier newClassifier = service.createClassifier(builder.build()).execute().getResult(); - try { - assertEquals(classifierName, newClassifier.getName()); - boolean ready = false; - for (int x = 0; (x < 20) && !ready; x++) { - Thread.sleep(2000); - GetClassifierOptions getOptions = new GetClassifierOptions.Builder(newClassifier.getClassifierId()).build(); - newClassifier = service.getClassifier(getOptions).execute().getResult(); - ready = newClassifier.getStatus().equals(Status.READY); - } - assertEquals(Status.READY, newClassifier.getStatus()); - - ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(imageToClassify).build(); - ClassifiedImages classification = service.classify(options).execute().getResult(); - assertNotNull(classification); - } finally { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder(newClassifier.getClassifierId()) - .build(); - service.deleteClassifier(deleteOptions).execute(); - } - } - - /** - * Test create a classifier. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testCreateClassifier() throws FileNotFoundException, InterruptedException { - String classifierName = "integration-test-java-sdk"; - String carClassifier = "car"; - - File carImages = new File("src/test/resources/visual_recognition/v3/car_positive.zip"); - InputStream negativeImages = new FileInputStream("src/test/resources/visual_recognition/v3/negative.zip"); - - CreateClassifierOptions.Builder builder = new CreateClassifierOptions.Builder().name(classifierName); - builder.addPositiveExamples(carClassifier, carImages); - builder.negativeExamples(negativeImages); - builder.negativeExamplesFilename("negative.zip"); - - Classifier newClass = service.createClassifier(builder.build()).execute().getResult(); - try { - assertEquals(classifierName, newClass.getName()); - boolean ready = false; - for (int x = 0; (x < 40) && !ready; x++) { - Thread.sleep(2000); - GetClassifierOptions getOptions = new GetClassifierOptions.Builder(newClass.getClassifierId()).build(); - newClass = service.getClassifier(getOptions).execute().getResult(); - ready = newClass.getStatus().equals(Status.READY); - } - // if it at least hasn't failed, we're probably fine - assertNotEquals(Status.FAILED, newClass.getStatus()); - } finally { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder(newClass.getClassifierId()).build(); - service.deleteClassifier(deleteOptions).execute(); - } - } - - /** - * Delete all the visual classifiers. - */ - @Test - @Ignore - public void testDeleteAllClassifiers() { - List classifiers = service.listClassifiers(null).execute().getResult().getClassifiers(); - for (Classifier classifier : classifiers) { - if (!classifier.getClassifierId().equals(classifierId)) { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder(classifier.getClassifierId()) - .build(); - service.deleteClassifier(deleteOptions).execute(); - } - } - } - - /** - * Test list all the classifiers. - */ - @Ignore - @Test - public void testListClassifiers() { - ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build(); - List classifiers = service.listClassifiers(options).execute().getResult().getClassifiers(); - assertNotNull(classifiers); - assertTrue(!classifiers.isEmpty()); - - Classifier classifier = classifiers.get(0); - assertNotNull(classifier.getClassifierId()); - assertNotNull(classifier.getName()); - assertNotNull(classifier.getOwner()); - assertNotNull(classifier.getStatus()); - assertNotNull(classifier.getClasses()); - assertNotNull(classifier.getCreated()); - } - - /** - * Test getting the Core ML file for a classifier. - */ - @Ignore - @Test - public void testGetCoreMlModel() { - ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build(); - List classifiers = service.listClassifiers(options).execute().getResult().getClassifiers(); - - for (Classifier classifier : classifiers) { - if (classifier.isCoreMlEnabled()) { - GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder() - .classifierId(classifier.getClassifierId()) - .build(); - InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute().getResult(); - assertNotNull(coreMlFile); - break; - } - } - } - - @Test - public void testDeleteUserData() { - String customerId = "java_sdk_test_id"; - - try { - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); - service.deleteUserData(deleteOptions); - } catch (Exception ex) { - fail(ex.getMessage()); - } - } -} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java deleted file mode 100644 index 36ea64aacd9..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.visual_recognition.v3; - -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.visual_recognition.v3.model.Classifier; -import com.ibm.watson.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions; -import com.ibm.watson.visual_recognition.v3.model.UpdateClassifierOptions; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Unit tests for the {@link VisualRecognition} service. - */ -public class VisualRecognitionTest extends WatsonServiceUnitTest { - private static final String FIXTURE_CLASSIFICATION - = "src/test/resources/visual_recognition/v3/visual_classification.json"; - private static final String FIXTURE_CLASSIFIER = "src/test/resources/visual_recognition/v3/visual_classifier.json"; - private static final String IMAGE_FILE = "src/test/resources/visual_recognition/v3/test.zip"; - private static final String SINGLE_IMAGE_FILE = "src/test/resources/visual_recognition/v3/car.png"; - private static final String PATH_CLASSIFY = "/v3/classify"; - private static final String VERSION_KEY = "version"; - private static final String VERSION = "2018-03-19"; - private static final String PATH_CLASSIFIERS = "/v3/classifiers"; - private static final String PATH_CLASSIFIER = "/v3/classifiers/%s"; - private static final String PATH_CORE_ML = "/v3/classifiers/%s/core_ml_model"; - private static final String FILENAME = "test_file"; - - private VisualRecognition service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new VisualRecognition(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } - - /** - * Test classify with file. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testClassifyWithFile() throws IOException, InterruptedException { - ClassifiedImages mockResponse = loadFixture(FIXTURE_CLASSIFICATION, ClassifiedImages.class); - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - File images = new File(IMAGE_FILE); - ClassifyOptions options = new ClassifyOptions.Builder() - .imagesFile(images) - .classifierIds(Collections.singletonList("car")) - .build(); - ClassifiedImages serviceResponse = service.classify(options).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = PATH_CLASSIFY + "?" + VERSION_KEY + "=" + VERSION; - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(serviceResponse, mockResponse); - } - - /** - * Test classify with bytes or stream. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testClassifyWithBytes() throws IOException, InterruptedException { - ClassifiedImages mockResponse = loadFixture(FIXTURE_CLASSIFICATION, ClassifiedImages.class); - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - File images = new File(SINGLE_IMAGE_FILE); - - InputStream fileStream = new FileInputStream(images); - - ClassifyOptions options = new ClassifyOptions.Builder() - .imagesFile(fileStream) - .imagesFilename(FILENAME) - .classifierIds(Collections.singletonList("car")) - .build(); - ClassifiedImages serviceResponse = service.classify(options).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = PATH_CLASSIFY + "?" + VERSION_KEY + "=" + VERSION; - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(serviceResponse, mockResponse); - } - - /** - * Test update classifier. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testUpdateClassifier() throws IOException, InterruptedException { - Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); - - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - File images = new File(IMAGE_FILE); - String class1 = "class1"; - String classifierId = "foo123"; - - UpdateClassifierOptions options = new UpdateClassifierOptions.Builder(classifierId) - .addPositiveExamples(class1, images) - .build(); - - Classifier serviceResponse = service.updateClassifier(options).execute().getResult(); - - // first request - String path = String.format(PATH_CLASSIFIER, classifierId); - RecordedRequest request = server.takeRequest(); - path += "?" + VERSION_KEY + "=" + VERSION; - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - String body = request.getBody().readUtf8(); - - String contentDisposition = "Content-Disposition: form-data; name=\"class1_positive_examples\";"; - assertTrue(body.contains(contentDisposition)); - assertTrue(!body.contains("Content-Disposition: form-data; name=\"name\"")); - assertEquals(serviceResponse, mockResponse); - } - - /** - * Test create classifier. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testCreateClassifier() throws IOException, InterruptedException { - Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); - - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - File positiveImages = new File(IMAGE_FILE); - File negativeImages = new File(IMAGE_FILE); - String class1 = "class1"; - CreateClassifierOptions options = new CreateClassifierOptions.Builder() - .name(class1) - .addPositiveExamples(class1, positiveImages) - .negativeExamples(negativeImages) - .build(); - - Classifier serviceResponse = service.createClassifier(options).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = PATH_CLASSIFIERS + "?" + VERSION_KEY + "=" + VERSION; - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - String body = request.getBody().readUtf8(); - - String contentDisposition = "Content-Disposition: form-data; name=\"class1_positive_examples\";"; - assertTrue(body.contains(contentDisposition)); - assertTrue(body.contains("Content-Disposition: form-data; name=\"name\"")); - assertEquals(serviceResponse, mockResponse); - } - - /** - * Test delete classifier. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteClassifier() throws IOException, InterruptedException { - server.enqueue(new MockResponse().setBody("")); - - String class1 = "class1"; - DeleteClassifierOptions options = new DeleteClassifierOptions.Builder(class1).build(); - service.deleteClassifier(options).execute(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CLASSIFIER + "?" + VERSION_KEY + "=" + VERSION, class1); - - assertEquals(path, request.getPath()); - assertEquals("DELETE", request.getMethod()); - } - - /** - * Test get classifier. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testGetClassifier() throws InterruptedException, IOException { - try { - Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); - - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - String class1 = "class1"; - GetClassifierOptions getOptions = new GetClassifierOptions.Builder(class1).build(); - Classifier serviceResponse = service.getClassifier(getOptions).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CLASSIFIER + "?" + VERSION_KEY + "=" + VERSION, class1); - - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(serviceResponse, mockResponse); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - /** - * Test get classifiers. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testGetClassifiers() throws InterruptedException, IOException { - Classifier mockClassifier = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); - List classifiers = new ArrayList<>(); - classifiers.add(mockClassifier); - classifiers.add(mockClassifier); - classifiers.add(mockClassifier); - - JsonObject mockResponse = new JsonObject(); - mockResponse.add("classifiers", new Gson().toJsonTree(classifiers)); - - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build(); - List serviceResponse = service.listClassifiers(options).execute().getResult().getClassifiers(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = PATH_CLASSIFIERS + "?" + VERSION_KEY + "=" + VERSION + "&verbose=true"; - - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(serviceResponse, classifiers); - } - - @Test - public void testGetCoreMlModel() throws IOException, InterruptedException { - final File model = new File("src/test/resources/visual_recognition/v3/custom_model.mlmodel"); - @SuppressWarnings("resource") - final Buffer buffer = new Buffer().write(Files.toByteArray(model)); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_OCTET_STREAM).setBody(buffer)); - - String classifierId = "classifier_id"; - GetCoreMlModelOptions options = new GetCoreMlModelOptions.Builder() - .classifierId(classifierId) - .build(); - - InputStream modelFile = service.getCoreMlModel(options).execute().getResult(); - - RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CORE_ML, classifierId) + "?" + VERSION_KEY + "=" + VERSION; - - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - File outputFile = new File("src/test/resources/visual_recognition/v3/model_result.mlmodel"); - outputFile.createNewFile(); - writeInputStreamToFile(modelFile, outputFile); - } - - @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "java_sdk_test_id"; - - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); - - assertEquals(deleteOptions.customerId(), customerId); - } -} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionIT.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionIT.java deleted file mode 100644 index e7f25396686..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionIT.java +++ /dev/null @@ -1,407 +0,0 @@ -package com.ibm.watson.visual_recognition.v4; - -import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.IamAuthenticator; -import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; -import com.ibm.watson.common.RetryRunner; -import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.visual_recognition.v4.model.AddImageTrainingDataOptions; -import com.ibm.watson.visual_recognition.v4.model.AddImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeResponse; -import com.ibm.watson.visual_recognition.v4.model.Collection; -import com.ibm.watson.visual_recognition.v4.model.CollectionsList; -import com.ibm.watson.visual_recognition.v4.model.CreateCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteImageOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteUserDataOptions; -import com.ibm.watson.visual_recognition.v4.model.GetCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.GetImageDetailsOptions; -import com.ibm.watson.visual_recognition.v4.model.GetJpegImageOptions; -import com.ibm.watson.visual_recognition.v4.model.GetTrainingUsageOptions; -import com.ibm.watson.visual_recognition.v4.model.ImageDetails; -import com.ibm.watson.visual_recognition.v4.model.ImageDetailsList; -import com.ibm.watson.visual_recognition.v4.model.ImageSummary; -import com.ibm.watson.visual_recognition.v4.model.ImageSummaryList; -import com.ibm.watson.visual_recognition.v4.model.ListImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.Location; -import com.ibm.watson.visual_recognition.v4.model.TrainOptions; -import com.ibm.watson.visual_recognition.v4.model.TrainingDataObject; -import com.ibm.watson.visual_recognition.v4.model.TrainingDataObjects; -import com.ibm.watson.visual_recognition.v4.model.TrainingEvents; -import com.ibm.watson.visual_recognition.v4.model.UpdateCollectionOptions; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Visual Recognition Integration test. - * - * @version v4 - */ -@RunWith(RetryRunner.class) -public class VisualRecognitionIT extends WatsonServiceTest { - private static final String VERSION = "2019-02-11"; - private static final String RESOURCE = "src/test/resources/visual_recognition/v4/"; - - private static final String COLLECTION_ID = "10e96193-0e08-406b-b8fb-b5b9ea9fe99a"; - private static final String GIRAFFE_CLASSNAME = "giraffe"; - private static final String SINGLE_GIRAFFE_IMAGE_PATH = RESOURCE + "giraffe_to_classify.jpg"; - private static final String GIRAFFE_POSITIVE_EXAMPLES_PATH = RESOURCE + "giraffe_positive_examples.zip"; - private static final String SINGLE_TURTLE_IMAGE_PATH = RESOURCE + "turtle_to_classify.jpg"; - private static final String DOG_IMAGE_URL = "https://upload.wikimedia" - + ".org/wikipedia/commons/thumb/4/47/American_Eskimo_Dog.jpg/1280px-American_Eskimo_Dog.jpg"; - private static final String CAT_IMAGE_URL = "https://upload.wikimedia" - + ".org/wikipedia/commons/thumb/4/4f/Felis_silvestris_catus_lying_on_rice_straw" - + ".jpg/1280px-Felis_silvestris_catus_lying_on_rice_straw.jpg"; - - private VisualRecognition service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String iamApiKey = getProperty("visual_recognition.apikey"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (iamApiKey == null) || iamApiKey.equals("API_KEY")); - - Authenticator authenticator = new IamAuthenticator(iamApiKey); - service = new VisualRecognition(VERSION, authenticator); - service.setDefaultHeaders(getDefaultHeaders()); - } - - private String createTestCollection() { - String testCollectionName = "java-sdk-test-collection"; - String testCollectionDescription = "Collection for integration testing of the Visual Recognition v4 service in " - + "the Java SDK"; - CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder() - .name(testCollectionName) - .description(testCollectionDescription) - .build(); - Collection newCollection = service.createCollection(createCollectionOptions).execute().getResult(); - String testCollectionId = newCollection.getCollectionId(); - - return testCollectionId; - } - - private void deleteTestCollection(String collectionId) { - DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder() - .collectionId(collectionId) - .build(); - service.deleteCollection(deleteCollectionOptions).execute(); - } - - @Test - public void testAnalyzeWithFiles() throws FileNotFoundException { - FileWithMetadata giraffeImage = new FileWithMetadata.Builder() - .data(new File(SINGLE_GIRAFFE_IMAGE_PATH)) - .contentType("image/jpeg") - .build(); - FileWithMetadata turtleImage = new FileWithMetadata.Builder() - .data(new File(SINGLE_TURTLE_IMAGE_PATH)) - .contentType("image/jpeg") - .build(); - List filesToAnalyze = Arrays.asList(giraffeImage, turtleImage); - List collectionIds = Collections.singletonList(COLLECTION_ID); - - AnalyzeOptions options = new AnalyzeOptions.Builder() - .imagesFile(filesToAnalyze) - .collectionIds(collectionIds) - .addFeatures(AnalyzeOptions.Features.OBJECTS) - .threshold(.5f) - .build(); - AnalyzeResponse response = service.analyze(options).execute().getResult(); - - assertNotNull(response); - assertEquals(2, response.getImages().size()); - } - - @Test - public void testAnalyzeWithUrl() throws FileNotFoundException { - AnalyzeOptions options = new AnalyzeOptions.Builder() - .addImageUrl(DOG_IMAGE_URL) - .addCollectionIds(COLLECTION_ID) - .addFeatures(AnalyzeOptions.Features.OBJECTS) - .build(); - AnalyzeResponse response = service.analyze(options).execute().getResult(); - - assertNotNull(response); - assertEquals(1, response.getImages().size()); - } - - @Test - public void testCollectionOperations() { - String testCollectionId = null; - - try { - // test create - String newCollectionName = "java-sdk-test-collection"; - String newCollectionDescription = "Collection for integration testing of the Visual Recognition v4 service in" - + " the Java SDK"; - CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder() - .name(newCollectionName) - .description(newCollectionDescription) - .build(); - Collection newCollection = service.createCollection(createCollectionOptions).execute().getResult(); - - assertNotNull(newCollection); - assertEquals(newCollectionName, newCollection.getName()); - assertEquals(newCollectionDescription, newCollection.getDescription()); - - // test get - testCollectionId = newCollection.getCollectionId(); - GetCollectionOptions getCollectionOptions = new GetCollectionOptions.Builder() - .collectionId(testCollectionId) - .build(); - Collection retrievedCollection = service.getCollection(getCollectionOptions).execute().getResult(); - - assertNotNull(retrievedCollection); - assertEquals(newCollection.getCollectionId(), retrievedCollection.getCollectionId()); - - // test update - String updatedDescription = "Collection with an updated description, still for testing in the Java SDK."; - UpdateCollectionOptions updateCollectionOptions = new UpdateCollectionOptions.Builder() - .collectionId(testCollectionId) - .description(updatedDescription) - .build(); - Collection updatedCollection = service.updateCollection(updateCollectionOptions).execute().getResult(); - - assertNotNull(updatedCollection); - assertEquals(updatedDescription, updatedCollection.getDescription()); - } finally { - if (testCollectionId != null) { - // test delete - DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder() - .collectionId(testCollectionId) - .build(); - service.deleteCollection(deleteCollectionOptions).execute(); - - // test list - CollectionsList collectionsList = service.listCollections().execute().getResult(); - - assertNotNull(collectionsList); - for (Collection collection : collectionsList.getCollections()) { - assertFalse(collection.getCollectionId().equals(testCollectionId)); - } - } - } - } - - @Test - public void testImageOperations() throws IOException { - // create new collection so we don't run into duplicate image issues - String testCollectionId = createTestCollection(); - - List imageUrlList = Arrays.asList(CAT_IMAGE_URL, DOG_IMAGE_URL); - FileWithMetadata turtleFile = new FileWithMetadata.Builder() - .data(new File(SINGLE_TURTLE_IMAGE_PATH)) - .contentType("image/jpeg") - .build(); - - AddImagesOptions addImagesOptions = new AddImagesOptions.Builder() - .imageUrl(imageUrlList) - .addImagesFile(turtleFile) - .collectionId(testCollectionId) - .build(); - ImageDetailsList imageDetailsList = service.addImages(addImagesOptions).execute().getResult(); - - assertNotNull(imageDetailsList); - String singleImageId = null; - Set addedImageIds = new HashSet<>(); - for (ImageDetails imageDetails : imageDetailsList.getImages()) { - addedImageIds.add(imageDetails.getImageId()); - if (singleImageId == null) { - singleImageId = imageDetails.getImageId(); - } - } - - try { - // test get - GetImageDetailsOptions getImageDetailsOptions = new GetImageDetailsOptions.Builder() - .collectionId(testCollectionId) - .imageId(singleImageId) - .build(); - ImageDetails imageDetails = service.getImageDetails(getImageDetailsOptions).execute().getResult(); - - assertNotNull(imageDetails); - assertEquals(singleImageId, imageDetails.getImageId()); - - // test get JPEG - GetJpegImageOptions getJpegImageOptions = new GetJpegImageOptions.Builder() - .collectionId(testCollectionId) - .imageId(singleImageId) - .size(GetJpegImageOptions.Size.FULL) - .build(); - InputStream imageStream = service.getJpegImage(getJpegImageOptions).execute().getResult(); - - assertNotNull(imageStream); - imageStream.close(); - } finally { - // delete images - for (String imageId : addedImageIds) { - DeleteImageOptions deleteImageOptions = new DeleteImageOptions.Builder() - .imageId(imageId) - .collectionId(testCollectionId) - .build(); - service.deleteImage(deleteImageOptions).execute(); - } - - // test list and delete - ListImagesOptions listImagesOptions = new ListImagesOptions.Builder() - .collectionId(testCollectionId) - .build(); - ImageSummaryList imageSummaryList = service.listImages(listImagesOptions).execute().getResult(); - - assertNotNull(imageSummaryList); - for (ImageSummary imageSummary : imageSummaryList.getImages()) { - assertFalse(addedImageIds.contains(imageSummary.getImageId())); - } - - // remove test collection - deleteTestCollection(testCollectionId); - } - } - - @Test - public void testTrainingOperations() throws FileNotFoundException { - String testCollectionId = createTestCollection(); - - // start by adding images for training - FileWithMetadata giraffeFileZip = new FileWithMetadata.Builder() - .data(new File(GIRAFFE_POSITIVE_EXAMPLES_PATH)) - .contentType(HttpMediaType.APPLICATION_ZIP) - .build(); - - AddImagesOptions addImagesOptions = new AddImagesOptions.Builder() - .addImagesFile(giraffeFileZip) - .collectionId(testCollectionId) - .build(); - ImageDetailsList imageDetailsList = service.addImages(addImagesOptions).execute().getResult(); - - String imageIdForTraining = null; - Set addedImageIds = new HashSet<>(); - for (ImageDetails imageDetails : imageDetailsList.getImages()) { - addedImageIds.add(imageDetails.getImageId()); - if (imageIdForTraining == null) { - imageIdForTraining = imageDetails.getImageId(); - } - } - - try { - Long top = 64L; - Long left = 270L; - Long width = 755L; - Long height = 784L; - Location testLocation = new Location.Builder() - .top(top) - .left(left) - .width(width) - .height(height) - .build(); - TrainingDataObject trainingDataObject = new TrainingDataObject.Builder() - .object(GIRAFFE_CLASSNAME) - .location(testLocation) - .build(); - - // test adding training data - AddImageTrainingDataOptions addTrainingDataOptions = new AddImageTrainingDataOptions.Builder() - .collectionId(testCollectionId) - .addObjects(trainingDataObject) - .imageId(imageIdForTraining) - .build(); - TrainingDataObjects trainingDataObjects = service.addImageTrainingData(addTrainingDataOptions).execute() - .getResult(); - - assertNotNull(trainingDataObjects); - assertEquals(GIRAFFE_CLASSNAME, trainingDataObjects.getObjects().get(0).object()); - assertEquals(top, trainingDataObjects.getObjects().get(0).location().top()); - assertEquals(left, trainingDataObjects.getObjects().get(0).location().left()); - assertEquals(width, trainingDataObjects.getObjects().get(0).location().width()); - assertEquals(height, trainingDataObjects.getObjects().get(0).location().height()); - - // test train - TrainOptions trainOptions = new TrainOptions.Builder() - .collectionId(testCollectionId) - .build(); - Collection trainingCollection = service.train(trainOptions).execute().getResult(); - - assertNotNull(trainingCollection); - assertTrue( - trainingCollection.getTrainingStatus().objects().inProgress() - || trainingCollection.getTrainingStatus().objects().ready()); - } finally { - // delete images we added earlier - for (String imageId : addedImageIds) { - DeleteImageOptions deleteImageOptions = new DeleteImageOptions.Builder() - .collectionId(testCollectionId) - .imageId(imageId) - .build(); - service.deleteImage(deleteImageOptions).execute(); - } - - deleteTestCollection(testCollectionId); - } - } - - @Test - public void testDeleteUserData() { - DeleteUserDataOptions deleteUserDataOptions = new DeleteUserDataOptions.Builder() - .customerId("test_customer_id") - .build(); - int statusCode = service.deleteUserData(deleteUserDataOptions).execute().getStatusCode(); - - assertEquals(202, statusCode); - } - - @Test - public void testGetTrainingUsage() { - TrainingEvents response = service.getTrainingUsage().execute().getResult(); - assertNotNull(response); - } - - @Test - public void testGetTrainingUsageWithStartTime() { - String timeBeforeServiceAvailability = "1995-06-12"; - GetTrainingUsageOptions options = new GetTrainingUsageOptions.Builder() - .startTime(timeBeforeServiceAvailability) - .build(); - TrainingEvents response = service.getTrainingUsage(options).execute().getResult(); - - assertNotNull(response); - assertTrue(response.getTrainedImages() > 0); - } - - @Test - public void testGetTrainingUsageWithEndTime() { - String futureTime = "3000-01-01"; - GetTrainingUsageOptions options = new GetTrainingUsageOptions.Builder() - .endTime(futureTime) - .build(); - TrainingEvents response = service.getTrainingUsage(options).execute().getResult(); - System.out.println(response); - - assertNotNull(response); - assertTrue(response.getTrainedImages() > 0); - } -} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java deleted file mode 100644 index 2659f518083..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java +++ /dev/null @@ -1,702 +0,0 @@ -package com.ibm.watson.visual_recognition.v4; - -import com.google.common.io.Files; -import com.ibm.cloud.sdk.core.security.Authenticator; -import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; -import com.ibm.watson.common.WatsonServiceUnitTest; -import com.ibm.watson.visual_recognition.v4.model.AddImageTrainingDataOptions; -import com.ibm.watson.visual_recognition.v4.model.AddImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeOptions; -import com.ibm.watson.visual_recognition.v4.model.AnalyzeResponse; -import com.ibm.watson.visual_recognition.v4.model.Collection; -import com.ibm.watson.visual_recognition.v4.model.CollectionsList; -import com.ibm.watson.visual_recognition.v4.model.CreateCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteImageOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteObjectOptions; -import com.ibm.watson.visual_recognition.v4.model.DeleteUserDataOptions; -import com.ibm.watson.visual_recognition.v4.model.GetCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.GetImageDetailsOptions; -import com.ibm.watson.visual_recognition.v4.model.GetJpegImageOptions; -import com.ibm.watson.visual_recognition.v4.model.GetObjectMetadataOptions; -import com.ibm.watson.visual_recognition.v4.model.GetTrainingUsageOptions; -import com.ibm.watson.visual_recognition.v4.model.ImageDetails; -import com.ibm.watson.visual_recognition.v4.model.ImageDetailsList; -import com.ibm.watson.visual_recognition.v4.model.ImageSummaryList; -import com.ibm.watson.visual_recognition.v4.model.ListCollectionsOptions; -import com.ibm.watson.visual_recognition.v4.model.ListImagesOptions; -import com.ibm.watson.visual_recognition.v4.model.ListObjectMetadataOptions; -import com.ibm.watson.visual_recognition.v4.model.Location; -import com.ibm.watson.visual_recognition.v4.model.ObjectMetadata; -import com.ibm.watson.visual_recognition.v4.model.ObjectMetadataList; -import com.ibm.watson.visual_recognition.v4.model.ObjectTrainingStatus; -import com.ibm.watson.visual_recognition.v4.model.TrainOptions; -import com.ibm.watson.visual_recognition.v4.model.TrainingDataObject; -import com.ibm.watson.visual_recognition.v4.model.TrainingDataObjects; -import com.ibm.watson.visual_recognition.v4.model.TrainingEvents; -import com.ibm.watson.visual_recognition.v4.model.TrainingStatus; -import com.ibm.watson.visual_recognition.v4.model.UpdateCollectionOptions; -import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadata; -import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadataOptions; - -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; - -/** - * Unit tests for the {@link VisualRecognition} service. - */ -public class VisualRecognitionTest extends WatsonServiceUnitTest { - private static final String VERSION = "2019-02-11"; - private static final String RESOURCE = "src/test/resources/visual_recognition/v4/"; - - private static final String COLLECTION_ID = "123456789"; - private static final String IMAGE_URL = "www.image.jpg"; - private static final String TRAINING_DATA = "training_data"; - private static final String OBJECT = "object"; - private static final Long TOP = 0L; - private static final Long LEFT = 10L; - private static final Long WIDTH = 100L; - private static final Long HEIGHT = 200L; - private static final String IMAGE_ID = "image_id"; - private static final Float THRESHOLD = 12f; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final Long IMAGE_COUNT = 50L; - private static final String CUSTOMER_ID = "customer_id"; - private static final String IMAGE_TYPE = "file"; - private static final String FILENAME = "filename"; - private static final String ARCHIVE_FILENAME = "archive_filename"; - private static final String SOURCE_URL = "source_url"; - private static final String RESOLVED_URL = "resolved_url"; - private static final Float SCORE = 5.0f; - private static final String CODE = "code"; - private static final String MESSAGE = "message"; - private static final String MORE_INFO = "more_info"; - private static final String ERROR_TYPE = "field"; - private static final String TRACE = "trace"; - private static final Long COMPLETED_EVENTS = 7L; - private static final Long TRAINED_IMAGES = 15L; - private static final String TYPE = "objects"; - private static final String STATUS = "succeeded"; - private static final String START_TIME = "1995-06-12"; - private static final String END_TIME = "2019-11-19"; - - private FileWithMetadata fileWithMetadata; - private TrainingDataObject trainingDataObject; - private ObjectTrainingStatus objectTrainingStatus; - private Date testDate; - - private AnalyzeResponse analyzeResponse; - private Collection collection; - private CollectionsList collectionsList; - private ImageDetailsList imageDetailsList; - private ImageSummaryList imageSummaryList; - private ImageDetails imageDetails; - private File imageFile; - private TrainingDataObjects trainingDataObjects; - private TrainingEvents trainingEvents; - private ObjectMetadataList objectMetadataList; - private ObjectMetadata objectName; - - private VisualRecognition service; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developer_cloud.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new VisualRecognition(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - // create test models - fileWithMetadata = new FileWithMetadata.Builder() - .data(new File("src/test/resources/visual_recognition/v4/giraffe_to_classify.jpg")).build(); - new Location.Builder().top(TOP).left(LEFT).height(HEIGHT).width(WIDTH).build(); - trainingDataObject = new TrainingDataObject.Builder().build(); - objectTrainingStatus = new ObjectTrainingStatus.Builder().ready(true).inProgress(true).dataChanged(true) - .latestFailed(true).description(DESCRIPTION).build(); - new TrainingStatus.Builder().objects(objectTrainingStatus).build(); - String dateString = "1995-06-12T01:11:11.111+0000"; - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - testDate = dateFormat.parse(dateString); - - // load mock responses - analyzeResponse = loadFixture(RESOURCE + "analyze-response.json", AnalyzeResponse.class); - collection = loadFixture(RESOURCE + "collection.json", Collection.class); - collectionsList = loadFixture(RESOURCE + "collections-list.json", CollectionsList.class); - imageDetailsList = loadFixture(RESOURCE + "image-details-list.json", ImageDetailsList.class); - imageSummaryList = loadFixture(RESOURCE + "image-summary-list.json", ImageSummaryList.class); - imageDetails = loadFixture(RESOURCE + "image-details.json", ImageDetails.class); - imageFile = new File(RESOURCE + "giraffe_to_classify.jpg"); - trainingDataObjects = loadFixture(RESOURCE + "training-data-objects.json", TrainingDataObjects.class); - trainingEvents = loadFixture(RESOURCE + "training-events.json", TrainingEvents.class); - objectMetadataList = loadFixture(RESOURCE + "object-metadata-list.json", ObjectMetadataList.class); - objectName = loadFixture(RESOURCE + "object-name.json", ObjectMetadata.class); - } - - @Test - public void testConfigBasedConstructor() { - VisualRecognition service = new VisualRecognition(VERSION); - assertEquals(Authenticator.AUTHTYPE_BASIC, service.getAuthenticator().authenticationType()); - } - - @Test - public void testAddImagesOptions() { - List imageList = new ArrayList<>(); - imageList.add(fileWithMetadata); - List imageUrlList = new ArrayList<>(); - imageUrlList.add(IMAGE_URL); - - AddImagesOptions options = new AddImagesOptions.Builder().imagesFile(imageList).addImagesFile(fileWithMetadata) - .imageUrl(imageUrlList).addImageUrl(IMAGE_URL).collectionId(COLLECTION_ID).trainingData(TRAINING_DATA).build(); - options = options.newBuilder().build(); - - assertEquals(2, options.imagesFile().size()); - assertEquals(fileWithMetadata, options.imagesFile().get(0)); - assertEquals(2, options.imageUrl().size()); - assertEquals(IMAGE_URL, options.imageUrl().get(0)); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(TRAINING_DATA, options.trainingData()); - } - - @Test - public void testAddImageTrainingDataOptions() { - List objectList = new ArrayList<>(); - objectList.add(trainingDataObject); - - AddImageTrainingDataOptions options = new AddImageTrainingDataOptions.Builder().collectionId(COLLECTION_ID) - .imageId(IMAGE_ID).objects(objectList).addObjects(trainingDataObject).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - assertEquals(2, options.objects().size()); - assertEquals(trainingDataObject, options.objects().get(0)); - } - - @Test - public void testAnalyzeOptions() { - List collectionIdList = new ArrayList<>(); - collectionIdList.add(COLLECTION_ID); - List featureList = new ArrayList<>(); - featureList.add(AnalyzeOptions.Features.OBJECTS); - List imageList = new ArrayList<>(); - imageList.add(fileWithMetadata); - List imageUrlList = new ArrayList<>(); - imageUrlList.add(IMAGE_URL); - - AnalyzeOptions options = new AnalyzeOptions.Builder().collectionIds(collectionIdList) - .addCollectionIds(COLLECTION_ID).features(featureList).addFeatures(AnalyzeOptions.Features.OBJECTS) - .imagesFile(imageList).addImagesFile(fileWithMetadata).imageUrl(imageUrlList).addImageUrl(IMAGE_URL) - .threshold(THRESHOLD).build(); - options = options.newBuilder().build(); - - assertEquals(2, options.collectionIds().size()); - assertEquals(COLLECTION_ID, options.collectionIds().get(0)); - assertEquals(2, options.features().size()); - assertEquals(AnalyzeOptions.Features.OBJECTS, options.features().get(0)); - assertEquals(2, options.imagesFile().size()); - assertEquals(fileWithMetadata, options.imagesFile().get(0)); - assertEquals(2, options.imageUrl().size()); - assertEquals(IMAGE_URL, options.imageUrl().get(0)); - assertEquals(THRESHOLD, options.threshold()); - } - - @Test - public void testCreateCollectionOptions() { - CreateCollectionOptions options = new CreateCollectionOptions.Builder().name(NAME).description(DESCRIPTION).build(); - options = options.newBuilder().build(); - - assertEquals(NAME, options.name()); - assertEquals(DESCRIPTION, options.description()); - } - - @Test - public void testDeleteCollectionOptions() { - DeleteCollectionOptions options = new DeleteCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - } - - @Test - public void testDeleteImageOptions() { - DeleteImageOptions options = new DeleteImageOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - } - - @Test - public void testDeleteUserDataOptions() { - DeleteUserDataOptions options = new DeleteUserDataOptions.Builder().customerId(CUSTOMER_ID).build(); - options = options.newBuilder().build(); - - assertEquals(CUSTOMER_ID, options.customerId()); - } - - @Test - public void testGetCollectionOptions() { - GetCollectionOptions options = new GetCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - } - - @Test - public void testGetImageDetailsOptions() { - GetImageDetailsOptions options = new GetImageDetailsOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID) - .build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - } - - @Test - public void testGetJpegImageOptions() { - GetJpegImageOptions options = new GetJpegImageOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID) - .size(GetJpegImageOptions.Size.FULL).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - assertEquals(GetJpegImageOptions.Size.FULL, options.size()); - } - - @Test - public void testListCollectionsOptions() { - ListCollectionsOptions options = new ListCollectionsOptions.Builder().build(); - options = options.newBuilder().build(); - - assertNotNull(options); - } - - @Test - public void testListImagesOptions() { - ListImagesOptions options = new ListImagesOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - } - - @Test - public void testLocation() { - Location location = new Location.Builder().top(TOP).left(LEFT).width(WIDTH).height(HEIGHT).build(); - location = location.newBuilder().build(); - - assertEquals(TOP, location.top()); - assertEquals(LEFT, location.left()); - assertEquals(WIDTH, location.width()); - assertEquals(HEIGHT, location.height()); - } - - @Test - public void testObjectTrainingStatus() { - ObjectTrainingStatus trainingStatus = new ObjectTrainingStatus.Builder().ready(true).inProgress(true) - .dataChanged(true).latestFailed(true).description(DESCRIPTION).build(); - trainingStatus = trainingStatus.newBuilder().build(); - - assertTrue(trainingStatus.ready()); - assertTrue(trainingStatus.inProgress()); - assertTrue(trainingStatus.dataChanged()); - assertTrue(trainingStatus.latestFailed()); - assertEquals(DESCRIPTION, trainingStatus.description()); - } - - @Test - public void testTrainingStatus() { - TrainingStatus trainingStatus = new TrainingStatus.Builder().objects(objectTrainingStatus).build(); - trainingStatus = trainingStatus.newBuilder().build(); - - assertEquals(objectTrainingStatus, trainingStatus.objects()); - } - - @Test - public void testTrainOptions() { - TrainOptions options = new TrainOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - } - - @Test - public void testUpdateCollectionOptions() { - UpdateCollectionOptions options = new UpdateCollectionOptions.Builder().collectionId(COLLECTION_ID).name(NAME) - .description(DESCRIPTION).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(NAME, options.name()); - assertEquals(DESCRIPTION, options.description()); - } - - @Test - public void testGetTrainingUsageOptions() { - GetTrainingUsageOptions options = new GetTrainingUsageOptions.Builder().startTime(START_TIME).endTime(END_TIME) - .build(); - options = options.newBuilder().build(); - - assertEquals(START_TIME, options.startTime()); - assertEquals(END_TIME, options.endTime()); - } - - @Test - public void testAnalyze() { - server.enqueue(jsonResponse(analyzeResponse)); - - AnalyzeOptions options = new AnalyzeOptions.Builder().addCollectionIds(COLLECTION_ID) - .addFeatures(AnalyzeOptions.Features.OBJECTS).addImagesFile(fileWithMetadata).addImageUrl(IMAGE_URL) - .threshold(THRESHOLD).build(); - AnalyzeResponse response = service.analyze(options).execute().getResult(); - - assertEquals(IMAGE_TYPE, response.getImages().get(0).getSource().getType()); - assertEquals(FILENAME, response.getImages().get(0).getSource().getFilename()); - assertEquals(ARCHIVE_FILENAME, response.getImages().get(0).getSource().getArchiveFilename()); - assertEquals(SOURCE_URL, response.getImages().get(0).getSource().getSourceUrl()); - assertEquals(RESOLVED_URL, response.getImages().get(0).getSource().getResolvedUrl()); - assertEquals(HEIGHT, response.getImages().get(0).getDimensions().getHeight()); - assertEquals(WIDTH, response.getImages().get(0).getDimensions().getWidth()); - assertEquals(COLLECTION_ID, response.getImages().get(0).getObjects().getCollections().get(0).getCollectionId()); - assertEquals(OBJECT, - response.getImages().get(0).getObjects().getCollections().get(0).getObjects().get(0).getObject()); - assertEquals(TOP, - response.getImages().get(0).getObjects().getCollections().get(0).getObjects().get(0).getLocation().top()); - assertEquals(LEFT, - response.getImages().get(0).getObjects().getCollections().get(0).getObjects().get(0).getLocation().left()); - assertEquals(WIDTH, - response.getImages().get(0).getObjects().getCollections().get(0).getObjects().get(0).getLocation().width()); - assertEquals(HEIGHT, - response.getImages().get(0).getObjects().getCollections().get(0).getObjects().get(0).getLocation().height()); - assertEquals(SCORE, - response.getImages().get(0).getObjects().getCollections().get(0).getObjects().get(0).getScore()); - assertEquals(CODE, response.getImages().get(0).getErrors().get(0).getCode()); - assertEquals(MESSAGE, response.getImages().get(0).getErrors().get(0).getMessage()); - assertEquals(MORE_INFO, response.getImages().get(0).getErrors().get(0).getMoreInfo()); - assertEquals(ERROR_TYPE, response.getImages().get(0).getErrors().get(0).getTarget().getType()); - assertEquals(NAME, response.getImages().get(0).getErrors().get(0).getTarget().getName()); - assertEquals(CODE, response.getWarnings().get(0).getCode()); - assertEquals(MESSAGE, response.getWarnings().get(0).getMessage()); - assertEquals(MORE_INFO, response.getWarnings().get(0).getMoreInfo()); - assertEquals(TRACE, response.getTrace()); - } - - private void assertCollection(Collection response) { - assertEquals(COLLECTION_ID, response.getCollectionId()); - assertEquals(NAME, response.getName()); - assertEquals(DESCRIPTION, response.getDescription()); - assertEquals(testDate, response.getCreated()); - assertEquals(testDate, response.getUpdated()); - assertEquals(IMAGE_COUNT, response.getImageCount()); - assertTrue(response.getTrainingStatus().objects().ready()); - assertTrue(response.getTrainingStatus().objects().inProgress()); - assertTrue(response.getTrainingStatus().objects().dataChanged()); - assertTrue(response.getTrainingStatus().objects().latestFailed()); - assertEquals(DESCRIPTION, response.getTrainingStatus().objects().description()); - } - - @Test - public void testCreateCollection() { - server.enqueue(jsonResponse(collection)); - - CreateCollectionOptions options = new CreateCollectionOptions.Builder().name(NAME).description(DESCRIPTION).build(); - Collection response = service.createCollection(options).execute().getResult(); - - assertCollection(response); - } - - private void assertCollectionsList(CollectionsList response) { - assertEquals(COLLECTION_ID, response.getCollections().get(0).getCollectionId()); - assertEquals(NAME, response.getCollections().get(0).getName()); - assertEquals(DESCRIPTION, response.getCollections().get(0).getDescription()); - assertEquals(testDate, response.getCollections().get(0).getCreated()); - assertEquals(testDate, response.getCollections().get(0).getUpdated()); - assertEquals(IMAGE_COUNT, response.getCollections().get(0).getImageCount()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().ready()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().inProgress()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().dataChanged()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().latestFailed()); - assertEquals(DESCRIPTION, response.getCollections().get(0).getTrainingStatus().objects().description()); - } - - @Test - public void testListCollections() { - server.enqueue(jsonResponse(collectionsList)); - - ListCollectionsOptions options = new ListCollectionsOptions.Builder().build(); - CollectionsList response = service.listCollections(options).execute().getResult(); - - assertCollectionsList(response); - } - - @Test - public void testListCollectionsNoOptions() { - server.enqueue(jsonResponse(collectionsList)); - - CollectionsList response = service.listCollections().execute().getResult(); - - assertCollectionsList(response); - } - - @Test - public void testGetCollection() { - server.enqueue(jsonResponse(collection)); - - GetCollectionOptions options = new GetCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - Collection response = service.getCollection(options).execute().getResult(); - - assertCollection(response); - } - - @Test - public void testUpdateCollection() { - server.enqueue(jsonResponse(collection)); - - UpdateCollectionOptions options = new UpdateCollectionOptions.Builder().collectionId(COLLECTION_ID).name(NAME) - .description(DESCRIPTION).build(); - Collection response = service.updateCollection(options).execute().getResult(); - - assertCollection(response); - } - - @Test - public void testDeleteCollection() throws InterruptedException { - server.enqueue(new MockResponse()); - - DeleteCollectionOptions options = new DeleteCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - service.deleteCollection(options).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - } - - private void assertImageDetails(ImageDetails response) { - assertEquals(IMAGE_ID, response.getImageId()); - assertEquals(testDate, response.getCreated()); - assertEquals(testDate, response.getUpdated()); - assertEquals(IMAGE_TYPE, response.getSource().getType()); - assertEquals(FILENAME, response.getSource().getFilename()); - assertEquals(ARCHIVE_FILENAME, response.getSource().getArchiveFilename()); - assertEquals(SOURCE_URL, response.getSource().getSourceUrl()); - assertEquals(RESOLVED_URL, response.getSource().getResolvedUrl()); - assertEquals(HEIGHT, response.getDimensions().getHeight()); - assertEquals(WIDTH, response.getDimensions().getWidth()); - assertEquals(CODE, response.getErrors().get(0).getCode()); - assertEquals(MESSAGE, response.getErrors().get(0).getMessage()); - assertEquals(MORE_INFO, response.getErrors().get(0).getMoreInfo()); - assertEquals(ERROR_TYPE, response.getErrors().get(0).getTarget().getType()); - assertEquals(NAME, response.getErrors().get(0).getTarget().getName()); - assertEquals(OBJECT, response.getTrainingData().getObjects().get(0).object()); - assertEquals(TOP, response.getTrainingData().getObjects().get(0).location().top()); - assertEquals(LEFT, response.getTrainingData().getObjects().get(0).location().left()); - assertEquals(WIDTH, response.getTrainingData().getObjects().get(0).location().width()); - assertEquals(HEIGHT, response.getTrainingData().getObjects().get(0).location().height()); - } - - @Test - public void testAddImages() { - server.enqueue(jsonResponse(imageDetailsList)); - - AddImagesOptions options = new AddImagesOptions.Builder().addImagesFile(fileWithMetadata).addImageUrl(IMAGE_URL) - .collectionId(COLLECTION_ID).trainingData(TRAINING_DATA).build(); - ImageDetailsList response = service.addImages(options).execute().getResult(); - - assertImageDetails(response.getImages().get(0)); - assertEquals(CODE, response.getWarnings().get(0).getCode()); - assertEquals(MESSAGE, response.getWarnings().get(0).getMessage()); - assertEquals(MORE_INFO, response.getWarnings().get(0).getMoreInfo()); - assertEquals(TRACE, response.getTrace()); - } - - @Test - public void testListImages() { - server.enqueue(jsonResponse(imageSummaryList)); - - ListImagesOptions options = new ListImagesOptions.Builder().collectionId(COLLECTION_ID).build(); - ImageSummaryList response = service.listImages(options).execute().getResult(); - - assertEquals(IMAGE_ID, response.getImages().get(0).getImageId()); - assertEquals(testDate, response.getImages().get(0).getUpdated()); - } - - @Test - public void testGetImageDetails() { - server.enqueue(jsonResponse(imageDetails)); - - GetImageDetailsOptions options = new GetImageDetailsOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID) - .build(); - ImageDetails response = service.getImageDetails(options).execute().getResult(); - - assertImageDetails(response); - } - - @Test - public void testDeleteImage() throws InterruptedException { - server.enqueue(new MockResponse()); - - DeleteImageOptions options = new DeleteImageOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID).build(); - service.deleteImage(options).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - } - - @Test - public void testGetJpegImage() throws IOException, InterruptedException { - @SuppressWarnings("resource") - Buffer buffer = new Buffer().write(Files.toByteArray(imageFile)); - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, "image/jpeg").setBody(buffer)); - - GetJpegImageOptions options = new GetJpegImageOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID) - .size(GetJpegImageOptions.Size.FULL).build(); - InputStream response = service.getJpegImage(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertNotNull(response); - response.close(); - } - - @Test - public void testTrain() { - server.enqueue(jsonResponse(collection)); - - TrainOptions options = new TrainOptions.Builder().collectionId(COLLECTION_ID).build(); - Collection response = service.train(options).execute().getResult(); - - assertCollection(response); - } - - @Test - public void testAddImageTrainingData() { - server.enqueue(jsonResponse(trainingDataObjects)); - - AddImageTrainingDataOptions options = new AddImageTrainingDataOptions.Builder().collectionId(COLLECTION_ID) - .imageId(IMAGE_ID).addObjects(trainingDataObject).build(); - TrainingDataObjects response = service.addImageTrainingData(options).execute().getResult(); - - assertEquals(OBJECT, response.getObjects().get(0).object()); - assertEquals(TOP, response.getObjects().get(0).location().top()); - assertEquals(LEFT, response.getObjects().get(0).location().left()); - assertEquals(WIDTH, response.getObjects().get(0).location().width()); - assertEquals(HEIGHT, response.getObjects().get(0).location().height()); - } - - @Test - public void testDeleteUserData() throws InterruptedException { - server.enqueue(new MockResponse()); - - DeleteUserDataOptions options = new DeleteUserDataOptions.Builder().customerId(CUSTOMER_ID).build(); - service.deleteUserData(options).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - } - - @Test - public void testGetTrainingUsage() throws InterruptedException { - server.enqueue(jsonResponse(trainingEvents)); - - GetTrainingUsageOptions options = new GetTrainingUsageOptions.Builder().build(); - TrainingEvents response = service.getTrainingUsage(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(testDate, response.getStartTime()); - assertEquals(testDate, response.getEndTime()); - assertEquals(COMPLETED_EVENTS, response.getCompletedEvents()); - assertEquals(TRAINED_IMAGES, response.getTrainedImages()); - assertEquals(TYPE, response.getEvents().get(0).getType()); - assertEquals(COLLECTION_ID, response.getEvents().get(0).getCollectionId()); - assertEquals(testDate, response.getEvents().get(0).getCompletionTime()); - assertEquals(STATUS, response.getEvents().get(0).getStatus()); - assertEquals(IMAGE_COUNT, response.getEvents().get(0).getImageCount()); - } - - @Test - public void testListObjectMetadata() throws InterruptedException { - server.enqueue(jsonResponse(objectMetadataList)); - - ListObjectMetadataOptions options = new ListObjectMetadataOptions.Builder() - .collectionId(COLLECTION_ID) - .build(); - ObjectMetadataList response = service.listObjectMetadata(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(objectMetadataList.getObjects(), response.getObjects()); - assertEquals(objectMetadataList.getObjectCount(), response.getObjectCount()); - } - - @Test - public void testUpdateObjectName() throws InterruptedException { - server.enqueue(jsonResponse(objectName)); - - UpdateObjectMetadataOptions options = new UpdateObjectMetadataOptions.Builder() - .collectionId(COLLECTION_ID) - .object(NAME) - .newObject(MESSAGE) - .build(); - UpdateObjectMetadata response = service.updateObjectMetadata(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(objectName.getObject(), response.object()); - assertEquals(objectName.getCount(), response.count()); - } - - @Test - public void testGetObjectMetadata() throws InterruptedException { - server.enqueue(jsonResponse(objectName)); - - GetObjectMetadataOptions options = new GetObjectMetadataOptions.Builder() - .collectionId(COLLECTION_ID) - .object(NAME) - .build(); - ObjectMetadata response = service.getObjectMetadata(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(objectName.getObject(), response.getObject()); - assertEquals(objectName.getCount(), response.getCount()); - } - - @Test - public void testDeleteObject() throws InterruptedException { - server.enqueue(new MockResponse()); - - DeleteObjectOptions options = new DeleteObjectOptions.Builder() - .collectionId(COLLECTION_ID) - .object(NAME) - .build(); - - service.deleteObject(options).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - } -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive.zip b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive.zip deleted file mode 100644 index c606ddc7da8..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/0.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/0.jpg deleted file mode 100644 index 999b16a284d..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/0.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/1.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/1.jpg deleted file mode 100644 index e59eedb0e7d..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/1.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/10.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/10.jpg deleted file mode 100644 index 88f90f137df..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/10.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/2.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/2.jpg deleted file mode 100644 index 9efc556217e..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/2.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/3.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/3.jpg deleted file mode 100644 index da5772f0644..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/3.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/4.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/4.jpg deleted file mode 100644 index f04ee61628b..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/4.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/5.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/5.jpg deleted file mode 100644 index d601fdb24c3..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/5.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/6.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/6.jpg deleted file mode 100644 index fffa7de348c..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/6.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/7.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/7.jpg deleted file mode 100644 index a6cabb00dfb..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/7.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/8.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/8.jpg deleted file mode 100644 index e15ca368202..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/8.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/9.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/9.jpg deleted file mode 100644 index 5a3ae2543f7..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/baseball_positive/9.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/car.png b/visual-recognition/src/test/resources/visual_recognition/v3/car.png deleted file mode 100644 index 61df4dc567e..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/car.png and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/car_positive.zip b/visual-recognition/src/test/resources/visual_recognition/v3/car_positive.zip deleted file mode 100644 index b75086611e7..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/car_positive.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/collection.json b/visual-recognition/src/test/resources/visual_recognition/v3/collection.json deleted file mode 100644 index 441d9366a4b..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v3/collection.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "collection_id": "dresses_1257263", - "name": "dresses", - "images": "0", - "status": "available", - "capacity": 1000000 -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/custom_model.mlmodel b/visual-recognition/src/test/resources/visual_recognition/v3/custom_model.mlmodel deleted file mode 100644 index 35611c91142..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/custom_model.mlmodel and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/detected_text.json b/visual-recognition/src/test/resources/visual_recognition/v3/detected_text.json deleted file mode 100644 index 0856935e95c..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v3/detected_text.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "images_processed": 1, - "images": [ - { - "text": "its\nopen", - "words": [ - { - "word": "its", - "location": { - "width": 72, - "height": 36, - "left": 28, - "top": 28 - }, - "score": 0.979764, - "line_number": 0 - }, - { - "word": "open", - "location": { - "width": 171, - "height": 69, - "left": 29, - "top": 69 - }, - "score": 0.993262, - "line_number": 1 - } - ], - "image": "open.png" - } - ] -} \ No newline at end of file diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/eiffel-tower.jpg b/visual-recognition/src/test/resources/visual_recognition/v3/eiffel-tower.jpg deleted file mode 100644 index 63dee36d765..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/eiffel-tower.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/image.json b/visual-recognition/src/test/resources/visual_recognition/v3/image.json deleted file mode 100644 index 5cd955932d3..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v3/image.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "image_id":"565838654", - "image_file":"red_dress.jpg", - "metadata":{ - "weight":10, - "cut":"a line", - "color":"red" - } -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/negative.zip b/visual-recognition/src/test/resources/visual_recognition/v3/negative.zip deleted file mode 100644 index 2357c87a25c..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/negative.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/open.png b/visual-recognition/src/test/resources/visual_recognition/v3/open.png deleted file mode 100644 index 8d7c00da61e..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/open.png and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/positive.zip b/visual-recognition/src/test/resources/visual_recognition/v3/positive.zip deleted file mode 100644 index b75086611e7..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/positive.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/test.zip b/visual-recognition/src/test/resources/visual_recognition/v3/test.zip deleted file mode 100644 index d9a285b00bf..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v3/test.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/visual_classification.json b/visual-recognition/src/test/resources/visual_recognition/v3/visual_classification.json deleted file mode 100644 index b6d8cbab644..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v3/visual_classification.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "images_processed": 2, - "images": [ - { - "classifiers": [ - { - "classifier_id": "default", - "name": "default", - "classes": [ - { - "class": "car", - "score": 0.973403, - "type_hierarchy": "/vehicles/car" - }, - { - "class": "vehicle", - "score": 0.549834, - "type_hierarchy": "/vehicles" - } - ] - } - ], - "image": "test.zip/0.jpg" - }, - { - "classifiers": [ - { - "classifier_id": "default", - "name": "default", - "classes": [ - { - "class": "car", - "score": 0.845535, - "type_hierarchy": "/vehicles/car" - } - ] - } - ], - "image": "test.zip/1.jpg" - } - ] -} \ No newline at end of file diff --git a/visual-recognition/src/test/resources/visual_recognition/v3/visual_classifier.json b/visual-recognition/src/test/resources/visual_recognition/v3/visual_classifier.json deleted file mode 100644 index 248e909e101..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v3/visual_classifier.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "classifier_id": "foo", - "name": "Foo", - "owner": "IBM", - "status": "ready", - "explanation": "Working as expected", - "classes": [ - { - "class": "Bar" - }, - { - "class": "Buu" - }, - { - "class": "Boo" - } - ] -} \ No newline at end of file diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/analyze-response.json b/visual-recognition/src/test/resources/visual_recognition/v4/analyze-response.json deleted file mode 100644 index c88441a2984..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/analyze-response.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "images": [ - { - "source": { - "type": "file", - "filename": "filename", - "archive_filename": "archive_filename", - "source_url": "source_url", - "resolved_url": "resolved_url" - }, - "dimensions": { - "height": 200, - "width": 100 - }, - "objects": { - "collections": [ - { - "collection_id": "123456789", - "objects": [ - { - "object": "object", - "location": { - "top": 0, - "left": 10, - "width": 100, - "height": 200 - }, - "score": 5.0 - } - ] - } - ] - }, - "errors": [ - { - "code": "code", - "message": "message", - "more_info": "more_info", - "target": { - "type": "field", - "name": "name" - } - } - ] - } - ], - "warnings": [ - { - "code": "code", - "message": "message", - "more_info": "more_info" - } - ], - "trace": "trace" -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/collection.json b/visual-recognition/src/test/resources/visual_recognition/v4/collection.json deleted file mode 100644 index b1d457a13b1..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/collection.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "collection_id": "123456789", - "name": "name", - "description": "description", - "created": "1995-06-12T01:11:11.111Z", - "updated": "1995-06-12T01:11:11.111Z", - "image_count": 50, - "training_status": { - "objects": { - "ready": true, - "in_progress": true, - "data_changed": true, - "latest_failed": true, - "description": "description" - } - } -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/collections-list.json b/visual-recognition/src/test/resources/visual_recognition/v4/collections-list.json deleted file mode 100644 index 621853d9f32..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/collections-list.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "collections": [ - { - "collection_id": "123456789", - "name": "name", - "description": "description", - "created": "1995-06-12T01:11:11.111Z", - "updated": "1995-06-12T01:11:11.111Z", - "image_count": 50, - "training_status": { - "objects": { - "ready": true, - "in_progress": true, - "data_changed": true, - "latest_failed": true, - "description": "description" - } - } - } - ] -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/giraffe_positive_examples.zip b/visual-recognition/src/test/resources/visual_recognition/v4/giraffe_positive_examples.zip deleted file mode 100644 index abb38a0f9a3..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v4/giraffe_positive_examples.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/giraffe_to_classify.jpg b/visual-recognition/src/test/resources/visual_recognition/v4/giraffe_to_classify.jpg deleted file mode 100644 index c0571429514..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v4/giraffe_to_classify.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/image-details-list.json b/visual-recognition/src/test/resources/visual_recognition/v4/image-details-list.json deleted file mode 100644 index 4ca53b6283d..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/image-details-list.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "images": [ - { - "image_id": "image_id", - "updated": "1995-06-12T01:11:11.111Z", - "created": "1995-06-12T01:11:11.111Z", - "source": { - "type": "file", - "filename": "filename", - "archive_filename": "archive_filename", - "source_url": "source_url", - "resolved_url": "resolved_url" - }, - "dimensions": { - "height": 200, - "width": 100 - }, - "errors": [ - { - "code": "code", - "message": "message", - "more_info": "more_info", - "target": { - "type": "field", - "name": "name" - } - } - ], - "training_data": { - "objects": [ - { - "object": "object", - "location": { - "top": 0, - "left": 10, - "width": 100, - "height": 200 - } - } - ] - } - } - ], - "warnings": [ - { - "code": "code", - "message": "message", - "more_info": "more_info" - } - ], - "trace": "trace" -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/image-details.json b/visual-recognition/src/test/resources/visual_recognition/v4/image-details.json deleted file mode 100644 index 3a43322f782..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/image-details.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "image_id": "image_id", - "updated": "1995-06-12T01:11:11.111Z", - "created": "1995-06-12T01:11:11.111Z", - "source": { - "type": "file", - "filename": "filename", - "archive_filename": "archive_filename", - "source_url": "source_url", - "resolved_url": "resolved_url" - }, - "dimensions": { - "height": 200, - "width": 100 - }, - "errors": [ - { - "code": "code", - "message": "message", - "more_info": "more_info", - "target": { - "type": "field", - "name": "name" - } - } - ], - "training_data": { - "objects": [ - { - "object": "object", - "location": { - "top": 0, - "left": 10, - "width": 100, - "height": 200 - } - } - ] - } -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/image-summary-list.json b/visual-recognition/src/test/resources/visual_recognition/v4/image-summary-list.json deleted file mode 100644 index bac5f76fabf..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/image-summary-list.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "images": [ - { - "image_id": "image_id", - "updated": "1995-06-12T01:11:11.111Z" - } - ] -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/negative_examples.zip b/visual-recognition/src/test/resources/visual_recognition/v4/negative_examples.zip deleted file mode 100644 index 1fbef1d57d9..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v4/negative_examples.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/object-metadata-list.json b/visual-recognition/src/test/resources/visual_recognition/v4/object-metadata-list.json deleted file mode 100644 index 47ea100d224..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/object-metadata-list.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "object_count": 4, - "objects": [ - { - "object": "2018-Fit", - "count": 2 - }, - { - "object": "auto_dice", - "count": 1 - }, - { - "object": "automobile", - "count": 1 - } - ] -} \ No newline at end of file diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/object-name.json b/visual-recognition/src/test/resources/visual_recognition/v4/object-name.json deleted file mode 100644 index b0ad8a88b08..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/object-name.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "object": "subcompact", - "count": 2 -} \ No newline at end of file diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/training-data-objects.json b/visual-recognition/src/test/resources/visual_recognition/v4/training-data-objects.json deleted file mode 100644 index f1e1d0c2360..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/training-data-objects.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "objects": [ - { - "object": "object", - "location": { - "top": 0, - "left": 10, - "width": 100, - "height": 200 - } - } - ] -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/training-events.json b/visual-recognition/src/test/resources/visual_recognition/v4/training-events.json deleted file mode 100644 index 2e5281263fd..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/v4/training-events.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "start_time": "1995-06-12T01:11:11.111Z", - "end_time": "1995-06-12T01:11:11.111Z", - "completed_events": 7, - "trained_images": 15, - "events": [ - { - "type": "objects", - "collection_id": "123456789", - "completion_time": "1995-06-12T01:11:11.111Z", - "status": "succeeded", - "image_count": 50 - } - ] -} diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/turtle_positive_examples.zip b/visual-recognition/src/test/resources/visual_recognition/v4/turtle_positive_examples.zip deleted file mode 100644 index f808aefd5d2..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v4/turtle_positive_examples.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/v4/turtle_to_classify.jpg b/visual-recognition/src/test/resources/visual_recognition/v4/turtle_to_classify.jpg deleted file mode 100644 index 3dd7befec93..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/v4/turtle_to_classify.jpg and /dev/null differ